ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBookmarkExplorer.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 /*
25 * Explorer View for Bookmarks
26 *
27 * @author Alex Killing <alex.killing@gmx.de>
28 * @author Manfred Thaler <manfred.thaler@endo7.com>
29 * @version $Id: class.ilBookmarkExplorer.php 23986 2010-05-26 10:08:27Z mwarkus $
30 *
31 */
32 
33 require_once("classes/class.ilExplorer.php");
34 
36 {
42  var $user_id;
43 
49  var $root_id;
50 
57 
64  function ilBookmarkExplorer($a_target,$a_user_id)
65  {
66  parent::ilExplorer($a_target);
67  $this->tree = new ilTree($a_user_id);
68  $this->tree->setTableNames('bookmark_tree','bookmark_data');
69  $this->root_id = $this->tree->readRootId();
70  $this->user_id = $a_user_id;
71  $this->allowed_types= array ('bmf','dum');
72  $this->enablesmallmode = false;
73  }
74 
80  function setEnableSmallMode($a_enablesmallmode)
81  {
82  $this->enablesmallmode = $a_enablesmallmode;
83  }
84 
90  function getEnableSmallMode()
91  {
92  return $this->enablesmallmode;
93  }
94 
95 
104  function setOutput($a_parent, $a_depth = 1)
105  {
106  global $lng;
107  static $counter = 0;
108 
109  if ($objects = $this->tree->getChilds($a_parent,"type DESC,title"))
110  {
111 // var_dump("<pre>",$objects,"</pre");
112  $tab = ++$a_depth - 2;
113 
114  if($a_depth < 4)
115  {
116  for($i=0;$i<count($objects);++$i)
117  {
118  //$objects[$i]["title"] = $lng->txt("mail_".$objects[$i]["title"]);
119  //$objects[$i]["title"] = "TEEST";
120  }
121  }
122 
123  foreach ($objects as $key => $object)
124  {
125  if (!in_array($object["type"],$this->allowed_types))
126  {
127  continue;
128  }
129 
130  //ask for FILTER
131  if ($object["child"] != $this->root_id)
132  {
133  //$data = $this->tree->getParentNodeData($object["child"]);
134  $parent_index = $this->getIndex($object);
135  }
136  // Store targets for Bookmarks
137  if ($object["type"]=='bm') {
138  $this->bm_targets[$object["child"]]=$object["target"];
139  };
140  $this->format_options["$counter"]["parent"] = $object["parent"];
141  $this->format_options["$counter"]["child"] = $object["child"];
142  $this->format_options["$counter"]["title"] = $object["title"];
143  $this->format_options["$counter"]["description"] = $object["description"];
144  $this->format_options["$counter"]["type"] = $object["type"];
145  $this->format_options["$counter"]["depth"] = $tab;
146  $this->format_options["$counter"]["container"] = false;
147  $this->format_options["$counter"]["visible"] = true;
148 
149  // Create prefix array
150  for ($i = 0; $i < $tab; ++$i)
151  {
152  $this->format_options["$counter"]["tab"][] = 'blank';
153  }
154  // only if parent is expanded and visible, object is visible
155  if ($object["child"] != $this->root_id and (!in_array($object["parent"],$this->expanded)
156  or !$this->format_options["$parent_index"]["visible"]))
157  {
158  $this->format_options["$counter"]["visible"] = false;
159  }
160 
161  // if object exists parent is container
162  if ($object["child"] != $this->root_id)
163  {
164  $this->format_options["$parent_index"]["container"] = true;
165 
166  if (in_array($object["parent"],$this->expanded))
167  {
168  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
169  }
170  else
171  {
172  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
173  }
174  }
175 
176  ++$counter;
177 
178  // Recursive
179  $this->setOutput($object["child"],$a_depth);
180  } //foreach
181  } //if
182  } //function
183 
191  function formatHeader($a_obj_id,$a_option)
192  {
193  global $lng, $ilias;
194 
195  }
196 
203  function setExpand($a_node_id)
204  {
205  if ($a_node_id == "")
206  {
207  $a_node_id = $this->root_id;
208  }
209 
210  // IF ISN'T SET CREATE SESSION VARIABLE
211  if(!is_array($_SESSION["mexpand"]))
212  {
213  $_SESSION["mexpand"] = array();
214  }
215  // IF $_GET["expand"] is positive => expand this node
216  if($a_node_id > 0 && !in_array($a_node_id,$_SESSION["mexpand"]))
217  {
218  array_push($_SESSION["mexpand"],$a_node_id);
219  }
220  // IF $_GET["expand"] is negative => compress this node
221  if($a_node_id < 0)
222  {
223  $key = array_keys($_SESSION["mexpand"],-(int) $a_node_id);
224  unset($_SESSION["mexpand"][$key[0]]);
225  }
226  $this->expanded = $_SESSION["mexpand"];
227  }
232  function buildLinkTarget($a_node_id, $a_type)
233  {
234  if ($_REQUEST['bm_link'] && $a_type == 'bmf')
235  {
236  $link = $_SERVER['REQUEST_URI'];
237  $link = ereg_replace('bmf_id=[0-9]*', 'bmf_id=' . $a_node_id, $link);
238  return $link;
239  }
240 
241  switch ($a_type) {
242  case 'bm':
243  // return stored Bookmark target;
244  return htmlentities($this->bm_targets[$a_node_id]);
245  break;
246  default:
247  $target = (strpos($this->target, "?") === false)
248  ? $this->target."?"
249  : $this->target."&";
250  return $target.$this->target_get."=".$a_node_id.$this->params_get;
251  }
252  }
257  function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
258  {
259  switch ($a_type) {
260  case 'bm':
261  // return _blank for Bookmarks;
262  return '_blank';
263  break;
264  default:
265  return '';
266  }
267  }
268 
274  function setAllowedTypes($a_types)
275  {
276  $this->allowed_types = $a_types;
277  }
283  function setShowDetails($s_details)
284  {
285  $this->show_details = $s_details;
286  }
287 
292  function buildDescription($a_desc, $a_id, $a_type)
293  {
294  if ($this->show_details=='y' && !empty($a_desc))
295  {
296  return $a_desc;
297 
298  }
299  else
300  {
301  return "";
302  }
303  }
304 
305  function getImageAlt($a_def, $a_type, $a_obj_id)
306  {
307  global $lng;
308 
309  return $lng->txt("icon")." ".$lng->txt($a_type);
310  }
311 
312 }
313 ?>