ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNavigationHistoryGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13 
14  private $items;
15 
20  public function __construct()
21  {
22  }
23 
27  function getHTML()
28  {
29  global $ilNavigationHistory, $lng;
30 
31  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
32  $selection = new ilAdvancedSelectionListGUI();
33  $selection->setFormSelectMode("url_ref_id", "ilNavHistorySelect", true,
34  "goto.php?target=navi_request", "ilNavHistory", "ilNavHistoryForm",
35  "_top", $lng->txt("go"), "ilNavHistorySubmit");
36  $selection->setListTitle($lng->txt("last_visited"));
37  $selection->setId("lastvisited");
38  $selection->setSelectionHeaderClass("MMInactive");
39  $selection->setHeaderIcon(ilAdvancedSelectionListGUI::NO_ICON);
40  $selection->setItemLinkClass("small");
41  $selection->setUseImages(true);
42  include_once("./Services/Accessibility/classes/class.ilAccessKey.php");
43  $selection->setAccessKey(ilAccessKey::LAST_VISITED);
44 
45  $items = $ilNavigationHistory->getItems();
46  //$sel_arr = array(0 => "-- ".$lng->txt("last_visited")." --");
47  reset($items);
48  $cnt = 0;
49  foreach($items as $item)
50  {
51  if ($cnt++ > 20) break;
52 
53  if (!isset($item["ref_id"]) || !isset($_GET["ref_id"]) || $item["ref_id"] != $_GET["ref_id"]) // do not list current item
54  {
55  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
56  $selection->addItem($item["title"], $item["ref_id"], $item["link"],
57  ilObject::_getIcon($obj_id, "tiny", $item["type"]),
58  $lng->txt("obj_".$item["type"]), "_top");
59  }
60  }
61  $html = $selection->getHTML();
62 
63  if ($html == "")
64  {
65  $selection->addItem($lng->txt("no_items"), "", "#",
66  "", "", "_top");
67  $selection->setUseImages(false);
68  $html = $selection->getHTML();
69  }
70  return $html;
71  }
72 
76  public function getHTMLOld()
77  {
78  global $ilNavigationHistory, $lng;
79 
80  $items = $ilNavigationHistory->getItems();
81 
82  // do not show list, if no item is in list
83  if (count($items) == 0)
84  {
85  return "";
86  }
87 
88  // do not show list, if only current item is in list
89  $item = current($items);
90  if (count($items) == 1 && $item["ref_id"] == $_GET["ref_id"])
91  {
92  return "";
93  }
94 
95  $GLOBALS["tpl"]->addJavascript("./Services/Navigation/js/ServiceNavigation.js");
96 
97  $tpl = new ilTemplate("tpl.navigation_history.html", true, true,
98  "Services/Navigation");
99 
100  $sel_arr = array(0 => "-- ".$lng->txt("last_visited")." --");
101  reset($items);
102 
103  $cnt = 0;
104  foreach($items as $item)
105  {
106  if ($cnt++ > 20) break;
107 
108  if ($item["ref_id"] != $_GET["ref_id"]) // do not list current item
109  {
110  $sel_arr[$item["ref_id"]] = $item["title"];
111  $this->css_row = ($this->css_row != "tblrow1_mo")
112  ? "tblrow1_mo"
113  : "tblrow2_mo";
114  $tpl->setCurrentBlock("item");
115  $tpl->setVariable("HREF_ITEM", $item["link"]);
116  $tpl->setVariable("CSS_ROW", $this->css_row);
117  $tpl->setVariable("TXT_ITEM", $item["title"]);
118 
119  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
120  $tpl->setVariable("IMG_ITEM",
121  ilObject::_getIcon($obj_id, "tiny", $item["type"]));
122  $tpl->setVariable("ALT_ITEM", $lng->txt("obj_".$item["type"]));
123  $tpl->parseCurrentBlock();
124  }
125  }
126  $select = ilUtil::formSelect("", "url_ref_id", $sel_arr, false, true, "0", "ilEditSelect");
127  $tpl->setVariable("TXT_LAST_VISITED", $lng->txt("last_visited"));
128  $tpl->setVariable("IMG_DOWN", ilUtil::getImagePath("mm_down_arrow.gif"));
129  $tpl->setVariable("NAVI_SELECT", $select);
130  $tpl->setVariable("TXT_GO", $lng->txt("go"));
131  $tpl->setVariable("ACTION", "goto.php?target=navi_request&ref_id=".$_GET["ref_id"]);
132 
133  return $tpl->get();
134  }
135 
140  {
141  global $ilNavigationHistory;
142 
143  if ($_GET["target"] == "navi_request")
144  {
145  $items = $ilNavigationHistory->getItems();
146  foreach($items as $item)
147  {
148  if ($item["ref_id"] == $_POST["url_ref_id"])
149  {
150  ilUtil::redirect($item["link"]);
151  }
152  }
153  reset($items);
154  $item = current($items);
155  if ($_POST["url_ref_id"] == 0 && $item["ref_id"] == $_GET["ref_id"])
156  {
157  $item = next($items); // omit current item
158  }
159  if ($_POST["url_ref_id"] == 0 && $item["link"] != "")
160  {
161  ilUtil::redirect($item["link"]);
162  }
163  ilUtil::redirect("repository.php?cmd=frameset&getlast=true");
164  }
165  }
166 
167 }
168 ?>