ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $lng
 
 $ctrl
 
 $tpl
 
 $toolbar
 
 $user
 
 $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 51 of file class.ilMultilingualismGUI.php.

52 {
53 global $DIC;
54
55 $this->toolbar = $DIC->toolbar();
56 $this->user = $DIC->user();
57 $lng = $DIC->language();
58 $ilCtrl = $DIC->ctrl();
59 $tpl = $DIC["tpl"];
60
61 $this->lng = $lng;
62 $this->ctrl = $ilCtrl;
63 $this->tpl = $tpl;
64
65 include_once("./Services/Multilingualism/classes/class.ilMultilingualism.php");
66 $this->obj_trans = ilMultilingualism::getInstance($a_obj_id, $a_type);
67 }
user()
Definition: user.php:4
static getInstance($a_obj_id, $a_type)
Get instance.
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLanguages()

ilMultilingualismGUI::addLanguages ( ilPropertyFormGUI  $form = null)

Add language.

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

312 {
314
315 if (!$form instanceof ilPropertyFormGUI) {
316 $form = $this->getMultiLangForm(true);
317 }
318 $tpl->setContent($form->getHTML());
319 }
getMultiLangForm($a_add=false)
Get multi language form.
This class represents a property form user interface.
if(isset($_POST['submit'])) $form

References $form, $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 150 of file class.ilMultilingualismGUI.php.

151 {
152 $ilToolbar = $this->toolbar;
153 if ($this->getTitleDescrOnlyMode()) {
154 $ilToolbar->addButton(
155 $this->lng->txt("obj_add_languages"),
156 $this->ctrl->getLinkTarget($this, "addLanguages")
157 );
158 }
159 }
getTitleDescrOnlyMode()
Get enable title/description only mode.

References $toolbar, and 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 288 of file class.ilMultilingualismGUI.php.

289 {
293
294 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
295 $cgui = new ilConfirmationGUI();
296 $cgui->setFormAction($ilCtrl->getFormAction($this));
297 if ($this->getTitleDescrOnlyMode()) {
298 $cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
299 } else {
300 $cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
301 }
302
303 $cgui->setCancel($lng->txt("cancel"), "listTranslations");
304 $cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
305 $tpl->setContent($cgui->getHTML());
306 }
Confirmation screen class.

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

+ Here is the call graph for this function:

◆ confirmRemoveLanguages()

ilMultilingualismGUI::confirmRemoveLanguages ( )

Confirm remove languages.

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

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

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

+ Here is the call graph for this function:

◆ deleteTranslations()

ilMultilingualismGUI::deleteTranslations ( )

Remove translation.

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

211 {
212 foreach ($_POST["title"] as $k => $v) {
213 if ($_POST["check"][$k]) {
214 // default translation cannot be deleted
215 if ($k != $_POST["default"]) {
216 unset($_POST["title"][$k]);
217 unset($_POST["desc"][$k]);
218 unset($_POST["lang"][$k]);
219 } else {
220 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
221 $this->listTranslations();
222 return;
223 }
224 }
225 }
226 $this->saveTranslations();
227 }
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 92 of file class.ilMultilingualismGUI.php.

93 {
94 $next_class = $this->ctrl->getNextClass($this);
95
96 switch ($next_class) {
97 default:
98 $cmd = $this->ctrl->getCmd("listTranslations");
99 if (in_array($cmd, array("listTranslations", "saveTranslations",
100 "addTranslation", "deleteTranslations", "activateContentMultilinguality",
101 "confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
102 "saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages"))) {
103 $this->$cmd();
104 }
105 break;
106 }
107 }

◆ getMultiLangForm()

ilMultilingualismGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

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

