ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
21  protected $tree; // [ilTree]
22  protected $node_id; // [int]
23 
27  public function __construct()
28  {
29  global $ilCtrl, $lng, $ilHelp;
30 
31  $lng->loadLanguageModule("wsp");
32 
33  $this->initTree();
34 
35  $ilCtrl->saveParameter($this, "wsp_id");
36 
37  $this->node_id = (int) $_REQUEST["wsp_id"];
38  if(!$this->node_id)
39  {
40  $this->node_id = $this->tree->getRootId();
41  }
42  }
43 
47  public function executeCommand()
48  {
49  global $ilCtrl, $objDefinition, $tpl, $ilMainMenu;
50 
51  $ilCtrl->setReturn($this, "render");
52  $cmd = $ilCtrl->getCmd();
53 
54  // new type
55  if($_REQUEST["new_type"])
56  {
57  $class_name = $objDefinition->getClassName($_REQUEST["new_type"]);
58 
59  // Only set the fixed cmdClass if the next class is different to
60  // the GUI class of the new object.
61  // An example:
62  // ilObjLinkResourceGUI tries to forward to ilLinkInputGUI (adding an internal link
63  // when creating a link resource)
64  // Without this fix, the cmdClass ilObjectCopyGUI would never be reached
65  if (strtolower($ilCtrl->getNextClass($this)) != strtolower("ilObj".$class_name."GUI"))
66  {
67  $ilCtrl->setCmdClass("ilObj".$class_name."GUI");
68  }
69  }
70 
71  // root node
72  $next_class = $ilCtrl->getNextClass();
73  if(!$next_class)
74  {
75  $node = $this->tree->getNodeData($this->node_id);
76  $next_class = "ilObj".$objDefinition->getClassName($node["type"])."GUI";
77  $ilCtrl->setCmdClass($next_class);
78  }
79 
80  // if we do this here the object can still change the breadcrumb
81  $this->renderLocator();
82 
83  // current node
84  $class_path = $ilCtrl->lookupClassPath($next_class);
85  include_once($class_path);
86  $class_name = $ilCtrl->getClassForClasspath($class_path);
87  if($_REQUEST["new_type"])
88  {
89  $gui = new $class_name(null, ilObject2GUI::WORKSPACE_NODE_ID, $this->node_id);
90  $gui->setCreationMode();
91  }
92  else
93  {
94  $gui = new $class_name($this->node_id, ilObject2GUI::WORKSPACE_NODE_ID, false);
95  }
96  $ilCtrl->forwardCommand($gui);
97 
98  if($ilMainMenu->getMode() == ilMainMenuGUI::MODE_FULL)
99  {
100  $this->renderBack();
101  }
102 
103  $tpl->setLocator();
104  }
105 
109  protected function initTree()
110  {
111  global $ilUser;
112 
113  $user_id = $ilUser->getId();
114 
115  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
116  $this->tree = new ilWorkspaceTree($user_id);
117  if(!$this->tree->getRootId())
118  {
119  $this->tree->createTreeForUser($user_id);
120  }
121  }
122 
123  protected function renderBack()
124  {
125  global $lng, $ilTabs, $ilCtrl, $ilUser;
126 
127  $root = $this->tree->getNodeData($this->node_id);
128  if($root["type"] != "wfld" && $root["type"] != "wsrt")
129  {
130  // do not override existing back targets, e.g. public user profile gui
131  if(!$ilTabs->back_target)
132  {
133  $owner = $this->tree->lookupOwner($this->node_id);
134  // workspace
135  if($owner == $ilUser->getId())
136  {
137  $parent = $this->tree->getParentNodeData($this->node_id);
138  if($parent["wsp_id"])
139  {
140  if($parent["type"] == "wsrt")
141  {
142  $class = "ilobjworkspacerootfoldergui";
143  }
144  else
145  {
146  $class = "ilobjworkspacefoldergui";
147  }
148  $ilCtrl->setParameterByClass($class, "wsp_id", $parent["wsp_id"]);
149  $ilTabs->setBackTarget($lng->txt("back"),
150  $ilCtrl->getLinkTargetByClass($class, ""));
151  }
152  }
153  // "shared by others"
154  else
155  {
156  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "wsp_id", "");
157  $ilCtrl->setParameterByClass("ilobjworkspacerootfoldergui", "user", $owner);
158  $ilTabs->setBackTarget($lng->txt("back"),
159  $ilCtrl->getLinkTargetByClass("ilobjworkspacerootfoldergui", "share"));
160  }
161  }
162  }
163  }
164 
168  protected function renderLocator()
169  {
170  global $lng, $ilCtrl, $ilLocator, $tpl, $objDefinition;
171 
172  $ilLocator->clearItems();
173 
174  // we have no path if shared item
175  $path = $this->tree->getPathFull($this->node_id);
176  if($path)
177  {
178  foreach($path as $node)
179  {
180  $obj_class = "ilObj".$objDefinition->getClassName($node["type"])."GUI";
181 
182  $ilCtrl->setParameter($this, "wsp_id", $node["wsp_id"]);
183 
184  switch($node["type"])
185  {
186  case "wsrt":
187  $ilLocator->addItem($lng->txt("wsp_personal_workspace"), $ilCtrl->getLinkTargetByClass($obj_class, "render"));
188  break;
189 
190  case "blog":
191  case $objDefinition->isContainer($node["type"]):
192  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "render"));
193  break;
194 
195  default:
196  $ilLocator->addItem($node["title"], $ilCtrl->getLinkTargetByClass($obj_class, "edit"));
197  break;
198  }
199  }
200  }
201 
202  $ilCtrl->setParameter($this, "wsp_id", $this->node_id);
203  }
204 }
205 
206 ?>
$path
Definition: aliased.php:25
GUI class for personal workspace.
renderLocator()
Build locator for current node.
$cmd
Definition: sahs_server.php:35
Tree handler for personal workspace.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
global $lng
Definition: privfeed.php:17