ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailExplorer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
13 
15 {
21  var $user_id;
22 
28  var $root_id;
29 
36  public function __construct($a_target,$a_user_id)
37  {
38  parent::__construct($a_target);
39  $this->tree = new ilTree($a_user_id);
40  $this->tree->setTableNames('mail_tree','mail_obj_data');
41  $this->root_id = $this->tree->readRootId();
42  $this->user_id = $a_user_id;
43  }
44 
51  function getOutput()
52  {
53  global $tpl;
54 
55  $this->format_options[0]["tab"] = array();
56 
57  $depth = $this->tree->getMaximumDepth();
58 
59  for ($i=0;$i<$depth;++$i)
60  {
61  $this->createLines($i);
62  }
63 
64  $tpl->addBlockFile("EXPLORER_TOP", "exp_top", "tpl.explorer_top.html");
65 
66  // set global body class
67  $tpl->setBodyClass("il_Explorer");
68 
69  $tpl_tree = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer");
70 
71  $cur_depth = -1;
72 
73  foreach ($this->format_options as $key => $options)
74  {
75  if (!$options["visible"])
76  {
77  continue;
78  }
79 
80  // end tags
81  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
82 
83  // start tags
84  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
85 
86  $cur_depth = $options["depth"];
87 
88  if ($options["visible"] and $key != 0)
89  {
90  $this->formatObject($tpl_tree, $options["child"],$options);
91  }
92  if($key == 0)
93  {
94  $this->formatHeader($tpl_tree, $options["child"],$options);
95  }
96  }
97 
98  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
99 
100  return $tpl_tree->get();
101  }
102 
103 
113  function setOutput($a_parent, $a_depth = 1)
114  {
115  global $lng;
116  static $counter = 0;
117 
118  if ($objects = $this->tree->getChilds($a_parent,"title,m_type"))
119  {
120 // var_dump("<pre>",$objects,"</pre");
121  $tab = ++$a_depth - 2;
122 
123  if($a_depth < 4)
124  {
125  for($i=0;$i<count($objects);++$i)
126  {
127  $objects[$i]["title"] = $lng->txt("mail_".$objects[$i]["title"]);
128  }
129  }
130 
131  foreach ($objects as $key => $object)
132  {
133  //ask for FILTER
134  if ($object["child"] != $this->root_id)
135  {
136  //$data = $this->tree->getParentNodeData($object["child"]);
137  $parent_index = $this->getIndex($object);
138  }
139  $this->format_options["$counter"]["parent"] = $object["parent"];
140  $this->format_options["$counter"]["child"] = $object["child"];
141  $this->format_options["$counter"]["title"] = $object["title"];
142  $this->format_options["$counter"]["type"] = $object["m_type"];
143  $this->format_options["$counter"]["desc"] = $object["m_type"];
144  $this->format_options["$counter"]["depth"] = $tab;
145  $this->format_options["$counter"]["container"] = false;
146  $this->format_options["$counter"]["visible"] = true;
147 
148  // Create prefix array
149  for ($i = 0; $i < $tab; ++$i)
150  {
151  $this->format_options["$counter"]["tab"][] = 'blank';
152  }
153 
154  // fix explorer (sometimes explorer disappears)
155  if ($parent_index == 0)
156  {
157  if (!in_array($object["parent"], $this->expanded))
158  {
159  $this->expanded[] = $object["parent"];
160  }
161  }
162 
163  // only if parent is expanded and visible, object is visible
164  if ($object["child"] != $this->root_id and (!in_array($object["parent"],$this->expanded)
165  or !$this->format_options["$parent_index"]["visible"]))
166  {
167  $this->format_options["$counter"]["visible"] = false;
168  }
169 
170  // if object exists parent is container
171  if ($object["child"] != $this->root_id)
172  {
173  $this->format_options["$parent_index"]["container"] = true;
174 
175  if (in_array($object["parent"],$this->expanded))
176  {
177  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'minus';
178  }
179  else
180  {
181  $this->format_options["$parent_index"]["tab"][($tab-2)] = 'plus';
182  }
183  }
184 
185  ++$counter;
186 
187  // Recursive
188  $this->setOutput($object["child"],$a_depth);
189  } //foreach
190  } //if
191  } //function
192 
200  function formatHeader($a_obj_id,$a_option)
201  {
202  }
203 
210  function setExpand($a_node_id)
211  {
212  // IF ISN'T SET CREATE SESSION VARIABLE
213  if(!is_array($_SESSION["mexpand"]))
214  {
215  $_SESSION["mexpand"] = array();
216  }
217  // IF $_GET["expand"] is positive => expand this node
218  if($a_node_id > 0 && !in_array($a_node_id,$_SESSION["mexpand"]))
219  {
220  array_push($_SESSION["mexpand"],$a_node_id);
221  }
222  // IF $_GET["expand"] is negative => compress this node
223  if($a_node_id < 0)
224  {
225  $key = array_keys($_SESSION["mexpand"],-(int) $a_node_id);
226  unset($_SESSION["mexpand"][$key[0]]);
227  }
228  $this->expanded = $_SESSION["mexpand"];
229  }
237  function createTarget($a_type,$a_child)
238  {
239  // SET expand parameter:
240  // positive if object is expanded
241  // negative if object is compressed
242  $a_child = $a_type == '+' ? $a_child : -(int) $a_child;
243 
244  return eregi_replace("(mexpand=)(-?[0-9]+)", "\\1".$a_child, $_SERVER["REQUEST_URI"]);
245  }
246 
250  function getImage($a_name, $a_type = "", $a_obj_id = "")
251  {
252  if ($a_type) return ilUtil::getImagePath("icon_".$a_type."_s.png");
253  else return ilUtil::getImagePath($a_name);
254  }
255 
256 } // END class.ilMailExplorer
257 ?>