ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMultilingualismGUI Class Reference

GUI class for object translation handling. More...

+ Collaboration diagram for ilMultilingualismGUI:

Public Member Functions

 __construct ($a_obj_id, $a_type)
 ilTranslationGUI 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...
 
 addToolbar ()
 
 saveTranslations ()
 Save translations. More...
 
 deleteTranslations ()
 Remove translation. More...
 
 getMultiLangForm ($a_add=false)
 Get multi language form. More...
 
 confirmDeactivateContentMultiLang ()
 Confirm page translation creation. More...
 
 addLanguages (ilPropertyFormGUI $form=null)
 Add language. More...
 
 saveLanguages ()
 Save languages. More...
 
 confirmRemoveLanguages ()
 Confirm remove languages. More...
 
 removeLanguages ()
 Remove languages. More...
 
 setStartValues ($a_title, $a_description)
 

Protected Attributes

 $obj_trans
 
 $title_descr_only = true
 
 $start_title = ""
 
 $start_description = ""
 

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$

@ilCtrl_IsCalledBy ilTranslationGUI: ilDidacticTemplateSettingsGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilMultilingualismGUI::__construct (   $a_obj_id,
  $a_type 
)

ilTranslationGUI constructor.

Parameters
int$a_obj_id
stirng$a_type

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

27 {
28 global $lng, $ilCtrl, $tpl;
29
30 $this->lng = $lng;
31 $this->ctrl = $ilCtrl;
32 $this->tpl = $tpl;
33
34 include_once("./Services/Multilingualism/classes/class.ilMultilingualism.php");
35 $this->obj_trans = ilMultilingualism::getInstance($a_obj_id, $a_type);
36 }
global $tpl
Definition: ilias.php:8
static getInstance($a_obj_id, $a_type)
Get instance.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$a_type
Definition: workflow.php:93

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilMultilingualismGUI::addLanguages ( ilPropertyFormGUI  $form = null)

Add language.

Definition at line 299 of file class.ilMultilingualismGUI.php.

300 {
301 global $tpl;
302
303 if(!$form instanceof ilPropertyFormGUI)
304 {
305 $form = $this->getMultiLangForm(true);
306 }
307 $tpl->setContent($form->getHTML());
308 }
getMultiLangForm($a_add=false)
Get multi language form.
This class represents a property form user interface.

References $tpl, and getMultiLangForm().

Referenced by saveLanguages().

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

◆ addToolbar()

ilMultilingualismGUI::addToolbar ( )

Definition at line 124 of file class.ilMultilingualismGUI.php.

125 {
126 global $ilToolbar;
127 if ($this->getTitleDescrOnlyMode())
128 {
129 $ilToolbar->addButton($this->lng->txt("obj_add_languages"),
130 $this->ctrl->getLinkTarget($this, "addLanguages"));
131 }
132 }
getTitleDescrOnlyMode()
Get enable title/description only mode.

References getTitleDescrOnlyMode().

Referenced by listTranslations().

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

◆ confirmDeactivateContentMultiLang()

ilMultilingualismGUI::confirmDeactivateContentMultiLang ( )

Confirm page translation creation.

Definition at line 275 of file class.ilMultilingualismGUI.php.

276 {
277 global $ilCtrl, $tpl, $lng;
278
279 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
280 $cgui = new ilConfirmationGUI();
281 $cgui->setFormAction($ilCtrl->getFormAction($this));
282 if ($this->getTitleDescrOnlyMode())
283 {
284 $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
285 }
286 else
287 {
288 $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
289 }
290
291 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
292 $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
293 $tpl->setContent($cgui->getHTML());
294 }
Confirmation screen class.

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

+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilMultilingualismGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

