ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailExplorer.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 
33 require_once("classes/class.ilExplorer.php");
34 
36 {
42  var $user_id;
43 
49  var $root_id;
50 
57  function ilMailExplorer($a_target,$a_user_id)
58  {
59  parent::ilExplorer($a_target);
60  $this->tree = new ilTree($a_user_id);
61  $this->tree->setTableNames('mail_tree','mail_obj_data');
62  $this->root_id = $this->tree->readRootId();
63  $this->user_id = $a_user_id;
64  }
65 
72  function getOutput()
73  {
74  global $tpl;
75 
76  $this->format_options[0]["tab"] = array();
77 
78  $depth = $this->tree->getMaximumDepth();
79 
80  for ($i=0;$i<$depth;++$i)
81  {
82  $this->createLines($i);
83  }
84 
85  $tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
86 
87  // set global body class
88  $tpl->setBodyClass("il_Explorer");
89 
90  $tpl_tree = new ilTemplate("tpl.tree.html", true, true);
91 
92  $cur_depth = -1;
93 
94  foreach ($this->format_options as $key => $options)
95  {
96  if (!$options["visible"])
97  {
98  continue;
99  }
100 
101  // end tags
102  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
103 
104  // start tags
105  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
106 
107  $cur_depth = $options["depth"];
108 
109  if ($options["visible"] and $key != 0)
110  {
111  $this->formatObject($tpl_tree, $options["child"],$options);
112  }
113  if($key == 0)
114  {
115  $this->formatHeader($tpl_tree, $options["child"],$options);
116  }
117  }
118 
119  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
120 
121  return $tpl_tree->get();
122  }
123 
124 
134  function setOutput($a_parent, $a_depth = 1)
135  {
136  global $lng;
137  static $counter = 0;
138 
139  if ($objects = $this->tree->getChilds($a_parent,"title,m_type"))
140  {
141 // var_dump("<pre>",$objects,"</pre");
142  $tab = ++$a_depth - 2;
143 
144  if($a_depth < 4)
145  {
146  for($i=0;$i<count($objects);++$i)
147  {
148  $objects[$i]["title"] = $lng->txt("mail_".$objects[$i]["title"]);
149  }
150  }
151 
152  foreach ($objects as $key => $object)
153  {
154  //ask for FILTER
155  if ($object["child"] != $this->root_id)
156  {
157  //$data = $this->tree->getParentNodeData($object["child"]);
158  $parent_index = $this->getIndex($object);
159  }
160  $this->format_options["$counter"]["parent"] = $object["parent"];
161  $this->format_options["$counter"]["child"] = $object["child"];
162  $this->format_options["$counter"]["title"] = $object["title"];
163  $this->format_options["$counter"]["type"] = $object["m_type"];
164  $this->format_options["$counter"]["desc"] = $object["m_type"];
165  $this->format_options["$counter"]["depth"] = $tab;
166  $this->format_options["$counter"]["container"] = false;
167  $this->format_options["$counter"]["visible"] = true;
168 
169  // Create prefix array
170  for ($i = 0; $i < $tab; ++$i)
171  {
172  $this->format_options["$counter"]["tab"][] = 'blank';
173  }
174 
175  // fix explorer (sometimes explorer disappears)
176  if ($parent_index == 0)
177  {
178  if (!in_array($object["parent"], $this->expanded))
179  {
180  $this->expanded[] = $object["parent"];
181  }
182  }
183 
184  // only if parent is expanded and visible, object is visible
185  if ($object["child"] != $this->root_id and (!in_array($object["parent"],$this->expanded)
186  or !$this->format_options["$parent_index"]["visible"]))
187  {
188  $this->format_options["$counter"]["visible"] = false;
189  }
190 
191  // if object exists parent is container
192  if ($object["child"] != $this->root_id)
193  {
194  $this->format_options["$parent_index"]["container"] = true;
195 
196  if (in_array($object["parent"],$this->expanded))
197  {
198  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
199  }
200  else
201  {
202  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
203  }
204  }
205 
206  ++$counter;
207 
208  // Recursive
209  $this->setOutput($object["child"],$a_depth);
210  } //foreach
211  } //if
212  } //function
213 
221  function formatHeader($a_obj_id,$a_option)
222  {
223  }
224 
231  function setExpand($a_node_id)
232  {
233  // IF ISN'T SET CREATE SESSION VARIABLE
234  if(!is_array($_SESSION["mexpand"]))
235  {
236  $_SESSION["mexpand"] = array();
237  }
238  // IF $_GET["expand"] is positive => expand this node
239  if($a_node_id > 0 && !in_array($a_node_id,$_SESSION["mexpand"]))
240  {
241  array_push($_SESSION["mexpand"],$a_node_id);
242  }
243  // IF $_GET["expand"] is negative => compress this node
244  if($a_node_id < 0)
245  {
246  $key = array_keys($_SESSION["mexpand"],-(int) $a_node_id);
247  unset($_SESSION["mexpand"][$key[0]]);
248  }
249  $this->expanded = $_SESSION["mexpand"];
250  }
258  function createTarget($a_type,$a_child)
259  {
260  // SET expand parameter:
261  // positive if object is expanded
262  // negative if object is compressed
263  $a_child = $a_type == '+' ? $a_child : -(int) $a_child;
264 
265  return eregi_replace("(mexpand=)(-?[0-9]+)", "\\1".$a_child, $_SERVER["REQUEST_URI"]);
266  }
267 
271  function getImage($a_name, $a_type = "", $a_obj_id = "")
272  {
273  if ($a_type) return ilUtil::getImagePath("icon_".$a_type."_s.gif");
274  else return ilUtil::getImagePath($a_name);
275  }
276 
277 } // END class.ilMailExplorer
278 ?>