ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjRootFolderGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
19 require_once "./Services/Container/classes/class.ilContainerGUI.php";
20 require_once "./Modules/Category/classes/class.ilObjCategoryGUI.php";
21 
23 {
28  function ilObjRootFolderGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
29  {
30  global $lng;
31 
32  $this->type = "root";
33  $this->ilContainerGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
34 
35  $lng->loadLanguageModule("cntr");
36  }
37 
42  {
43  ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
44  }
45 
52  {
53  $this->ctrl->returnToParent($this);
54  }
55 
60  {
61  ilObjCategoryGUI::_importCategories($this->ref_id,0);
62  }
63 
64 
69  {
70  ilObjCategoryGUI::_importCategories($this->ref_id,1);
71  }
72 
73 
74  function getTabs(&$tabs_gui)
75  {
76  global $rbacsystem, $lng, $ilHelp;
77 
78  $ilHelp->setScreenIdComponent("root");
79 
80  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
81 
82  if ($rbacsystem->checkAccess('read',$this->ref_id))
83  {
84  $tabs_gui->addTab('view_content', $lng->txt("content"),
85  $this->ctrl->getLinkTarget($this, ""));
86  }
87 
88  if ($rbacsystem->checkAccess('write',$this->ref_id))
89  {
90  $force_active = ($_GET["cmd"] == "edit")
91  ? true
92  : false;
93  $tabs_gui->addTarget("settings",
94  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
95  , "", $force_active);
96  }
97 
98  // parent tabs (all container: edit_permission, clipboard, trash
99  parent::getTabs($tabs_gui);
100 
101  }
102 
103  function &executeCommand()
104  {
105  global $rbacsystem;
106 
107  $next_class = $this->ctrl->getNextClass($this);
108  $cmd = $this->ctrl->getCmd();
109 
110  switch($next_class)
111  {
112  case 'ilcontainerlinklistgui':
113  include_once("Services/Container/classes/class.ilContainerLinkListGUI.php");
114  $link_list_gui =& new ilContainerLinkListGUI();
115  $ret =& $this->ctrl->forwardCommand($link_list_gui);
116  break;
117 
118  // container page editing
119  case "ilpageobjectgui":
120  $this->prepareOutput(false);
121  $ret = $this->forwardToPageObject();
122  if ($ret != "")
123  {
124  $this->tpl->setContent($ret);
125  }
126  break;
127 
128  case 'ilpermissiongui':
129  $this->prepareOutput();
130  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
131  $perm_gui =& new ilPermissionGUI($this);
132  $ret =& $this->ctrl->forwardCommand($perm_gui);
133  break;
134 
135  case "ilcolumngui":
136  $this->checkPermission("read");
137  $this->prepareOutput();
138  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
139  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
140  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
141  $this->renderObject();
142  break;
143 
144  case 'ilobjectcopygui':
145  $this->prepareOutput();
146  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
147  $cp = new ilObjectCopyGUI($this);
148  $cp->setType('root');
149  $this->ctrl->forwardCommand($cp);
150  break;
151 
152  case "ilobjstylesheetgui":
153  $this->forwardToStyleSheet();
154  break;
155 
156  case "ilcommonactiondispatchergui":
157  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
159  $this->ctrl->forwardCommand($gui);
160  break;
161 
162  default:
163 
164  // fix bug http://www.ilias.de/mantis/view.php?id=10305
165  if ($cmd == "infoScreen")
166  {
167  $this->checkPermission("visible");
168  }
169  else
170  {
171  $this->checkPermission("read");
172  }
173  $this->prepareOutput();
174  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
175  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
176  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
177 
178  if(!$cmd)
179  {
180  $cmd = "render";
181  }
182 
183  $cmd .= "Object";
184  $this->$cmd();
185 
186  break;
187  }
188  return true;
189  }
190 
194  function renderObject()
195  {
196  global $ilTabs;
197 
198  include_once "Services/Object/classes/class.ilObjectListGUI.php";
199  ilObjectListGUI::prepareJSLinks("",
200  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
201  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
202 
203  $ilTabs->activateTab("view_content");
205  return $ret;
206  }
207 
208 
213  {
214  global $lng;
215 
217  $this->tpl->setDescription("");
218  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
219  {
220  if ($this->object->getTitle() == "ILIAS")
221  {
222  $this->tpl->setTitle($lng->txt("repository"));
223  }
224  else
225  {
226  if ($this->object->getDescription() != "")
227  {
228  $this->tpl->setDescription($this->object->getDescription()); // #13479
229  }
230  }
231  }
232  }
233 
234  protected function setEditTabs($active_tab = "settings_misc")
235  {
236  $this->tabs_gui->addSubTab("settings_misc",
237  $this->lng->txt("settings"),
238  $this->ctrl->getLinkTarget($this, "edit"));
239 
240  $this->tabs_gui->addSubTab("settings_trans",
241  $this->lng->txt("title_and_translations"),
242  $this->ctrl->getLinkTarget($this, "editTranslations"));
243 
244  $this->tabs_gui->activateTab("settings");
245  $this->tabs_gui->activateSubTab($active_tab);
246  }
247 
248  function initEditForm()
249  {
250  $this->setEditTabs();
251 
252  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
253  $form = new ilPropertyFormGUI();
254  $form->setFormAction($this->ctrl->getFormAction($this));
255  $form->setTitle($this->lng->txt("repository"));
256 
257 
258  // sorting
259 
260  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
261  $settings = new ilContainerSortingSettings($this->object->getId());
262 
263  $sort = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), "sorting");
264  $sort_title = new ilRadioOption($this->lng->txt('sorting_title_header'),
266  $sort_title->setInfo($this->lng->txt('sorting_info_title'));
267  $sort->addOption($sort_title);
268 
269  $sort_manual = new ilRadioOption($this->lng->txt('sorting_manual_header'),
271  $sort_manual->setInfo($this->lng->txt('sorting_info_manual'));
272  $sort->addOption($sort_manual);
273 
274  $sort->setValue($settings->getSortMode());
275  $form->addItem($sort);
276 
277 
278  $this->showCustomIconsEditing(1, $form, false);
279 
280 
281  $hide = new ilCheckboxInputGUI($this->lng->txt("cntr_hide_title_and_icon"), "hide_header_icon_and_title");
282  $hide->setChecked(ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
283  $form->addItem($hide);
284 
285 
286  $form->addCommandButton("update", $this->lng->txt("save"));
287  $form->addCommandButton("addTranslation", $this->lng->txt("add_translation"));
288 
289  return $form;
290  }
291 
292  function getEditFormValues()
293  {
294  // values are set in initEditForm()
295  }
296 
302  function updateObject()
303  {
304  if (!$this->checkPermissionBool("write"))
305  {
306  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
307  }
308  else
309  {
310  $form = $this->initEditForm();
311  if($form->checkInput())
312  {
313  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
314  $settings = new ilContainerSortingSettings($this->object->getId());
315  $settings->setSortMode($form->getInput("sorting"));
316  $settings->update();
317 
318  // save custom icons
319  if ($this->ilias->getSetting("custom_icons"))
320  {
321  if($form->getItemByPostVar("cont_big_icon")->getDeletionFlag())
322  {
323  $this->object->removeBigIcon();
324  }
325  if($form->getItemByPostVar("cont_tiny_icon")->getDeletionFlag())
326  {
327  $this->object->removeTinyIcon();
328  }
329 
330  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
331  null, $_FILES["cont_tiny_icon"]['tmp_name']);
332  }
333 
334  // hide icon/title
335  ilContainer::_writeContainerSetting($this->object->getId(),
336  "hide_header_icon_and_title",
337  $form->getInput("hide_header_icon_and_title"));
338 
339  // BEGIN ChangeEvent: Record update
340  global $ilUser;
341  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
342  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
343  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
344  // END ChangeEvent: Record update
345 
346  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
347  $this->ctrl->redirect($this, "edit");
348  }
349 
350  // display form to correct errors
351  $this->setEditTabs();
352  $form->setValuesByPost();
353  $this->tpl->setContent($form->getHTML());
354  }
355  }
356 
360  function editTranslationsObject($a_get_post_values = false)
361  {
362  global $tpl;
363 
364  $this->lng->loadLanguageModule($this->object->getType());
365  $this->setEditTabs("settings_trans");
366 
367  include_once("./Services/Object/classes/class.ilObjectTranslationTableGUI.php");
368  $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
369  "Translation");
370  if ($a_get_post_values)
371  {
372  $vals = array();
373  foreach($_POST["title"] as $k => $v)
374  {
375  $vals[] = array("title" => $v,
376  "desc" => $_POST["desc"][$k],
377  "lang" => $_POST["lang"][$k],
378  "default" => ($_POST["default"] == $k));
379  }
380  $table->setData($vals);
381  }
382  else
383  {
384  $data = $this->object->getTranslations();
385  foreach($data["Fobject"] as $k => $v)
386  {
387  $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
388  }
389  $table->setData($data["Fobject"]);
390  }
391  $tpl->setContent($table->getHTML());
392  }
393 
398  {
399  if (!$this->checkPermissionBool("write"))
400  {
401  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
402  }
403 
404  // default language set?
405  if (!isset($_POST["default"]) && count($_POST["lang"]) > 0)
406  {
407  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
408  return $this->editTranslationsObject(true);
409  }
410 
411  // all languages set?
412  if (array_key_exists("",$_POST["lang"]))
413  {
414  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
415  return $this->editTranslationsObject(true);
416  }
417 
418  // no single language is selected more than once?
419  if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
420  {
421  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
422  return $this->editTranslationsObject(true);
423  }
424 
425  // save the stuff
426  $this->object->removeTranslations();
427 
428  if(sizeof($_POST["title"]))
429  {
430  foreach($_POST["title"] as $k => $v)
431  {
432  // update object data if default
433  $is_default = ($_POST["default"] == $k);
434  if($is_default)
435  {
436  $this->object->setTitle(ilUtil::stripSlashes($v));
437  $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
438  $this->object->update();
439  }
440 
441  $this->object->addTranslation(
443  ilUtil::stripSlashes($_POST["desc"][$k]),
444  ilUtil::stripSlashes($_POST["lang"][$k]),
445  $is_default);
446  }
447  }
448  else
449  {
450  // revert to original title
451  $this->object->setTitle("ILIAS");
452  $this->object->setDescription("");
453  $this->object->update();
454  }
455 
456  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
457  $this->ctrl->redirect($this, "editTranslations");
458  }
459 
464  {
465  if(sizeof($_POST["title"]))
466  {
467  $k = max(array_keys($_POST["title"]))+1;
468  }
469  else
470  {
471  $k = 0;
472  }
473  $_POST["title"][$k] = "";
474  $this->editTranslationsObject(true);
475  }
476 
481  {
482  $del_default = true;
483  foreach($_POST["title"] as $k => $v)
484  {
485  if ($_POST["check"][$k])
486  {
487  unset($_POST["title"][$k]);
488  unset($_POST["desc"][$k]);
489  unset($_POST["lang"][$k]);
490  if($_POST["default"] == $k)
491  {
492  $del_default = true;
493  }
494  }
495  }
496  // set new default
497  if($del_default && sizeof($_POST["title"]))
498  {
499  $_POST["default"] = array_shift(array_keys($_POST["title"]));
500  }
501  $this->saveTranslationsObject();
502  }
503 
507  function _goto($a_target)
508  {
509  global $ilAccess, $ilErr, $lng;
510 
512  }
513 
519  protected function showSortingSettings()
520  {
521  $this->tpl->setVariable('TXT_SORTING',$this->lng->txt('sorting_header'));
522  $this->tpl->setVariable('TXT_SORT_TITLE',$this->lng->txt('sorting_title_header'));
523  $this->tpl->setVariable('INFO_SORT_TITLE',$this->lng->txt('sorting_info_title'));
524  $this->tpl->setVariable('TXT_SORT_MANUAL',$this->lng->txt('sorting_manual_header'));
525  $this->tpl->setVariable('INFO_SORT_MANUAL',$this->lng->txt('sorting_info_manual'));
526 
527  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
528  if($this->getCreationMode())
529  {
530  $settings = new ilContainerSortingSettings(0);
531  }
532  else
533  {
534  $settings = new ilContainerSortingSettings($this->object->getId());
535  }
536 
537 
538  $this->tpl->setVariable('RADIO_SORT_TITLE',ilUtil::formRadioButton(
539  $settings->getSortMode() == ilContainer::SORT_TITLE,
540  'sorting',
542  $this->tpl->setVariable('RADIO_SORT_MANUAL',ilUtil::formRadioButton(
543  $settings->getSortMode() == ilContainer::SORT_MANUAL,
544  'sorting',
546  }
547 
548 }
549 ?>