362 {
363 global $ilCtrl, $tpl, $lng;
364
365 $lng->loadLanguageModule("meta");
366
367 if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0)
368 {
369 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
370 $ilCtrl->redirect($this, "listTranslations");
371 }
372 else
373 {
374 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
375 $cgui = new ilConfirmationGUI();
376 $cgui->setFormAction($ilCtrl->getFormAction($this));
377 $cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
378 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
379 $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
380
381 foreach ($_POST["lang"] as $i)
382 {
383 $cgui->addItem("lang[]", $i, $lng->txt("meta_l_".$i));
384 }
385
386 $tpl->setContent($cgui->getHTML());
387 }
388 }
$_POST["username"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

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

+ Here is the call graph for this function:

◆ deleteTranslations()

ilMultilingualismGUI::deleteTranslations ( )

Remove translation.

Definition at line 187 of file class.ilMultilingualismGUI.php.

188 {
189 foreach($_POST["title"] as $k => $v)
190 {
191 if ($_POST["check"][$k])
192 {
193 // default translation cannot be deleted
194 if($k != $_POST["default"])
195 {
196 unset($_POST["title"][$k]);
197 unset($_POST["desc"][$k]);
198 unset($_POST["lang"][$k]);
199 }
200 else
201 {
202 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
203 $this->listTranslations();
204 return;
205 }
206 }
207 }
208 $this->saveTranslations();
209 }
saveTranslations()
Save translations.
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()

ilMultilingualismGUI::executeCommand ( )

Execute command.

Definition at line 61 of file class.ilMultilingualismGUI.php.

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

References $cmd.

◆ getMultiLangForm()

ilMultilingualismGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

Definition at line 218 of file class.ilMultilingualismGUI.php.

219 {
220 global $tpl, $lng, $ilCtrl, $ilUser;
221
222 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
223 $form = new ilPropertyFormGUI();
224
225 // master language
226 if (!$a_add)
227 {
228 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
230 $si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
231 $si->setOptions($options);
232 $si->setValue($ilUser->getLanguage());
233 $form->addItem($si);
234 }
235
236 // additional languages
237 if ($a_add)
238 {
239 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
241 $options = array("" => $lng->txt("please_select")) + $options;
242 $si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
243 $si->setOptions($options);
244 $si->setMulti(true);
245 $form->addItem($si);
246 }
247
248 if ($a_add)
249 {
250 $form->setTitle($lng->txt("obj_add_languages"));
251 $form->addCommandButton("saveLanguages", $lng->txt("save"));
252 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
253 }
254 else
255 {
256 if ($this->getTitleDescrOnlyMode())
257 {
258 $form->setTitle($lng->txt("obj_activate_content_lang"));
259 }
260 else
261 {
262 $form->setTitle($lng->txt("obj_activate_multilang"));
263 }
264 $form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
265 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
266 }
267 $form->setFormAction($ilCtrl->getFormAction($this));
268
269 return $form;
270 }
This class represents a selection list property in a property form.
if(!is_array($argv)) $options
$ilUser
Definition: imgupload.php:18

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

Referenced by addLanguages(), and saveLanguages().

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

◆ getTitleDescrOnlyMode()

ilMultilingualismGUI::getTitleDescrOnlyMode ( )

Get enable title/description only mode.

Returns
bool enable title/description only mode

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

References $title_descr_only.

Referenced by addToolbar(), confirmDeactivateContentMultiLang(), and getMultiLangForm().

+ Here is the caller graph for this function:

◆ listTranslations()

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

List translations.

Definition at line 83 of file class.ilMultilingualismGUI.php.

84 {
85 $this->lng->loadLanguageModule("translation");
86
87
88 $this->addToolbar();
89
90 include_once("./Services/Multilingualism/classes/class.ilMultilingualismTableGUI.php");
91 $table = new ilMultilingualismTableGUI($this, "listTranslations", true,
92 "Translation");
93 if ($a_get_post_values)
94 {
95 $vals = array();
96 foreach($_POST["title"] as $k => $v)
97 {
98 $vals[] = array("title" => $v,
99 "desc" => $_POST["desc"][$k],
100 "lang" => $_POST["lang"][$k],
101 "default" => ($_POST["default"] == $k));
102 }
103 $table->setData($vals);
104 }
105 else
106 {
107 $data = $this->obj_trans->getLanguages();
108 foreach($data as $k => $v)
109 {
110 $data[$k]["default"] = $v["lang_default"];
111 $data[$k]["desc"] = $v["description"];
112 $data[$k]["lang"] = $v["lang_code"];
113 }
114 if($a_add)
115 {
116 $data["Fobject"][++$k]["title"] = "";
117 }
118 $table->setData($data);
119 }
120 $this->tpl->setContent($table->getHTML());
121
122 }
TableGUI class for title/description translations.

References $_POST, $data, and addToolbar().

Referenced by deleteTranslations(), and saveTranslations().

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

◆ removeLanguages()

ilMultilingualismGUI::removeLanguages ( )

Remove languages.

Definition at line 393 of file class.ilMultilingualismGUI.php.

394 {
395 global $lng, $ilCtrl;
396
397 if (is_array($_POST["lang"]))
398 {
399 $langs = $this->obj_trans->getLanguages();
400 foreach ($langs as $k => $l)
401 {
402 if (in_array($l, $_POST["lang"]))
403 {
404 $this->obj_trans->removeLanguage();
405 }
406 }
407 $this->obj_trans->save();
408 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
409 }
410 $ilCtrl->redirect($this, "listTranslations");
411 }
global $l
Definition: afr.php:30

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

+ Here is the call graph for this function:

◆ saveLanguages()

ilMultilingualismGUI::saveLanguages ( )

Save languages.

Definition at line 313 of file class.ilMultilingualismGUI.php.

314 {
315 global $ilCtrl, $lng;
316
317 ilLoggerFactory::getLogger('otpl')->debug('Save languages');
318
319 $form = $this->getMultiLangForm(true);
320 if($form->checkInput())
321 {
322 $ad = $form->getInput("additional_langs");
323
324 ilLoggerFactory::getLogger('otpl')->dump($ad);
325
326 if (is_array($ad))
327 {
328
329 foreach ($ad as $l)
330 {
331 if ($l != "")
332 {
333 $std = false;
334
335 //if no other language is set, set this one as standard
336 if(!count($this->obj_trans->getLanguages()))
337 {
338 $std = true;
339 }
340
341 $this->obj_trans->addLanguage($l, $this->start_title, $this->start_description,$std);
342 }
343 }
344 }
345 $this->obj_trans->save();
346 ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
347 $ilCtrl->redirect($this, "listTranslations");
348 }
349 else
350 {
351 $form->setValuesByPost();
352 ilUtil::sendFailure($lng->txt('err_check_input'));
353 $this->addLanguages($form);
354 }
355
356 }
static getLogger($a_component_id)
Get component logger.
addLanguages(ilPropertyFormGUI $form=null)
Add language.

References $ilCtrl, $l, $lng, addLanguages(), ilLoggerFactory\getLogger(), getMultiLangForm(), ilUtil\sendFailure(), and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ saveTranslations()

ilMultilingualismGUI::saveTranslations ( )

Save translations.

Definition at line 137 of file class.ilMultilingualismGUI.php.

138 {
139 // default language set?
140 if (!isset($_POST["default"]))
141 {
142 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
143 $this->listTranslations(true);
144 return;
145 }
146
147 // all languages set?
148 if (array_key_exists("",$_POST["lang"]))
149 {
150 ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
151 $this->listTranslations(true);
152 return;
153 }
154
155 // no single language is selected more than once?
156 if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
157 {
158 ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
159 $this->listTranslations(true);
160 return;
161 }
162
163 // save the stuff
164 $this->obj_trans->setLanguages(array());
165
166 foreach($_POST["title"] as $k => $v)
167 {
168 // update object data if default
169 $is_default = ($_POST["default"] == $k);
170
171 $this->obj_trans->addLanguage(ilUtil::stripSlashes($_POST["lang"][$k]),
173 ilUtil::stripSlashes($_POST["desc"][$k]),
174 $is_default
175 );
176 }
177 $this->obj_trans->save();
178
179 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
180 $this->ctrl->redirect($this, "listTranslations");
181
182 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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:

◆ setStartValues()

ilMultilingualismGUI::setStartValues (   $a_title,
  $a_description 
)
Parameters
string$a_title
string$a_description

Definition at line 417 of file class.ilMultilingualismGUI.php.

418 {
419 $this->start_title = $a_title;
420 $this->start_description = $a_description;
421 }

◆ setTitleDescrOnlyMode()

ilMultilingualismGUI::setTitleDescrOnlyMode (   $a_val)

Set enable title/description only mode.

Parameters
bool$a_valenable title/description only mode

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

44 {
45 $this->title_descr_only = $a_val;
46 }

Field Documentation

◆ $obj_trans

ilMultilingualismGUI::$obj_trans
protected

Definition at line 16 of file class.ilMultilingualismGUI.php.

◆ $start_description

ilMultilingualismGUI::$start_description = ""
protected

Definition at line 19 of file class.ilMultilingualismGUI.php.

◆ $start_title

ilMultilingualismGUI::$start_title = ""
protected

Definition at line 18 of file class.ilMultilingualismGUI.php.

◆ $title_descr_only

ilMultilingualismGUI::$title_descr_only = true
protected

Definition at line 17 of file class.ilMultilingualismGUI.php.

Referenced by getTitleDescrOnlyMode().


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