ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilRepositorySelectorExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php");
5 
22 {
23  protected $type_grps = array();
24  protected $session_materials = array();
25  protected $highlighted_node = null;
26  protected $clickable_types = array();
27 
31  protected $nc_modifier = null;
32 
42  public function __construct($a_parent_obj, $a_parent_cmd, $a_selection_gui = null, $a_selection_cmd = "selectObject",
43  $a_selection_par = "sel_ref_id", $a_id = "rep_exp_sel")
44  {
45  global $tree, $objDefinition;
46 
47  if (is_null($a_selection_gui))
48  {
49  $a_selection_gui = $a_parent_obj;
50  }
51 
52  $this->selection_gui = is_object($a_selection_gui)
53  ? strtolower(get_class($a_selection_gui))
54  : strtolower($a_selection_gui);
55  $this->selection_cmd = $a_selection_cmd;
56  $this->selection_par = $a_selection_par;
57  parent::__construct($a_id, $a_parent_obj, $a_parent_cmd, $tree);
58 
59  $this->setSkipRootNode(false);
60  $this->setAjax(true);
61  $this->setOrderField("title");
62 
63  // per default: all object types, except item groups
64  $white = array();
65  foreach ($objDefinition->getSubObjectsRecursively("root") as $rtype)
66  {
67  if ($rtype["name"] != "itgr" && !$objDefinition->isSideBlock($rtype["name"]))
68  {
69  $white[] = $rtype["name"];
70  }
71  }
72  $this->setTypeWhiteList($white);
73 
74  // always open the path to the current ref id
75  if ((int) $_GET["ref_id"] > 0)
76  {
77  $this->setPathOpen((int) $_GET["ref_id"]);
78  }
79  }
80 
86  function setNodeContentModifier(callable $a_val)
87  {
88  $this->nc_modifier = $a_val;
89  }
90 
97  {
98  return $this->nc_modifier;
99  }
100 
107  function getNodeContent($a_node)
108  {
109  global $lng;
110 
111  $c = $this->getNodeContentModifier();
112  if (is_callable($c))
113  {
114  return $c($a_node);
115  }
116 
117  $title = $a_node["title"];
118  if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
119  {
120  if ($title == "ILIAS")
121  {
122  $title = $lng->txt("repository");
123  }
124  }
125 
126  return $title;
127  }
128 
135  function getNodeIcon($a_node)
136  {
137  $obj_id = ilObject::_lookupObjId($a_node["child"]);
138  return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
139  }
140 
147  function getNodeIconAlt($a_node)
148  {
149  global $lng;
150 
151  if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
152  {
153  $title = $a_node["title"];
154  if ($title == "ILIAS")
155  {
156  $title = $lng->txt("repository");
157  }
158  return $lng->txt("icon")." ".$title;
159  }
160 
161 
162  return parent::getNodeIconAlt($a_node);
163  }
164 
171  function isNodeHighlighted($a_node)
172  {
173  if($this->getHighlightedNode())
174  {
175  if($this->getHighlightedNode() == $a_node["child"])
176  {
177  return true;
178  }
179  return false;
180  }
181 
182  if ($a_node["child"] == $_GET["ref_id"] ||
183  ($_GET["ref_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode())))
184  {
185  return true;
186  }
187  return false;
188  }
189 
196  function getNodeHref($a_node)
197  {
198  global $ilCtrl;
199 
200  if ($this->select_postvar == "")
201  {
202  $ilCtrl->setParameterByClass($this->selection_gui, $this->selection_par, $a_node["child"]);
203  $link = $ilCtrl->getLinkTargetByClass($this->selection_gui, $this->selection_cmd);
204  $ilCtrl->setParameterByClass($this->selection_gui, $this->selection_par, "");
205  }
206  else
207  {
208  return "#";
209  }
210 
211  return $link;
212  }
213 
220  function isNodeVisible($a_node)
221  {
222  global $ilAccess,$tree,$ilSetting;
223 
224  if (!$ilAccess->checkAccess('visible', '', $a_node["child"]))
225  {
226  return false;
227  }
228 
229  return true;
230  }
231 
239  function sortChilds($a_childs, $a_parent_node_id)
240  {
241  global $objDefinition;
242 
243  $parent_obj_id = ilObject::_lookupObjId($a_parent_node_id);
244 
245  if ($parent_obj_id > 0)
246  {
247  $parent_type = ilObject::_lookupType($parent_obj_id);
248  }
249  else
250  {
251  $parent_type = "dummy";
252  $this->type_grps["dummy"] = array("root" => "dummy");
253  }
254 
255  if (empty($this->type_grps[$parent_type]))
256  {
257  $this->type_grps[$parent_type] =
258  $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
259  }
260  $group = array();
261 
262  foreach ($a_childs as $child)
263  {
264  $g = $objDefinition->getGroupOfObj($child["type"]);
265  if ($g == "")
266  {
267  $g = $child["type"];
268  }
269  $group[$g][] = $child;
270  }
271 
272  // #14587 - $objDefinition->getGroupedRepositoryObjectTypes does NOT include side blocks!
273  $wl = $this->getTypeWhiteList();
274  if(is_array($wl) && in_array("poll", $wl))
275  {
276  $this->type_grps[$parent_type]["poll"] = array();
277  }
278 
279  $childs = array();
280  foreach ($this->type_grps[$parent_type] as $t => $g)
281  {
282  if (is_array($group[$t]))
283  {
284  // do we have to sort this group??
285  include_once("./Services/Container/classes/class.ilContainer.php");
286  include_once("./Services/Container/classes/class.ilContainerSorting.php");
287  $sort = ilContainerSorting::_getInstance($parent_obj_id);
288  $group = $sort->sortItems($group);
289 
290  // need extra session sorting here
291  if ($t == "sess")
292  {
293 
294  }
295 
296  foreach ($group[$t] as $k => $item)
297  {
298  $childs[] = $item;
299  }
300  }
301  }
302 
303  return $childs;
304  }
305 
312  function getChildsOfNode($a_parent_node_id)
313  {
314  global $ilAccess;
315 
316  if (!$ilAccess->checkAccess("read", "", $a_parent_node_id))
317  {
318  return array();
319  }
320 
321  return parent::getChildsOfNode($a_parent_node_id);
322  }
323 
330  function isNodeClickable($a_node)
331  {
332  global $ilAccess;
333 
334  if ($this->select_postvar != "")
335  {
336  // return false; #14354
337  }
338 
339  if (!$ilAccess->checkAccess("read", "", $a_node["child"]))
340  {
341  return false;
342  }
343 
344  if(is_array($this->getClickableTypes()) && count($this->getClickableTypes())>0)
345  {
346  return in_array($a_node["type"], $this->getClickableTypes());
347  }
348 
349  return true;
350  }
351 
357  public function setHighlightedNode($a_value)
358  {
359  $this->highlighted_node = $a_value;
360  }
361 
368  public function getHighlightedNode()
369  {
371  }
372 
378  function setClickableTypes($a_types)
379  {
380  if(!is_array($a_types))
381  {
382  $a_types = array($a_types);
383  }
384  $this->clickable_types = $a_types;
385  }
386 
392  function getClickableTypes()
393  {
395  }
396 
403  /* function getHTML()
404  {
405  global $ilCtrl, $tpl;
406 
407  $add = "";
408  if ($ilCtrl->isAsynch())
409  {
410  $add = $this->getOnLoadCode();
411  }
412  else
413  {
414  $tpl->addOnloadCode($this->getOnLoadCode());
415  }
416 
417  return parent::getHTML().$add;
418  }
419  */
420 
426  function setSelectableTypes($a_types)
427  {
428  if(!is_array($a_types))
429  {
430  $a_types = array($a_types);
431  }
432  $this->selectable_types = $a_types;
433  }
434 
441  {
442  return (array)$this->selectable_types;
443  }
444 
451  protected function isNodeSelectable($a_node)
452  {
453  if(count($this->getSelectableTypes()))
454  {
455  return in_array($a_node['type'],$this->getSelectableTypes() );
456  }
457  return true;
458  }
459 }
460 
461 ?>
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
Explorer for selecting repository items.
$_GET["client_id"]
setNodeContentModifier(callable $a_val)
Set node content modifier.
setSkipRootNode($a_val)
Set skip root node.
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
getHighlightedNode()
get an alternate highlighted node if $_GET["ref_id"] is not set or wrong Returns null if not set ...
setPathOpen($a_id)
Set node path to be opened.
setHighlightedNode($a_value)
set an alternate highlighted node if $_GET["ref_id"] is not set or wrong
setTypeWhiteList($a_val)
Set type white list.
global $ilCtrl
Definition: ilias.php:18
static _lookupObjId($a_id)
getNodeId($a_node)
Get id for node.
__construct($a_parent_obj, $a_parent_cmd, $a_selection_gui=null, $a_selection_cmd="selectObject", $a_selection_par="sel_ref_id", $a_id="rep_exp_sel")
Constructor.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
getRootNode()
Get root node.
$white
Definition: example_030.php:84
getClickableTypes()
get whitelist for clickable items
global $ilSetting
Definition: privfeed.php:17
Explorer class that works on tree objects (Services/Tree)
getChildsOfNode($a_parent_node_id)
Get childs of node.
global $lng
Definition: privfeed.php:17
getSelectableTypes()
get whitelist for clickable items
setOrderField($a_val, $a_numeric=false)
Set order field.
static _getInstance($a_obj_id)
get instance by obj_id
setClickableTypes($a_types)
set Whitelist for clickable items
getTypeWhiteList()
Get type white list.