ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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 $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(&$tabs_gui)
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 $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 $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($tabs_gui);
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/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/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
222
227 {
228 global $lng;
229
230 parent::setTitleAndDescription();
231 $this->tpl->setDescription("");
232 if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"))
233 {
234 if ($this->object->getTitle() == "ILIAS")
235 {
236 $this->tpl->setTitle($lng->txt("repository"));
237 }
238 else
239 {
240 if ($this->object->getDescription() != "")
241 {
242 $this->tpl->setDescription($this->object->getDescription()); // #13479
243 }
244 }
245 }
246 }
247
248 protected function setEditTabs($active_tab = "settings_misc")
249 {
250 $this->tabs_gui->addSubTab("settings_misc",
251 $this->lng->txt("settings"),
252 $this->ctrl->getLinkTarget($this, "edit"));
253
254 /*$this->tabs_gui->addSubTab("settings_trans",
255 $this->lng->txt("title_and_translations"),
256 $this->ctrl->getLinkTarget($this, "editTranslations"));*/
257
258 $this->tabs_gui->addSubTab("settings_trans",
259 $this->lng->txt("obj_multilinguality"),
260 $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", ""));
261
262
263 $this->tabs_gui->activateTab("settings");
264 $this->tabs_gui->activateSubTab($active_tab);
265 }
266
267 function initEditForm()
268 {
269 $this->setEditTabs();
270
271 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
272 $form = new ilPropertyFormGUI();
273 $form->setFormAction($this->ctrl->getFormAction($this));
274 $form->setTitle($this->lng->txt("repository"));
275
276
277 $this->initSortingForm(
278 $form,
279 array(
282 ilcontainer::SORT_MANUAL
283 )
284 );
285
286
287 $this->showCustomIconsEditing(1, $form, false);
288
289
290 $hide = new ilCheckboxInputGUI($this->lng->txt("cntr_hide_title_and_icon"), "hide_header_icon_and_title");
291 $hide->setChecked(ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
292 $form->addItem($hide);
293
294
295 $form->addCommandButton("update", $this->lng->txt("save"));
296 $form->addCommandButton("addTranslation", $this->lng->txt("add_translation"));
297
298 return $form;
299 }
300
302 {
303 // values are set in initEditForm()
304 }
305
311 function updateObject()
312 {
313 global $ilSetting;
314
315 if (!$this->checkPermissionBool("write"))
316 {
317 $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"),$this->ilias->error_obj->MESSAGE);
318 }
319 else
320 {
321 $form = $this->initEditForm();
322 if($form->checkInput())
323 {
324 $this->saveSortingSettings($form);
325
326 // save custom icons
327 //save custom icons
328 if ($ilSetting->get("custom_icons"))
329 {
330 if($_POST["cont_icon_delete"])
331 {
332 $this->object->removeCustomIcon();
333 }
334 $this->object->saveIcons($_FILES["cont_icon"]['tmp_name']);
335 }
336
337 // hide icon/title
338 ilContainer::_writeContainerSetting($this->object->getId(),
339 "hide_header_icon_and_title",
340 $form->getInput("hide_header_icon_and_title"));
341
342 // BEGIN ChangeEvent: Record update
343 global $ilUser;
344 require_once('Services/Tracking/classes/class.ilChangeEvent.php');
345 ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
346 ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
347 // END ChangeEvent: Record update
348
349 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
350 $this->ctrl->redirect($this, "edit");
351 }
352
353 // display form to correct errors
354 $this->setEditTabs();
355 $form->setValuesByPost();
356 $this->tpl->setContent($form->getHTML());
357 }
358 }
359
363 function editTranslationsObject($a_get_post_values = false)
364 {
365 global $tpl;
366
367
368 $this->ctrl->redirectByClass("ilobjecttranslationgui", "");
369
370 $this->lng->loadLanguageModule($this->object->getType());
371 $this->setEditTabs("settings_trans");
372
373 include_once("./Services/Object/classes/class.ilObjectTranslationTableGUI.php");
374 $table = new ilObjectTranslationTableGUI($this, "editTranslations", true,
375 "Translation");
376 if ($a_get_post_values)
377 {
378 $vals = array();
379 foreach($_POST["title"] as $k => $v)
380 {
381 $vals[] = array("title" => $v,
382 "desc" => $_POST["desc"][$k],
383 "lang" => $_POST["lang"][$k],
384 "default" => ($_POST["default"] == $k));
385 }
386 $table->setData($vals);
387 }
388 else
389 {
390 $data = $this->object->getTranslations();
391 foreach($data["Fobject"] as $k => $v)
392 {
393 $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
394 }
395 $table->setData($data["Fobject"]);
396 }
397 $tpl->setContent($table->getHTML());
398 }
399
404 {
405 if (!$this->checkPermissionBool("write"))
406 {
407 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
408 }
409
410 // default language set?
411 if (!isset($_POST["default"]) && count($_POST["lang"]) > 0)
412 {
413 ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
414 return $this->editTranslationsObject(true);
415 }
416
417 // all languages set?
418 if (array_key_exists("",$_POST["lang"]))
419 {
420 ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
421 return $this->editTranslationsObject(true);
422 }
423
424 // no single language is selected more than once?
425 if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
426 {
427 ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
428 return $this->editTranslationsObject(true);
429 }
430
431 // save the stuff
432 $this->object->removeTranslations();
433
434 if(sizeof($_POST["title"]))
435 {
436 foreach($_POST["title"] as $k => $v)
437 {
438 // update object data if default
439 $is_default = ($_POST["default"] == $k);
440 if($is_default)
441 {
442 $this->object->setTitle(ilUtil::stripSlashes($v));
443 $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
444 $this->object->update();
445 }
446
447 $this->object->addTranslation(
449 ilUtil::stripSlashes($_POST["desc"][$k]),
450 ilUtil::stripSlashes($_POST["lang"][$k]),
451 $is_default);
452 }
453 }
454 else
455 {
456 // revert to original title
457 $this->object->setTitle("ILIAS");
458 $this->object->setDescription("");
459 $this->object->update();
460 }
461
462 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
463 $this->ctrl->redirect($this, "editTranslations");
464 }
465
470 {
471 if(sizeof($_POST["title"]))
472 {
473 $k = max(array_keys($_POST["title"]))+1;
474 }
475 else
476 {
477 $k = 0;
478 }
479 $_POST["title"][$k] = "";
480 $this->editTranslationsObject(true);
481 }
482
487 {
488 $del_default = true;
489 foreach($_POST["title"] as $k => $v)
490 {
491 if ($_POST["check"][$k])
492 {
493 unset($_POST["title"][$k]);
494 unset($_POST["desc"][$k]);
495 unset($_POST["lang"][$k]);
496 if($_POST["default"] == $k)
497 {
498 $del_default = true;
499 }
500 }
501 }
502 // set new default
503 if($del_default && sizeof($_POST["title"]))
504 {
505 $_POST["default"] = array_shift(array_keys($_POST["title"]));
506 }
507 $this->saveTranslationsObject();
508 }
509
513 public static function _goto($a_target)
514 {
515 global $ilAccess, $ilErr, $lng;
516
518 }
519
520}
521?>
$_GET["client_id"]
_recordWriteEvent($obj_id, $usr_id, $action, $parent_obj_id=null)
Records a write event.
_catchupWriteEvents($obj_id, $usr_id, $timestamp=null)
Catches up with all write events which occured before the specified timestamp.
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.
ilContainerGUI($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
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.
_lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
_writeContainerSetting($a_id, $a_keyword, $a_value)
_importCategoriesForm($a_ref_id, &$a_tpl)
display form for category import (static, also called by RootFolderGUI)
_importCategories($a_ref_id, $withrol_tmp)
import categories (static, also called by RootFolderGUI)
Class ilObjRootFolderGUI.
importCategoriesFormObject()
import categories form
importCategoriesWithRolObject()
import categories
updateObject()
updates object entry in object_data
saveTranslationsObject()
Save title and translations.
static _goto($a_target)
goto target group
ilObjRootFolderGUI($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
getEditFormValues()
Get values for edit form.
getTabs(&$tabs_gui)
common tabs for all container objects (should be called at the end of child getTabs() method
initEditForm()
Init object edit form.
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.
& executeCommand()
execute command note: this method is overwritten in all container objects
editTranslationsObject($a_get_post_values=false)
Edit title and translations.
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.
prepareOutput()
prepare output
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
$_POST['username']
Definition: cron.php:12
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15