ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjectTranslationGUI Class Reference

GUI class for object translation handling. More...

+ Collaboration diagram for ilObjectTranslationGUI:

Public Member Functions

 __construct ($a_obj_gui)
 Constructor. More...
 
 setTitleDescrOnlyMode ($a_val)
 Set enable title/description only mode. More...
 
 getTitleDescrOnlyMode ()
 Get enable title/description only mode. More...
 
 executeCommand ()
 Execute command. More...
 
 listTranslations ($a_get_post_values=false, $a_add=false)
 List translations. More...
 
 saveTranslations ()
 Save translations. More...
 
 deleteTranslations ()
 Remove translation. More...
 
 activateContentMultilinguality ()
 Activate multi language (-> master language selection) More...
 
 getMultiLangForm ($a_add=false)
 Get multi language form. More...
 
 saveContentTranslationActivation ()
 Save content translation activation. More...
 
 confirmDeactivateContentMultiLang ()
 Get multi lang info. More...
 
 deactivateContentMultiLang ()
 Deactivate multilanguage. More...
 
 addLanguages ()
 Add language. More...
 
 saveLanguages ()
 Save languages. More...
 
 confirmRemoveLanguages ()
 Confirm remove languages. More...
 
 removeLanguages ()
 Remove languages. More...
 

Protected Attributes

 $lng
 
 $ctrl
 
 $tpl
 
 $toolbar
 
 $user
 
 $obj_trans
 
 $title_descr_only = true
 

Detailed Description

GUI class for object translation handling.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilObjectTranslationGUI::__construct (   $a_obj_gui)

Constructor.

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

References $DIC, $ilCtrl, $lng, $tpl, ilObjectTranslation\getInstance(), and user().

46  {
47  global $DIC;
48 
49  $this->toolbar = $DIC->toolbar();
50  $this->user = $DIC->user();
51  $lng = $DIC->language();
52  $ilCtrl = $DIC->ctrl();
53  $tpl = $DIC["tpl"];
54 
55  $this->lng = $lng;
56  $this->ctrl = $ilCtrl;
57  $this->tpl = $tpl;
58  $this->obj_gui = $a_obj_gui;
59  $this->obj = $a_obj_gui->object;
60 
61  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
62  $this->obj_trans = ilObjectTranslation::getInstance($this->obj->getId());
63  }
global $DIC
Definition: saml.php:7
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
static getInstance($a_obj_id)
Get instance.
+ Here is the call graph for this function:

Member Function Documentation

◆ activateContentMultilinguality()

ilObjectTranslationGUI::activateContentMultilinguality ( )

Activate multi language (-> master language selection)

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

References $form, $lng, $tpl, getMultiLangForm(), and ilUtil\sendInfo().

269  {
270  $tpl = $this->tpl;
271  $lng = $this->lng;
272 
273  ilUtil::sendInfo($lng->txt("obj_select_master_lang"));
274 
275  $form = $this->getMultiLangForm();
276  $tpl->setContent($form->getHTML());
277  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_POST['submit'])) $form
getMultiLangForm($a_add=false)
Get multi language form.
+ Here is the call graph for this function:

◆ addLanguages()

ilObjectTranslationGUI::addLanguages ( )

Add language.

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

References $form, $tpl, and getMultiLangForm().

435  {
436  $tpl = $this->tpl;
437 
438  $form = $this->getMultiLangForm(true);
439  $tpl->setContent($form->getHTML());
440  }
if(isset($_POST['submit'])) $form
getMultiLangForm($a_add=false)
Get multi language form.
+ Here is the call graph for this function:

◆ confirmDeactivateContentMultiLang()

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Get multi lang info.

Confirm page translation creation

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

References $ctrl, $ilCtrl, $lng, $tpl, and getTitleDescrOnlyMode().

388  {
390  $tpl = $this->tpl;
391  $lng = $this->lng;
392 
393  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
394  $cgui = new ilConfirmationGUI();
395  $cgui->setFormAction($ilCtrl->getFormAction($this));
396  if ($this->getTitleDescrOnlyMode()) {
397  $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
398  } else {
399  $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
400  }
401 
402  $cgui->setCancel($lng->txt("cancel"), "listTranslations");
403  $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
404  $tpl->setContent($cgui->getHTML());
405  }
global $ilCtrl
Definition: ilias.php:18
getTitleDescrOnlyMode()
Get enable title/description only mode.
Confirmation screen class.
+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

References $_POST, $ctrl, $i, $ilCtrl, $lng, $tpl, and ilUtil\sendInfo().

