ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjectTranslationGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilObjectTranslationGUI:

Public Member Functions

 __construct ($obj_gui)
 
 hideDescription (bool $hide)
 
 supportContentTranslation (bool $content_translation)
 
 setTitleDescrOnlyMode (bool $val)
 Some objects like learning modules do not support to translate only the title and the description. More...
 
 getTitleDescrOnlyMode ()
 
 setEnableFallbackLanguage (bool $val)
 
 getEnableFallbackLanguage ()
 
 executeCommand ()
 
 listTranslations (bool $get_post_values=false, bool $add=false)
 
 saveTranslations (bool $delete_checked=false)
 
 deleteTranslations ()
 
 activateContentMultilinguality ()
 Activate multi language (-> master language selection) More...
 
 getMultiLangForm (bool $add=false)
 
 saveContentTranslationActivation ()
 
 confirmDeactivateContentMultiLang ()
 
 deactivateContentMultiLang ()
 
 addLanguages ()
 
 saveLanguages ()
 
 confirmRemoveLanguages ()
 
 setFallback ()
 

Data Fields

const CMD_LIST_TRANSLATIONS = "listTranslations"
 
const CMD_SAVE_TRANSLATIONS = "saveTranslations"
 
const CMD_ADD_TRANSLATION = "addTranslation"
 
const CMD_DELETE_TRANSLATIONS = "deleteTranslations"
 
const CMD_ADD_LANGUAGES = "addLanguages"
 
const CMD_SAVE_LANGUAGES = "saveLanguages"
 
const CMD_CONFIRM_REMOVE_LANGUAGES = "confirmRemoveLanguages"
 
const CMD_REMOVE_LANGUAGES = "removeLanguages"
 
const CMD_SET_FALLBACK = "setFallback"
 

Protected Attributes

ilToolbarGUI $toolbar
 
ilObjUser $user
 
ilAccess $access
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ILIAS HTTP Wrapper ArrayBasedRequestWrapper $post_wrapper
 
ILIAS Refinery Factory $refinery
 
ilObjectGUI $obj_gui
 
ilObject $obj
 
ilObjectTranslation $obj_trans
 
bool $title_descr_only = true
 
bool $hide_description = false
 
bool $fallback_lang_mode = true
 
bool $support_content_translation = true
 

Private Member Functions

 getTableValuesByObjects ()
 
 getTableValuesByRequest ()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning GUI class for object translation handling.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilObjectTranslationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjectTranslationGUI::__construct (   $obj_gui)

Definition at line 55 of file class.ilObjectTranslationGUI.php.

