ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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

 $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 20 of file class.ilObjectTranslationGUI.php.

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

21  {
22  global $lng, $ilCtrl, $tpl;
23 
24  $this->lng = $lng;
25  $this->ctrl = $ilCtrl;
26  $this->tpl = $tpl;
27  $this->obj_gui = $a_obj_gui;
28  $this->obj = $a_obj_gui->object;
29 
30  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
31  $this->obj_trans = ilObjectTranslation::getInstance($this->obj->getId());
32  }
global $ilCtrl
Definition: ilias.php:18
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
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 252 of file class.ilObjectTranslationGUI.php.

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

253  {
254  global $tpl, $lng;
255 
256  ilUtil::sendInfo($lng->txt("obj_select_master_lang"));
257 
258  $form = $this->getMultiLangForm();
259  $tpl->setContent($form->getHTML());
260  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getMultiLangForm($a_add=false)
Get multi language form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ addLanguages()

ilObjectTranslationGUI::addLanguages ( )

Add language.

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

References $tpl, and getMultiLangForm().

414  {
415  global $tpl;
416 
417  $form = $this->getMultiLangForm(true);
418  $tpl->setContent($form->getHTML());
419  }
getMultiLangForm($a_add=false)
Get multi language form.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
+ Here is the call graph for this function:

◆ confirmDeactivateContentMultiLang()

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Get multi lang info.

Confirm page translation creation

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

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

369  {
370  global $ilCtrl, $tpl, $lng;
371 
372  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
373  $cgui = new ilConfirmationGUI();
374  $cgui->setFormAction($ilCtrl->getFormAction($this));
375  if ($this->getTitleDescrOnlyMode())
376  {
377  $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
378  }
379  else
380  {
381  $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
382  }
383 
384  $cgui->setCancel($lng->txt("cancel"), "listTranslations");
385  $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
386  $tpl->setContent($cgui->getHTML());
387  }
global $ilCtrl
Definition: ilias.php:18
getTitleDescrOnlyMode()
Get enable title/description only mode.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
Confirmation screen class.
+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

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

453  {
454  global $ilCtrl, $tpl, $lng;
455 
456  $lng->loadLanguageModule("meta");
457 
458  if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0)
459  {
460  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
461  $ilCtrl->redirect($this, "listTranslations");
462  }
463  else
464  {
465  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
466  $cgui = new ilConfirmationGUI();
467  $cgui->setFormAction($ilCtrl->getFormAction($this));
468  $cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
469  $cgui->setCancel($lng->txt("cancel"), "listTranslations");
470  $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
471 
472  foreach ($_POST["lang"] as $i)
473  {
474  $cgui->addItem("lang[]", $i, $lng->txt("meta_l_".$i));
475  }
476 
477  $tpl->setContent($cgui->getHTML());
478  }
479  }
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
Confirmation screen class.
+ Here is the call graph for this function:

◆ deactivateContentMultiLang()

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Deactivate multilanguage.

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

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

393  {
394  global $lng, $ilCtrl;
395 
396  $this->obj_trans->deactivateContentTranslation();
397  if ($this->getTitleDescrOnlyMode())
398  {
399  ilUtil::sendSuccess($lng->txt("obj_cont_transl_deactivated"), true);
400  }
401  else
402  {
403  ilUtil::sendSuccess($lng->txt("obj_multilang_deactivated"), true);
404  }
405 
406 
407  $ilCtrl->redirect($this, "listTranslations");
408  }
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.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ deleteTranslations()

ilObjectTranslationGUI::deleteTranslations ( )

Remove translation.

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

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

222  {
223  foreach($_POST["title"] as $k => $v)
224  {
225  if ($_POST["check"][$k])
226  {
227  // default translation cannot be deleted
228  if($k != $_POST["default"])
229  {
230  unset($_POST["title"][$k]);
231  unset($_POST["desc"][$k]);
232  unset($_POST["lang"][$k]);
233  }
234  else
235  {
236  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
237  $this->listTranslations();
238  return;
239  }
240  }
241  }
242  $this->saveTranslations();
243  }
$_POST['username']
Definition: cron.php:12
listTranslations($a_get_post_values=false, $a_add=false)
List translations.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ executeCommand()

ilObjectTranslationGUI::executeCommand ( )

Execute command.

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

References $cmd.

