ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilLocatorGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
16{
17 protected $lng;
18 protected $entries;
19
24 function ilLocatorGUI()
25 {
26 global $lng;
27
28 $this->lng =& $lng;
29 $this->entries = array();
30 $this->setTextOnly(false);
31 $this->offline = false;
32 }
33
39 function setTextOnly($a_textonly)
40 {
41 $this->textonly = $a_textonly;
42 }
43
44 function setOffline($a_offline)
45 {
46 $this->offline = $a_offline;
47 }
48
49 function getOffline()
50 {
51 return $this->offline;
52 }
53
59 function getTextOnly()
60 {
61 return $this->textonly;
62 }
63
70 function addRepositoryItems($a_ref_id = 0)
71 {
72 global $tree, $ilCtrl;
73
74 if ($a_ref_id == 0)
75 {
76 $a_ref_id = $_GET["ref_id"];
77 }
78
79 include_once './Services/Container/classes/class.ilMemberViewSettings.php';
80 if(ilMemberViewSettings::getInstance()->isActive() and $a_ref_id != ROOT_FOLDER_ID)
81 {
82 $a_start = ilMemberViewSettings::getInstance()->getContainer();
83 }
84 else
85 {
86 $a_start = ROOT_FOLDER_ID;
87 }
88
89 if ($a_ref_id > 0)
90 {
91 $path = $tree->getPathFull($a_ref_id,$a_start);
92
93 // add item for each node on path
94 foreach ((array) $path as $key => $row)
95 {
96 if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp", "prg")))
97 {
98 continue;
99 }
100 if ($row["title"] == "ILIAS" && $row["type"] == "root")
101 {
102 $row["title"] = $this->lng->txt("repository");
103 }
104
105 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $row["child"]);
106 $this->addItem($row["title"],
107 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"),
108 ilFrameTargetInfo::_getFrame("MainContent"), $row["child"]);
109 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
110 }
111 }
112 }
113
120 function addAdministrationItems($a_ref_id = 0)
121 {
122 global $tree, $ilCtrl, $objDefinition, $lng;
123
124 if ($a_ref_id == 0)
125 {
126 $a_ref_id = $_GET["ref_id"];
127 }
128
129 if ($a_ref_id > 0)
130 {
131 $path = $tree->getPathFull($a_ref_id);
132
133 // add item for each node on path
134 foreach ($path as $key => $row)
135 {
136 if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp")))
137 {
138 continue;
139 }
140
141 if ($row["child"] == ROOT_FOLDER_ID)
142 {
143 $row["title"] = $lng->txt("repository");
144 }
145
146 $class_name = $objDefinition->getClassName($row["type"]);
147 $class = strtolower("ilObj".$class_name."GUI");
148 $ilCtrl->setParameterByClass($class, "ref_id", $row["child"]);
149 $this->addItem($row["title"],
150 $ilCtrl->getLinkTargetbyClass($class, "view"), "", $row["child"]);
151 }
152 }
153 }
154
155 function addContextItems($a_ref_id, $a_omit_node = false, $a_stop = 0)
156 {
157 global $tree;
158
159 if ($a_ref_id > 0)
160 {
161 $path = $tree->getPathFull($a_ref_id);
162
163 // we want to show the full path, from the major container to the item
164 // (folders are not! treated as containers here), at least one parent item
165 $r_path = array_reverse($path);
166 $first = "";
167 $omit = array();
168 $do_omit = false;
169 foreach ($r_path as $key => $row)
170 {
171 if ($first == "")
172 {
173 if (in_array($row["type"], array("root", "cat", "grp", "crs")) &&
174 $row["child"] != $a_ref_id)
175 {
176 $first = $row["child"];
177 }
178 }
179 if ($a_stop == $row["child"])
180 {
181 $do_omit = true;
182 }
183 $omit[$row["child"]] = $do_omit;
184 }
185
186 $add_it = false;
187 foreach ($path as $key => $row)
188 {
189 if ($first == $row["child"])
190 {
191 $add_it = true;
192 }
193
194
195 if ($add_it && !$omit[$row["child"]] &&
196 (!$a_omit_node || ($row["child"] != $a_ref_id)))
197 {
198//echo "-".ilObject::_lookupTitle($row["obj_id"])."-";
199 if ($row["title"] == "ILIAS" && $row["type"] == "root")
200 {
201 $row["title"] = $this->lng->txt("repository");
202 }
203 $this->addItem($row["title"],
204 "./goto.php?client_id=".rawurlencode(CLIENT_ID)."&target=".$row["type"]."_".$row["child"],
205 "_top", $row["child"], $row["type"]);
206 }
207 }
208 }
209 }
210
218 function addItem($a_title, $a_link, $a_frame = "", $a_ref_id = 0, $type = null)
219 {
220 global $ilAccess;
221
222 if ($a_ref_id > 0 && !$ilAccess->checkAccess("visible", "", $a_ref_id))
223 {
224 return;
225 }
226
227 $this->entries[] = array("title" => $a_title,
228 "link" => $a_link, "frame" => $a_frame, "ref_id" => $a_ref_id, "type" => $type);
229 }
230
234 function clearItems()
235 {
236 $this->entries = array();
237 }
238
242 function getItems()
243 {
244 return $this->entries;
245 }
246
250 function getHTML()
251 {
252 global $lng, $ilSetting;
253
254 if ($this->getTextOnly())
255 {
256 $loc_tpl = new ilTemplate("tpl.locator_text_only.html", true, true, "Services/Locator");
257 }
258 else
259 {
260 $loc_tpl = new ilTemplate("tpl.locator.html", true, true, "Services/Locator");
261 }
262
263 $items = $this->getItems();
264 $first = true;
265
266 if (is_array($items))
267 {
268 foreach($items as $item)
269 {
270 if (!$first)
271 {
272 $loc_tpl->touchBlock("locator_separator_prefix");
273 }
274
275 if ($item["ref_id"] > 0)
276 {
277 $obj_id = ilObject::_lookupObjId($item["ref_id"]);
278 $type = ilObject::_lookupType($obj_id);
279
280 if (!$this->getTextOnly())
281 {
282 $icon_path = ilObject::_getIcon($obj_id, "tiny", $type,
283 $this->getOffline());
284 }
285
286 $loc_tpl->setCurrentBlock("locator_img");
287 $loc_tpl->setVariable("IMG_SRC", $icon_path);
288 $loc_tpl->setVariable("IMG_ALT",
289 $lng->txt("obj_".$type));
290 $loc_tpl->parseCurrentBlock();
291 }
292
293 $loc_tpl->setCurrentBlock("locator_item");
294 if ($item["link"] != "")
295 {
296 $loc_tpl->setVariable("LINK_ITEM", $item["link"]);
297 if ($item["frame"] != "")
298 {
299 $loc_tpl->setVariable("LINK_TARGET", ' target="'.$item["frame"].'" ');
300 }
301 $loc_tpl->setVariable("ITEM", $item["title"]);
302 }
303 else
304 {
305 $loc_tpl->setVariable("PREFIX", $item["title"]);
306 }
307 $loc_tpl->parseCurrentBlock();
308
309 $first = false;
310 }
311 }
312 else
313 {
314 $loc_tpl->setVariable("NOITEM", "&nbsp;");
315 $loc_tpl->touchBlock("locator");
316 }
317 $loc_tpl->setVariable("TXT_BREADCRUMBS", $lng->txt("breadcrumb_navigation"));
318
319 return trim($loc_tpl->get());
320 }
321
325 function getTextVersion()
326 {
327 global $lng, $ilSetting;
328
329 $items = $this->getItems();
330 $first = true;
331
332 $str = "";
333 if (is_array($items))
334 {
335 foreach($items as $item)
336 {
337 if (!$first)
338 {
339 $str.= " > ";
340 }
341
342 $str.= $item["title"];
343
344 $first = false;
345 }
346 }
347
348 return $str;
349 }
350
351} // END class.LocatorGUI
352?>
$_GET["client_id"]
static _getFrame($a_class, $a_type='')
Get content frame name.
locator handling class
addContextItems($a_ref_id, $a_omit_node=false, $a_stop=0)
getTextOnly()
Get Only text, no HTML.
addRepositoryItems($a_ref_id=0)
add repository item
clearItems()
Clear all Items.
addAdministrationItems($a_ref_id=0)
add administration tree items
getItems()
Get all locator entries.
setTextOnly($a_textonly)
Set Only text, no HTML.
getHTML()
Get locator HTML.
ilLocatorGUI()
Constructor.
addItem($a_title, $a_link, $a_frame="", $a_ref_id=0, $type=null)
add locator item
setOffline($a_offline)
getTextVersion()
Get text version.
static getInstance()
Get instance.
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
special template class to simplify handling of ITX/PEAR
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22