476  {
478  $tpl = $this->tpl;
479  $lng = $this->lng;
480 
481  $lng->loadLanguageModule("meta");
482 
483  if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0) {
484  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
485  $ilCtrl->redirect($this, "listTranslations");
486  } else {
487  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
488  $cgui = new ilConfirmationGUI();
489  $cgui->setFormAction($ilCtrl->getFormAction($this));
490  $cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
491  $cgui->setCancel($lng->txt("cancel"), "listTranslations");
492  $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
493 
494  foreach ($_POST["lang"] as $i) {
495  $cgui->addItem("lang[]", $i, $lng->txt("meta_l_" . $i));
496  }
497 
498  $tpl->setContent($cgui->getHTML());
499  }
500  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$i
Definition: disco.tpl.php:19
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:

◆ deactivateContentMultiLang()

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Deactivate multilanguage.

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

References $ctrl, $ilCtrl, $lng, array, getTitleDescrOnlyMode(), and ilUtil\sendSuccess().

411  {
412  $lng = $this->lng;
414 
415  if (!$this->getTitleDescrOnlyMode()) {
416  $this->obj_trans->setMasterLanguage("");
417  $this->obj_trans->setLanguages(array());
418  $this->obj_trans->save();
419  }
420  $this->obj_trans->deactivateContentTranslation();
421  if ($this->getTitleDescrOnlyMode()) {
422  ilUtil::sendSuccess($lng->txt("obj_cont_transl_deactivated"), true);
423  } else {
424  ilUtil::sendSuccess($lng->txt("obj_multilang_deactivated"), true);
425  }
426 
427 
428  $ilCtrl->redirect($this, "listTranslations");
429  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
getTitleDescrOnlyMode()
Get enable title/description only mode.
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ deleteTranslations()

ilObjectTranslationGUI::deleteTranslations ( )

Remove translation.

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

References $_POST, listTranslations(), saveTranslations(), and ilUtil\sendFailure().

243  {
244  foreach ($_POST["title"] as $k => $v) {
245  if ($_POST["check"][$k]) {
246  // default translation cannot be deleted
247  if ($k != $_POST["default"]) {
248  unset($_POST["title"][$k]);
249  unset($_POST["desc"][$k]);
250  unset($_POST["lang"][$k]);
251  } else {
252  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
253  $this->listTranslations();
254  return;
255  }
256  }
257  }
258  $this->saveTranslations();
259  }
listTranslations($a_get_post_values=false, $a_add=false)
List translations.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectTranslationGUI::executeCommand ( )

Execute command.

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

References array.

89  {
90  $next_class = $this->ctrl->getNextClass($this);
91 
92  switch ($next_class) {
93  default:
94  $cmd = $this->ctrl->getCmd("listTranslations");
95  if (in_array($cmd, array("listTranslations", "saveTranslations",
96  "addTranslation", "deleteTranslations", "activateContentMultilinguality",
97  "confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
98  "saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages"))) {
99  $this->$cmd();
100  }
101  break;
102  }
103  }
Create styles array
The data for the language used.

◆ getMultiLangForm()

ilObjectTranslationGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

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

References $ctrl, $form, $ilCtrl, $ilUser, $lng, $options, $si, $tpl, $user, ilMDLanguageItem\_getLanguages(), array, getTitleDescrOnlyMode(), and ilSelectInputGUI\setOptions().

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

283  {
284  $tpl = $this->tpl;
285  $lng = $this->lng;
288 
289  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
290  $form = new ilPropertyFormGUI();
291 
292  // master language
293  if (!$a_add) {
294  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
296  $si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
297  $si->setOptions($options);
298  $si->setValue($ilUser->getLanguage());
299  $form->addItem($si);
300  }
301 
302  // additional languages
303  if ($a_add) {
304  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
306  $options = array("" => $lng->txt("please_select")) + $options;
307  $si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
308  $si->setOptions($options);
309  $si->setMulti(true);
310  $form->addItem($si);
311  }
312 
313  if ($a_add) {
314  $form->setTitle($lng->txt("obj_add_languages"));
315  $form->addCommandButton("saveLanguages", $lng->txt("save"));
316  $form->addCommandButton("listTranslations", $lng->txt("cancel"));
317  } else {
318  if ($this->getTitleDescrOnlyMode()) {
319  $form->setTitle($lng->txt("obj_activate_content_lang"));
320  } else {
321  $form->setTitle($lng->txt("obj_activate_multilang"));
322  }
323  $form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
324  $form->addCommandButton("listTranslations", $lng->txt("cancel"));
325  }
326  $form->setFormAction($ilCtrl->getFormAction($this));
327 
328  return $form;
329  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
getTitleDescrOnlyMode()
Get enable title/description only mode.
$ilUser
Definition: imgupload.php:18
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTitleDescrOnlyMode()

ilObjectTranslationGUI::getTitleDescrOnlyMode ( )

Get enable title/description only mode.

Returns
bool enable title/description only mode

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

References $title_descr_only.

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

+ Here is the caller graph for this function:

◆ listTranslations()

ilObjectTranslationGUI::listTranslations (   $a_get_post_values = false,
  $a_add = false 
)

List translations.

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

References $_POST, $data, $table, $toolbar, ilObject\_lookupType(), array, getTitleDescrOnlyMode(), and ilUtil\sendInfo().

Referenced by deleteTranslations(), and saveTranslations().

109  {
110  $ilToolbar = $this->toolbar;
111 
112  $this->lng->loadLanguageModule(ilObject::_lookupType($this->obj->getId()));
113 
114 
115  if ($this->getTitleDescrOnlyMode() || $this->obj_trans->getContentActivated()) {
116  $ilToolbar->addButton(
117  $this->lng->txt("obj_add_languages"),
118  $this->ctrl->getLinkTarget($this, "addLanguages")
119  );
120  }
121 
122  if ($this->getTitleDescrOnlyMode()) {
123  if (!$this->obj_trans->getContentActivated()) {
124  ilUtil::sendInfo($this->lng->txt("obj_multilang_title_descr_only"));
125  $ilToolbar->addButton(
126  $this->lng->txt("obj_activate_content_lang"),
127  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality")
128  );
129  } else {
130  $ilToolbar->addButton(
131  $this->lng->txt("obj_deactivate_content_lang"),
132  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang")
133  );
134  }
135  } else {
136  if ($this->obj_trans->getContentActivated()) {
137  $ilToolbar->addButton(
138  $this->lng->txt("obj_deactivate_multilang"),
139  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang")
140  );
141  } else {
142  $ilToolbar->addButton(
143  $this->lng->txt("obj_activate_multilang"),
144  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality")
145  );
146  return;
147  }
148  }
149 
150  include_once("./Services/Object/classes/class.ilObjectTranslation2TableGUI.php");
152  $this,
153  "listTranslations",
154  true,
155  "Translation",
156  $this->obj_trans->getMasterLanguage()
157  );
158  if ($a_get_post_values) {
159  $vals = array();
160  foreach ($_POST["title"] as $k => $v) {
161  $vals[] = array("title" => $v,
162  "desc" => $_POST["desc"][$k],
163  "lang" => $_POST["lang"][$k],
164  "default" => ($_POST["default"] == $k));
165  }
166  $table->setData($vals);
167  } else {
168  $data = $this->obj_trans->getLanguages();
169  foreach ($data as $k => $v) {
170  $data[$k]["default"] = $v["lang_default"];
171  $data[$k]["desc"] = $v["description"];
172  $data[$k]["lang"] = $v["lang_code"];
173  }
174  /* if($a_add)
175  {
176  $data["Fobject"][++$k]["title"] = "";
177  }*/
178  $table->setData($data);
179  }
180  $this->tpl->setContent($table->getHTML());
181  }
TableGUI class for title/description translations.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getTitleDescrOnlyMode()
Get enable title/description only mode.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLanguages()

ilObjectTranslationGUI::removeLanguages ( )

Remove languages.

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

References $_POST, $ctrl, $ilCtrl, $l, $lng, and ilUtil\sendInfo().

506  {
507  $lng = $this->lng;
509 
510  if (is_array($_POST["lang"])) {
511  $langs = $this->obj_trans->getLanguages();
512  foreach ($langs as $k => $l) {
513  if (in_array($l, $_POST["lang"])) {
514  $this->obj_trans->removeLanguage();
515  }
516  }
517  $this->obj_trans->save();
518  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
519  }
520  $ilCtrl->redirect($this, "listTranslations");
521  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $l
Definition: afr.php:30
$_POST["username"]
+ Here is the call graph for this function:

◆ saveContentTranslationActivation()

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Save content translation activation.

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

References $ctrl, $form, $ilCtrl, and getMultiLangForm().

335  {
337 
338  // include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
339 
340  $form = $this->getMultiLangForm();
341  if ($form->checkInput()) {
342  $ml = $form->getInput("master_lang");
343  $this->obj_trans->setMasterLanguage($ml);
344  $this->obj_trans->addLanguage(
345  $ml,
346  $this->obj->getTitle(),
347  $this->obj->getDescription(),
348  true
349  );
350  $this->obj_trans->setDefaultTitle($this->obj->getTitle());
351  $this->obj_trans->setDefaultDescription($this->obj->getDescription());
352  $this->obj_trans->save();
353  }
354 
355  $ilCtrl->redirect($this, "listTranslations");
356  }
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
getMultiLangForm($a_add=false)
Get multi language form.
+ Here is the call graph for this function:

◆ saveLanguages()

ilObjectTranslationGUI::saveLanguages ( )

Save languages.

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

References $ctrl, $form, $ilCtrl, $l, $lng, $tpl, getMultiLangForm(), ilUtil\sendFailure(), and ilUtil\sendInfo().

446  {
448  $lng = $this->lng;
449  $tpl = $this->tpl;
450 
451  $form = $this->getMultiLangForm(true);
452  if ($form->checkInput()) {
453  $ad = $form->getInput("additional_langs");
454  if (is_array($ad)) {
455  $ml = $this->obj_trans->getMasterLanguage();
456  foreach ($ad as $l) {
457  if ($l != $ml && $l != "") {
458  $this->obj_trans->addLanguage($l, false, "", "");
459  }
460  }
461  }
462  $this->obj_trans->save();
463  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
464  $ilCtrl->redirect($this, "listTranslations");
465  }
466 
467  ilUtil::sendFailure($this->lng->txt('err_check_input'));
468  $form->setValuesByPost();
469  $tpl->setContent($form->getHTML());
470  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_POST['submit'])) $form
getMultiLangForm($a_add=false)
Get multi language form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $l
Definition: afr.php:30
+ Here is the call graph for this function:

◆ saveTranslations()

ilObjectTranslationGUI::saveTranslations ( )

Save translations.

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

References $_POST, array, listTranslations(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and ilUtil\stripSlashes().

Referenced by deleteTranslations().

187  {
188  // default language set?
189  if (!isset($_POST["default"]) && $this->obj_trans->getMasterLanguage() == "") {
190  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
191  $this->listTranslations(true);
192  return;
193  }
194 
195  // all languages set?
196  if (array_key_exists("", $_POST["lang"])) {
197  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
198  $this->listTranslations(true);
199  return;
200  }
201 
202  // no single language is selected more than once?
203  if (count(array_unique($_POST["lang"])) < count($_POST["lang"])) {
204  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
205  $this->listTranslations(true);
206  return;
207  }
208 
209  // save the stuff
210  $this->obj_trans->setLanguages(array());
211 
212  foreach ($_POST["title"] as $k => $v) {
213  // update object data if default
214  $is_default = ($_POST["default"] == $k);
215 
216  // ensure master language is set as default
217  if ($this->obj_trans->getMasterLanguage() != "") {
218  $is_default = ($this->obj_trans->getMasterLanguage() == $_POST["lang"][$k]);
219  }
220  if ($is_default) {
221  $this->obj->setTitle(ilUtil::stripSlashes($v));
222  $this->obj->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
223  $this->obj->update();
224  }
225 
226  $this->obj_trans->addLanguage(
227  ilUtil::stripSlashes($_POST["lang"][$k]),
229  ilUtil::stripSlashes($_POST["desc"][$k]),
230  $is_default
231  );
232  }
233  $this->obj_trans->save();
234 
235  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
236  $this->ctrl->redirect($this, "listTranslations");
237  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
listTranslations($a_get_post_values=false, $a_add=false)
List translations.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTitleDescrOnlyMode()

ilObjectTranslationGUI::setTitleDescrOnlyMode (   $a_val)

Set enable title/description only mode.

Parameters
bool$a_valenable title/description only mode

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

71  {
72  $this->title_descr_only = $a_val;
73  }

Field Documentation

◆ $ctrl

◆ $lng

◆ $obj_trans

ilObjectTranslationGUI::$obj_trans
protected

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

◆ $title_descr_only

ilObjectTranslationGUI::$title_descr_only = true
protected

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

Referenced by getTitleDescrOnlyMode().

◆ $toolbar

ilObjectTranslationGUI::$toolbar
protected

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

Referenced by listTranslations().

◆ $tpl

◆ $user

ilObjectTranslationGUI::$user
protected

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

Referenced by getMultiLangForm().


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