58  {
59  $next_class = $this->ctrl->getNextClass($this);
60 
61  switch ($next_class)
62  {
63  default:
64  $cmd = $this->ctrl->getCmd("listTranslations");
65  if (in_array($cmd, array("listTranslations", "saveTranslations",
66  "addTranslation", "deleteTranslations", "activateContentMultilinguality",
67  "confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
68  "saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages")))
69  {
70  $this->$cmd();
71  }
72  break;
73  }
74  }
$cmd
Definition: sahs_server.php:35

◆ getMultiLangForm()

ilObjectTranslationGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

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

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

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

266  {
267  global $tpl, $lng, $ilCtrl, $ilUser;
268 
269  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
270  $form = new ilPropertyFormGUI();
271 
272  // master language
273  if (!$a_add)
274  {
275  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
277  $si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
278  $si->setOptions($options);
279  $si->setValue($ilUser->getLanguage());
280  $form->addItem($si);
281  }
282 
283  // additional languages
284  if ($a_add)
285  {
286  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
288  $options = array("" => $lng->txt("please_select")) + $options;
289  $si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
290  $si->setOptions($options);
291  $si->setMulti(true);
292  $form->addItem($si);
293  }
294 
295  if ($a_add)
296  {
297  $form->setTitle($lng->txt("obj_add_languages"));
298  $form->addCommandButton("saveLanguages", $lng->txt("save"));
299  $form->addCommandButton("listTranslations", $lng->txt("cancel"));
300  }
301  else
302  {
303  if ($this->getTitleDescrOnlyMode())
304  {
305  $form->setTitle($lng->txt("obj_activate_content_lang"));
306  }
307  else
308  {
309  $form->setTitle($lng->txt("obj_activate_multilang"));
310  }
311  $form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
312  $form->addCommandButton("listTranslations", $lng->txt("cancel"));
313  }
314  $form->setFormAction($ilCtrl->getFormAction($this));
315 
316  return $form;
317  }
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(!is_array($argv)) $options
getTitleDescrOnlyMode()
Get enable title/description only mode.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
setOptions($a_options)
Set Options.
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
+ 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 49 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 79 of file class.ilObjectTranslationGUI.php.

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

Referenced by deleteTranslations(), and saveTranslations().

