ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNavigationHistory.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
32 {
33 
34  private $items;
35 
41  public function __construct()
42  {
43  $this->items = array();
44  $items = null;
45  if (isset($_SESSION["il_nav_history"]))
46  {
47  $items = unserialize($_SESSION["il_nav_history"]);
48  }
49  if (is_array($items))
50  {
51  $this->items = $items;
52  }
53  }
54 
59  public function addItem($a_ref_id, $a_link, $a_type, $a_title = "")
60  {
61  if ($a_title == "" && $a_ref_id > 0)
62  {
63  $obj_id = ilObject::_lookupObjId($a_ref_id);
64  if (ilObject::_exists($obj_id))
65  {
66  $a_title = ilObject::_lookupTitle($obj_id);
67  }
68  }
69 
70  // remove ref id from stack, if existing
71  foreach($this->items as $key => $item)
72  {
73  if ($item["ref_id"] == $a_ref_id)
74  {
75  array_splice($this->items, $key, 1);
76  break;
77  }
78  }
79 
80  $this->items = array_merge(
81  array(array("ref_id" => $a_ref_id, "link" => $a_link, "title" => $a_title,
82  "type" => $a_type)), $this->items);
83 
84  $items = serialize($this->items);
85  $_SESSION["il_nav_history"] = $items;
86  }
87 
91  public function getItems()
92  {
93  global $tree;
94 
95  $items = array();
96 
97  foreach ($this->items as $it)
98  {
99  if ($tree->isInTree($it["ref_id"]))
100  {
101  $items[] = $it;
102  }
103  }
104 
105  return $items;
106  }
107 }
108 ?>