ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjRootFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2009 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
38 require_once "./Services/Container/classes/class.ilContainerGUI.php";
39 require_once "./Modules/Category/classes/class.ilObjCategoryGUI.php";
40 
42 {
47  function ilObjRootFolderGUI($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
48  {
49  global $lng;
50 
51  $this->type = "root";
52  $this->ilContainerGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
53 
54  $lng->loadLanguageModule("cntr");
55  }
56 
61  {
62  ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
63  }
64 
71  {
72  $this->ctrl->returnToParent($this);
73  }
74 
79  {
80  ilObjCategoryGUI::_importCategories($this->ref_id,0);
81  }
82 
83 
88  {
89  ilObjCategoryGUI::_importCategories($this->ref_id,1);
90  }
91 
92 
93  function getTabs(&$tabs_gui)
94  {
95  global $rbacsystem, $lng;
96 
97  $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
98 
99  if ($rbacsystem->checkAccess('read',$this->ref_id))
100  {
101  $tabs_gui->addTab('view_content', $lng->txt("content"),
102  $this->ctrl->getLinkTarget($this, ""));
103  }
104 
105  if ($rbacsystem->checkAccess('write',$this->ref_id))
106  {
107  $force_active = ($_GET["cmd"] == "edit")
108  ? true
109  : false;
110  $tabs_gui->addTarget("settings",
111  $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
112  , "", $force_active);
113  }
114 
115  // parent tabs (all container: edit_permission, clipboard, trash
116  parent::getTabs($tabs_gui);
117 
118  }
119 
120  function &executeCommand()
121  {
122  global $rbacsystem;
123 
124  $next_class = $this->ctrl->getNextClass($this);
125  $cmd = $this->ctrl->getCmd();
126 
127  switch($next_class)
128  {
129  case 'ilcontainerlinklistgui':
130  include_once("./classes/class.ilContainerLinkListGUI.php");
131  $link_list_gui =& new ilContainerLinkListGUI();
132  $ret =& $this->ctrl->forwardCommand($link_list_gui);
133  break;
134 
135  // container page editing
136  case "ilpageobjectgui":
137  $this->prepareOutput(false);
138  $ret = $this->forwardToPageObject();
139  if ($ret != "")
140  {
141  $this->tpl->setContent($ret);
142  }
143  break;
144 
145  case 'ilpermissiongui':
146  $this->prepareOutput();
147  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
148  $perm_gui =& new ilPermissionGUI($this);
149  $ret =& $this->ctrl->forwardCommand($perm_gui);
150  break;
151 
152  case "ilcolumngui":
153  $this->checkPermission("read");
154  $this->prepareOutput();
155  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
156  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
157  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
158  $this->renderObject();
159  break;
160 
161  case 'ilobjectcopygui':
162  $this->prepareOutput();
163  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
164  $cp = new ilObjectCopyGUI($this);
165  $cp->setType('root');
166  $this->ctrl->forwardCommand($cp);
167  break;
168 
169  case "ilobjstylesheetgui":
170  $this->forwardToStyleSheet();
171  break;
172 
173  case "ilcommonactiondispatchergui":
174  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
176  $this->ctrl->forwardCommand($gui);
177  break;
178 
179  default:
180  $this->prepareOutput();
181  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
182  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
183  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
184 
185  if(!$cmd)
186  {
187  $cmd = "render";
188  }
189 
190  $cmd .= "Object";
191  $this->$cmd();
192 
193  break;
194  }
195  return true;
196  }
197 
201  function renderObject()
202  {
203  global $ilTabs;
204 
205  include_once "Services/Object/classes/class.ilObjectListGUI.php";
206  ilObjectListGUI::prepareJSLinks("",
207  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
208  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
209 
210  $ilTabs->activateTab("view_content");
212  return $ret;
213  }
214 
215 
220  {
221  global $lng;
222 
224  $this->tpl->setDescription("");
225  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
226  {
227  if ($this->object->getTitle() == "ILIAS")
228  {
229  $this->tpl->setTitle($lng->txt("repository"));
230  }
231  else
232  {
233  if ($this->object->getDescription() != "")
234  {
235  $this->tpl->setTitle($this->object->getDescription());
236  }
237  }
238  }
239  }
240 
241  protected function setEditTabs($active_tab = "settings_misc")
242  {
243  $this->tabs_gui->addSubTab("settings_misc",
244  $this->lng->txt("settings"),
245  $this->ctrl->getLinkTarget($this, "edit"));
246 
247  $this->tabs_gui->addSubTab("settings_trans",
248  $this->lng->txt("title_and_translations"),
249  $this->ctrl->getLinkTarget($this, "editTranslations"));
250 
251  $this->tabs_gui->activateTab("settings");
252  $this->tabs_gui->activateSubTab($active_tab);
253  }
254 
255  function initEditForm()
256  {
257  $this->setEditTabs();
258 
259  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
260  $form = new ilPropertyFormGUI();
261  $form->setFormAction($this->ctrl->getFormAction($this));
262  $form->setTitle($this->lng->txt("repository"));
263 
264 
265  // sorting
266 
267  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
268  $settings = new ilContainerSortingSettings($this->object->getId());
269 
270  $sort = new ilRadioGroupInputGUI($this->lng->txt('sorting_header'), "sorting");
271  $sort_title = new ilRadioOption($this->lng->txt('sorting_title_header'),
273  $sort_title->setInfo($this->lng->txt('sorting_info_title'));
274  $sort->addOption($sort_title);
275 
276  $sort_manual = new ilRadioOption($this->lng->txt('sorting_manual_header'),
278  $sort_manual->setInfo($this->lng->txt('sorting_info_manual'));
279  $sort->addOption($sort_manual);
280 
281  $sort->setValue($settings->getSortMode());
282  $form->addItem($sort);
283 
284 
285  $this->showCustomIconsEditing(1, $form, false);
286 
287 
288  $hide = new ilCheckboxInputGUI($this->lng->txt("cntr_hide_title_and_icon"), "hide_header_icon_and_title");
289  $hide->setChecked(ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
290  $form->addItem($hide);
291 
292 
293  $form->addCommandButton("update", $this->lng->txt("save"));
294  $form->addCommandButton("addTranslation" , $this->lng->txt("add_translation"));
295 
296  return $form;
297  }
298 
299  function getEditFormValues()
300  {
301  // values are set in initEditForm()
302  }
303 
309  function updateObject()
310  {
311  if (!$this->checkPermissionBool("write"))
312  {
313  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
314  }
315  else
316  {
317  $form = $this->initEditForm();
318  if($form->checkInput())
319  {
320  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
321  $settings = new ilContainerSortingSettings($this->object->getId());
322  $settings->setSortMode($form->getInput("sorting"));
323  $settings->update();
324 
325  // save custom icons
326  if ($this->ilias->getSetting("custom_icons"))
327  {
328  if($form->getItemByPostVar("cont_big_icon")->getDeletionFlag())
329  {
330  $this->object->removeBigIcon();
331  }
332  if($form->getItemByPostVar("cont_tiny_icon")->getDeletionFlag())
333  {
334  $this->object->removeTinyIcon();
335  }
336 
337  $this->object->saveIcons($_FILES["cont_big_icon"]['tmp_name'],
338  null, $_FILES["cont_tiny_icon"]['tmp_name']);
339  }
340 
341  // hide icon/title
342  ilContainer::_writeContainerSetting($this->object->getId(),
343  "hide_header_icon_and_title",
344  $form->getInput("hide_header_icon_and_title"));
345 
346  // BEGIN ChangeEvent: Record update
347  global $ilUser;
348  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
349  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
350  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
351  // END ChangeEvent: Record update
352 
353  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
354  $this->ctrl->redirect($this, "edit");
355  }
356 
357  // display form to correct errors
358  $this->setEditTabs();
359  $form->setValuesByPost();
360  $this->tpl->setContent($form->getHTML());
361  }
362  }
363 
367  function editTranslationsObject($a_get_post_values = false)
368  {
369  global $tpl;
370 
371  $this->lng->loadLanguageModule($this->object->getType());
372  $this->setEditTabs("settings_trans");
373 
374  include_once("./Services/Object/classes/class.ilObjectTranslationTableGUI.php");
375  $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
376  "Translation");
377  if ($a_get_post_values)
378  {
379  $vals = array();
380  foreach($_POST["title"] as $k => $v)
381  {
382  $vals[] = array("title" => $v,
383  "desc" => $_POST["desc"][$k],
384  "lang" => $_POST["lang"][$k],
385  "default" => ($_POST["default"] == $k));
386  }
387  $table->setData($vals);
388  }
389  else
390  {
391  $data = $this->object->getTranslations();
392  foreach($data["Fobject"] as $k => $v)
393  {
394  $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
395  }
396  $table->setData($data["Fobject"]);
397  }
398  $tpl->setContent($table->getHTML());
399  }
400 
405  {
406  if (!$this->checkPermissionBool("write"))
407  {
408  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
409  }
410 
411  // default language set?
412  if (!isset($_POST["default"]) && count($_POST["lang"]) > 0)
413  {
414  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
415  return $this->editTranslationsObject(true);
416  }
417 
418  // all languages set?
419  if (array_key_exists("",$_POST["lang"]))
420  {
421  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
422  return $this->editTranslationsObject(true);
423  }
424 
425  // no single language is selected more than once?
426  if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
427  {
428  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
429  return $this->editTranslationsObject(true);
430  }
431 
432  // save the stuff
433  $this->object->removeTranslations();
434 
435  if(sizeof($_POST["title"]))
436  {
437  foreach($_POST["title"] as $k => $v)
438  {
439  // update object data if default
440  $is_default = ($_POST["default"] == $k);
441  if($is_default)
442  {
443  $this->object->setTitle(ilUtil::stripSlashes($v));
444  $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
445  $this->object->update();
446  }
447 
448  $this->object->addTranslation(
450  ilUtil::stripSlashes($_POST["desc"][$k]),
451  ilUtil::stripSlashes($_POST["lang"][$k]),
452  $is_default);
453  }
454  }
455  else
456  {
457  // revert to original title
458  $this->object->setTitle("ILIAS");
459  $this->object->setDescription("");
460  $this->object->update();
461  }
462 
463  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
464  $this->ctrl->redirect($this, "editTranslations");
465  }
466 
471  {
472  if(sizeof($_POST["title"]))
473  {
474  $k = max(array_keys($_POST["title"]))+1;
475  }
476  else
477  {
478  $k = 0;
479  }
480  $_POST["title"][$k] = "";
481  $this->editTranslationsObject(true);
482  }
483 
488  {
489  $del_default = true;
490  foreach($_POST["title"] as $k => $v)
491  {
492  if ($_POST["check"][$k])
493  {
494  unset($_POST["title"][$k]);
495  unset($_POST["desc"][$k]);
496  unset($_POST["lang"][$k]);
497  if($_POST["default"] == $k)
498  {
499  $del_default = true;
500  }
501  }
502  }
503  // set new default
504  if($del_default && sizeof($_POST["title"]))
505  {
506  $_POST["default"] = array_shift(array_keys($_POST["title"]));
507  }
508  $this->saveTranslationsObject();
509  }
510 
514  function _goto($a_target)
515  {
516  global $ilAccess, $ilErr, $lng;
517 
518  if ($ilAccess->checkAccess("read", "",1))
519  {
520  $_GET["cmd"] = "frameset";
521  $_GET["ref_id"] = 1;
522  include("repository.php");
523  exit;
524  }
525  $ilErr->raiseError($lng->txt("msg_no_perm_read"), $ilErr->FATAL);
526  }
527 
533  protected function showSortingSettings()
534  {
535  $this->tpl->setVariable('TXT_SORTING',$this->lng->txt('sorting_header'));
536  $this->tpl->setVariable('TXT_SORT_TITLE',$this->lng->txt('sorting_title_header'));
537  $this->tpl->setVariable('INFO_SORT_TITLE',$this->lng->txt('sorting_info_title'));
538  $this->tpl->setVariable('TXT_SORT_MANUAL',$this->lng->txt('sorting_manual_header'));
539  $this->tpl->setVariable('INFO_SORT_MANUAL',$this->lng->txt('sorting_info_manual'));
540 
541  include_once('Services/Container/classes/class.ilContainerSortingSettings.php');
542  if($this->getCreationMode())
543  {
544  $settings = new ilContainerSortingSettings(0);
545  }
546  else
547  {
548  $settings = new ilContainerSortingSettings($this->object->getId());
549  }
550 
551 
552  $this->tpl->setVariable('RADIO_SORT_TITLE',ilUtil::formRadioButton(
553  $settings->getSortMode() == ilContainer::SORT_TITLE,
554  'sorting',
556  $this->tpl->setVariable('RADIO_SORT_MANUAL',ilUtil::formRadioButton(
557  $settings->getSortMode() == ilContainer::SORT_MANUAL,
558  'sorting',
560  }
561 
562 }
563 ?>