References $DIC, $obj_gui, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilObjectTranslation\getInstance(), ilObjectGUI\getObject(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

56  {
57  global $DIC;
58 
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();
66  $this->refinery = $DIC->refinery();
67 
68 
69  $this->obj_gui = $obj_gui;
70  $this->obj = $obj_gui->getObject();
71 
72  $this->obj_trans = ilObjectTranslation::getInstance($this->obj->getId());
73  }
global $DIC
Definition: feed.php:28
static getInstance(int $obj_id)
+ Here is the call graph for this function:

Member Function Documentation

◆ activateContentMultilinguality()

ilObjectTranslationGUI::activateContentMultilinguality ( )

Activate multi language (-> master language selection)

Definition at line 396 of file class.ilObjectTranslationGUI.php.

References getMultiLangForm(), and ILIAS\Repository\lng().

396  : void
397  {
398  $this->tpl->setOnScreenMessage('info', $this->lng->txt("obj_select_master_lang"));
399  $form = $this->getMultiLangForm();
400  $this->tpl->setContent($form->getHTML());
401  }
+ Here is the call graph for this function:

◆ addLanguages()

ilObjectTranslationGUI::addLanguages ( )

Definition at line 495 of file class.ilObjectTranslationGUI.php.

References getMultiLangForm().

495  : void
496  {
497  $form = $this->getMultiLangForm(true);
498  $this->tpl->setContent($form->getHTML());
499  }
+ Here is the call graph for this function:

◆ confirmDeactivateContentMultiLang()

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Definition at line 463 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\ctrl(), getTitleDescrOnlyMode(), and ILIAS\Repository\lng().

463  : void
464  {
465  $cgui = new ilConfirmationGUI();
466  $cgui->setFormAction($this->ctrl->getFormAction($this));
467  if ($this->getTitleDescrOnlyMode()) {
468  $cgui->setHeaderText($this->lng->txt("obj_deactivate_content_transl_conf"));
469  } else {
470  $cgui->setHeaderText($this->lng->txt("obj_deactivate_multilang_conf"));
471  }
472 
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());
476  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Definition at line 524 of file class.ilObjectTranslationGUI.php.

References $i, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

524  : void
525  {
526  $this->lng->loadLanguageModule("meta");
527 
528  $languages = $this->post_wrapper->has("lang")
529  ? $this->post_wrapper->retrieve(
530  "lang",
531  $this->refinery->kindlyTo()->dictOf(
532  $this->refinery->kindlyTo()->string()
533  )
534  )
535  : null;
536 
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);
540  } else {
541  $cgui = new ilConfirmationGUI();
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);
546 
547  foreach ($languages as $i) {
548  $cgui->addItem("lang[]", $i, $this->lng->txt("meta_l_" . $i));
549  }
550 
551  $this->tpl->setContent($cgui->getHTML());
552  }
553  }
$i
Definition: metadata.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ deactivateContentMultiLang()

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Definition at line 478 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\ctrl(), getTitleDescrOnlyMode(), and ILIAS\Repository\lng().

478  : void
479  {
480  if (!$this->getTitleDescrOnlyMode()) {
481  $this->obj_trans->setMasterLanguage("");
482  $this->obj_trans->setLanguages([]);
483  $this->obj_trans->save();
484  }
485  $this->obj_trans->deactivateContentTranslation();
486  if ($this->getTitleDescrOnlyMode()) {
487  $this->tpl->setOnScreenMessage('success', $this->lng->txt("obj_cont_transl_deactivated"), true);
488  } else {
489  $this->tpl->setOnScreenMessage('success', $this->lng->txt("obj_multilang_deactivated"), true);
490  }
491 
492  $this->ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
493  }
+ Here is the call graph for this function:

◆ deleteTranslations()

ilObjectTranslationGUI::deleteTranslations ( )

Definition at line 361 of file class.ilObjectTranslationGUI.php.

References $check, listTranslations(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and saveTranslations().

361  : void
362  {
363  $titles = $this->post_wrapper->has('title')
364  ? $this->post_wrapper->retrieve(
365  "title",
366  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
367  )
368  : [];
369  $check = $this->post_wrapper->has('check')
370  ? $this->post_wrapper->retrieve(
371  "check",
372  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
373  )
374  : [];
375 
376  foreach ($titles as $k => $v) {
377  if (isset($check[$k])) {
378  // default translation cannot be deleted
379  if (
380  !$this->post_wrapper->has("default") ||
381  $k != $this->post_wrapper->retrieve("default", $this->refinery->kindlyTo()->string())
382  ) {
383  } else {
384  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_default_language"));
385  $this->listTranslations();
386  return;
387  }
388  }
389  }
390  $this->saveTranslations(true);
391  }
saveTranslations(bool $delete_checked=false)
$check
Definition: buildRTE.php:81
listTranslations(bool $get_post_values=false, bool $add=false)
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectTranslationGUI::executeCommand ( )

Definition at line 167 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

167  : void
168  {
169  $commands = [
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
183  ];
184 
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);
190  }
191 
192  if (in_array($cmd, $commands)) {
193  $this->$cmd();
194  }
195  }
+ Here is the call graph for this function:

