ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPersonalWorkspaceGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
36 {
37  protected ilSetting $settings;
38  protected ilCtrl $ctrl;
39  protected ilLanguage $lng;
40  protected ilHelpGUI $help;
43  protected ilObjUser $user;
44  protected ilTabsGUI $tabs;
46  protected ilTree $tree;
47  protected int $node_id; // [int]
50 
51  public function __construct()
52  {
54  global $DIC;
55 
56  $this->ctrl = $DIC->ctrl();
57  $this->lng = $DIC->language();
58  $this->help = $DIC["ilHelp"];
59  $this->obj_definition = $DIC["objDefinition"];
60  $this->tpl = $DIC->ui()->mainTemplate();
61  $this->user = $DIC->user();
62  $this->tabs = $DIC->tabs();
63  $this->locator = $DIC["ilLocator"];
64  $ilCtrl = $DIC->ctrl();
65  $lng = $DIC->language();
66  $this->settings = $DIC->settings();
67 
68  $lng->loadLanguageModule("wsp");
69 
70  $this->std_request = new StandardGUIRequest(
71  $DIC->http(),
72  $DIC->refinery()
73  );
74 
75  $this->initTree();
76 
77  $ilCtrl->saveParameter($this, "wsp_id");
78 
79  $this->node_id = $this->std_request->getWspId();
80  if (!$this->node_id || !$this->tree->isInTree($this->node_id)) {
81  $this->node_id = $this->tree->getRootId();
82  }
83  $this->tool_context = $DIC->globalScreen()->tool()->context();
84  }
85 
86  public function executeCommand(): void
87  {
88  $ilCtrl = $this->ctrl;
89  $objDefinition = $this->obj_definition;
90  $tpl = $this->tpl;
91 
92  if ($this->settings->get("disable_personal_workspace")) {
93  throw new ilException($this->lng->txt("no_permission"));
94  }
95 
96  $ilCtrl->setReturn($this, "render");
97 
98  if (!in_array($ilCtrl->getCmd(), ["shareFilter"]) &&
99  !in_array(strtolower($ilCtrl->getCmdClass()), ["ilobjectownershipmanagementgui"])
100  ) {
101  $this->tool_context->current()->addAdditionalData(ilWorkspaceGSToolProvider::SHOW_WS_TREE, true);
102  }
103 
104  // new type
105  if ($this->std_request->getNewType()) {
106  $class_name = $objDefinition->getClassName(
107  $this->std_request->getNewType()
108  );
109 
110  // Only set the fixed cmdClass if the next class is different to
111  // the GUI class of the new object.
112  // An example:
113  // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
114  // when creating a link resource)
115  // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
116  if (strtolower($ilCtrl->getNextClass($this)) !== strtolower("ilObj" . $class_name . "GUI")) {
117  $ilCtrl->setCmdClass("ilObj" . $class_name . "GUI");
118  }
119  }
120 
121  // root node
122  $next_class = $ilCtrl->getNextClass();
123  if (!$next_class) {
124  $node = $this->tree->getNodeData($this->node_id);
125  $next_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
126  $ilCtrl->setCmdClass($next_class);
127  }
128 
129  // if we do this here the object can still change the breadcrumb
130  $this->renderLocator();
131 
132  // current node
133  $class_path = $ilCtrl->lookupClassPath($next_class);
134  include_once($class_path);
135  $class_name = $ilCtrl->getClassForClasspath($class_path);
136  if ($this->std_request->getNewType()) {
137  $gui = new $class_name(0, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
138  $gui->setCreationMode();
139  } else {
140  $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
141  }
142  $ilCtrl->forwardCommand($gui);
143 
144  //$this->renderBack();
145 
146  $tpl->setLocator();
147  }
148 
149  protected function initTree(): void
150  {
152 
153  $user_id = $ilUser->getId();
154 
155  $this->tree = new ilWorkspaceTree($user_id);
156  if (!$this->tree->getRootId()) {
157  $this->tree->createTreeForUser($user_id);
158  }
159  }
160 
161  protected function renderBack(): void
162  {
163  $lng = $this->lng;
164  $ilTabs = $this->tabs;
165  $ilCtrl = $this->ctrl;
167 
168  $root = $this->tree->getNodeData($this->node_id);
169  if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
170  // do not override existing back targets, e.g. public user profile gui
171  if (!$ilTabs->back_target) {
172  $owner = $this->tree->lookupOwner($this->node_id);
173  // workspace
174  if ($owner == $ilUser->getId()) {
175  $parent = $this->tree->getParentNodeData($this->node_id);
176  if ($parent["wsp_id"]) {
177  if ($parent["type"] == "wsrt") {
178  $class = "ilobjworkspacerootfoldergui";
179  } else {
180  $class = "ilobjworkspacefoldergui";
181  }
182  $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
183  $ilTabs->setBackTarget(
184  $lng->txt("back"),
185  $ilCtrl->getLinkTargetByClass($class, "")
186  );
187  }
188  }
189  // "shared by others"
190  else {
191  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
192  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
193  $ilTabs->setBackTarget(
194  $lng->txt("back"),
195  $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
196  );
197  }
198  }
199  }
200  }
201 
205  protected function renderLocator(): void
206  {
207  $lng = $this->lng;
208  $ilCtrl = $this->ctrl;
209  $ilLocator = $this->locator;
210  $objDefinition = $this->obj_definition;
211 
212  $ilLocator->clearItems();
213 
214  // we have no path if shared item
215  $path = $this->tree->getPathFull($this->node_id);
216  if ($path) {
217  foreach ($path as $node) {
218  $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
219 
220  $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
221 
222  switch ($node["type"]) {
223  case "wsrt":
224  $ilLocator->addItem($lng->txt("mm_personal_and_shared_r"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
225  break;
226 
227  case "blog":
228  case $objDefinition->isContainer($node["type"]):
229  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
230  break;
231 
232  default:
233  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
234  break;
235  }
236  }
237  }
238 
239  $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
240  }
241 }
GUI class for personal workspace.
setLocator()
Insert locator.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
renderLocator()
Build locator for current node.
Help GUI class.
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
parses the objects.xml it handles the xml-description of all ilias objects
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34