26 protected \ILIAS\Multilingualism\StandardGUIRequest
$request;
43 $this->
toolbar = $DIC->toolbar();
44 $this->
user = $DIC->user();
45 $this->
lng = $DIC->language();
46 $this->
lng->loadLanguageModule(
'obj');
47 $this->
ctrl = $DIC->ctrl();
48 $this->tpl = $DIC->ui()->mainTemplate();
51 $this->request = new \ILIAS\Multilingualism\StandardGUIRequest(
62 $this->title_descr_only = $a_val;
75 $next_class = $this->
ctrl->getNextClass($this);
77 switch ($next_class) {
79 $cmd = $this->
ctrl->getCmd(
"listTranslations");
80 if (in_array($cmd, array(
"listTranslations",
"saveTranslations",
81 "addTranslation",
"deleteTranslations",
"activateContentMultilinguality",
82 "confirmRemoveLanguages",
"removeLanguages",
"confirmDeactivateContentMultiLang",
"saveLanguages",
83 "saveContentTranslationActivation",
"deactivateContentMultiLang",
"addLanguages"))) {
91 bool $a_get_post_values =
false,
94 $this->
lng->loadLanguageModule(
"translation");
99 $titles = $this->request->getTitles();
100 $langs = $this->request->getLanguages();
101 $descs = $this->request->getDescriptions();
102 $default = $this->request->getDefault();
110 if ($a_get_post_values) {
112 foreach ($titles as $k => $v) {
113 $vals[] = array(
"title" => $v,
114 "desc" => $descs[$k],
115 "lang" => $langs[$k],
116 "default" => ($default == $k));
118 $table->setData($vals);
121 $data = $this->obj_trans->getLanguages();
122 foreach (
$data as $k => $v) {
123 $data[$k][
"default"] = $v[
"lang_default"];
124 $data[$k][
"desc"] = $v[
"description"];
125 $data[$k][
"lang"] = $v[
"lang_code"];
128 $data[
"Fobject"][++$k][
"title"] =
"";
130 $table->setData(
$data);
132 $this->tpl->setContent($table->getHTML());
140 $this->
lng->txt(
"obj_add_languages"),
141 $this->
ctrl->getLinkTarget($this,
"addLanguages")
148 $default = $this->request->getDefault();
149 $langs = $this->request->getLanguages();
150 $titles = $this->request->getTitles();
151 $descs = $this->request->getDescriptions();
154 if ($default ===
"") {
155 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
161 if (array_key_exists(
"", $langs)) {
162 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_language_selected"));
168 if (count(array_unique($langs)) < count($langs)) {
169 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_multi_language_selected"));
174 $check = $this->request->getCheck();
177 $this->obj_trans->setLanguages(array());
179 foreach ($titles as $k => $v) {
181 $is_default = ($default == $k);
182 if ($delete_checked && !$is_default && isset(
$check[$k])) {
186 $this->obj_trans->addLanguage(
193 $this->obj_trans->save();
195 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
196 $this->
ctrl->redirect($this,
"listTranslations");
201 $default = $this->request->getDefault();
202 $langs = $this->request->getLanguages();
203 $titles = $this->request->getTitles();
204 $descs = $this->request->getDescriptions();
205 $check = $this->request->getCheck();
206 foreach ($titles as $k => $v) {
207 if (
$check[$k] ??
false) {
209 if ($k != $default) {
210 unset($titles[$k], $descs[$k], $langs[$k]);
212 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
240 $si->setOptions($options);
241 $si->setValue(
$ilUser->getLanguage());
248 $options = array(
"" => $lng->
txt(
"please_select")) + $options;
250 $si->setOptions($options);
256 $form->setTitle($lng->
txt(
"obj_add_languages"));
257 $form->addCommandButton(
"saveLanguages", $lng->
txt(
"save"));
260 $form->setTitle($lng->
txt(
"obj_activate_content_lang"));
262 $form->setTitle($lng->
txt(
"obj_activate_multilang"));
264 $form->addCommandButton(
"saveContentTranslationActivation", $lng->
txt(
"save"));
266 $form->addCommandButton(
"listTranslations", $lng->
txt(
"cancel"));
267 $form->setFormAction($ilCtrl->getFormAction($this));
282 $cgui->setFormAction($ilCtrl->getFormAction($this));
284 $cgui->setHeaderText($lng->
txt(
"obj_deactivate_content_transl_conf"));
286 $cgui->setHeaderText($lng->
txt(
"obj_deactivate_multilang_conf"));
289 $cgui->setCancel($lng->
txt(
"cancel"),
"listTranslations");
290 $cgui->setConfirm($lng->
txt(
"confirm"),
"deactivateContentMultiLang");
315 if ($form->checkInput()) {
316 $ad = $form->getInput(
"additional_langs");
321 foreach ($ad as $l) {
326 if (!count($this->obj_trans->getLanguages())) {
330 $this->obj_trans->addLanguage($l, $this->start_title, $this->start_description, $std);
334 $this->obj_trans->save();
335 $this->tpl->setOnScreenMessage(
'info', $lng->
txt(
"msg_obj_modified"),
true);
336 $ilCtrl->redirect($this,
"listTranslations");
338 $form->setValuesByPost();
339 $this->tpl->setOnScreenMessage(
'failure', $lng->
txt(
'err_check_input'));
354 $langs = $this->request->getLanguages();
356 if (count($langs) === 0) {
357 $this->tpl->setOnScreenMessage(
'info', $lng->
txt(
"no_checkbox"),
true);
358 $ilCtrl->redirect($this,
"listTranslations");
361 $cgui->setFormAction($ilCtrl->getFormAction($this));
362 $cgui->setHeaderText($lng->
txt(
"obj_conf_delete_lang"));
363 $cgui->setCancel($lng->
txt(
"cancel"),
"listTranslations");
364 $cgui->setConfirm($lng->
txt(
"remove"),
"removeLanguages");
366 foreach ($langs as
$i) {
367 $cgui->addItem(
"lang[]", $i, $lng->
txt(
"meta_l_" . $i));
382 $post_langs = $this->request->getLanguages();
384 if (count($post_langs) > 0) {
385 $langs = $this->obj_trans->getLanguages();
386 foreach ($langs as $k => $l) {
387 if (in_array($l, $post_langs)) {
388 $this->obj_trans->removeLanguage($l);
391 $this->obj_trans->save();
392 $this->tpl->setOnScreenMessage(
'info', $lng->
txt(
"msg_obj_modified"),
true);
394 $ilCtrl->
redirect($this,
"listTranslations");
399 string $a_description
401 $this->start_title = $a_title;
402 $this->start_description = $a_description;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(int $a_obj_id, string $a_type)
static getLogger(string $a_component_id)
Get component logger.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getInstance(int $a_obj_id, string $a_type)
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
ilGlobalTemplateInterface $tpl
saveTranslations(bool $delete_checked=false)
loadLanguageModule(string $a_module)
Load language module.
getMultiLangForm(bool $a_add=false)
Get multi language form.
getTitleDescrOnlyMode()
Get enable title/description only mode.
ilMultilingualism $obj_trans
setStartValues(string $a_title, string $a_description)
setTitleDescrOnlyMode(bool $a_val)
Set enable title/description only mode.
setContent(string $a_html)
Sets content for standard template.
confirmDeactivateContentMultiLang()
Confirm page translation creation.
ILIAS Multilingualism StandardGUIRequest $request
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addLanguages(ilPropertyFormGUI $form=null)
Add language.
removeLanguages()
Remove languages.
confirmRemoveLanguages()
Confirm remove languages.
listTranslations(bool $a_get_post_values=false, bool $a_add=false)
string $start_description
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...