ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
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  $pre = "";
90  if (defined("ILIAS_MODULE"))
91  {
92  $pre = "../";
93  }
94 
95  if ($a_ref_id > 0)
96  {
97  $path = $tree->getPathFull($a_ref_id,$a_start);
98 
99  // add item for each node on path
100  foreach ((array) $path as $key => $row)
101  {
102  if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp", "icrs")))
103  {
104  continue;
105  }
106  if ($row["title"] == "ILIAS" && $row["type"] == "root")
107  {
108  $row["title"] = $this->lng->txt("repository");
109  }
110 
111  $this->addItem($row["title"],
112  $pre."repository.php?cmd=frameset&amp;ref_id=".$row["child"],
113  ilFrameTargetInfo::_getFrame("MainContent"), $row["child"]);
114  }
115  }
116  }
117 
124  function addAdministrationItems($a_ref_id = 0)
125  {
126  global $tree, $ilCtrl, $objDefinition, $lng;
127 
128  if ($a_ref_id == 0)
129  {
130  $a_ref_id = $_GET["ref_id"];
131  }
132 
133  if ($a_ref_id > 0)
134  {
135  $path = $tree->getPathFull($a_ref_id);
136 
137  // add item for each node on path
138  foreach ($path as $key => $row)
139  {
140  if (!in_array($row["type"], array("root", "cat", "crs", "fold", "grp", "icrs")))
141  {
142  continue;
143  }
144 
145  if ($row["child"] == ROOT_FOLDER_ID)
146  {
147  $row["title"] = $lng->txt("repository");
148  }
149 
150  $class_name = $objDefinition->getClassName($row["type"]);
151  $class = strtolower("ilObj".$class_name."GUI");
152  $ilCtrl->setParameterByClass($class, "ref_id", $row["child"]);
153  $this->addItem($row["title"],
154  $ilCtrl->getLinkTargetbyClass($class, "view"), "", $row["child"]);
155  }
156  }
157  }
158 
159  function addContextItems($a_ref_id, $a_omit_node = false, $a_stop = 0)
160  {
161  global $tree;
162 
163  if ($a_ref_id > 0)
164  {
165  $path = $tree->getPathFull($a_ref_id);
166 
167  // we want to show the full path, from the major container to the item
168  // (folders are not! treated as containers here), at least one parent item
169  $r_path = array_reverse($path);
170  $first = "";
171  $omit = array();
172  $do_omit = false;
173  foreach ($r_path as $key => $row)
174  {
175  if ($first == "")
176  {
177  if (in_array($row["type"], array("root", "cat", "grp", "crs")) &&
178  $row["child"] != $a_ref_id)
179  {
180  $first = $row["child"];
181  }
182  }
183  if ($a_stop == $row["child"])
184  {
185  $do_omit = true;
186  }
187  $omit[$row["child"]] = $do_omit;
188  }
189 
190  $add_it = false;
191  foreach ($path as $key => $row)
192  {
193  if ($first == $row["child"])
194  {
195  $add_it = true;
196  }
197 
198 
199  if ($add_it && !$omit[$row["child"]] &&
200  (!$a_omit_node || ($row["child"] != $a_ref_id)))
201  {
202 //echo "-".ilObject::_lookupTitle($row["obj_id"])."-";
203  if ($row["title"] == "ILIAS" && $row["type"] == "root")
204  {
205  $row["title"] = $this->lng->txt("repository");
206  }
207  $this->addItem($row["title"],
208  "./goto.php?client_id=".rawurlencode(CLIENT_ID)."&target=".$row["type"]."_".$row["child"],
209  "_top", $row["child"], $row["type"]);
210  }
211  }
212  }
213  }
214 
222  function addItem($a_title, $a_link, $a_frame = "", $a_ref_id = 0, $type = null)
223  {
224  $this->entries[] = array("title" => $a_title,
225  "link" => $a_link, "frame" => $a_frame, "ref_id" => $a_ref_id, "type" => $type);
226  }
227 
231  function clearItems()
232  {
233  $this->entries = array();
234  }
235 
239  function getItems()
240  {
241  return $this->entries;
242  }
243 
247  function getHTML()
248  {
249  global $lng, $ilSetting;
250 
251  if ($this->getTextOnly())
252  {
253  $loc_tpl = new ilTemplate("tpl.locator_text_only.html", true, true, "Services/Locator");
254  }
255  else
256  {
257  $loc_tpl = new ilTemplate("tpl.locator.html", true, true, "Services/Locator");
258  }
259 
260  $items = $this->getItems();
261  $first = true;
262 
263  if (is_array($items))
264  {
265  foreach($items as $item)
266  {
267  if (!$first)
268  {
269  $loc_tpl->touchBlock("locator_separator_prefix");
270  }
271 
272  if ($item["ref_id"] > 0)
273  {
274  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
275  $type = ilObject::_lookupType($obj_id);
276 
277  if (!$this->getTextOnly())
278  {
279  $icon_path = ilObject::_getIcon($obj_id, "tiny", $type,
280  $this->getOffline());
281  }
282 
283  $loc_tpl->setCurrentBlock("locator_img");
284  $loc_tpl->setVariable("IMG_SRC", $icon_path);
285  $loc_tpl->setVariable("IMG_ALT",
286  $lng->txt("obj_".$type));
287  $loc_tpl->parseCurrentBlock();
288  }
289 
290  $loc_tpl->setCurrentBlock("locator_item");
291  if ($item["link"] != "")
292  {
293  $loc_tpl->setVariable("LINK_ITEM", $item["link"]);
294  if ($item["frame"] != "")
295  {
296  $loc_tpl->setVariable("LINK_TARGET", ' target="'.$item["frame"].'" ');
297  }
298  $loc_tpl->setVariable("ITEM", $item["title"]);
299  }
300  else
301  {
302  $loc_tpl->setVariable("PREFIX", $item["title"]);
303  }
304  $loc_tpl->parseCurrentBlock();
305 
306  $first = false;
307  }
308  }
309  else
310  {
311  $loc_tpl->setVariable("NOITEM", "&nbsp;");
312  $loc_tpl->touchBlock("locator");
313  }
314  $loc_tpl->setVariable("TXT_BREADCRUMBS", $lng->txt("breadcrumb_navigation"));
315 
316  return trim($loc_tpl->get());
317  }
318 
319 
320 } // END class.LocatorGUI
321 ?>