ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules 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 
17 {
22  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
23  {
24  global $lng;
25 
26  $this->type = "root";
27  parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
28 
29  $lng->loadLanguageModule("cntr");
30  $lng->loadLanguageModule("obj");
31  }
32 
36  public function importCategoriesFormObject()
37  {
38  ilObjCategoryGUI::_importCategoriesForm($this->ref_id, $this->tpl);
39  }
40 
46  public function importCancelledObject()
47  {
48  $this->ctrl->returnToParent($this);
49  }
50 
54  public function importCategoriesObject()
55  {
56  ilObjCategoryGUI::_importCategories($this->ref_id, 0);
57  }
58 
59 
64  {
65  ilObjCategoryGUI::_importCategories($this->ref_id, 1);
66  }
67 
68 
69  public function getTabs()
70  {
71  global $rbacsystem, $lng, $ilHelp;
72 
73  $ilHelp->setScreenIdComponent("root");
74 
75  $this->ctrl->setParameter($this, "ref_id", $this->ref_id);
76 
77  if ($rbacsystem->checkAccess('read', $this->ref_id)) {
78  $this->tabs_gui->addTab(
79  'view_content',
80  $lng->txt("content"),
81  $this->ctrl->getLinkTarget($this, "")
82  );
83  }
84 
85  if ($rbacsystem->checkAccess('write', $this->ref_id)) {
86  $force_active = ($_GET["cmd"] == "edit")
87  ? true
88  : false;
89  $this->tabs_gui->addTarget(
90  "settings",
91  $this->ctrl->getLinkTarget($this, "edit"),
92  "edit",
93  get_class($this),
94  "",
95  $force_active
96  );
97  }
98 
99  // parent tabs (all container: edit_permission, clipboard, trash
100  parent::getTabs();
101  }
102 
103  public function executeCommand()
104  {
105  global $rbacsystem;
106 
107  $next_class = $this->ctrl->getNextClass($this);
108  $cmd = $this->ctrl->getCmd();
109 
110 
111  switch ($next_class) {
112  case 'ilreputilgui':
113  $ru = new \ilRepUtilGUI($this);
114  $this->ctrl->setReturn($this, 'trash');
115  $this->ctrl->forwardCommand($ru);
116  break;
117 
118 
119  case 'ilcontainerlinklistgui':
120  include_once("Services/Container/classes/class.ilContainerLinkListGUI.php");
121  $link_list_gui = new ilContainerLinkListGUI();
122  $ret = &$this->ctrl->forwardCommand($link_list_gui);
123  break;
124 
125  // container page editing
126  case "ilcontainerpagegui":
127  $this->prepareOutput(false);
128  $ret = $this->forwardToPageObject();
129  if ($ret != "") {
130  $this->tpl->setContent($ret);
131  }
132  break;
133 
134  case 'ilpermissiongui':
135  $this->prepareOutput();
136  $this->tabs_gui->activateTab('perm_settings');
137  $perm_gui = new ilPermissionGUI($this);
138  $ret = $this->ctrl->forwardCommand($perm_gui);
139  break;
140 
141  case "ilcolumngui":
142  $this->checkPermission("read");
143  $this->prepareOutput();
144  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
145  $this->tpl->setVariable(
146  "LOCATION_CONTENT_STYLESHEET",
147  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
148  );
149  $this->renderObject();
150  break;
151 
152  case 'ilobjectcopygui':
153  $this->prepareOutput();
154  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
155  $cp = new ilObjectCopyGUI($this);
156  $cp->setType('root');
157  $this->ctrl->forwardCommand($cp);
158  break;
159 
160  case "ilobjstylesheetgui":
161  $this->forwardToStyleSheet();
162  break;
163 
164  case "ilcommonactiondispatchergui":
165  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
167  $this->ctrl->forwardCommand($gui);
168  break;
169 
170  case 'ilobjecttranslationgui':
171  $this->checkPermissionBool("write");
172  $this->prepareOutput();
173  //$this->tabs_gui->setTabActive('export');
174  $this->setEditTabs("settings_trans");
175  include_once("./Services/Object/classes/class.ilObjectTranslationGUI.php");
176  $transgui = new ilObjectTranslationGUI($this);
177  $this->ctrl->forwardCommand($transgui);
178  break;
179 
180  default:
181  if ($cmd == "infoScreen") {
182  $this->checkPermission("visible");
183  } else {
184  try {
185  $this->checkPermission("read");
186  } catch (ilObjectException $exception) {
187  $this->ctrl->redirectToURL("login.php?client_id=" . CLIENT_ID . "&cmd=force_login");
188  }
189  }
190  $this->prepareOutput();
191  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
192  $this->tpl->setVariable(
193  "LOCATION_CONTENT_STYLESHEET",
194  ilObjStyleSheet::getContentStylePath($this->object->getStyleSheetId())
195  );
196 
197  if (!$cmd) {
198  $cmd = "render";
199  }
200 
201  $cmd .= "Object";
202  $this->$cmd();
203 
204  break;
205  }
206  return true;
207  }
208 
212  public function renderObject()
213  {
214  global $ilTabs;
215 
216  include_once "Services/Object/classes/class.ilObjectListGUI.php";
217  ilObjectListGUI::prepareJSLinks(
218  "",
219  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
220  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false)
221  );
222 
223  $ilTabs->activateTab("view_content");
224  $ret = parent::renderObject();
225  return $ret;
226  }
227 
233  public function viewObject()
234  {
235  $this->checkPermission('read');
236 
237  if (strtolower($_GET["baseClass"]) == "iladministrationgui") {
238  parent::viewObject();
239  return true;
240  }
241 
242  $this->renderObject();
243  return true;
244  }
245 
246 
247 
251  public function setTitleAndDescription()
252  {
253  global $lng;
254 
255  parent::setTitleAndDescription();
256  $this->tpl->setDescription("");
257  if (!ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title")) {
258  if ($this->object->getTitle() == "ILIAS") {
259  $this->tpl->setTitle($lng->txt("repository"));
260  } else {
261  if ($this->object->getDescription() != "") {
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(
271  "settings_misc",
272  $this->lng->txt("settings"),
273  $this->ctrl->getLinkTarget($this, "edit")
274  );
275 
276  /*$this->tabs_gui->addSubTab("settings_trans",
277  $this->lng->txt("title_and_translations"),
278  $this->ctrl->getLinkTarget($this, "editTranslations"));*/
279 
280  $this->tabs_gui->addSubTab(
281  "settings_trans",
282  $this->lng->txt("obj_multilinguality"),
283  $this->ctrl->getLinkTargetByClass("ilobjecttranslationgui", "")
284  );
285 
286 
287  $this->tabs_gui->activateTab("settings");
288  $this->tabs_gui->activateSubTab($active_tab);
289  }
290 
291  public function initEditForm()
292  {
293  $this->setEditTabs();
294  $obj_service = $this->getObjectService();
295 
296  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
297  $form = new ilPropertyFormGUI();
298  $form->setFormAction($this->ctrl->getFormAction($this));
299  $form->setTitle($this->lng->txt('obj_presentation'));
300 
301  // list presentation
302  $form = $this->initListPresentationForm($form);
303 
304  $this->initSortingForm(
305  $form,
306  array(
309  ilcontainer::SORT_MANUAL
310  )
311  );
312 
313 
314  $this->showCustomIconsEditing(1, $form, false);
315 
316  $form = $obj_service->commonSettings()->legacyForm($form, $this->object)->addTitleIconVisibility();
317 
318  //$hide = new ilCheckboxInputGUI($this->lng->txt("cntr_hide_title_and_icon"), "hide_header_icon_and_title");
319  //$hide->setChecked(ilContainer::_lookupContainerSetting($this->object->getId(), "hide_header_icon_and_title"));
320  //$form->addItem($hide);
321 
322 
323  $form->addCommandButton("update", $this->lng->txt("save"));
324  $form->addCommandButton("addTranslation", $this->lng->txt("add_translation"));
325 
326  return $form;
327  }
328 
329  public function getEditFormValues()
330  {
331  // values are set in initEditForm()
332  }
333 
339  public function updateObject()
340  {
341  global $ilSetting;
342 
343  $obj_service = $this->getObjectService();
344 
345  if (!$this->checkPermissionBool("write")) {
346  $this->ilias->raiseError($this->lng->txt("msg_no_perm_write"), $this->ilias->error_obj->MESSAGE);
347  } else {
348  $form = $this->initEditForm();
349  if ($form->checkInput()) {
350  $this->saveSortingSettings($form);
351 
352  // list presentation
353  $this->saveListPresentation($form);
354 
355  if ($ilSetting->get('custom_icons')) {
356  global $DIC;
358  $customIconFactory = $DIC['object.customicons.factory'];
359  $customIcon = $customIconFactory->getByObjId($this->object->getId(), $this->object->getType());
360 
362  $fileData = (array) $form->getInput('cont_icon');
363  $item = $form->getItemByPostVar('cont_icon');
364 
365  if ($item->getDeletionFlag()) {
366  $customIcon->remove();
367  }
368 
369  if ($fileData['tmp_name']) {
370  $customIcon->saveFromHttpRequest();
371  }
372  // cognos-blu-patch: end
373  }
374 
375  // custom icon
376  $obj_service->commonSettings()->legacyForm($form, $this->object)->saveTitleIconVisibility();
377 
378  // hide icon/title
379  //ilContainer::_writeContainerSetting($this->object->getId(),
380  // "hide_header_icon_and_title",
381  // $form->getInput("hide_header_icon_and_title"));
382 
383  // BEGIN ChangeEvent: Record update
384  global $ilUser;
385  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
386  ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
387  ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
388  // END ChangeEvent: Record update
389 
390  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
391  $this->ctrl->redirect($this, "edit");
392  }
393 
394  // display form to correct errors
395  $this->setEditTabs();
396  $form->setValuesByPost();
397  $this->tpl->setContent($form->getHTML());
398  }
399  }
400 
404  public function editTranslationsObject($a_get_post_values = false)
405  {
406  global $tpl;
407 
408 
409  $this->ctrl->redirectByClass("ilobjecttranslationgui", "");
410 
411  $this->lng->loadLanguageModule($this->object->getType());
412  $this->setEditTabs("settings_trans");
413 
414  include_once("./Services/Object/classes/class.ilObjectTranslationTableGUI.php");
415  $table = new ilObjectTranslationTableGUI(
416  $this,
417  "editTranslations",
418  true,
419  "Translation"
420  );
421  if ($a_get_post_values) {
422  $vals = array();
423  foreach ($_POST["title"] as $k => $v) {
424  $vals[] = array("title" => $v,
425  "desc" => $_POST["desc"][$k],
426  "lang" => $_POST["lang"][$k],
427  "default" => ($_POST["default"] == $k));
428  }
429  $table->setData($vals);
430  } else {
431  $data = $this->object->getTranslations();
432  foreach ($data["Fobject"] as $k => $v) {
433  $data["Fobject"][$k]["default"] = ($k == $data["default_language"]);
434  }
435  $table->setData($data["Fobject"]);
436  }
437  $tpl->setContent($table->getHTML());
438  }
439 
443  public function saveTranslationsObject()
444  {
445  if (!$this->checkPermissionBool("write")) {
446  $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE);
447  }
448 
449  // default language set?
450  if (!isset($_POST["default"]) && count($_POST["lang"]) > 0) {
451  ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
452  return $this->editTranslationsObject(true);
453  }
454 
455  // all languages set?
456  if (array_key_exists("", $_POST["lang"])) {
457  ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
458  return $this->editTranslationsObject(true);
459  }
460 
461  // no single language is selected more than once?
462  if (count(array_unique($_POST["lang"])) < count($_POST["lang"])) {
463  ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
464  return $this->editTranslationsObject(true);
465  }
466 
467  // save the stuff
468  $this->object->removeTranslations();
469 
470  if (sizeof($_POST["title"])) {
471  foreach ($_POST["title"] as $k => $v) {
472  // update object data if default
473  $is_default = ($_POST["default"] == $k);
474  if ($is_default) {
475  $this->object->setTitle(ilUtil::stripSlashes($v));
476  $this->object->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
477  $this->object->update();
478  }
479 
480  $this->object->addTranslation(
482  ilUtil::stripSlashes($_POST["desc"][$k]),
483  ilUtil::stripSlashes($_POST["lang"][$k]),
484  $is_default
485  );
486  }
487  } else {
488  // revert to original title
489  $this->object->setTitle("ILIAS");
490  $this->object->setDescription("");
491  $this->object->update();
492  }
493 
494  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
495  $this->ctrl->redirect($this, "editTranslations");
496  }
497 
501  public function addTranslationObject()
502  {
503  if (sizeof($_POST["title"])) {
504  $k = max(array_keys($_POST["title"])) + 1;
505  } else {
506  $k = 0;
507  }
508  $_POST["title"][$k] = "";
509  $this->editTranslationsObject(true);
510  }
511 
515  public function deleteTranslationsObject()
516  {
517  $del_default = true;
518  foreach ($_POST["title"] as $k => $v) {
519  if ($_POST["check"][$k]) {
520  unset($_POST["title"][$k]);
521  unset($_POST["desc"][$k]);
522  unset($_POST["lang"][$k]);
523  if ($_POST["default"] == $k) {
524  $del_default = true;
525  }
526  }
527  }
528  // set new default
529  if ($del_default && sizeof($_POST["title"])) {
530  $_POST["default"] = array_shift(array_keys($_POST["title"]));
531  }
532  $this->saveTranslationsObject();
533  }
534 
538  public static function _goto($a_target)
539  {
540  global $ilAccess, $ilErr, $lng;
541 
543  }
544 }
Class ilObjRootFolderGUI.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
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.
$_GET["client_id"]
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")
const CLIENT_ID
Definition: constants.php:39
global $DIC
Definition: goto.php:24
forwardToStyleSheet()
Forward to style object.
& forwardToPageObject()
forward command to page object
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
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
__construct(Container $dic, ilPlugin $plugin)
$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.
$ilUser
Definition: imgupload.php:18
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.