80  {
81  global $ilToolbar;
82 
83  $this->lng->loadLanguageModule(ilObject::_lookupType($this->obj->getId()));
84 
85 
86  if ($this->getTitleDescrOnlyMode() || $this->obj_trans->getContentActivated())
87  {
88  $ilToolbar->addButton($this->lng->txt("obj_add_languages"),
89  $this->ctrl->getLinkTarget($this, "addLanguages"));
90  }
91 
92  if ($this->getTitleDescrOnlyMode())
93  {
94  if (!$this->obj_trans->getContentActivated())
95  {
96  ilUtil::sendInfo($this->lng->txt("obj_multilang_title_descr_only"));
97  $ilToolbar->addButton($this->lng->txt("obj_activate_content_lang"),
98  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality"));
99  }
100  else
101  {
102  $ilToolbar->addButton($this->lng->txt("obj_deactivate_content_lang"),
103  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang"));
104  }
105  }
106  else
107  {
108 
109  if ($this->obj_trans->getContentActivated())
110  {
111  $ilToolbar->addButton($this->lng->txt("obj_deactivate_multilang"),
112  $this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang"));
113  }
114  else
115  {
116  $ilToolbar->addButton($this->lng->txt("obj_activate_multilang"),
117  $this->ctrl->getLinkTarget($this, "activateContentMultilinguality"));
118  return;
119  }
120  }
121 
122  include_once("./Services/Object/classes/class.ilObjectTranslation2TableGUI.php");
123  $table = new ilObjectTranslation2TableGUI($this, "listTranslations", true,
124  "Translation", $this->obj_trans->getMasterLanguage());
125  if ($a_get_post_values)
126  {
127  $vals = array();
128  foreach($_POST["title"] as $k => $v)
129  {
130  $vals[] = array("title" => $v,
131  "desc" => $_POST["desc"][$k],
132  "lang" => $_POST["lang"][$k],
133  "default" => ($_POST["default"] == $k));
134  }
135  $table->setData($vals);
136  }
137  else
138  {
139  $data = $this->obj_trans->getLanguages();
140  foreach($data as $k => $v)
141  {
142  $data[$k]["default"] = $v["lang_default"];
143  $data[$k]["desc"] = $v["description"];
144  $data[$k]["lang"] = $v["lang_code"];
145  }
146 /* if($a_add)
147  {
148  $data["Fobject"][++$k]["title"] = "";
149  }*/
150  $table->setData($data);
151  }
152  $this->tpl->setContent($table->getHTML());
153 
154  }
$_POST['username']
Definition: cron.php:12
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.
static _lookupType($a_id, $a_reference=false)
lookup object type
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLanguages()

ilObjectTranslationGUI::removeLanguages ( )

Remove languages.

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

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

485  {
486  global $lng, $ilCtrl;
487 
488  if (is_array($_POST["lang"]))
489  {
490  $langs = $this->obj_trans->getLanguages();
491  foreach ($langs as $k => $l)
492  {
493  if (in_array($l, $_POST["lang"]))
494  {
495  $this->obj_trans->removeLanguage();
496  }
497  }
498  $this->obj_trans->save();
499  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
500  }
501  $ilCtrl->redirect($this, "listTranslations");
502  }
$_POST['username']
Definition: cron.php:12
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ saveContentTranslationActivation()

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Save content translation activation.

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

References $ilCtrl, and getMultiLangForm().

323  {
324  global $ilCtrl;
325 
326 // include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
327 
328  $form = $this->getMultiLangForm();
329  if ($form->checkInput())
330  {
331  $ml = $form->getInput("master_lang");
332  $this->obj_trans->setMasterLanguage($ml);
333  $this->obj_trans->save();
334  }
335 
336  $ilCtrl->redirect($this, "listTranslations");
337  }
global $ilCtrl
Definition: ilias.php:18
getMultiLangForm($a_add=false)
Get multi language form.
+ Here is the call graph for this function:

◆ saveLanguages()

ilObjectTranslationGUI::saveLanguages ( )

Save languages.

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

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

425  {
426  global $ilCtrl, $lng;
427 
428  $form = $this->getMultiLangForm();
429  if ($form->checkInput())
430  {
431  $ad = $form->getInput("additional_langs");
432  if (is_array($ad))
433  {
434  $ml = $this->obj_trans->getMasterLanguage();
435  foreach ($ad as $l)
436  {
437  if ($l != $ml && $l != "")
438  {
439  $this->obj_trans->addLanguage($l, false, "", "");
440  }
441  }
442  }
443  }
444  $this->obj_trans->save();
445  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
446  $ilCtrl->redirect($this, "listTranslations");
447  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getMultiLangForm($a_add=false)
Get multi language form.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ saveTranslations()

ilObjectTranslationGUI::saveTranslations ( )

Save translations.

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

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

Referenced by deleteTranslations().

160  {
161  // default language set?
162  if (!isset($_POST["default"]) && $this->obj_trans->getMasterLanguage() == "")
163  {
164  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
165  $this->listTranslations(true);
166  return;
167  }
168 
169  // all languages set?
170  if (array_key_exists("",$_POST["lang"]))
171  {
172  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
173  $this->listTranslations(true);
174  return;
175  }
176 
177  // no single language is selected more than once?
178  if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
179  {
180  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
181  $this->listTranslations(true);
182  return;
183  }
184 
185  // save the stuff
186  $this->obj_trans->setLanguages(array());
187 
188  foreach($_POST["title"] as $k => $v)
189  {
190  // update object data if default
191  $is_default = ($_POST["default"] == $k);
192 
193  // ensure master language is set as default
194  if ($this->obj_trans->getMasterLanguage() != "")
195  {
196  $is_default = ($this->obj_trans->getMasterLanguage() == $_POST["lang"][$k]);
197  }
198  if($is_default)
199  {
200  $this->obj->setTitle(ilUtil::stripSlashes($v));
201  $this->obj->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
202  $this->obj->update();
203  }
204 
205  $this->obj_trans->addLanguage(ilUtil::stripSlashes($_POST["lang"][$k]),
207  ilUtil::stripSlashes($_POST["desc"][$k]),
208  $is_default
209  );
210  }
211  $this->obj_trans->save();
212 
213  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
214  $this->ctrl->redirect($this, "listTranslations");
215 
216  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
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
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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 39 of file class.ilObjectTranslationGUI.php.

40  {
41  $this->title_descr_only = $a_val;
42  }

Field Documentation

◆ $obj_trans

ilObjectTranslationGUI::$obj_trans
protected

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

◆ $title_descr_only

ilObjectTranslationGUI::$title_descr_only = true
protected

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

Referenced by getTitleDescrOnlyMode().


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