ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilWorkspaceExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
27 {
29  protected bool $link_to_node_class = false;
30  protected string $custom_link_target = "";
34  protected $select_gui = null;
35  protected string $select_cmd = "";
36  protected string $select_par = "";
37  protected array $selectable_types = array();
38  protected bool $activate_highlighting = false;
40 
46  public function __construct(
47  int $a_user_id,
48  $a_parent_obj,
49  string $a_parent_cmd,
50  $a_select_gui,
51  string $a_select_cmd,
52  string $a_select_par = "sel_wsp_obj"
53  ) {
54  global $DIC;
55 
56  $this->ctrl = $DIC->ctrl();
57  $this->lng = $DIC->language();
58 
59  $this->select_gui = (is_object($a_select_gui))
60  ? strtolower(get_class($a_select_gui))
61  : $a_select_gui;
62  $this->select_cmd = $a_select_cmd;
63  $this->select_par = $a_select_par;
64 
65  $this->request = new StandardGUIRequest(
66  $DIC->http(),
67  $DIC->refinery()
68  );
69 
70  $this->tree = new ilWorkspaceTree($a_user_id);
71  $this->root_id = $this->tree->readRootId();
72  $this->access_handler = new ilWorkspaceAccessHandler($this->tree);
73 
74  parent::__construct("wsp_sel", $a_parent_obj, $a_parent_cmd, $this->tree);
75  $this->setSkipRootNode(false);
76  $this->setAjax(true);
77  $this->setPathOpen($this->root_id);
78 
79  $this->setTypeWhiteList(array("wsrt", "wfld"));
80  }
81 
82  public function setLinkToNodeClass(bool $a_val): void
83  {
84  $this->link_to_node_class = $a_val;
85  }
86 
87  public function getLinkToNodeClass(): bool
88  {
90  }
91 
92  public function setActivateHighlighting(bool $a_val): void
93  {
94  $this->activate_highlighting = $a_val;
95  }
96 
97  public function getActivateHighlighting(): bool
98  {
100  }
101 
102  public function setSelectableTypes(array $a_val): void
103  {
104  $this->selectable_types = $a_val;
105  }
106 
107  public function getSelectableTypes(): array
108  {
110  }
111 
112  public function setCustomLinkTarget(string $a_val): void
113  {
114  $this->custom_link_target = $a_val;
115  }
116 
117  public function getCustomLinkTarget(): string
118  {
120  }
121 
125  public function getNodeHref($a_node): string
126  {
127  if ($this->select_postvar != "") {
128  return "";
129  }
130  if ($this->getCustomLinkTarget() != "") {
131  return $this->getCustomLinkTarget() . "&" . $this->select_par . "=" . $a_node["child"];
132  }
133 
134  $ilCtrl = $this->ctrl;
135 
136  $target_class = $this->select_gui;
137  if (is_object($this->parent_obj)) {
138  $target_path = [get_class($this->parent_obj)];
139  } else {
140  $target_path = $this->parent_obj;
141  }
142  $target_path = $target_path + [$target_class];
143 
144  if ($this->getLinkToNodeClass()) {
145  switch ($a_node["type"]) {
146  case "wsrt":
147  $target_class = "ilobjworkspacerootfoldergui";
148  $target_path = ["ilDashboardGUI", "ilPersonalWorkspaceGUI", "ilobjworkspacerootfoldergui"];
149  break;
150  case "wfld":
151  $target_class = "ilobjworkspacefoldergui";
152  break;
153  }
154  }
155 
156  /*var_dump($target_path);
157  var_dump($target_class);
158  var_dump($this->select_par);
159  var_dump($a_node);*/
160  $ilCtrl->setParameterByClass($target_class, $this->select_par, $a_node["child"]);
161  $ret = $ilCtrl->getLinkTargetByClass($target_path, $this->select_cmd);
162  /*var_dump($ret);
163  exit;*/
164  $ilCtrl->setParameterByClass($target_class, $this->select_par, $this->request->getSelectPar());
165  return $ret;
166  }
167 
171  public function getNodeContent($a_node): string
172  {
173  $lng = $this->lng;
174 
175  if ($a_node["child"] == $this->tree->getRootId()) {
176  return $lng->txt("personal_resources");
177  }
178 
179  return $a_node["title"];
180  }
181 
185  public function isNodeClickable($a_node): bool
186  {
187  if (in_array($a_node["type"], $this->getSelectableTypes())) {
188  return true;
189  }
190  return false;
191  }
192 
196  protected function isNodeSelectable($a_node): bool
197  {
198  if (in_array($a_node["type"], $this->getSelectableTypes())) {
199  return true;
200  }
201  return false;
202  }
203 
207  public function getNodeIcon($a_node): string
208  {
209  $t = $a_node["type"];
210  if (in_array($t, array("sktr"))) {
211  return ilUtil::getImagePath("icon_skll.svg");
212  }
213  return ilUtil::getImagePath("icon_" . $t . ".svg");
214  }
215 
219  public function isNodeHighlighted($a_node): bool
220  {
221  $wsp_id = $this->request->getWspId();
222  if ($this->getActivateHighlighting() &&
223  ((int) $a_node["child"] == $wsp_id || $wsp_id == 0 && $a_node["child"] == $this->getRootId())) {
224  return true;
225  }
226  return false;
227  }
228 }
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...
__construct(int $a_user_id, $a_parent_obj, string $a_parent_cmd, $a_select_gui, string $a_select_cmd, string $a_select_par="sel_wsp_obj")
ilWorkspaceExplorerGUI constructor.
setTypeWhiteList(array $a_val)
Set type white list.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPathOpen($a_id)
Set node path to be opened.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
ilWorkspaceAccessHandler $access_handler
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Explorer for selecting a personal workspace item.
Explorer class that works on tree objects (Services/Tree)
__construct(Container $dic, ilPlugin $plugin)