ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
14 {
18  protected $ctrl;
19 
23  protected $nav_history;
24 
28  protected $lng;
29 
30 
31  private $items;
32 
37  public function __construct()
38  {
39  global $DIC;
40 
41  $this->ctrl = $DIC->ctrl();
42  $this->nav_history = $DIC["ilNavigationHistory"];
43  $this->lng = $DIC->language();
44  }
45 
49  public function executeCommand()
50  {
52 
53  $next_class = $ilCtrl->getNextClass();
54  $cmd = $ilCtrl->getCmd();
55 
56  switch ($next_class) {
57  default:
58  $this->$cmd();
59  break;
60  }
61  }
62 
66  public function getHTML()
67  {
68  $ilNavigationHistory = $this->nav_history;
69  $lng = $this->lng;
70 
71  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
72  $selection = new ilAdvancedSelectionListGUI();
73  $selection->setFormSelectMode(
74  "url_ref_id",
75  "ilNavHistorySelect",
76  true,
77  "goto.php?target=navi_request",
78  "ilNavHistory",
79  "ilNavHistoryForm",
80  "_top",
81  $lng->txt("go"),
82  "ilNavHistorySubmit"
83  );
84  $selection->setListTitle($lng->txt("last_visited"));
85  $selection->setId("lastvisited");
86  $selection->setSelectionHeaderClass("MMInactive");
87  $selection->setHeaderIcon(ilAdvancedSelectionListGUI::NO_ICON);
88  $selection->setItemLinkClass("small");
89  $selection->setUseImages(true);
90  include_once("./Services/Accessibility/classes/class.ilAccessKey.php");
91  $selection->setAccessKey(ilAccessKey::LAST_VISITED);
92 
93  $items = $ilNavigationHistory->getItems();
94  //$sel_arr = array(0 => "-- ".$lng->txt("last_visited")." --");
95  reset($items);
96  $cnt = 0;
97  foreach ($items as $k => $item) {
98  if ($cnt++ > 20) {
99  break;
100  }
101  if (!isset($item["ref_id"]) || !isset($_GET["ref_id"]) ||
102  $item["ref_id"] != $_GET["ref_id"] || $k > 0) { // do not list current item
103  $obj_id = ilObject::_lookupObjId($item["ref_id"]);
104  $selection->addItem(
105  $item["title"],
106  $item["ref_id"],
107  $item["link"],
108  ilObject::_getIcon($obj_id, "tiny", $item["type"]),
109  $lng->txt("obj_" . $item["type"]),
110  "_top"
111  );
112  }
113  }
114  $html = $selection->getHTML();
115 
116  if ($html == "") {
117  $selection->addItem(
118  $lng->txt("no_items"),
119  "",
120  "#",
121  "",
122  "",
123  "_top"
124  );
125  $selection->setUseImages(false);
126  $html = $selection->getHTML();
127  }
128  return $html;
129  }
130 
134  public function handleNavigationRequest()
135  {
136  $ilNavigationHistory = $this->nav_history;
138 
139  if ($_GET["target"] == "navi_request") {
140  $items = $ilNavigationHistory->getItems();
141  foreach ($items as $item) {
142  if ($item["ref_id"] == $_POST["url_ref_id"]) {
143  ilUtil::redirect($item["link"]);
144  }
145  }
146  reset($items);
147  $item = current($items);
148  if ($_POST["url_ref_id"] == 0 && $item["ref_id"] == $_GET["ref_id"]) {
149  $item = next($items); // omit current item
150  }
151  if ($_POST["url_ref_id"] == 0 && $item["link"] != "") {
152  ilUtil::redirect($item["link"]);
153  }
154 
155  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "");
156  $ilCtrl->setParameterByClass("ilrepositorygui", "getlast", "true");
157  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
158  }
159  }
160 
167  public function removeEntries()
168  {
169  $ilNavigationHistory = $this->nav_history;
170 
171  $ilNavigationHistory->deleteDBEntries();
172  $ilNavigationHistory->deleteSessionEntries();
173  }
174 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
handleNavigationRequest()
Handle navigation request.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
User Interface Class for Navigation History.
static _lookupObjId($a_id)
getHTML()
Get HTML for navigation history.
User interface class for advanced drop-down selection lists.
removeEntries()
Remove all entries form list.
static redirect($a_script)
$_POST["username"]
$html
Definition: example_001.php:87