ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageMultiLangGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
6 
16 {
17  protected $single_page_mode = false;
18 
26  function __construct($a_parent_type, $a_parent_id, $a_single_page_mode = false)
27  {
28  //$this->ml = new ilPageMultiLang($a_parent_type, $a_parent_id);
29 
30  // object translation
31  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
32  $this->ot = ilObjectTranslation::getInstance($a_parent_id);
33 
34 // $this->single_page_mode = $a_single_page_mode;
35  }
36 
40  function executeCommand()
41  {
42  global $ilCtrl;
43 
44  $next_class = $ilCtrl->getNextClass();
45 
46  switch ($next_class)
47  {
48  default:
49  $cmd = $ilCtrl->getCmd("settings");
50  if (in_array($cmd, array("settings", "activateMultilinguality", "cancel",
51  "saveMultilingualitySettings", "confirmDeactivateMultiLanguage", "addLanguage",
52  "saveLanguages", "deactivateMultiLang", "confirmRemoveLanguages",
53  "removeLanguages")))
54  {
55  $this->$cmd();
56  }
57  }
58  }
59 
63 /* function settings()
64  {
65  global $tpl, $ilToolbar, $lng, $ilCtrl;
66 
67  $this->setTabs();
68 
69  if (!$this->ml->getActivated())
70  {
71  ilUtil::sendInfo($lng->txt("cont_multilang_currently_deactivated"));
72  $ilToolbar->addButton($lng->txt("cont_activate_multi_lang"),
73  $ilCtrl->getLinkTarget($this, "activateMultilinguality"));
74  }
75  else
76  {
77  $ilToolbar->addButton($lng->txt("cont_add_lang"),
78  $ilCtrl->getLinkTarget($this, "addLanguage"));
79 
80  $ilToolbar->addButton($lng->txt("cont_deactivate_multi_lang"),
81  $ilCtrl->getLinkTarget($this, "confirmDeactivateMultiLanguage"));
82 
83  include_once("./Services/COPage/classes/class.ilPageMultiLangTableGUI.php");
84  $tab = new ilPageMultiLangTableGUI($this, "managaMultiLanguage");
85  $langs[] = array("master" => true, "lang" => $this->ml->getMasterLanguage());
86  foreach ($this->ml->getLanguages() as $l)
87  {
88  $langs[] = array("master" => false, "lang" => $l);
89  }
90  $tab->setData($langs);
91 
92 
93  $tpl->setContent($tab->getHTML());
94  }
95  }
96 */
100 /* function activateMultilinguality()
101  {
102  global $tpl, $lng;
103 
104  $this->setTabs();
105 
106  ilUtil::sendInfo($lng->txt("cont_select_master_lang"));
107 
108  $form = $this->getMultiLangForm();
109  $tpl->setContent($form->getHTML());
110  }
111 */
115 /* function getMultiLangForm($a_add = false)
116  {
117  global $tpl, $lng, $ilCtrl, $ilUser;
118 
119  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
120  $form = new ilPropertyFormGUI();
121 
122  // master language
123  if (!$a_add)
124  {
125  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
126  $options = ilMDLanguageItem::_getLanguages();
127  $si = new ilSelectInputGUI($lng->txt("cont_master_lang"), "master_lang");
128  $si->setOptions($options);
129  $si->setValue($ilUser->getLanguage());
130  $form->addItem($si);
131  }
132 
133  // additional languages
134  include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
135  $options = ilMDLanguageItem::_getLanguages();
136  $options = array("" => $lng->txt("please_select")) + $options;
137  $si = new ilSelectInputGUI($lng->txt("cont_additional_langs"), "additional_langs");
138  $si->setOptions($options);
139  $si->setMulti(true);
140  $form->addItem($si);
141 
142  if ($a_add)
143  {
144  $form->addCommandButton("saveLanguages", $lng->txt("save"));
145  $form->addCommandButton("settings", $lng->txt("cancel"));
146  }
147  else
148  {
149  $form->addCommandButton("saveMultilingualitySettings", $lng->txt("save"));
150  $form->addCommandButton("cancel", $lng->txt("cancel"));
151  }
152  $form->setTitle($lng->txt("cont_activate_multi_lang"));
153  $form->setFormAction($ilCtrl->getFormAction($this));
154 
155  return $form;
156  }
157 */
161 /* function cancel()
162  {
163  global $ilCtrl;
164 
165  $ilCtrl->returnToParent($this);
166  }
167 */
171 /* function saveMultilingualitySettings()
172  {
173  global $ilCtrl;
174 
175  include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
176 
177  $form = $this->getMultiLangForm();
178  if ($form->checkInput())
179  {
180  $ml = $form->getInput("master_lang");
181  $this->ml->setMasterLanguage($ml);
182 
183  $ad = $form->getInput("additional_langs");
184  foreach ($ad as $l)
185  {
186  if ($l != $ml && $l != "")
187  {
188  $this->ml->addLanguage($l);
189  }
190  }
191  $this->ml->save();
192  }
193 
194  $ilCtrl->redirect($this, "settings");
195  }*/
196 
200  function getMultiLangInfo($a_page_lang = "-")
201  {
202  global $lng;
203 
204  if ($a_page_lang == "")
205  {
206  $a_page_lang = "-";
207  }
208 
209  $lng->loadLanguageModule("meta");
210 
211  $tpl = new ilTemplate("tpl.page_multi_lang_info.html", true, true, "Services/COPage");
212  $tpl->setVariable("TXT_MASTER_LANG", $lng->txt("obj_master_lang"));
213  $tpl->setVariable("VAL_ML", $lng->txt("meta_l_".$this->ot->getMasterLanguage()));
214  $cl = ($a_page_lang == "-")
215  ? $this->ot->getMasterLanguage()
216  : $a_page_lang;
217  $tpl->setVariable("TXT_CURRENT_LANG", $lng->txt("cont_current_lang"));
218  $tpl->setVariable("VAL_CL", $lng->txt("meta_l_".$cl));
219  return $tpl->get();
220  }
221 
225 /* function confirmDeactivateMultiLanguage()
226  {
227  global $ilCtrl, $tpl, $lng;
228 
229  $this->setTabs();
230 
231  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
232  $cgui = new ilConfirmationGUI();
233  $cgui->setFormAction($ilCtrl->getFormAction($this));
234  $cgui->setHeaderText($lng->txt("cont_deactivate_multi_lang_conf"));
235  $cgui->setCancel($lng->txt("cancel"), "settings");
236  $cgui->setConfirm($lng->txt("confirm"), "deactivateMultiLang");
237  $tpl->setContent($cgui->getHTML());
238  }*/
239 
243 /* function deactivateMultiLang()
244  {
245  global $lng, $ilCtrl;
246 
247  $this->ml->delete();
248  ilUtil::sendSuccess($lng->txt("cont_multilang_deactivated"), true);
249  $ilCtrl->redirect($this, "settings");
250  }*/
251 
255 /* function addLanguage()
256  {
257  global $tpl;
258 
259  $this->setTabs();
260  $form = $this->getMultiLangForm(true);
261  $tpl->setContent($form->getHTML());
262  }*/
263 
267 /* function saveLanguages()
268  {
269  global $ilCtrl, $lng;
270 
271  $form = $this->getMultiLangForm();
272  if ($form->checkInput())
273  {
274  $ad = $form->getInput("additional_langs");
275  if (is_array($ad))
276  {
277  $ml = $this->ml->getMasterLanguage();
278  foreach ($ad as $l)
279  {
280  if ($l != $ml && $l != "")
281  {
282  $this->ml->addLanguage($l);
283  }
284  }
285  }
286  }
287  $this->ml->save();
288  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
289  $ilCtrl->redirect($this, "settings");
290  }*/
291 
295 /* function confirmRemoveLanguages()
296  {
297  global $ilCtrl, $tpl, $lng;
298 
299  $this->setTabs();
300 
301  $lng->loadLanguageModule("meta");
302 
303  if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0)
304  {
305  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
306  $ilCtrl->redirect($this, "settings");
307  }
308  else
309  {
310  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
311  $cgui = new ilConfirmationGUI();
312  $cgui->setFormAction($ilCtrl->getFormAction($this));
313  $cgui->setHeaderText($lng->txt("cont_conf_delete_lang"));
314  $cgui->setCancel($lng->txt("cancel"), "settings");
315  $cgui->setConfirm($lng->txt("remove"), "removeLanguages");
316 
317  foreach ($_POST["lang"] as $i)
318  {
319  $cgui->addItem("lang[]", $i, $lng->txt("meta_l_".$i));
320  }
321 
322  $tpl->setContent($cgui->getHTML());
323  }
324  }
325 */
329 /* function removeLanguages()
330  {
331  global $lng, $ilCtrl;
332 
333  if (is_array($_POST["lang"]))
334  {
335  $langs = $this->ml->getLanguages();
336  foreach ($langs as $k => $l)
337  {
338  if (in_array($l, $_POST["lang"]))
339  {
340  unset($langs[$k]);
341  }
342  }
343  $this->ml->setLanguages($langs);
344  $this->ml->save();
345  ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
346  }
347  $ilCtrl->redirect($this, "settings");
348  }*/
349 
353 /* function setTabs()
354  {
355  global $ilTabs, $lng, $ilCtrl;
356 
357  if ($this->single_page_mode)
358  {
359  $ilTabs->clearTargets();
360  $ilTabs->setBackTarget($lng->txt("cont_back_to_page"),
361  $ilCtrl->getLinkTarget($this, "cancel"));
362  }
363  }*/
364 
365 }
366 
367 ?>