ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
66  protected $tree; // [ilTree]
67  protected $node_id; // [int]
68 
72  public function __construct()
73  {
74  global $DIC;
75 
76  $this->ctrl = $DIC->ctrl();
77  $this->lng = $DIC->language();
78  $this->help = $DIC["ilHelp"];
79  $this->obj_definition = $DIC["objDefinition"];
80  $this->tpl = $DIC["tpl"];
81  $this->main_menu = $DIC["ilMainMenu"];
82  $this->user = $DIC->user();
83  $this->tabs = $DIC->tabs();
84  $this->locator = $DIC["ilLocator"];
85  $ilCtrl = $DIC->ctrl();
86  $lng = $DIC->language();
87  $ilHelp = $DIC["ilHelp"];
88 
89  $lng->loadLanguageModule("wsp");
90 
91  $this->initTree();
92 
93  $ilCtrl->saveParameter($this, "wsp_id");
94 
95  $this->node_id = (int) $_REQUEST["wsp_id"];
96  if (!$this->node_id) {
97  $this->node_id = $this->tree->getRootId();
98  }
99  }
100 
104  public function executeCommand()
105  {
107  $objDefinition = $this->obj_definition;
108  $tpl = $this->tpl;
109  $ilMainMenu = $this->main_menu;
110 
111  $ilCtrl->setReturn($this, "render");
112  $cmd = $ilCtrl->getCmd();
113 
114  // new type
115  if ($_REQUEST["new_type"]) {
116  $class_name = $objDefinition->getClassName($_REQUEST["new_type"]);
117 
118  // Only set the fixed cmdClass if the next class is different to
119  // the GUI class of the new object.
120  // An example:
121  // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
122  // when creating a link resource)
123  // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
124  if (strtolower($ilCtrl->getNextClass($this)) != strtolower("ilObj" . $class_name . "GUI")) {
125  $ilCtrl->setCmdClass("ilObj" . $class_name . "GUI");
126  }
127  }
128 
129  // root node
130  $next_class = $ilCtrl->getNextClass();
131  if (!$next_class) {
132  $node = $this->tree->getNodeData($this->node_id);
133  $next_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
134  $ilCtrl->setCmdClass($next_class);
135  }
136 
137  // if we do this here the object can still change the breadcrumb
138  $this->renderLocator();
139 
140  // current node
141  $class_path = $ilCtrl->lookupClassPath($next_class);
142  include_once($class_path);
143  $class_name = $ilCtrl->getClassForClasspath($class_path);
144  if ($_REQUEST["new_type"]) {
145  $gui = new $class_name(null, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
146  $gui->setCreationMode();
147  } else {
148  $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
149  }
150  $ilCtrl->forwardCommand($gui);
151 
152  if ($ilMainMenu->getMode() == ilMainMenuGUI::MODE_FULL) {
153  $this->renderBack();
154  }
155 
156  $tpl->setLocator();
157  }
158 
162  protected function initTree()
163  {
165 
166  $user_id = $ilUser->getId();
167 
168  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
169  $this->tree = new ilWorkspaceTree($user_id);
170  if (!$this->tree->getRootId()) {
171  $this->tree->createTreeForUser($user_id);
172  }
173  }
174 
175  protected function renderBack()
176  {
177  $lng = $this->lng;
178  $ilTabs = $this->tabs;
181 
182  $root = $this->tree->getNodeData($this->node_id);
183  if ($root["type"] != "wfld" && $root["type"] != "wsrt") {
184  // do not override existing back targets, e.g. public user profile gui
185  if (!$ilTabs->back_target) {
186  $owner = $this->tree->lookupOwner($this->node_id);
187  // workspace
188  if ($owner == $ilUser->getId()) {
189  $parent = $this->tree->getParentNodeData($this->node_id);
190  if ($parent["wsp_id"]) {
191  if ($parent["type"] == "wsrt") {
192  $class = "ilobjworkspacerootfoldergui";
193  } else {
194  $class = "ilobjworkspacefoldergui";
195  }
196  $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
197  $ilTabs->setBackTarget(
198  $lng->txt("back"),
199  $ilCtrl->getLinkTargetByClass($class, "")
200  );
201  }
202  }
203  // "shared by others"
204  else {
205  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
206  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
207  $ilTabs->setBackTarget(
208  $lng->txt("back"),
209  $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share")
210  );
211  }
212  }
213  }
214  }
215 
219  protected function renderLocator()
220  {
221  $lng = $this->lng;
223  $ilLocator = $this->locator;
224  $tpl = $this->tpl;
225  $objDefinition = $this->obj_definition;
226 
227  $ilLocator->clearItems();
228 
229  // we have no path if shared item
230  $path = $this->tree->getPathFull($this->node_id);
231  if ($path) {
232  foreach ($path as $node) {
233  $obj_class = "ilObj" . $objDefinition->getClassName($node["type"]) . "GUI";
234 
235  $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
236 
237  switch ($node["type"]) {
238  case "wsrt":
239  $ilLocator->addItem($lng->txt("wsp_personal_workspace"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
240  break;
241 
242  case "blog":
243  case $objDefinition->isContainer($node["type"]):
244  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
245  break;
246 
247  default:
248  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
249  break;
250  }
251  }
252  }
253 
254  $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
255  }
256 }
GUI class for personal workspace.
global $DIC
Definition: saml.php:7
renderLocator()
Build locator for current node.
user()
Definition: user.php:4
Tree handler for personal workspace.
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18