ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBookmarkExplorer.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
6 
7 /*
8 * Explorer View for Bookmarks
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @author Manfred Thaler <manfred.thaler@endo7.com>
12 * @version $Id$
13 * @ingroup ServicesBookmarks
14 *
15 */
17 {
23  var $user_id;
24 
30  var $root_id;
31 
38 
45  function ilBookmarkExplorer($a_target,$a_user_id)
46  {
47  parent::ilExplorer($a_target);
48  $this->tree = new ilTree($a_user_id);
49  $this->tree->setTableNames('bookmark_tree','bookmark_data');
50  $this->root_id = $this->tree->readRootId();
51  $this->user_id = $a_user_id;
52  $this->allowed_types= array ('bmf','dum');
53  $this->enablesmallmode = false;
54  }
55 
61  function setEnableSmallMode($a_enablesmallmode)
62  {
63  $this->enablesmallmode = $a_enablesmallmode;
64  }
65 
71  function getEnableSmallMode()
72  {
73  return $this->enablesmallmode;
74  }
75 
76 
85  function setOutput($a_parent, $a_depth = 1)
86  {
87  global $lng;
88  static $counter = 0;
89 
90  if ($objects = $this->tree->getChilds($a_parent,"type DESC,title"))
91  {
92 // var_dump("<pre>",$objects,"</pre");
93  $tab = ++$a_depth - 2;
94 
95  if($a_depth < 4)
96  {
97  for($i=0;$i<count($objects);++$i)
98  {
99  //$objects[$i]["title"] = $lng->txt("mail_".$objects[$i]["title"]);
100  //$objects[$i]["title"] = "TEEST";
101  }
102  }
103 
104  foreach ($objects as $key => $object)
105  {
106  if (!in_array($object["type"],$this->allowed_types))
107  {
108  continue;
109  }
110 
111  //ask for FILTER
112  if ($object["child"] != $this->root_id)
113  {
114  //$data = $this->tree->getParentNodeData($object["child"]);
115  $parent_index = $this->getIndex($object);
116  }
117  // Store targets for Bookmarks
118  if ($object["type"]=='bm') {
119  $this->bm_targets[$object["child"]]=$object["target"];
120  };
121 
122  if($this->root && !$counter)
123  {
124  $counter++;
125  $object["title"] = $this->root;
126  $a_depth++;
127  }
128 
129  $this->format_options["$counter"]["parent"] = $object["parent"];
130  $this->format_options["$counter"]["child"] = $object["child"];
131  $this->format_options["$counter"]["title"] = $object["title"];
132  $this->format_options["$counter"]["description"] = $object["description"];
133  $this->format_options["$counter"]["type"] = $object["type"];
134  $this->format_options["$counter"]["depth"] = $tab;
135  $this->format_options["$counter"]["container"] = false;
136  $this->format_options["$counter"]["visible"] = true;
137 
138  // Create prefix array
139  for ($i = 0; $i < $tab; ++$i)
140  {
141  $this->format_options["$counter"]["tab"][] = 'blank';
142  }
143  // only if parent is expanded and visible, object is visible
144  if ($object["child"] != $this->root_id and ((!in_array($object["parent"],$this->expanded) && !$this->expand_all)
145  or !$this->format_options["$parent_index"]["visible"]))
146  {
147  $this->format_options["$counter"]["visible"] = false;
148  }
149 
150  // if object exists parent is container
151  if ($object["child"] != $this->root_id)
152  {
153  $this->format_options["$parent_index"]["container"] = true;
154 
155  if(!$this->expand_all)
156  {
157  if (in_array($object["parent"],$this->expanded))
158  {
159  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
160  }
161  else
162  {
163  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
164  }
165  }
166  }
167 
168  ++$counter;
169 
170  // Recursive
171  $this->setOutput($object["child"],$a_depth);
172  } //foreach
173  } //if
174  } //function
175 
183  function formatHeader($a_obj_id,$a_option)
184  {
185  global $lng, $ilias;
186 
187  }
188 
195  function setExpand($a_node_id)
196  {
197  if ($a_node_id == "")
198  {
199  $a_node_id = $this->root_id;
200  }
201 
202  // IF ISN'T SET CREATE SESSION VARIABLE
203  if(!is_array($_SESSION["mexpand"]))
204  {
205  $_SESSION["mexpand"] = array();
206  }
207  // IF $_GET["expand"] is positive => expand this node
208  if($a_node_id > 0 && !in_array($a_node_id,$_SESSION["mexpand"]))
209  {
210  array_push($_SESSION["mexpand"],$a_node_id);
211  }
212  // IF $_GET["expand"] is negative => compress this node
213  if($a_node_id < 0)
214  {
215  $key = array_keys($_SESSION["mexpand"],-(int) $a_node_id);
216  unset($_SESSION["mexpand"][$key[0]]);
217  }
218  $this->expanded = $_SESSION["mexpand"];
219  }
224  function buildLinkTarget($a_node_id, $a_type)
225  {
226  if ($_REQUEST['bm_link'] && $a_type == 'bmf')
227  {
228  $link = $_SERVER['REQUEST_URI'];
229  $link = ereg_replace('bmf_id=[0-9]*', 'bmf_id=' . $a_node_id, $link);
230  return $link;
231  }
232 
233  switch ($a_type) {
234  case 'bm':
235  // return stored Bookmark target;
236  return htmlentities($this->bm_targets[$a_node_id]);
237  break;
238  default:
239  $target = (strpos($this->target, "?") === false)
240  ? $this->target."?"
241  : $this->target."&";
242  return $target.$this->target_get."=".$a_node_id.$this->params_get;
243  }
244  }
249  function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
250  {
251  switch ($a_type) {
252  case 'bm':
253  // return _blank for Bookmarks;
254  return '_blank';
255  break;
256  default:
257  return '';
258  }
259  }
260 
266  function setAllowedTypes($a_types)
267  {
268  $this->allowed_types = $a_types;
269  }
275  function setShowDetails($s_details)
276  {
277  $this->show_details = $s_details;
278  }
279 
284  function buildDescription($a_desc, $a_id, $a_type)
285  {
286  if ($this->show_details=='y' && !empty($a_desc))
287  {
288  return $a_desc;
289 
290  }
291  else
292  {
293  return "";
294  }
295  }
296 
297  function getImageAlt($a_def, $a_type, $a_obj_id)
298  {
299  global $lng;
300 
301  return $lng->txt("icon")." ".$lng->txt($a_type);
302  }
303 
304  function addRoot($a_caption)
305  {
306  $this->root = $a_caption;
307  }
308 }
309 ?>