ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
19require_once "./Services/Container/classes/class.ilContainerGUI.php";
20require_once "./Modules/Category/classes/class.ilObjCategoryGUI.php";
21
23{
28 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
29 {
30 global $lng;
31
32 $this->type = "root";
33 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
34
35 $lng->loadLanguageModule("cntr");
36 $lng->loadLanguageModule("obj");
37 }
38
43 {
44 ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
45 }
46
53 {
54 $this->ctrl->returnToParent($this);
55 }
56
61 {
63 }
64
65
70 {
72 }
73
74
75 function getTabs()
76 {
77 global $rbacsystem, $lng, $ilHelp;
78
79 $ilHelp->setScreenIdComponent("root");
80
81 $this->ctrl->setParameter($this,"ref_id",$this->ref_id);
82
83 if ($rbacsystem->checkAccess('read',$this->ref_id))
84 {
85 $this->tabs_gui->addTab('view_content', $lng->txt("content"),
86 $this->ctrl->getLinkTarget($this, ""));
87 }
88
89 if ($rbacsystem->checkAccess('write',$this->ref_id))
90 {
91 $force_active = ($_GET["cmd"] == "edit")
92 ? true
93 : false;
94 $this->tabs_gui->addTarget("settings",
95 $this->ctrl->getLinkTarget($this, "edit"), "edit", get_class($this)
96 , "", $force_active);
97 }
98
99 // parent tabs (all container: edit_permission, clipboard, trash
100 parent::getTabs();
101
102 }
103
104 function executeCommand()
105 {
106 global $rbacsystem;
107
108 $next_class = $this->ctrl->getNextClass($this);
109 $cmd = $this->ctrl->getCmd();
110
111 // show repository tree
112 $this->showRepTree();
113
114 switch($next_class)
115 {
116 case 'ilcontainerlinklistgui':
117 include_once("Services/Container/classes/class.ilContainerLinkListGUI.php");
118 $link_list_gui = new ilContainerLinkListGUI();
119 $ret =& $this->ctrl->forwardCommand($link_list_gui);
120 break;
121
122 // container page editing
123 case "ilcontainerpagegui":
124 $this->prepareOutput(false);
125 $ret = $this->forwardToPageObject();
126 if ($ret != "")
127 {
128 $this->tpl->setContent($ret);
129 }
130 break;
131
132 case 'ilpermissiongui':
133 $this->prepareOutput();
134 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
135 $perm_gui = new ilPermissionGUI($this);
136 $ret =& $this->ctrl->forwardCommand($perm_gui);
137 break;
138
139 case "ilcolumngui":
140 $this->checkPermission("read");
141 $this->prepareOutput();
142 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
143 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
144 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
145 $this->renderObject();
146 break;
147
148 case 'ilobjectcopygui':
149 $this->prepareOutput();
150 include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
151 $cp = new ilObjectCopyGUI($this);
152 $cp->setType('root');
153 $this->ctrl->forwardCommand($cp);
154 break;
155
156 case "ilobjstylesheetgui":
157 $this->forwardToStyleSheet();
158 break;
159
160 case "ilcommonactiondispatchergui":
161 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
163 $this->ctrl->forwardCommand($gui);
164 break;
165
166 case 'ilobjecttranslationgui':
167 $this->checkPermissionBool("write");
168 $this->prepareOutput();
169 //$this->tabs_gui->setTabActive('export');
170 $this->setEditTabs("settings_trans");
171 include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
172 $transgui = new ilObjectTranslationGUI($this);
173 $this->ctrl->forwardCommand($transgui);
174 break;
175
176 default:
177
178 // fix bug http://www.ilias.de/mantis/view.php?id=10305
179 if ($cmd == "infoScreen")
180 {
181 $this->checkPermission("visible");
182 }
183 else
184 {
185 $this->checkPermission("read");
186 }
187 $this->prepareOutput();
188 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
189 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
190 ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId()));
191
192 if(!$cmd)
193 {
194 $cmd = "render";
195 }
196
197 $cmd .= "Object";
198 $this->$cmd();
199
200 break;
201 }
202 return true;
203 }
204
208 function renderObject()
209 {
210 global $ilTabs;
211
212 include_once "Services/Object/classes/class.ilObjectListGUI.php";
213 ilObjectListGUI::prepareJSLinks("",
214 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
215 $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false));
216
217 $ilTabs->activateTab("view_content");
218 $ret = parent::renderObject();
219 return $ret;
220 }
221
227 function viewObject()
228 {
229 $this->checkPermission('read');
230
231 if (strtolower($_GET["baseClass"]) == "iladministrationgui")
232 {
233 parent::viewObject();
234 return true;
235 }
236
237 $this->renderObject();
238 return true;
239 }
240
241
242
247 {
248 global $lng;
249
250 parent::setTitleAndDescription();
251 $this->tpl->setDescription("");
252 if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
253 {
254 if ($this->object->getTitle() == "ILIAS")
255 {
256 $this->tpl->setTitle($lng->txt("repository"));
257 }
258 else
259 {
260 if ($this->object->getDescription() != "")
261 {
262 $this->tpl->setDescription($this->object->getDescription()); // #13479
263 }
264 }
265 }
266 }
267
268 protected function setEditTabs($active_tab = "settings_misc")
269 {
270 $this->tabs_gui->addSubTab("settings_misc",
271 $this->lng->txt("settings"),
272 $this->ctrl->getLinkTarget($this, "edit"));
273
274 /*$this->tabs_gui->addSubTab("settings_trans",
275 $this->lng->txt("title_and_translations"),
276 $this->ctrl->getLinkTarget($this, "editTranslations"));*/
277
278 $this->tabs_gui->addSubTab("settings_trans",
279 $this->lng->txt("obj_multilinguality"),
280 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", ""));
281
282
283 $this->tabs_gui->activateTab("settings");
284 $this->tabs_gui->activateSubTab($active_tab);
285 }
286
287 function initEditForm()
288 {
289 $this->setEditTabs();
290
291 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
292 $form = new ilPropertyFormGUI();
293 $form->setFormAction($this->ctrl->getFormAction($this));
294 $form->setTitle($this->lng->txt("repository"));
295
296
297 $this->initSortingForm(
298 $form,
299 array(
302 ilcontainer::SORT_MANUAL
303 )
304 );
305
306
307 $this->showCustomIconsEditing(1, $form, false);
308
309
310 $hide = new ilCheckboxInputGUI($this->lng->txt("cntr_hide_title_and_icon"), "hide_header_icon_and_title");
311 $hide->setChecked(ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
312 $form->addItem($hide);
313
314
315 $form->addCommandButton("update", $this->lng->txt("save"));
316 $form->addCommandButton("addTranslation", $this->lng->txt("add_translation"));
317
318 return $form;
319 }
320
322 {
323 // values are set in initEditForm()
324 }
325
331 function updateObject()
332 {
333 global $ilSetting;
334
335 if (!$this->checkPermissionBool("write"))
336 {
337 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
338 }
339 else
340 {
341 $form = $this->initEditForm();
342 if($form->checkInput())
343 {
344 $this->saveSortingSettings($form);
345
346 // save custom icons
347 //save custom icons
348 if ($ilSetting->get("custom_icons"))
349 {
350 if($_POST["cont_icon_delete"])
351 {
352 $this->object->removeCustomIcon();
353 }
354 $this->object->saveIcons($_FILES["cont_icon"]['tmp_name']);
355 }
356
357 // hide icon/title
358 ilContainer::_writeContainerSetting($this->object->getId(),
359 "hide_header_icon_and_title",
360 $form->getInput("hide_header_icon_and_title"));
361
362 // BEGIN ChangeEvent: Record update
363 global $ilUser;
364 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
365 ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
366 ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
367 // END ChangeEvent: Record update
368
369 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
370 $this->ctrl->redirect($this, "edit");
371 }
372
373 // display form to correct errors
374 $this->setEditTabs();
375 $form->setValuesByPost();
376 $this->tpl->setContent($form->getHTML());
377 }
378 }
379
383 function editTranslationsObject($a_get_post_values = false)
384 {
385 global $tpl;
386
387
388 $this->ctrl->redirectByClass("ilobjecttranslationgui", "");
389
390 $this->lng->loadLanguageModule($this->object->getType());
391 $this->setEditTabs("settings_trans");
392
393 include_once("./Services/Object/classes/class.ilObjectTranslationTableGUI.php");
394 $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
395 "Translation");
396 if ($a_get_post_values)
397 {
398 $vals = array();
399 foreach($_POST["title"] as $k => $v)
400 {
401 $vals[] = array("title" => $v,
402 "desc" => $_POST["desc"][$k],
403 "lang" => $_POST["lang"][$k],
404 "default" => ($_POST["default"] == $k));
405 }
406 $table->setData($vals);
407 }
408 else
409 {
410 $data = $this->object->getTranslations();
411 foreach($data["Fobject"] as $k => $v)
412 {
413 $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
414 }
415 $table->setData($data["Fobject"]);
416 }
417 $tpl->setContent($table->getHTML());
418 }
419
424 {
425 if (!$this->checkPermissionBool("write"))
426 {
427 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
428 }
429
430 // default language set?
431 if (!isset($_POST["default"]) && count($_POST["lang"]) > 0)
432 {
433 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
434 return $this->editTranslationsObject(true);
435 }
436
437 // all languages set?
438 if (array_key_exists("",$_POST["lang"]))
439 {
440 ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
441 return $this->editTranslationsObject(true);
442 }
443
444 // no single language is selected more than once?
445 if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
446 {
447 ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
448 return $this->editTranslationsObject(true);
449 }
450
451 // save the stuff
452 $this->object->removeTranslations();
453
454 if(sizeof($_POST["title"]))
455 {
456 foreach($_POST["title"] as $k => $v)
457 {
458 // update object data if default
459 $is_default = ($_POST["default"] == $k);
460 if($is_default)
461 {
462 $this->object->setTitle(ilUtil::stripSlashes($v));
463 $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
464 $this->object->update();
465 }
466
467 $this->object->addTranslation(
469 ilUtil::stripSlashes($_POST["desc"][$k]),
470 ilUtil::stripSlashes($_POST["lang"][$k]),
471 $is_default);
472 }
473 }
474 else
475 {
476 // revert to original title
477 $this->object->setTitle("ILIAS");
478 $this->object->setDescription("");
479 $this->object->update();
480 }
481
482 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
483 $this->ctrl->redirect($this, "editTranslations");
484 }
485
490 {
491 if(sizeof($_POST["title"]))
492 {
493 $k = max(array_keys($_POST["title"]))+1;
494 }
495 else
496 {
497 $k = 0;
498 }
499 $_POST["title"][$k] = "";
500 $this->editTranslationsObject(true);
501 }
502
507 {
508 $del_default = true;
509 foreach($_POST["title"] as $k => $v)
510 {
511 if ($_POST["check"][$k])
512 {
513 unset($_POST["title"][$k]);
514 unset($_POST["desc"][$k]);
515 unset($_POST["lang"][$k]);
516 if($_POST["default"] == $k)
517 {
518 $del_default = true;
519 }
520 }
521 }
522 // set new default
523 if($del_default && sizeof($_POST["title"]))
524 {
525 $_POST["default"] = array_shift(array_keys($_POST["title"]));
526 }
527 $this->saveTranslationsObject();
528 }
529
533 public static function _goto($a_target)
534 {
535 global $ilAccess, $ilErr, $lng;
536
538 }
539
540}
541?>
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
static _recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Class ilContainerGUI.
& forwardToPageObject()
forward command to page object
initSortingForm(ilPropertyFormGUI $form, array $a_sorting_settings)
Append sorting settings to property form.
prepareOutput($a_show_subobjects=true)
prepare output
forwardToStyleSheet()
Forward to style object.
showCustomIconsEditing($a_input_colspan=1, ilPropertyFormGUI $a_form=null, $a_as_section=true)
show edit section of custom icons for container
saveSortingSettings(ilPropertyFormGUI $form)
Save sorting settings.
Class ilContainerLinkListGUI.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
static _writeContainerSetting($a_id, $a_keyword, $a_value)
static _importCategories($a_ref_id, $withrol_tmp)
import categories (static, also called by RootFolderGUI)
static _importCategoriesForm($a_ref_id, &$a_tpl)
display form for category import (static, also called by RootFolderGUI)
Class ilObjRootFolderGUI.
importCategoriesFormObject()
import categories form
importCategoriesWithRolObject()
import categories
updateObject()
updates object entry in object_data
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
saveTranslationsObject()
Save title and translations.
static _goto($a_target)
goto target group
getTabs()
common tabs for all container objects (should be called at the end of child getTabs() method
getEditFormValues()
Get values for edit form.
initEditForm()
Init object edit form.
executeCommand()
execute command note: this method is overwritten in all container objects
viewObject()
View root folder.
importCancelledObject()
import cancelled
deleteTranslationsObject()
Remove translation.
setTitleAndDescription()
called by prepare output
setEditTabs($active_tab="settings_misc")
addTranslationObject()
Add a translation.
importCategoriesObject()
import categories
renderObject()
Render root folder.
editTranslationsObject($a_get_post_values=false)
Edit title and translations.
static getContentStylePath($a_style_id)
get content style path
GUI class for the workflow of copying objects.
checkPermission($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission and redirect on error.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
GUI class for object translation handling.
TableGUI class for title/description translations.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
redirection script todo: (a better solution should control the processing via a xml file)
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
global $ilErr
Definition: raiseError.php:16
$cmd
Definition: sahs_server.php:35
$ilUser
Definition: imgupload.php:18