ILIAS  release_8 Revision v8.24
class.ilAdvancedMDRecordTranslationGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
11{
12 protected function translations(): void
13 {
14 $this->setTabs(self::CMD_DEFAULT);
15
16 $language_table = new ilAdvancedMDRecordLanguageTableGUI(
17 $this->record,
18 $this,
19 self::CMD_DEFAULT
20 );
21 $language_table->init();
22 $language_table->parse();
23
24 $this->tpl->setContent($language_table->getHTML());
25 }
26
30 protected function saveTranslations(): void
31 {
32 $languages = (array) ($this->request->getParsedBody()['active_languages'] ?? []);
33 $default = (string) $this->request->getParsedBody()['default'];
34
35 if (!in_array($default, $languages)) {
36 $this->tpl->setOnScreenMessage('failure', $this->language->txt('err_check_input'), true);
37 $this->tpl->setOnScreenMessage('info', $this->language->txt('md_adn_int_error_no_default'), true);
38 $this->ctrl->redirect($this, self::CMD_DEFAULT);
39 }
40
41 $translations = ilAdvancedMDRecordTranslations::getInstanceByRecordId($this->record->getRecordId());
42 foreach ($translations->getTranslations() as $translation) {
43 if (!in_array($translation->getLangKey(), $languages)) {
44 $translation->delete();
45 }
46 }
47 foreach ($languages as $lang_key) {
48 if (!$translations->isConfigured($lang_key)) {
49 $translations->addTranslationEntry($lang_key);
50 }
51 }
52
53 $this->record->setDefaultLanguage($default);
54 $this->record->update();
55
56 $this->tpl->setOnScreenMessage('success', $this->language->txt('settings_saved'), true);
57 $this->ctrl->redirect($this, self::CMD_DEFAULT);
58 }
59}
Class ilAdvancedMDRecordTranslationGUI @ilCtrl_isCalledBy ilAdvancedMDRecordTranslationGUI: ilAdvance...