ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPersonalWorkspaceGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
20{
24 protected $ctrl;
25
29 protected $lng;
30
34 protected $help;
35
39 protected $obj_definition;
40
44 protected $tpl;
45
49 protected $main_menu;
50
54 protected $user;
55
59 protected $tabs;
60
64 protected $locator;
65
69 protected $tree;
70 protected $node_id; // [int]
71
75 public function __construct()
76 {
77 global $DIC;
78
79 $this->ctrl = $DIC->ctrl();
80 $this->lng = $DIC->language();
81 $this->help = $DIC["ilHelp"];
82 $this->obj_definition = $DIC["objDefinition"];
83 $this->tpl = $DIC["tpl"];
84 $this->main_menu = $DIC["ilMainMenu"];
85 $this->user = $DIC->user();
86 $this->tabs = $DIC->tabs();
87 $this->locator = $DIC["ilLocator"];
88 $ilCtrl = $DIC->ctrl();
89 $lng = $DIC->language();
90 $ilHelp = $DIC["ilHelp"];
91
92 $lng->loadLanguageModule("wsp");
93
94 $this->initTree();
95
96 $ilCtrl->saveParameter($this, "wsp_id");
97
98 $this->node_id = (int) $_REQUEST["wsp_id"];
99 if (!$this->node_id || !$this->tree->isInTree($this->node_id)) {
100 $this->node_id = $this->tree->getRootId();
101 }
102 }
103
107 public function executeCommand()
108 {
110 $objDefinition = $this->obj_definition;
112 $ilMainMenu = $this->main_menu;
113
114 $ilCtrl->setReturn($this, "render");
115 $cmd = $ilCtrl->getCmd();
116
117 // new type
118 if ($_REQUEST["new_type"]) {
119 $class_name = $objDefinition->getClassName($_REQUEST["new_type"]);
120
121 // Only set the fixed cmdClass if the next class is different to
122 // the GUI class of the new object.
123 // An example:
124 // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
125 // when creating a link resource)
126 // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
127 if (strtolower($ilCtrl->getNextClass($this)) != strtolower("ilObj" . $class_name . "GUI")) {
128 $ilCtrl->setCmdClass("ilObj" . $class_name . "GUI");
129 }
130 }
131
132 // root node
133 $next_class = $ilCtrl->getNextClass();
134 if (!$next_class) {
135 $node = $this->tree->getNodeData($this->node_id);
136 $next_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
137 $ilCtrl->setCmdClass($next_class);
138 }
139
140 // if we do this here the object can still change the breadcrumb
141 $this->renderLocator();
142
143 // current node
144 $class_path = $ilCtrl->lookupClassPath($next_class);
145 include_once($class_path);
146 $class_name = $ilCtrl->getClassForClasspath($class_path);
147 if ($_REQUEST["new_type"]) {
148 $gui = new $class_name(null, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
149 $gui->setCreationMode();
150 } else {
151 $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
152 }
153 $ilCtrl->forwardCommand($gui);
154
155 if ($ilMainMenu->getMode() == ilMainMenuGUI::MODE_FULL) {
156 $this->renderBack();
157 }
158
159 $tpl->setLocator();
160 }
161
165 protected function initTree()
166 {
168
169 $user_id = $ilUser->getId();
170
171 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
172 $this->tree = new ilWorkspaceTree($user_id);
173 if (!$this->tree->getRootId()) {
174 $this->tree->createTreeForUser($user_id);
175 }
176 }
177
178 protected function renderBack()
179 {
181 $ilTabs = $this->tabs;
184
185 $root = $this->tree->getNodeData($this->node_id);
186 if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
187 // do not override existing back targets, e.g. public user profile gui
188 if (!$ilTabs->back_target) {
189 $owner = $this->tree->lookupOwner($this->node_id);
190 // workspace
191 if ($owner == $ilUser->getId()) {
192 $parent = $this->tree->getParentNodeData($this->node_id);
193 if ($parent["wsp_id"]) {
194 if ($parent["type"] == "wsrt") {
195 $class = "ilobjworkspacerootfoldergui";
196 } else {
197 $class = "ilobjworkspacefoldergui";
198 }
199 $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
200 $ilTabs->setBackTarget(
201 $lng->txt("back"),
202 $ilCtrl->getLinkTargetByClass($class, "")
203 );
204 }
205 }
206 // "shared by others"
207 else {
208 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
209 $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
210 $ilTabs->setBackTarget(
211 $lng->txt("back"),
212 $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
213 );
214 }
215 }
216 }
217 }
218
222 protected function renderLocator()
223 {
226 $ilLocator = $this->locator;
228 $objDefinition = $this->obj_definition;
229
230 $ilLocator->clearItems();
231
232 // we have no path if shared item
233 $path = $this->tree->getPathFull($this->node_id);
234 if ($path) {
235 foreach ($path as $node) {
236 $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
237
238 $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
239
240 switch ($node["type"]) {
241 case "wsrt":
242 $ilLocator->addItem($lng->txt("wsp_personal_workspace"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
243 break;
244
245 case "blog":
246 case $objDefinition->isContainer($node["type"]):
247 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
248 break;
249
250 default:
251 $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
252 break;
253 }
254 }
255 }
256
257 $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
258 }
259}
user()
Definition: user.php:4
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
GUI class for personal workspace.
renderLocator()
Build locator for current node.
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$root
Definition: sabredav.php:45
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18