ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMDRecordTranslationGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected function translations(): void
29 {
30 $this->setTabs(self::CMD_DEFAULT);
31
32 $language_table = new ilAdvancedMDRecordLanguageTableGUI(
33 $this->record,
34 $this,
35 self::CMD_DEFAULT
36 );
37 $language_table->init();
38 $language_table->parse();
39
40 $this->tpl->setContent($language_table->getHTML());
41 }
42
46 protected function saveTranslations(): void
47 {
48 $languages = (array) ($this->request->getParsedBody()['active_languages'] ?? []);
49 $default = (string) $this->request->getParsedBody()['default'];
50
51 if (!in_array($default, $languages)) {
52 $this->tpl->setOnScreenMessage('failure', $this->language->txt('err_check_input'), true);
53 $this->tpl->setOnScreenMessage('info', $this->language->txt('md_adn_int_error_no_default'), true);
54 $this->ctrl->redirect($this, self::CMD_DEFAULT);
55 }
56
57 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
58 foreach ($translations->getTranslations() as $translation) {
59 if (!in_array($translation->getLangKey(), $languages)) {
60 $translation->delete();
61 }
62 }
63 foreach ($languages as $lang_key) {
64 if (!$translations->isConfigured($lang_key)) {
65 $translations->addTranslationEntry($lang_key);
66 }
67 }
68
69 $this->record->setDefaultLanguage($default);
70 $this->record->update();
71
72 $this->tpl->setOnScreenMessage('success', $this->language->txt('settings_saved'), true);
73 $this->ctrl->redirect($this, self::CMD_DEFAULT);
74 }
75}
Class ilAdvancedMDRecordTranslationGUI @ilCtrl_isCalledBy ilAdvancedMDRecordTranslationGUI: ilAdvance...