3 declare(strict_types=1);
59 $this->
toolbar = $DIC->toolbar();
60 $this->
user = $DIC->user();
61 $this->
access = $DIC[
'ilAccess'];
62 $this->
lng = $DIC->language();
63 $this->
ctrl = $DIC->ctrl();
64 $this->tpl = $DIC[
"tpl"];
65 $this->post_wrapper = $DIC->http()->wrapper()->post();
77 $this->hide_description = $hide;
82 $this->support_content_translation = $content_translation;
88 foreach ($this->obj_trans->getLanguages() as $k => $v) {
89 $data[$k][
"default"] = (
int) $v->isDefault();
90 $data[$k][
"title"] = $v->getTitle();
91 $data[$k][
"desc"] = $v->getDescription();
92 $data[$k][
"lang"] = $v->getLanguageCode();
101 $titles = $this->post_wrapper->has(
"title")
102 ? $this->post_wrapper->retrieve(
108 $descriptions = $this->post_wrapper->has(
"desc")
109 ? $this->post_wrapper->retrieve(
115 $languages = $this->post_wrapper->has(
"lang")
116 ? $this->post_wrapper->retrieve(
122 $default = $this->post_wrapper->has(
"default")
123 ? $this->post_wrapper->retrieve(
129 foreach ($titles as $k => $v) {
132 "desc" => $descriptions[$k],
133 "lang" => $languages[$k],
134 "default" => ($default == $k)
149 $this->title_descr_only = $val;
159 $this->fallback_lang_mode = $val;
170 self::CMD_LIST_TRANSLATIONS,
171 self::CMD_SAVE_TRANSLATIONS,
172 self::CMD_ADD_TRANSLATION,
173 self::CMD_DELETE_TRANSLATIONS,
174 "activateContentMultilinguality",
175 self::CMD_CONFIRM_REMOVE_LANGUAGES,
176 self::CMD_REMOVE_LANGUAGES,
177 "confirmDeactivateContentMultiLang",
178 self::CMD_SAVE_LANGUAGES,
179 "saveContentTranslationActivation",
180 "deactivateContentMultiLang",
181 self::CMD_ADD_LANGUAGES,
182 self::CMD_SET_FALLBACK
185 $this->
ctrl->getNextClass($this);
186 $cmd = $this->
ctrl->getCmd(self::CMD_LIST_TRANSLATIONS);
187 if (!$this->
access->checkAccess(
'write',
'', $this->obj_gui->getRefId())) {
188 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_permission'));
189 $this->
ctrl->redirect($this->obj_gui);
192 if (in_array($cmd, $commands)) {
203 $this->
lng->txt(
"obj_add_languages"),
204 $this->
ctrl->getLinkTarget($this, self::CMD_ADD_LANGUAGES)
208 if ($this->support_content_translation) {
210 if (!$this->obj_trans->getContentActivated()) {
211 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"obj_multilang_title_descr_only"));
213 $this->
lng->txt(
"obj_activate_content_lang"),
214 $this->
ctrl->getLinkTarget($this,
"activateContentMultilinguality")
218 $this->
lng->txt(
"obj_deactivate_content_lang"),
219 $this->
ctrl->getLinkTarget($this,
"confirmDeactivateContentMultiLang")
223 if ($this->obj_trans->getContentActivated()) {
225 $this->
lng->txt(
"obj_deactivate_multilang"),
226 $this->
ctrl->getLinkTarget($this,
"confirmDeactivateContentMultiLang")
230 $this->
lng->txt(
"obj_activate_multilang"),
231 $this->
ctrl->getLinkTarget($this,
"activateContentMultilinguality")
240 self::CMD_LIST_TRANSLATIONS,
241 !$this->hide_description,
243 $this->obj_trans->getMasterLanguage(),
245 $this->obj_trans->getFallbackLanguage()
247 if ($get_post_values) {
252 $this->tpl->setContent($table->getHTML());
258 if (!$this->post_wrapper->has(
"default") && $this->obj_trans->getMasterLanguage() ===
"") {
259 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
265 $languages = $this->post_wrapper->has(
"lang")
266 ? $this->post_wrapper->retrieve(
268 $this->
refinery->kindlyTo()->dictOf(
269 $this->
refinery->kindlyTo()->string()
273 if (array_key_exists(
"", $languages)) {
274 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_language_selected"));
280 if (count(array_unique($languages)) < count($languages)) {
281 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_multi_language_selected"));
287 $this->obj_trans->setLanguages([]);
289 $titles = $this->post_wrapper->has(
"title")
290 ? $this->post_wrapper->retrieve(
292 $this->
refinery->kindlyTo()->dictOf(
293 $this->
refinery->kindlyTo()->string()
297 $descriptions = $this->post_wrapper->has(
"desc")
298 ? $this->post_wrapper->retrieve(
300 $this->
refinery->kindlyTo()->dictOf(
301 $this->
refinery->kindlyTo()->string()
306 $post_default = $this->post_wrapper->has(
"default")
307 ? $this->post_wrapper->retrieve(
313 $check = $this->post_wrapper->has(
'check')
314 ? $this->post_wrapper->retrieve(
320 if ($this->obj_trans->getFallbackLanguage() !==
"") {
321 $obj_store_lang = $this->obj_trans->getFallbackLanguage();
323 $obj_store_lang = ($this->obj_trans->getMasterLanguage() !=
"")
324 ? $this->obj_trans->getMasterLanguage()
325 : $languages[$post_default];
328 foreach ($titles as $k => $v) {
329 if ($delete_checked && isset(
$check[$k])) {
333 $is_default = ($post_default === $k);
336 if ($this->obj_trans->getMasterLanguage() !=
"") {
337 $is_default = ($this->obj_trans->getMasterLanguage() === $languages[$k]);
339 if ($languages[$k] === $obj_store_lang) {
344 $this->obj_trans->addLanguage(
351 $this->obj_trans->save();
352 if (method_exists($this->obj,
"setObjectTranslation")) {
353 $this->obj->setObjectTranslation($this->obj_trans);
355 $this->obj->update();
357 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
358 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
363 $titles = $this->post_wrapper->has(
'title')
364 ? $this->post_wrapper->retrieve(
369 $check = $this->post_wrapper->has(
'check')
370 ? $this->post_wrapper->retrieve(
376 foreach ($titles as $k => $v) {
380 !$this->post_wrapper->has(
"default") ||
381 $k != $this->post_wrapper->retrieve(
"default", $this->
refinery->kindlyTo()->string())
384 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
398 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"obj_select_master_lang"));
400 $this->tpl->setContent($form->getHTML());
411 $si->setOptions($options);
412 $si->setValue($this->
user->getLanguage());
419 $options = [
"" => $this->
lng->txt(
"please_select")] + $options;
421 $si->setOptions($options);
427 $form->setTitle($this->
lng->txt(
"obj_add_languages"));
428 $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->
lng->txt(
"save"));
431 $form->setTitle($this->
lng->txt(
"obj_activate_content_lang"));
433 $form->setTitle($this->
lng->txt(
"obj_activate_multilang"));
435 $form->addCommandButton(
"saveContentTranslationActivation", $this->
lng->txt(
"save"));
437 $form->addCommandButton(self::CMD_LIST_TRANSLATIONS, $this->
lng->txt(
"cancel"));
438 $form->setFormAction($this->
ctrl->getFormAction($this));
446 if ($form->checkInput()) {
447 $ml = $form->getInput(
"master_lang");
448 $this->obj_trans->setMasterLanguage($ml);
449 if (!in_array($ml, $this->obj_trans->getLanguages())) {
450 $this->obj_trans->addLanguage(
452 $this->obj->getTitle(),
453 $this->obj->getDescription(),
457 $this->obj_trans->save();
460 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
466 $cgui->setFormAction($this->
ctrl->getFormAction($this));
468 $cgui->setHeaderText($this->
lng->txt(
"obj_deactivate_content_transl_conf"));
470 $cgui->setHeaderText($this->
lng->txt(
"obj_deactivate_multilang_conf"));
473 $cgui->setCancel($this->
lng->txt(
"cancel"), self::CMD_LIST_TRANSLATIONS);
474 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"deactivateContentMultiLang");
475 $this->tpl->setContent($cgui->getHTML());
481 $this->obj_trans->setMasterLanguage(
"");
482 $this->obj_trans->setLanguages([]);
483 $this->obj_trans->save();
485 $this->obj_trans->deactivateContentTranslation();
487 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"obj_cont_transl_deactivated"),
true);
489 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"obj_multilang_deactivated"),
true);
492 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
498 $this->tpl->setContent($form->getHTML());
504 if ($form->checkInput()) {
505 $ad = $form->getInput(
"additional_langs");
507 $ml = $this->obj_trans->getMasterLanguage();
508 foreach ($ad as $l) {
509 if ($l != $ml && $l !=
"") {
510 $this->obj_trans->addLanguage($l,
"",
"",
false);
514 $this->obj_trans->save();
515 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"msg_obj_modified"),
true);
516 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
519 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'err_check_input'));
520 $form->setValuesByPost();
521 $this->tpl->setContent($form->getHTML());
526 $this->
lng->loadLanguageModule(
"meta");
528 $languages = $this->post_wrapper->has(
"lang")
529 ? $this->post_wrapper->retrieve(
531 $this->
refinery->kindlyTo()->dictOf(
532 $this->
refinery->kindlyTo()->string()
537 if (!is_array($languages) || count($languages) === 0) {
538 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"no_checkbox"),
true);
539 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
542 $cgui->setFormAction($this->
ctrl->getFormAction($this));
543 $cgui->setHeaderText($this->
lng->txt(
"obj_conf_delete_lang"));
544 $cgui->setCancel($this->
lng->txt(
"cancel"), self::CMD_LIST_TRANSLATIONS);
545 $cgui->setConfirm($this->
lng->txt(
"remove"), self::CMD_REMOVE_LANGUAGES);
547 foreach ($languages as
$i) {
548 $cgui->addItem(
"lang[]", $i, $this->
lng->txt(
"meta_l_" . $i));
551 $this->tpl->setContent($cgui->getHTML());
558 $checkboxes = $this->post_wrapper->has(
"check")
559 ? $this->post_wrapper->retrieve(
561 $this->
refinery->kindlyTo()->dictOf(
567 if ($checkboxes === []) {
568 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"obj_select_one_language"));
572 $checked = key($checkboxes);
574 $languages = $this->post_wrapper->has(
"lang")
575 ? $this->post_wrapper->retrieve(
581 $fallback_lang = $languages[$checked];
582 if ($fallback_lang !== $this->obj_trans->getFallbackLanguage()) {
583 $this->obj_trans->setFallbackLanguage($fallback_lang);
585 $this->obj_trans->setFallbackLanguage(
"");
587 $this->obj_trans->save();
588 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"msg_obj_modified"),
true);
589 $this->
ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
confirmDeactivateContentMultiLang()
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
ILIAS HTTP Wrapper ArrayBasedRequestWrapper $post_wrapper
getEnableFallbackLanguage()
activateContentMultilinguality()
Activate multi language (-> master language selection)
saveTranslations(bool $delete_checked=false)
getTableValuesByRequest()
bool $support_content_translation
ilGlobalTemplateInterface $tpl
const CMD_REMOVE_LANGUAGES
Class ilObjectGUI Basic methods of all Output classes.
static getInstance(int $obj_id)
getTableValuesByObjects()
const CMD_ADD_TRANSLATION
getMultiLangForm(bool $add=false)
supportContentTranslation(bool $content_translation)
deactivateContentMultiLang()
setEnableFallbackLanguage(bool $val)
ILIAS Refinery Factory $refinery
const CMD_CONFIRM_REMOVE_LANGUAGES
hideDescription(bool $hide)
static _lookupType(int $id, bool $reference=false)
saveContentTranslationActivation()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CMD_DELETE_TRANSLATIONS