ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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.

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 $tpl
Definition: ilias.php:8
static getInstance($a_obj_id)
Get instance.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

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

+ 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.

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 }
getMultiLangForm($a_add=false)
Get multi language form.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

+ Here is the call graph for this function:

◆ addLanguages()

ilObjectTranslationGUI::addLanguages ( )

Add language.

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

427 {
428 global $tpl;
429
430 $form = $this->getMultiLangForm(true);
431 $tpl->setContent($form->getHTML());
432 }

References $tpl, and getMultiLangForm().

+ Here is the call graph for this function:

◆ confirmDeactivateContentMultiLang()

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Get multi lang info.

Confirm page translation creation

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

376 {
377 global $ilCtrl, $tpl, $lng;
378
379 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
380 $cgui = new ilConfirmationGUI();
381 $cgui->setFormAction($ilCtrl->getFormAction($this));
382 if ($this->getTitleDescrOnlyMode())
383 {
384 $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
385 }
386 else
387 {
388 $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
389 }
390
391 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
392 $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
393 $tpl->setContent($cgui->getHTML());
394 }
Confirmation screen class.
getTitleDescrOnlyMode()
Get enable title/description only mode.

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

+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

466 {
467 global $ilCtrl, $tpl, $lng;
468
469 $lng->loadLanguageModule("meta");
470
471 if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0)
472 {
473 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
474 $ilCtrl->redirect($this, "listTranslations");
475 }
476 else
477 {
478 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
479 $cgui = new ilConfirmationGUI();
480 $cgui->setFormAction($ilCtrl->getFormAction($this));
481 $cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
482 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
483 $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
484
485 foreach ($_POST["lang"] as $i)
486 {
487 $cgui->addItem("lang[]", $i, $lng->txt("meta_l_".$i));
488 }
489
490 $tpl->setContent($cgui->getHTML());
491 }
492 }
$_POST['username']
Definition: cron.php:12

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

+ Here is the call graph for this function:

◆ deactivateContentMultiLang()

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Deactivate multilanguage.

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

400 {
401 global $lng, $ilCtrl;
402
403 if (!$this->getTitleDescrOnlyMode())
404 {
405 $this->obj_trans->setMasterLanguage("");
406 $this->obj_trans->setLanguages(array());
407 $this->obj_trans->save();
408 }
409 $this->obj_trans->deactivateContentTranslation();
410 if ($this->getTitleDescrOnlyMode())
411 {
412 ilUtil::sendSuccess($lng->txt("obj_cont_transl_deactivated"), true);
413 }
414 else
415 {
416 ilUtil::sendSuccess($lng->txt("obj_multilang_deactivated"), true);
417 }
418
419
420 $ilCtrl->redirect($this, "listTranslations");
421 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

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

+ Here is the call graph for this function:

◆ deleteTranslations()

ilObjectTranslationGUI::deleteTranslations ( )

Remove translation.

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

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 }
listTranslations($a_get_post_values=false, $a_add=false)
List translations.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

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

+ Here is the call graph for this function:

◆ executeCommand()

ilObjectTranslationGUI::executeCommand ( )

Execute command.

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

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

References $cmd.

◆ getMultiLangForm()

ilObjectTranslationGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

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

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 property form user interface.
This class represents a selection list property in a property form.
if(!is_array($argv)) $options
global $ilUser
Definition: imgupload.php:15

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

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

+ 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.

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 }
TableGUI class for title/description translations.
static _lookupType($a_id, $a_reference=false)
lookup object type
$data

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

Referenced by deleteTranslations(), and saveTranslations().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLanguages()

ilObjectTranslationGUI::removeLanguages ( )

Remove languages.

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

498 {
499 global $lng, $ilCtrl;
500
501 if (is_array($_POST["lang"]))
502 {
503 $langs = $this->obj_trans->getLanguages();
504 foreach ($langs as $k => $l)
505 {
506 if (in_array($l, $_POST["lang"]))
507 {
508 $this->obj_trans->removeLanguage();
509 }
510 }
511 $this->obj_trans->save();
512 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
513 }
514 $ilCtrl->redirect($this, "listTranslations");
515 }
global $l
Definition: afr.php:30

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

+ Here is the call graph for this function:

◆ saveContentTranslationActivation()

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Save content translation activation.

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

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->addLanguage($ml,
334 $this->obj->getTitle(),
335 $this->obj->getDescription(),
336 true
337 );
338 $this->obj_trans->setDefaultTitle($this->obj->getTitle());
339 $this->obj_trans->setDefaultDescription($this->obj->getDescription());
340 $this->obj_trans->save();
341 }
342
343 $ilCtrl->redirect($this, "listTranslations");
344 }

References $ilCtrl, and getMultiLangForm().

+ Here is the call graph for this function:

◆ saveLanguages()

ilObjectTranslationGUI::saveLanguages ( )

Save languages.

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

438 {
439 global $ilCtrl, $lng;
440
441 $form = $this->getMultiLangForm();
442 if ($form->checkInput())
443 {
444 $ad = $form->getInput("additional_langs");
445 if (is_array($ad))
446 {
447 $ml = $this->obj_trans->getMasterLanguage();
448 foreach ($ad as $l)
449 {
450 if ($l != $ml && $l != "")
451 {
452 $this->obj_trans->addLanguage($l, false, "", "");
453 }
454 }
455 }
456 }
457 $this->obj_trans->save();
458 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
459 $ilCtrl->redirect($this, "listTranslations");
460 }

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

+ Here is the call graph for this function:

◆ saveTranslations()

ilObjectTranslationGUI::saveTranslations ( )

Save translations.

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

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 stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

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

Referenced by deleteTranslations().

+ 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: