19 declare(strict_types=1);
51 $this->main_tpl = $DIC->ui()->mainTemplate();
54 $this->
lng()->loadLanguageModule(
"mme");
59 $this->
ctrl()->saveParameter($this, self::IDENTIFIER);
60 switch ($this->
ctrl()->getNextClass()) {
62 $cmd = $this->
ctrl()->getCmd(self::CMD_DEFAULT);
67 protected function index(): void
72 $this->tpl()->setContent($table->getHTML());
78 $this->
lng()->txt(
"add_languages"),
80 ->getLinkTarget($this, self::CMD_ADD_LANGUAGE)
84 protected function saveTranslations():
void 86 $to_translate = (array) $this->
http()->request()->getParsedBody()[self::P_TRANSLATIONS];
87 foreach ($to_translate as
$id =>
$data) {
91 $translation = ilMMItemTranslationStorage::find(
$id);
92 $translation->setTranslation(
$data[
'translation']);
93 $translation->update();
96 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
'msg_translations_saved'),
true);
102 $to_delete = (array) ($this->
http()->request()->getParsedBody()[self::P_DELETE] ?? []);
103 foreach ($to_delete as
$id) {
104 ilMMItemTranslationStorage::find($id)->delete();
106 $this->
repository->updateItem($this->item_facade);
107 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
'msg_translations_deleted'),
true);
115 $this->tpl()->setContent($form->getHTML());
121 if ($form->checkInput()) {
122 $ad = $form->getInput(
"additional_langs");
124 foreach ($ad as $language_key) {
128 $this->
repository->updateItem($this->item_facade);
129 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
"msg_languages_added"),
true);
133 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng()->txt(
'err_check_input'));
134 $form->setValuesByPost();
135 $this->tpl()->setContent($form->getHTML());
144 $form->setFormAction($this->
ctrl()->getFormAction($this));
148 $options = array(
"" => $this->
lng()->txt(
"please_select")) + $options;
150 $si->setOptions($options);
154 $form->setTitle($this->
lng()->txt(
"add_languages"));
155 $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->
lng()->txt(
"save"));
156 $form->addCommandButton(self::CMD_DEFAULT, $this->
lng()->txt(
"cancel"));
163 $this->
ctrl()->redirect($this, self::CMD_DEFAULT);
const CMD_DELETE_TRANSLATIONS
ilGlobalTemplateInterface $main_tpl
Class ilMMItemRepository.
__construct(ilMMItemFacadeInterface $item_facade, ilMMItemRepository $repository)
ilMMItemTranslationGUI constructor.
static http()
Fetches the global http state from ILIAS.
const CMD_SAVE_TRANSLATIONS
Class ilMMItemTranslationGUI.
Class ilMMItemTranslationTableGUI.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
ilMMItemFacadeInterface $item_facade
static storeTranslation(IdentificationInterface $identification, string $language_key, string $translation)
Interface ilMMItemFacadeInterface.
ilMMItemRepository $repository