237 {
242
243 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
244 $form = new ilPropertyFormGUI();
245
246 // master language
247 if (!$a_add) {
248 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
250 $si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
251 $si->setOptions($options);
252 $si->setValue($ilUser->getLanguage());
253 $form->addItem($si);
254 }
255
256 // additional languages
257 if ($a_add) {
258 include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
260 $options = array("" => $lng->txt("please_select")) + $options;
261 $si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
262 $si->setOptions($options);
263 $si->setMulti(true);
264 $form->addItem($si);
265 }
266
267 if ($a_add) {
268 $form->setTitle($lng->txt("obj_add_languages"));
269 $form->addCommandButton("saveLanguages", $lng->txt("save"));
270 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
271 } else {
272 if ($this->getTitleDescrOnlyMode()) {
273 $form->setTitle($lng->txt("obj_activate_content_lang"));
274 } else {
275 $form->setTitle($lng->txt("obj_activate_multilang"));
276 }
277 $form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
278 $form->addCommandButton("listTranslations", $lng->txt("cancel"));
279 }
280 $form->setFormAction($ilCtrl->getFormAction($this));
281
282 return $form;
283 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
This class represents a selection list property in a property form.
$ilUser
Definition: imgupload.php:18

References $ctrl, $form, $ilCtrl, $ilUser, $lng, $options, $si, $tpl, $user, 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 84 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 112 of file class.ilMultilingualismGUI.php.

113 {
114 $this->lng->loadLanguageModule("translation");
115
116
117 $this->addToolbar();
118
119 include_once("./Services/Multilingualism/classes/class.ilMultilingualismTableGUI.php");
121 $this,
122 "listTranslations",
123 true,
124 "Translation"
125 );
126 if ($a_get_post_values) {
127 $vals = array();
128 foreach ($_POST["title"] as $k => $v) {
129 $vals[] = array("title" => $v,
130 "desc" => $_POST["desc"][$k],
131 "lang" => $_POST["lang"][$k],
132 "default" => ($_POST["default"] == $k));
133 }
134 $table->setData($vals);
135 } else {
136 $data = $this->obj_trans->getLanguages();
137 foreach ($data as $k => $v) {
138 $data[$k]["default"] = $v["lang_default"];
139 $data[$k]["desc"] = $v["description"];
140 $data[$k]["lang"] = $v["lang_code"];
141 }
142 if ($a_add) {
143 $data["Fobject"][++$k]["title"] = "";
144 }
145 $table->setData($data);
146 }
147 $this->tpl->setContent($table->getHTML());
148 }
TableGUI class for title/description translations.
if(empty($password)) $table
Definition: pwgen.php:24

References $_POST, $data, $table, 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 394 of file class.ilMultilingualismGUI.php.

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

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

+ Here is the call graph for this function:

◆ saveLanguages()

ilMultilingualismGUI::saveLanguages ( )

Save languages.

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

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

References $ctrl, $form, $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 164 of file class.ilMultilingualismGUI.php.

165 {
166 // default language set?
167 if (!isset($_POST["default"])) {
168 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
169 $this->listTranslations(true);
170 return;
171 }
172
173 // all languages set?
174 if (array_key_exists("", $_POST["lang"])) {
175 ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
176 $this->listTranslations(true);
177 return;
178 }
179
180 // no single language is selected more than once?
181 if (count(array_unique($_POST["lang"])) < count($_POST["lang"])) {
182 ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
183 $this->listTranslations(true);
184 return;
185 }
186
187 // save the stuff
188 $this->obj_trans->setLanguages(array());
189
190 foreach ($_POST["title"] as $k => $v) {
191 // update object data if default
192 $is_default = ($_POST["default"] == $k);
193
194 $this->obj_trans->addLanguage(
195 ilUtil::stripSlashes($_POST["lang"][$k]),
197 ilUtil::stripSlashes($_POST["desc"][$k]),
198 $is_default
199 );
200 }
201 $this->obj_trans->save();
202
203 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
204 $this->ctrl->redirect($this, "listTranslations");
205 }
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 416 of file class.ilMultilingualismGUI.php.

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

◆ setTitleDescrOnlyMode()

ilMultilingualismGUI::setTitleDescrOnlyMode (   $a_val)

Set enable title/description only mode.

Parameters
bool$a_valenable title/description only mode

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

75 {
76 $this->title_descr_only = $a_val;
77 }

Field Documentation

◆ $ctrl

ilMultilingualismGUI::$ctrl
protected

◆ $lng

◆ $obj_trans

ilMultilingualismGUI::$obj_trans
protected

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

◆ $start_description

ilMultilingualismGUI::$start_description = ""
protected

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

◆ $start_title

ilMultilingualismGUI::$start_title = ""
protected

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

◆ $title_descr_only

ilMultilingualismGUI::$title_descr_only = true
protected

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

Referenced by getTitleDescrOnlyMode().

◆ $toolbar

ilMultilingualismGUI::$toolbar
protected

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

Referenced by addToolbar().

◆ $tpl

ilMultilingualismGUI::$tpl
protected

◆ $user

ilMultilingualismGUI::$user
protected

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

Referenced by getMultiLangForm().


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