28 protected \ILIAS\DidacticTemplate\Multilingualism\StandardGUIRequest
$request;
46 $this->
toolbar = $DIC->toolbar();
47 $this->
user = $DIC->user();
48 $this->
lng = $DIC->language();
49 $this->
lng->loadLanguageModule(
'obj');
50 $this->
ctrl = $DIC->ctrl();
51 $this->tpl =
$DIC->ui()->mainTemplate();
52 $this->lom_services =
$DIC->learningObjectMetadata();
55 $this->request = new \ILIAS\Multilingualism\StandardGUIRequest(
66 $this->title_descr_only = $a_val;
79 $next_class = $this->
ctrl->getNextClass($this);
81 switch ($next_class) {
83 $cmd = $this->
ctrl->getCmd(
"listTranslations");
84 if (in_array($cmd, array(
"listTranslations",
"saveTranslations",
85 "addTranslation",
"deleteTranslations",
"activateContentMultilinguality",
86 "confirmRemoveLanguages",
"removeLanguages",
"confirmDeactivateContentMultiLang",
"saveLanguages",
87 "saveContentTranslationActivation",
"deactivateContentMultiLang",
"addLanguages"))) {
95 bool $a_get_post_values =
false,
98 $this->
lng->loadLanguageModule(
"translation");
103 $titles = $this->request->getTitles();
104 $langs = $this->request->getLanguages();
105 $descs = $this->request->getDescriptions();
106 $default = $this->request->getDefault();
114 if ($a_get_post_values) {
116 foreach ($titles as $k => $v) {
117 $vals[] = array(
"title" => $v,
118 "desc" => $descs[$k],
119 "lang" => $langs[$k],
120 "default" => ($default == $k));
122 $table->setData($vals);
125 $data = $this->obj_trans->getLanguages();
126 foreach (
$data as $k => $v) {
127 $data[$k][
"default"] = $v[
"lang_default"];
128 $data[$k][
"desc"] = $v[
"description"];
129 $data[$k][
"lang"] = $v[
"lang_code"];
132 $data[
"Fobject"][++$k][
"title"] =
"";
134 $table->setData(
$data);
136 $this->tpl->setContent($table->getHTML());
141 $ilToolbar = $this->toolbar;
142 if ($this->getTitleDescrOnlyMode()) {
143 $ilToolbar->addButton(
144 $this->
lng->txt(
"obj_add_languages"),
145 $this->ctrl->getLinkTarget($this,
"addLanguages")
152 $default = $this->request->getDefault();
153 $langs = $this->request->getLanguages();
154 $titles = $this->request->getTitles();
155 $descs = $this->request->getDescriptions();
158 if ($default ===
"") {
159 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
160 $this->listTranslations(
true);
165 if (array_key_exists(
"", $langs)) {
166 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_language_selected"));
167 $this->listTranslations(
true);
172 if (count(array_unique($langs)) < count($langs)) {
173 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_multi_language_selected"));
174 $this->listTranslations(
true);
178 $check = $this->request->getCheck();
181 $this->obj_trans->setLanguages(array());
183 foreach ($titles as $k => $v) {
185 $is_default = ($default == $k);
186 if ($delete_checked && !$is_default && isset(
$check[$k])) {
190 $this->obj_trans->addLanguage(
197 $this->obj_trans->save();
199 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"msg_obj_modified"),
true);
200 $this->
ctrl->redirect($this,
"listTranslations");
205 $default = $this->request->getDefault();
206 $langs = $this->request->getLanguages();
207 $titles = $this->request->getTitles();
208 $descs = $this->request->getDescriptions();
209 $check = $this->request->getCheck();
210 foreach ($titles as $k => $v) {
211 if (
$check[$k] ??
false) {
213 if ($k != $default) {
214 unset($titles[$k], $descs[$k], $langs[$k]);
216 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"msg_no_default_language"));
217 $this->listTranslations();
222 $this->saveTranslations(
true);
235 $ilCtrl = $this->ctrl;
236 $ilUser = $this->user;
241 foreach ($this->lom_services->dataHelper()->getAllLanguages() as $language) {
242 $options[$language->value()] = $language->presentableLabel();
248 $si->setOptions($options);
249 $si->setValue($ilUser->getLanguage());
255 $options = array(
"" =>
$lng->txt(
"please_select")) + $options;
257 $si->setOptions($options);
263 $form->setTitle(
$lng->txt(
"obj_add_languages"));
264 $form->addCommandButton(
"saveLanguages",
$lng->txt(
"save"));
266 if ($this->getTitleDescrOnlyMode()) {
267 $form->setTitle(
$lng->txt(
"obj_activate_content_lang"));
269 $form->setTitle(
$lng->txt(
"obj_activate_multilang"));
271 $form->addCommandButton(
"saveContentTranslationActivation",
$lng->txt(
"save"));
273 $form->addCommandButton(
"listTranslations",
$lng->txt(
"cancel"));
274 $form->setFormAction($ilCtrl->getFormAction($this));
284 $ilCtrl = $this->ctrl;
289 $cgui->setFormAction($ilCtrl->getFormAction($this));
290 if ($this->getTitleDescrOnlyMode()) {
291 $cgui->setHeaderText(
$lng->txt(
"obj_deactivate_content_transl_conf"));
293 $cgui->setHeaderText(
$lng->txt(
"obj_deactivate_multilang_conf"));
296 $cgui->setCancel(
$lng->txt(
"cancel"),
"listTranslations");
297 $cgui->setConfirm(
$lng->txt(
"confirm"),
"deactivateContentMultiLang");
309 $form = $this->getMultiLangForm(
true);
316 $ilCtrl = $this->ctrl;
321 $form = $this->getMultiLangForm(
true);
322 if ($form->checkInput()) {
323 $ad = $form->getInput(
"additional_langs");
328 foreach ($ad as $l) {
333 if (!count($this->obj_trans->getLanguages())) {
337 $this->obj_trans->addLanguage($l, $this->start_title, $this->start_description, $std);
341 $this->obj_trans->save();
342 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
343 $ilCtrl->redirect($this,
"listTranslations");
345 $form->setValuesByPost();
346 $this->tpl->setOnScreenMessage(
'failure',
$lng->txt(
'err_check_input'));
347 $this->addLanguages($form);
356 $ilCtrl = $this->ctrl;
360 $lng->loadLanguageModule(
"meta");
361 $langs = $this->request->getLanguages();
363 if (count($langs) === 0) {
364 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"no_checkbox"),
true);
365 $ilCtrl->redirect($this,
"listTranslations");
368 $cgui->setFormAction($ilCtrl->getFormAction($this));
369 $cgui->setHeaderText(
$lng->txt(
"obj_conf_delete_lang"));
370 $cgui->setCancel(
$lng->txt(
"cancel"),
"listTranslations");
371 $cgui->setConfirm(
$lng->txt(
"remove"),
"removeLanguages");
373 foreach ($langs as $i) {
374 $cgui->addItem(
"lang[]", $i,
$lng->txt(
"meta_l_" . $i));
387 $ilCtrl = $this->ctrl;
389 $post_langs = $this->request->getLanguages();
391 if (count($post_langs) > 0) {
392 $langs = $this->obj_trans->getLanguages();
393 foreach ($langs as $k => $l) {
394 if (in_array($l, $post_langs)) {
395 $this->obj_trans->removeLanguage($l);
398 $this->obj_trans->save();
399 $this->tpl->setOnScreenMessage(
'info',
$lng->txt(
"msg_obj_modified"),
true);
401 $ilCtrl->redirect($this,
"listTranslations");
406 string $a_description
408 $this->start_title = $a_title;
409 $this->start_description = $a_description;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setStartValues(string $a_title, string $a_description)
ilMultilingualism $obj_trans
listTranslations(bool $a_get_post_values=false, bool $a_add=false)
confirmDeactivateContentMultiLang()
Confirm page translation creation.
string $start_description
ILIAS DidacticTemplate Multilingualism StandardGUIRequest $request
setTitleDescrOnlyMode(bool $a_val)
Set enable title/description only mode.
confirmRemoveLanguages()
Confirm remove languages.
getMultiLangForm(bool $a_add=false)
Get multi language form.
__construct(int $a_obj_id, string $a_type)
LOMServices $lom_services
saveTranslations(bool $delete_checked=false)
addLanguages(?ilPropertyFormGUI $form=null)
Add language.
getTitleDescrOnlyMode()
Get enable title/description only mode.
ilGlobalTemplateInterface $tpl
removeLanguages()
Remove languages.
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...
static getInstance(int $a_obj_id, string $a_type)
setContent(string $a_html)
Sets content for standard template.