19 declare(strict_types=1);
53 $this->main_tpl = $DIC->ui()->mainTemplate();
54 $this->lom_services = $DIC->learningObjectMetadata();
57 $this->
lng()->loadLanguageModule(
"mme");
62 $this->
ctrl()->saveParameter($this, self::IDENTIFIER);
63 switch ($this->
ctrl()->getNextClass()) {
65 $cmd = $this->
ctrl()->getCmd(self::CMD_DEFAULT);
70 protected function index(): void
75 $this->tpl()->setContent($table->getHTML());
81 $this->
lng()->txt(
"add_languages"),
83 ->getLinkTarget($this, self::CMD_ADD_LANGUAGE)
87 protected function saveTranslations():
void 89 $to_translate = (array) $this->
http()->request()->getParsedBody()[self::P_TRANSLATIONS];
90 foreach ($to_translate as
$id =>
$data) {
94 $translation = ilMMItemTranslationStorage::find(
$id);
95 $translation->setTranslation(
$data[
'translation']);
96 $translation->update();
99 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
'msg_translations_saved'),
true);
105 $to_delete = (array) ($this->
http()->request()->getParsedBody()[self::P_DELETE] ?? []);
106 foreach ($to_delete as
$id) {
107 ilMMItemTranslationStorage::find($id)->delete();
109 $this->
repository->updateItem($this->item_facade);
110 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
'msg_translations_deleted'),
true);
118 $this->tpl()->setContent($form->getHTML());
124 if ($form->checkInput()) {
125 $ad = $form->getInput(
"additional_langs");
127 foreach ($ad as $language_key) {
131 $this->
repository->updateItem($this->item_facade);
132 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng()->txt(
"msg_languages_added"),
true);
136 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng()->txt(
'err_check_input'));
137 $form->setValuesByPost();
138 $this->tpl()->setContent($form->getHTML());
147 $form->setFormAction($this->
ctrl()->getFormAction($this));
151 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
152 $options[$language->value()] = $language->presentableLabel();
154 $options = array(
"" => $this->
lng()->txt(
"please_select")) + $options;
156 $si->setOptions($options);
160 $form->setTitle($this->
lng()->txt(
"add_languages"));
161 $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->
lng()->txt(
"save"));
162 $form->addCommandButton(self::CMD_DEFAULT, $this->
lng()->txt(
"cancel"));
169 $this->
ctrl()->redirect($this, self::CMD_DEFAULT);
LOMServices $lom_services
const CMD_DELETE_TRANSLATIONS
repository()
description: > Example for rendering a repository card
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