◆ getEnableFallbackLanguage()

ilObjectTranslationGUI::getEnableFallbackLanguage ( )

Definition at line 162 of file class.ilObjectTranslationGUI.php.

References $fallback_lang_mode.

162  : bool
163  {
165  }

◆ getMultiLangForm()

ilObjectTranslationGUI::getMultiLangForm ( bool  $add = false)

Definition at line 403 of file class.ilObjectTranslationGUI.php.

References ilMDLanguageItem\_getLanguages(), ILIAS\Repository\ctrl(), getTitleDescrOnlyMode(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

Referenced by activateContentMultilinguality(), addLanguages(), saveContentTranslationActivation(), and saveLanguages().

404  {
405  $form = new ilPropertyFormGUI();
406 
407  // master language
408  if (!$add) {
409  $options = ilMDLanguageItem::_getLanguages();
410  $si = new ilSelectInputGUI($this->lng->txt("obj_master_lang"), "master_lang");
411  $si->setOptions($options);
412  $si->setValue($this->user->getLanguage());
413  $form->addItem($si);
414  }
415 
416  // additional languages
417  if ($add) {
418  $options = ilMDLanguageItem::_getLanguages();
419  $options = ["" => $this->lng->txt("please_select")] + $options;
420  $si = new ilSelectInputGUI($this->lng->txt("obj_additional_langs"), "additional_langs");
421  $si->setOptions($options);
422  $si->setMulti(true);
423  $form->addItem($si);
424  }
425 
426  if ($add) {
427  $form->setTitle($this->lng->txt("obj_add_languages"));
428  $form->addCommandButton(self::CMD_SAVE_LANGUAGES, $this->lng->txt("save"));
429  } else {
430  if ($this->getTitleDescrOnlyMode()) {
431  $form->setTitle($this->lng->txt("obj_activate_content_lang"));
432  } else {
433  $form->setTitle($this->lng->txt("obj_activate_multilang"));
434  }
435  $form->addCommandButton("saveContentTranslationActivation", $this->lng->txt("save"));
436  }
437  $form->addCommandButton(self::CMD_LIST_TRANSLATIONS, $this->lng->txt("cancel"));
438  $form->setFormAction($this->ctrl->getFormAction($this));
439 
440  return $form;
441  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableValuesByObjects()

ilObjectTranslationGUI::getTableValuesByObjects ( )
private

Definition at line 85 of file class.ilObjectTranslationGUI.php.

References $data, and ILIAS\Repository\int().

Referenced by listTranslations().

85  : array
86  {
87  $data = [];
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();
93  }
94  return $data;
95  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableValuesByRequest()

ilObjectTranslationGUI::getTableValuesByRequest ( )
private

Definition at line 97 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\refinery().

Referenced by listTranslations().

97  : array
98  {
99  $vals = [];
100 
101  $titles = $this->post_wrapper->has("title")
102  ? $this->post_wrapper->retrieve(
103  "title",
104  $this->refinery->to()->listOf($this->refinery->kindlyTo()->string())
105  )
106  : [];
107 
108  $descriptions = $this->post_wrapper->has("desc")
109  ? $this->post_wrapper->retrieve(
110  "desc",
111  $this->refinery->to()->listOf($this->refinery->kindlyTo()->string())
112  )
113  : [];
114 
115  $languages = $this->post_wrapper->has("lang")
116  ? $this->post_wrapper->retrieve(
117  "lang",
118  $this->refinery->to()->listOf($this->refinery->kindlyTo()->string())
119  )
120  : [];
121 
122  $default = $this->post_wrapper->has("default")
123  ? $this->post_wrapper->retrieve(
124  "default",
125  $this->refinery->kindlyTo()->int()
126  )
127  : '';
128 
129  foreach ($titles as $k => $v) {
130  $vals[] = [
131  "title" => $v,
132  "desc" => $descriptions[$k],
133  "lang" => $languages[$k],
134  "default" => ($default == $k)
135  ];
136  }
137  return $vals;
138  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitleDescrOnlyMode()

ilObjectTranslationGUI::getTitleDescrOnlyMode ( )

Definition at line 152 of file class.ilObjectTranslationGUI.php.

References $title_descr_only.

Referenced by confirmDeactivateContentMultiLang(), deactivateContentMultiLang(), getMultiLangForm(), and listTranslations().

152  : bool
153  {
155  }
+ Here is the caller graph for this function:

◆ hideDescription()

ilObjectTranslationGUI::hideDescription ( bool  $hide)

Definition at line 75 of file class.ilObjectTranslationGUI.php.

75  : void
76  {
77  $this->hide_description = $hide;
78  }

◆ listTranslations()

ilObjectTranslationGUI::listTranslations ( bool  $get_post_values = false,
bool  $add = false 
)

Definition at line 197 of file class.ilObjectTranslationGUI.php.

References $fallback_lang_mode, ilObject\_lookupType(), ILIAS\Repository\ctrl(), getTableValuesByObjects(), getTableValuesByRequest(), getTitleDescrOnlyMode(), ILIAS\Repository\lng(), ilTable2GUI\setData(), and ILIAS\Repository\toolbar().

Referenced by deleteTranslations(), saveTranslations(), and setFallback().

197  : void
198  {
199  $this->lng->loadLanguageModule(ilObject::_lookupType($this->obj->getId()));
200 
201  if ($this->getTitleDescrOnlyMode() || $this->obj_trans->getContentActivated()) {
202  $this->toolbar->addButton(
203  $this->lng->txt("obj_add_languages"),
204  $this->ctrl->getLinkTarget($this, self::CMD_ADD_LANGUAGES)
205  );
206  }
207 
208  if ($this->support_content_translation) {
209  if ($this->getTitleDescrOnlyMode()) {
210  if (!$this->obj_trans->getContentActivated()) {
211  $this->tpl->setOnScreenMessage('info', $this->lng->txt("obj_multilang_title_descr_only"));
212  $this->toolbar->addButton(
213  $this->lng->txt("obj_activate_content_lang"),
214  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality")
215  );
216  } else {
217  $this->toolbar->addButton(
218  $this->lng->txt("obj_deactivate_content_lang"),
219  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang")
220  );
221  }
222  } else {
223  if ($this->obj_trans->getContentActivated()) {
224  $this->toolbar->addButton(
225  $this->lng->txt("obj_deactivate_multilang"),
226  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang")
227  );
228  } else {
229  $this->toolbar->addButton(
230  $this->lng->txt("obj_activate_multilang"),
231  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality")
232  );
233  return;
234  }
235  }
236  }
237 
238  $table = new ilObjectTranslation2TableGUI(
239  $this,
240  self::CMD_LIST_TRANSLATIONS,
241  !$this->hide_description,
242  "Translation",
243  $this->obj_trans->getMasterLanguage(),
245  $this->obj_trans->getFallbackLanguage()
246  );
247  if ($get_post_values) {
248  $table->setData($this->getTableValuesByRequest());
249  } else {
250  $table->setData($this->getTableValuesByObjects());
251  }
252  $this->tpl->setContent($table->getHTML());
253  }
setData(array $a_data)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveContentTranslationActivation()

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Definition at line 443 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\ctrl(), and getMultiLangForm().

443  : void
444  {
445  $form = $this->getMultiLangForm();
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(
451  $ml,
452  $this->obj->getTitle(),
453  $this->obj->getDescription(),
454  true
455  );
456  }
457  $this->obj_trans->save();
458  }
459 
460  $this->ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
461  }
+ Here is the call graph for this function:

◆ saveLanguages()

ilObjectTranslationGUI::saveLanguages ( )

Definition at line 501 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\ctrl(), getMultiLangForm(), and ILIAS\Repository\lng().

501  : void
502  {
503  $form = $this->getMultiLangForm(true);
504  if ($form->checkInput()) {
505  $ad = $form->getInput("additional_langs");
506  if (is_array($ad)) {
507  $ml = $this->obj_trans->getMasterLanguage();
508  foreach ($ad as $l) {
509  if ($l != $ml && $l != "") {
510  $this->obj_trans->addLanguage($l, "", "", false);
511  }
512  }
513  }
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);
517  }
518 
519  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('err_check_input'));
520  $form->setValuesByPost();
521  $this->tpl->setContent($form->getHTML());
522  }
+ Here is the call graph for this function:

