ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 ()
 Confirm page translation creation. 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.

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 }
user()
Definition: user.php:4
static getInstance($a_obj_id)
Get instance.
global $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46

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

+ Here is the call graph for this function:

Member Function Documentation

◆ activateContentMultilinguality()

ilObjectTranslationGUI::activateContentMultilinguality ( )

Activate multi language (-> master language selection)

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

272 {
275
276 ilUtil::sendInfo($lng->txt("obj_select_master_lang"));
277
278 $form = $this->getMultiLangForm();
279 $tpl->setContent($form->getHTML());
280 }
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 411 of file class.ilObjectTranslationGUI.php.

412 {
414
415 $form = $this->getMultiLangForm(true);
416 $tpl->setContent($form->getHTML());
417 }

References $tpl, and getMultiLangForm().

+ Here is the call graph for this function:

◆ confirmDeactivateContentMultiLang()

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Confirm page translation creation.

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

365 {
369
370 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
371 $cgui = new ilConfirmationGUI();
372 $cgui->setFormAction($ilCtrl->getFormAction($this));
373 if ($this->getTitleDescrOnlyMode()) {
374 $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
375 } else {
376 $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
377 }
378
379 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
380 $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
381 $tpl->setContent($cgui->getHTML());
382 }
Confirmation screen class.
getTitleDescrOnlyMode()
Get enable title/description only mode.

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

+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

453 {
457
458 $lng->loadLanguageModule("meta");
459
460 if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0) {
461 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
462 $ilCtrl->redirect($this, "listTranslations");
463 } else {
464 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
465 $cgui = new ilConfirmationGUI();
466 $cgui->setFormAction($ilCtrl->getFormAction($this));
467 $cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
468 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
469 $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
470
471 foreach ($_POST["lang"] as $i) {
472 $cgui->addItem("lang[]", $i, $lng->txt("meta_l_" . $i));
473 }
474
475 $tpl->setContent($cgui->getHTML());
476 }
477 }
$_POST["username"]
$i
Definition: metadata.php:24

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

+ Here is the call graph for this function:

◆ deactivateContentMultiLang()

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Deactivate multilanguage.

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

388 {
391
392 if (!$this->getTitleDescrOnlyMode()) {
393 $this->obj_trans->setMasterLanguage("");
394 $this->obj_trans->setLanguages(array());
395 $this->obj_trans->save();
396 }
397 $this->obj_trans->deactivateContentTranslation();
398 if ($this->getTitleDescrOnlyMode()) {
399 ilUtil::sendSuccess($lng->txt("obj_cont_transl_deactivated"), true);
400 } else {
401 ilUtil::sendSuccess($lng->txt("obj_multilang_deactivated"), true);
402 }
403
404
405 $ilCtrl->redirect($this, "listTranslations");
406 }

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

+ Here is the call graph for this function:

◆ deleteTranslations()

ilObjectTranslationGUI::deleteTranslations ( )

Remove translation.

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

246 {
247 foreach ($_POST["title"] as $k => $v) {
248 if ($_POST["check"][$k]) {
249 // default translation cannot be deleted
250 if ($k != $_POST["default"]) {
251 unset($_POST["title"][$k]);
252 unset($_POST["desc"][$k]);
253 unset($_POST["lang"][$k]);
254 } else {
255 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
256 $this->listTranslations();
257 return;
258 }
259 }
260 }
261 $this->saveTranslations();
262 }
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 88 of file class.ilObjectTranslationGUI.php.

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 }

◆ getMultiLangForm()

ilObjectTranslationGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

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

