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