19 declare(strict_types=1);
    71         $this->
toolbar = $DIC[
'ilToolbar'];
    72         $this->
user = $DIC[
'ilUser'];
    73         $this->
access = $DIC[
'ilAccess'];
    74         $this->
lng = $DIC[
'lng'];
    75         $this->
ctrl = $DIC[
'ilCtrl'];
    76         $this->tpl = $DIC[
'tpl'];
    77         $this->ui_factory = $DIC[
'ui.factory'];
    78         $this->ui_renderer = $DIC[
'ui.renderer'];
    79         $this->post_wrapper = $DIC->http()->wrapper()->post();
    80         $this->request = $DIC->http()->request();
    92         $this->hide_description = $hide;
    97         $this->support_content_translation = $content_translation;
   103         foreach ($this->obj_trans->getLanguages() as $k => $v) {
   104             $data[$k][
'default'] = (
int) $v->isDefault();
   105             $data[$k][
'title'] = $v->getTitle();
   106             $data[$k][
'desc'] = $v->getDescription();
   107             $data[$k][
'lang'] = $v->getLanguageCode();
   116         $titles = $this->post_wrapper->has(
'title')
   117             ? $this->post_wrapper->retrieve(
   123         $descriptions = $this->post_wrapper->has(
'desc')
   124             ? $this->post_wrapper->retrieve(
   130         $languages = $this->post_wrapper->has(
'lang')
   131             ? $this->post_wrapper->retrieve(
   137         $default = $this->post_wrapper->has(
'default')
   138             ? $this->post_wrapper->retrieve(
   144         foreach ($titles as $k => $v) {
   147                 'desc' => $descriptions[$k],
   148                 'lang' => $languages[$k],
   149                 'default' => ($default == $k)
   164         $this->title_descr_only = $val;
   174         $this->fallback_lang_mode = $val;
   185             self::CMD_LIST_TRANSLATIONS,
   186             self::CMD_SAVE_TRANSLATIONS,
   187             self::CMD_ADD_TRANSLATION,
   188             self::CMD_DELETE_TRANSLATIONS,
   189             self::CMD_CONFIRM_REMOVE_LANGUAGES,
   190             self::CMD_SAVE_LANGUAGES,
   191             self::CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION,
   192             self::CMD_DEACTIVATE_CONTENT_MULTILANG,
   193             self::CMD_SET_FALLBACK
   196         $this->
ctrl->getNextClass($this);
   197         $cmd = $this->
ctrl->getCmd(self::CMD_LIST_TRANSLATIONS);
   198         if (!$this->
access->checkAccess(
'write', 
'', $this->obj_gui->getRefId())) {
   199             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'));
   200             $this->
ctrl->redirect($this->obj_gui);
   202         if (in_array($cmd, $commands)) {
   214                 $this->ui_factory->button()->standard(
   215                     $this->
lng->txt(
'obj_add_languages'),
   216                     $add_langs_modal->getShowSignal()
   221         if ($this->support_content_translation) {
   227             self::CMD_LIST_TRANSLATIONS,
   228             !$this->hide_description,
   230             $this->obj_trans->getMasterLanguage(),
   232             $this->obj_trans->getFallbackLanguage()
   234         if ($get_post_values) {
   239         $page_content = $table->getHTML() . $this->ui_renderer->render($add_langs_modal);
   241         if (isset($content_translation_modal)) {
   242             $page_content .= $this->ui_renderer->render($content_translation_modal);
   245         $this->tpl->setContent($page_content);
   250         return $this->ui_factory->modal()->roundtrip(
   251             $this->
lng->txt(
'confirm'),
   256             $this->
ctrl->getFormActionByClass(self::class, self::CMD_SAVE_LANGUAGES)
   262         $lang_var_postfix = 
'_multilang';
   263         $deactivation_modal_text_tag = 
'obj_deactivate_multilang_conf';
   265             $lang_var_postfix = 
'_content_lang';
   266             $deactivation_modal_text_tag = 
'obj_deactivate_content_transl_conf';
   270             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'obj_multilang_title_descr_only'));
   274         if (!$this->obj_trans->getContentActivated()) {
   276                 $this->ui_factory->button()->standard(
   277                     $this->
lng->txt(
'obj_activate' . $lang_var_postfix),
   278                     $activate_modal->getShowSignal()
   281             return $activate_modal;
   286             $this->ui_factory->button()->standard(
   287                 $this->
lng->txt(
'obj_deactivate' . $lang_var_postfix),
   288                 $deactivate_modal->getShowSignal()
   291         return $deactivate_modal;
   296         return $this->ui_factory->modal()->interruptive(
   297             $this->
lng->txt(
'confirm'),
   298             $this->
lng->txt($text_tag),
   299             $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_DEACTIVATE_CONTENT_MULTILANG)
   300         )->withActionButtonLabel($this->
lng->txt(
'confirm'));
   305         return $this->ui_factory->modal()->roundtrip(
   306             $this->
lng->txt(
'confirm'),
   307             $this->ui_factory->legacy($this->
lng->txt(
'obj_select_master_lang')),
   311             $this->
ctrl->getFormActionByClass(self::class, self::CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION)
   318         if (!$this->post_wrapper->has(
'default') && $this->obj_trans->getMasterLanguage() === 
'') {
   319             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_default_language'));
   325         $languages = $this->post_wrapper->has(
'lang')
   326             ? $this->post_wrapper->retrieve(
   328                 $this->
refinery->kindlyTo()->dictOf(
   329                     $this->
refinery->kindlyTo()->string()
   333         if (array_key_exists(
'', $languages)) {
   334             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_no_language_selected'));
   340         if (count(array_unique($languages)) < count($languages)) {
   341             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_multi_language_selected'));
   347         $this->obj_trans->setLanguages([]);
   349         $titles = $this->post_wrapper->has(
'title')
   350             ? $this->post_wrapper->retrieve(
   352                 $this->
refinery->kindlyTo()->dictOf(
   353                     $this->
refinery->kindlyTo()->string()
   357         $descriptions = $this->post_wrapper->has(
'desc')
   358             ? $this->post_wrapper->retrieve(
   360                 $this->
refinery->kindlyTo()->dictOf(
   361                     $this->
refinery->kindlyTo()->string()
   366         $post_default = $this->post_wrapper->has(
'default')
   367             ? $this->post_wrapper->retrieve(
   373         $check = $this->post_wrapper->has(
'check')
   374             ? $this->post_wrapper->retrieve(
   380         if ($this->obj_trans->getFallbackLanguage() !== 
'') {
   381             $obj_store_lang = $this->obj_trans->getFallbackLanguage();
   383             $obj_store_lang = ($this->obj_trans->getMasterLanguage() != 
'')
   384                 ? $this->obj_trans->getMasterLanguage()
   385                 : $languages[$post_default];
   388         foreach ($titles as $k => $v) {
   390             $is_default = ($post_default === $k);
   393             if ($this->obj_trans->getMasterLanguage() != 
'') {
   394                 $is_default = ($this->obj_trans->getMasterLanguage() === $languages[$k]);
   396             if ($languages[$k] === $obj_store_lang) {
   401             $this->obj_trans->addLanguage(
   408         $this->obj_trans->save();
   409         if (method_exists($this->obj, 
'setObjectTranslation')) {
   410             $this->obj->setObjectTranslation($this->obj_trans);
   412         $this->obj->update();
   414         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'), 
true);
   415         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   423             $master_lang = $this->obj_trans->getMasterLanguage();
   424             $trafo = $this->
refinery->custom()->transformation(
   425                 function (array $vs) use ($master_lang) {
   427                     foreach ($vs as $v) {
   428                         if ($v !== $master_lang && $v !== 
'') {
   435             return $this->ui_factory->input()->field()->multiSelect(
   436                 $this->
lng->txt(
'obj_additional_langs'),
   441         $trafo = $this->
refinery->custom()->transformation(
   445         return $this->ui_factory->input()->field()->select(
   446             $this->
lng->txt(
'obj_master_lang'),
   449             ->withValue($this->
user->getLanguage());
   455             ->withRequest($this->request)
   457         $this->obj_trans->setMasterLanguage(
$data[
'lang']);
   458         if (!in_array(
$data[
'lang'], $this->obj_trans->getLanguages())) {
   459             $this->obj_trans->addLanguage(
   461                 $this->obj->getTitle(),
   462                 $this->obj->getDescription(),
   466         $this->obj_trans->save();
   468         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   474             $this->obj_trans->setMasterLanguage(
'');
   475             $this->obj_trans->setLanguages([]);
   476             $this->obj_trans->save();
   478         $this->obj_trans->deactivateContentTranslation();
   480             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'obj_cont_transl_deactivated'), 
true);
   482             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'obj_multilang_deactivated'), 
true);
   485         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   491             ->withRequest($this->request)
   494         if (
$data[
'langs'] === null || 
$data[
'langs'] === []) {
   495             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_checkbox'), 
true);
   496             $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   500             $this->obj_trans->addLanguage($lang, 
'', 
'', 
false);
   503         $this->obj_trans->save();
   504         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'), 
true);
   505         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   510         $this->
lng->loadLanguageModule(
'meta');
   513         $languages = $this->post_wrapper->has(
'lang')
   514             ? $this->post_wrapper->retrieve(
   520         $to_be_deleted = $this->post_wrapper->has(
'check')
   521             ? $this->post_wrapper->retrieve(
   527         if (count($to_be_deleted) === 0) {
   528             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'no_checkbox'), 
true);
   529             $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   533         $cgui->setFormAction($this->
ctrl->getFormAction($this));
   534         $cgui->setHeaderText($this->
lng->txt(
'obj_conf_delete_lang'));
   535         $cgui->setCancel($this->
lng->txt(
'cancel'), self::CMD_LIST_TRANSLATIONS);
   536         $cgui->setConfirm($this->
lng->txt(
'remove'), self::CMD_DELETE_TRANSLATIONS);
   538         foreach (array_keys($to_be_deleted) as $index) {
   539             if (!array_key_exists($index, $languages)) {
   542             $cgui->addItem(
'lang[]', $languages[$index], $this->
lng->txt(
'meta_l_' . $languages[$index]));
   545         $this->tpl->setContent($cgui->getHTML());
   551         $langs_to_be_deleted = $this->post_wrapper->has(
'lang')
   552             ? $this->post_wrapper->retrieve(
   558         foreach ($langs_to_be_deleted as 
$lang) {
   559             $this->obj_trans->removeLanguage($lang);
   561         $this->obj_trans->save();
   562         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'), 
true);
   563         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
   568         $default_lang = $this->obj_trans->getDefaultLanguage();
   569         return $this->
refinery->custom()->transformation(
   570             function (?array $vs) use ($default_lang) {
   576                 foreach ($vs as $k => $v) {
   577                     if ($v !== $default_lang) {
   578                         $langs[$k] = (string) $v;
   589         $checkboxes = $this->post_wrapper->has(
'check')
   590             ? $this->post_wrapper->retrieve(
   592                 $this->
refinery->kindlyTo()->dictOf(
   598         if ($checkboxes === []) {
   599             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'obj_select_one_language'));
   603         $checked = key($checkboxes);
   605         $languages = $this->post_wrapper->has(
'lang')
   606             ? $this->post_wrapper->retrieve(
   612         $fallback_lang = $languages[$checked];
   613         if ($fallback_lang !== $this->obj_trans->getFallbackLanguage()) {
   614             $this->obj_trans->setFallbackLanguage($fallback_lang);
   616             $this->obj_trans->setFallbackLanguage(
'');
   618         $this->obj_trans->save();
   619         $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'msg_obj_modified'), 
true);
   620         $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
 This describes commonalities between the different modals. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
An entity that renders components to a string output. 
 
const CMD_LIST_TRANSLATIONS
 
setTitleDescrOnlyMode(bool $val)
Some objects like learning modules do not support to translate only the title and the description...
 
const CMD_SAVE_TRANSLATIONS
 
addContentTranslationToolbarActionAndRetrieveCorrespondingModal()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
 
getEnableFallbackLanguage()
 
getActivateMultilingualityModal()
 
RequestInterface $request
 
getTableValuesByRequest()
 
bool $support_content_translation
 
ilGlobalTemplateInterface $tpl
 
static _getPossibleLanguageCodes()
 
confirmDeleteTranslations()
 
getMultiLangFormInput(bool $add=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getConfirmDeactivateMultilingualityModal(string $text_tag)
 
Class ilObjectGUI Basic methods of all Output classes. 
 
static getInstance(int $obj_id)
 
getTableValuesByObjects()
 
const CMD_ADD_TRANSLATION
 
ArrayBasedRequestWrapper $post_wrapper
 
supportContentTranslation(bool $content_translation)
 
deactivateContentMultiLang()
 
setEnableFallbackLanguage(bool $val)
 
const CMD_CONFIRM_REMOVE_LANGUAGES
 
const CMD_SAVE_CONTENT_TRANSLATION_ACTIVATION
 
const CMD_DEACTIVATE_CONTENT_MULTILANG
 
hideDescription(bool $hide)
 
retrieveTrafoToRemoveDefaultLang()
 
static _lookupType(int $id, bool $reference=false)
 
saveContentTranslationActivation()
 
GUI class for object translation handling. 
 
ilObjectTranslation $obj_trans
 
listTranslations(bool $get_post_values=false, bool $add=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
const CMD_DELETE_TRANSLATIONS