◆ saveTranslations()

ilObjectTranslationGUI::saveTranslations ( bool  $delete_checked = false)

Definition at line 255 of file class.ilObjectTranslationGUI.php.

References $check, ILIAS\Repository\ctrl(), listTranslations(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by deleteTranslations().

255  : void
256  {
257  // default language set?
258  if (!$this->post_wrapper->has("default") && $this->obj_trans->getMasterLanguage() === "") {
259  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_default_language"));
260  $this->listTranslations(true);
261  return;
262  }
263 
264  // all languages set?
265  $languages = $this->post_wrapper->has("lang")
266  ? $this->post_wrapper->retrieve(
267  "lang",
268  $this->refinery->kindlyTo()->dictOf(
269  $this->refinery->kindlyTo()->string()
270  )
271  )
272  : [];
273  if (array_key_exists("", $languages)) {
274  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_language_selected"));
275  $this->listTranslations(true);
276  return;
277  }
278 
279  // no single language is selected more than once?
280  if (count(array_unique($languages)) < count($languages)) {
281  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_multi_language_selected"));
282  $this->listTranslations(true);
283  return;
284  }
285 
286  // save the stuff
287  $this->obj_trans->setLanguages([]);
288 
289  $titles = $this->post_wrapper->has("title")
290  ? $this->post_wrapper->retrieve(
291  "title",
292  $this->refinery->kindlyTo()->dictOf(
293  $this->refinery->kindlyTo()->string()
294  )
295  )
296  : [];
297  $descriptions = $this->post_wrapper->has("desc")
298  ? $this->post_wrapper->retrieve(
299  "desc",
300  $this->refinery->kindlyTo()->dictOf(
301  $this->refinery->kindlyTo()->string()
302  )
303  )
304  : [];
305 
306  $post_default = $this->post_wrapper->has("default")
307  ? $this->post_wrapper->retrieve(
308  "default",
309  $this->refinery->kindlyTo()->int()
310  )
311  : null;
312 
313  $check = $this->post_wrapper->has('check')
314  ? $this->post_wrapper->retrieve(
315  "check",
316  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
317  )
318  : [];
319 
320  if ($this->obj_trans->getFallbackLanguage() !== "") {
321  $obj_store_lang = $this->obj_trans->getFallbackLanguage();
322  } else {
323  $obj_store_lang = ($this->obj_trans->getMasterLanguage() != "")
324  ? $this->obj_trans->getMasterLanguage()
325  : $languages[$post_default];
326  }
327 
328  foreach ($titles as $k => $v) {
329  if ($delete_checked && isset($check[$k])) {
330  continue;
331  }
332  // update object data if default
333  $is_default = ($post_default === $k);
334 
335  // ensure master language is set as default
336  if ($this->obj_trans->getMasterLanguage() != "") {
337  $is_default = ($this->obj_trans->getMasterLanguage() === $languages[$k]);
338  }
339  if ($languages[$k] === $obj_store_lang) {
340  $this->obj->setTitle(ilUtil::stripSlashes($v));
341  $this->obj->setDescription(ilUtil::stripSlashes($descriptions[$k] ?? ""));
342  }
343 
344  $this->obj_trans->addLanguage(
345  ilUtil::stripSlashes($languages[$k]),
347  ilUtil::stripSlashes($descriptions[$k] ?? ""),
348  $is_default
349  );
350  }
351  $this->obj_trans->save();
352  if (method_exists($this->obj, "setObjectTranslation")) {
353  $this->obj->setObjectTranslation($this->obj_trans);
354  }
355  $this->obj->update();
356 
357  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
358  $this->ctrl->redirect($this, self::CMD_LIST_TRANSLATIONS);
359  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$check
Definition: buildRTE.php:81
listTranslations(bool $get_post_values=false, bool $add=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setEnableFallbackLanguage()

ilObjectTranslationGUI::setEnableFallbackLanguage ( bool  $val)

Definition at line 157 of file class.ilObjectTranslationGUI.php.

157  : void
158  {
159  $this->fallback_lang_mode = $val;
160  }

◆ setFallback()

ilObjectTranslationGUI::setFallback ( )

Definition at line 555 of file class.ilObjectTranslationGUI.php.

References ILIAS\Repository\ctrl(), listTranslations(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

555  : void
556  {
557  // default language set?
558  $checkboxes = $this->post_wrapper->has("check")
559  ? $this->post_wrapper->retrieve(
560  "check",
561  $this->refinery->kindlyTo()->dictOf(
562  $this->refinery->kindlyTo()->int()
563  )
564  )
565  : [];
566 
567  if ($checkboxes === []) {
568  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("obj_select_one_language"));
569  $this->listTranslations(true);
570  return;
571  }
572  $checked = key($checkboxes);
573 
574  $languages = $this->post_wrapper->has("lang")
575  ? $this->post_wrapper->retrieve(
576  "lang",
577  $this->refinery->kindlyTo()->dictOf($this->refinery->kindlyTo()->string())
578  )
579  : [];
580 
581  $fallback_lang = $languages[$checked];
582  if ($fallback_lang !== $this->obj_trans->getFallbackLanguage()) {
583  $this->obj_trans->setFallbackLanguage($fallback_lang);
584  } else {
585  $this->obj_trans->setFallbackLanguage("");
586  }
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);
590  }
listTranslations(bool $get_post_values=false, bool $add=false)
+ Here is the call graph for this function:

◆ setTitleDescrOnlyMode()

ilObjectTranslationGUI::setTitleDescrOnlyMode ( bool  $val)

Some objects like learning modules do not support to translate only the title and the description.

If they acticate multilinguasm, they translate always title, description AND content. They have to call setTitleDescrOnlyMode(false) to indicate this. Other contexts, e.g. categories allow to only translate title and description and activate the content multilinguasm separately.

Definition at line 147 of file class.ilObjectTranslationGUI.php.

147  : void
148  {
149  $this->title_descr_only = $val;
150  }

◆ supportContentTranslation()

ilObjectTranslationGUI::supportContentTranslation ( bool  $content_translation)

Definition at line 80 of file class.ilObjectTranslationGUI.php.

80  : void
81  {
82  $this->support_content_translation = $content_translation;
83  }

Field Documentation

◆ $access

ilAccess ilObjectTranslationGUI::$access
protected

Definition at line 39 of file class.ilObjectTranslationGUI.php.

◆ $ctrl

ilCtrl ilObjectTranslationGUI::$ctrl
protected

Definition at line 41 of file class.ilObjectTranslationGUI.php.

◆ $fallback_lang_mode

bool ilObjectTranslationGUI::$fallback_lang_mode = true
protected

Definition at line 52 of file class.ilObjectTranslationGUI.php.

Referenced by getEnableFallbackLanguage(), and listTranslations().

◆ $hide_description

bool ilObjectTranslationGUI::$hide_description = false
protected

Definition at line 51 of file class.ilObjectTranslationGUI.php.

◆ $lng

ilLanguage ilObjectTranslationGUI::$lng
protected

Definition at line 40 of file class.ilObjectTranslationGUI.php.

◆ $obj

ilObject ilObjectTranslationGUI::$obj
protected

Definition at line 47 of file class.ilObjectTranslationGUI.php.

◆ $obj_gui

ilObjectGUI ilObjectTranslationGUI::$obj_gui
protected

Definition at line 46 of file class.ilObjectTranslationGUI.php.

Referenced by __construct().

◆ $obj_trans

ilObjectTranslation ilObjectTranslationGUI::$obj_trans
protected

Definition at line 48 of file class.ilObjectTranslationGUI.php.

◆ $post_wrapper

ILIAS HTTP Wrapper ArrayBasedRequestWrapper ilObjectTranslationGUI::$post_wrapper
protected

Definition at line 43 of file class.ilObjectTranslationGUI.php.

◆ $refinery

ILIAS Refinery Factory ilObjectTranslationGUI::$refinery
protected

Definition at line 44 of file class.ilObjectTranslationGUI.php.

◆ $support_content_translation

bool ilObjectTranslationGUI::$support_content_translation = true
protected

Definition at line 53 of file class.ilObjectTranslationGUI.php.

◆ $title_descr_only

bool ilObjectTranslationGUI::$title_descr_only = true
protected

Definition at line 50 of file class.ilObjectTranslationGUI.php.

Referenced by getTitleDescrOnlyMode().

◆ $toolbar

ilToolbarGUI ilObjectTranslationGUI::$toolbar
protected

Definition at line 37 of file class.ilObjectTranslationGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilObjectTranslationGUI::$tpl
protected

Definition at line 42 of file class.ilObjectTranslationGUI.php.

◆ $user

ilObjUser ilObjectTranslationGUI::$user
protected

Definition at line 38 of file class.ilObjectTranslationGUI.php.

◆ CMD_ADD_LANGUAGES

const ilObjectTranslationGUI::CMD_ADD_LANGUAGES = "addLanguages"

Definition at line 32 of file class.ilObjectTranslationGUI.php.

◆ CMD_ADD_TRANSLATION

const ilObjectTranslationGUI::CMD_ADD_TRANSLATION = "addTranslation"

Definition at line 30 of file class.ilObjectTranslationGUI.php.

◆ CMD_CONFIRM_REMOVE_LANGUAGES

const ilObjectTranslationGUI::CMD_CONFIRM_REMOVE_LANGUAGES = "confirmRemoveLanguages"

Definition at line 34 of file class.ilObjectTranslationGUI.php.

◆ CMD_DELETE_TRANSLATIONS

const ilObjectTranslationGUI::CMD_DELETE_TRANSLATIONS = "deleteTranslations"

Definition at line 31 of file class.ilObjectTranslationGUI.php.

◆ CMD_LIST_TRANSLATIONS

const ilObjectTranslationGUI::CMD_LIST_TRANSLATIONS = "listTranslations"

Definition at line 28 of file class.ilObjectTranslationGUI.php.

◆ CMD_REMOVE_LANGUAGES

const ilObjectTranslationGUI::CMD_REMOVE_LANGUAGES = "removeLanguages"

Definition at line 35 of file class.ilObjectTranslationGUI.php.

◆ CMD_SAVE_LANGUAGES

const ilObjectTranslationGUI::CMD_SAVE_LANGUAGES = "saveLanguages"

Definition at line 33 of file class.ilObjectTranslationGUI.php.

◆ CMD_SAVE_TRANSLATIONS

const ilObjectTranslationGUI::CMD_SAVE_TRANSLATIONS = "saveTranslations"

Definition at line 29 of file class.ilObjectTranslationGUI.php.

◆ CMD_SET_FALLBACK

const ilObjectTranslationGUI::CMD_SET_FALLBACK = "setFallback"

Definition at line 36 of file class.ilObjectTranslationGUI.php.


The documentation for this class was generated from the following file: