ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_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
37 public function __construct($a_parent_obj, $a_parent_cmd, $a_selection_gui = null, $a_selection_cmd = "selectObject",
38 $a_selection_par = "sel_ref_id")
39 {
40 global $tree, $objDefinition;
41
42 if (is_null($a_selection_gui))
43 {
44 $a_selection_gui = $a_parent_obj;
45 }
46
47 $this->selection_gui = is_object($a_selection_gui)
48 ? strtolower(get_class($a_selection_gui))
49 : strtolower($a_selection_gui);
50 $this->selection_cmd = $a_selection_cmd;
51 $this->selection_par = $a_selection_par;
52
53 parent::__construct("rep_exp_sel", $a_parent_obj, $a_parent_cmd, $tree);
54
55 $this->setSkipRootNode(false);
56 $this->setAjax(true);
57 $this->setOrderField("title");
58
59 // per default: all object types, except item groups
60 $white = array();
61 foreach ($objDefinition->getSubObjectsRecursively("root") as $rtype)
62 {
63 if ($rtype["name"] != "itgr" && !$objDefinition->isSideBlock($rtype["name"]))
64 {
65 $white[] = $rtype["name"];
66 }
67 }
69
70 // always open the path to the current ref id
71 if ((int) $_GET["ref_id"] > 0)
72 {
73 $this->setPathOpen((int) $_GET["ref_id"]);
74 }
75 }
76
83 function getNodeContent($a_node)
84 {
85 global $lng;
86
87 $title = $a_node["title"];
88 if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
89 {
90 if ($title == "ILIAS")
91 {
92 $title = $lng->txt("repository");
93 }
94 }
95
96 return $title;
97 }
98
105 function getNodeIcon($a_node)
106 {
107 $obj_id = ilObject::_lookupObjId($a_node["child"]);
108 return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
109 }
110
117 function getNodeIconAlt($a_node)
118 {
119 global $lng;
120
121 if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
122 {
123 $title = $a_node["title"];
124 if ($title == "ILIAS")
125 {
126 $title = $lng->txt("repository");
127 }
128 return $lng->txt("icon")." ".$title;
129 }
130
131
132 return parent::getNodeIconAlt($a_node);
133 }
134
141 function isNodeHighlighted($a_node)
142 {
143 if($this->getHighlightedNode())
144 {
145 if($this->getHighlightedNode() == $a_node["child"])
146 {
147 return true;
148 }
149 return false;
150 }
151
152 if ($a_node["child"] == $_GET["ref_id"] ||
153 ($_GET["ref_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode())))
154 {
155 return true;
156 }
157 return false;
158 }
159
166 function getNodeHref($a_node)
167 {
168 global $ilCtrl;
169
170 $ilCtrl->setParameterByClass($this->selection_gui, $this->selection_par, $a_node["child"]);
171 $link = $ilCtrl->getLinkTargetByClass($this->selection_gui, $this->selection_cmd);
172 $ilCtrl->setParameterByClass($this->selection_gui, $this->selection_par, "");
173
174 return $link;
175 }
176
183 function isNodeVisible($a_node)
184 {
185 global $ilAccess,$tree,$ilSetting;
186
187 if (!$ilAccess->checkAccess('visible', '', $a_node["child"]))
188 {
189 return false;
190 }
191
192 return true;
193 }
194
202 function sortChilds($a_childs, $a_parent_node_id)
203 {
204 global $objDefinition;
205
206 $parent_obj_id = ilObject::_lookupObjId($a_parent_node_id);
207
208 if ($parent_obj_id > 0)
209 {
210 $parent_type = ilObject::_lookupType($parent_obj_id);
211 }
212 else
213 {
214 $parent_type = "dummy";
215 $this->type_grps["dummy"] = array("root" => "dummy");
216 }
217
218 if (empty($this->type_grps[$parent_type]))
219 {
220 $this->type_grps[$parent_type] =
221 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
222 }
223 $group = array();
224
225 foreach ($a_childs as $child)
226 {
227 $g = $objDefinition->getGroupOfObj($child["type"]);
228 if ($g == "")
229 {
230 $g = $child["type"];
231 }
232 $group[$g][] = $child;
233 }
234
235 // #14587 - $objDefinition->getGroupedRepositoryObjectTypes does NOT include side blocks!
236 $wl = $this->getTypeWhiteList();
237 if(is_array($wl) && in_array("poll", $wl))
238 {
239 $this->type_grps[$parent_type]["poll"] = array();
240 }
241
242 $childs = array();
243 foreach ($this->type_grps[$parent_type] as $t => $g)
244 {
245 if (is_array($group[$t]))
246 {
247 // do we have to sort this group??
248 include_once("./Services/Container/classes/class.ilContainer.php");
249 include_once("./Services/Container/classes/class.ilContainerSorting.php");
250 $sort = ilContainerSorting::_getInstance($parent_obj_id);
251 $group = $sort->sortItems($group);
252
253 // need extra session sorting here
254 if ($t == "sess")
255 {
256
257 }
258
259 foreach ($group[$t] as $k => $item)
260 {
261 $childs[] = $item;
262 }
263 }
264 }
265
266 return $childs;
267 }
268
275 function getChildsOfNode($a_parent_node_id)
276 {
277 global $ilAccess;
278
279 if (!$ilAccess->checkAccess("read", "", $a_parent_node_id))
280 {
281 return array();
282 }
283
284 return parent::getChildsOfNode($a_parent_node_id);
285 }
286
293 function isNodeClickable($a_node)
294 {
295 global $ilAccess;
296
297 if ($this->select_postvar != "")
298 {
299 // return false; #14354
300 }
301
302 if (!$ilAccess->checkAccess("read", "", $a_node["child"]))
303 {
304 return false;
305 }
306
307 if(is_array($this->getClickableTypes()) && count($this->getClickableTypes())>0)
308 {
309 return in_array($a_node["type"], $this->getClickableTypes());
310 }
311
312 return true;
313 }
314
320 public function setHighlightedNode($a_value)
321 {
322 $this->highlighted_node = $a_value;
323 }
324
331 public function getHighlightedNode()
332 {
334 }
335
341 function setClickableTypes($a_types)
342 {
343 if(!is_array($a_types))
344 {
345 $a_types = array($a_types);
346 }
347 $this->clickable_types = $a_types;
348 }
349
356 {
357 return (array)$this->clickable_types;
358 }
359
360}
361
362?>
$_GET["client_id"]
static _getInstance($a_obj_id)
get instance by obj_id
setSkipRootNode($a_val)
Set skip root node.
static _lookupObjId($a_id)
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
Explorer for selecting repository items.
__construct($a_parent_obj, $a_parent_cmd, $a_selection_gui=null, $a_selection_cmd="selectObject", $a_selection_par="sel_ref_id")
Constructor.
getClickableTypes()
get whitelist for clickable items
setHighlightedNode($a_value)
set an alternate highlighted node if $_GET["ref_id"] is not set or wrong
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
getChildsOfNode($a_parent_node_id)
Get childs of node.
setClickableTypes($a_types)
set Whitelist for clickable items
Explorer class that works on tree objects (Services/Tree)
setTypeWhiteList($a_val)
Set type white list.
setPathOpen($a_id)
Set node path to be opened.
getTypeWhiteList()
Get type white list.
getNodeId($a_node)
Get id for node.
setOrderField($a_val, $a_numeric=false)
Set order field.
$white
Definition: example_030.php:84
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40