286 {
291
292 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
293 $form = new ilPropertyFormGUI();
294
295 // master language
296 if (!$a_add) {
297 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
299 $si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
300 $si->setOptions($options);
301 $si->setValue($ilUser->getLanguage());
302 $form->addItem($si);
303 }
304
305 // additional languages
306 if ($a_add) {
307 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
309 $options = array("" => $lng->txt("please_select")) + $options;
310 $si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
311 $si->setOptions($options);
312 $si->setMulti(true);
313 $form->addItem($si);
314 }
315
316 if ($a_add) {
317 $form->setTitle($lng->txt("obj_add_languages"));
318 $form->addCommandButton("saveLanguages", $lng->txt("save"));
319 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
320 } else {
321 if ($this->getTitleDescrOnlyMode()) {
322 $form->setTitle($lng->txt("obj_activate_content_lang"));
323 } else {
324 $form->setTitle($lng->txt("obj_activate_multilang"));
325 }
326 $form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
327 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
328 }
329 $form->setFormAction($ilCtrl->getFormAction($this));
330
331 return $form;
332 }
This class represents a property form user interface.
This class represents a selection list property in a property form.
$ilUser
Definition: imgupload.php:18

References $ctrl, $ilCtrl, $ilUser, $lng, $si, $tpl, $user, 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 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.

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");
151 $table = new ilObjectTranslation2TableGUI(
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 _lookupType($a_id, $a_reference=false)
lookup object type
$data
Definition: storeScorm.php:23

References $_POST, $data, $toolbar, 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 482 of file class.ilObjectTranslationGUI.php.

483 {
486
487 if (is_array($_POST["lang"])) {
488 $langs = $this->obj_trans->getLanguages();
489 foreach ($langs as $k => $l) {
490 if (in_array($l, $_POST["lang"])) {
491 $this->obj_trans->removeLanguage();
492 }
493 }
494 $this->obj_trans->save();
495 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
496 }
497 $ilCtrl->redirect($this, "listTranslations");
498 }

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

+ Here is the call graph for this function:

◆ saveContentTranslationActivation()

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Save content translation activation.

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

338 {
340
341 // include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
342
343 $form = $this->getMultiLangForm();
344 if ($form->checkInput()) {
345 $ml = $form->getInput("master_lang");
346 $this->obj_trans->setMasterLanguage($ml);
347 $this->obj_trans->addLanguage(
348 $ml,
349 $this->obj->getTitle(),
350 $this->obj->getDescription(),
351 true
352 );
353 $this->obj_trans->setDefaultTitle($this->obj->getTitle());
354 $this->obj_trans->setDefaultDescription($this->obj->getDescription());
355 $this->obj_trans->save();
356 }
357
358 $ilCtrl->redirect($this, "listTranslations");
359 }

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

+ Here is the call graph for this function:

◆ saveLanguages()

ilObjectTranslationGUI::saveLanguages ( )

Save languages.

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

423 {
427
428 $form = $this->getMultiLangForm(true);
429 if ($form->checkInput()) {
430 $ad = $form->getInput("additional_langs");
431 if (is_array($ad)) {
432 $ml = $this->obj_trans->getMasterLanguage();
433 foreach ($ad as $l) {
434 if ($l != $ml && $l != "") {
435 $this->obj_trans->addLanguage($l, false, "", "");
436 }
437 }
438 }
439 $this->obj_trans->save();
440 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
441 $ilCtrl->redirect($this, "listTranslations");
442 }
443
444 ilUtil::sendFailure($this->lng->txt('err_check_input'));
445 $form->setValuesByPost();
446 $tpl->setContent($form->getHTML());
447 }

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

+ Here is the call graph for this function:

◆ saveTranslations()

ilObjectTranslationGUI::saveTranslations ( )

Save translations.

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

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 }
224
225 $this->obj_trans->addLanguage(
226 ilUtil::stripSlashes($_POST["lang"][$k]),
228 ilUtil::stripSlashes($_POST["desc"][$k]),
229 $is_default
230 );
231 }
232 $this->obj_trans->save();
233 if (method_exists($this->obj, "setObjectTranslation")) {
234 $this->obj->setObjectTranslation($this->obj_trans);
235 }
236 $this->obj->update();
237
238 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
239 $this->ctrl->redirect($this, "listTranslations");
240 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, listTranslations(), ilUtil\sendFailure(), 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 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: