ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPublicSectionSelector.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 require_once("./Modules/LearningModule/classes/class.ilLMExplorer.php");
25 require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
26 
27 /*
28 * Public Section Explorer
29 *
30 * @author Sascha Hofmann <saschahofmann@gmx.de>
31 * @version $Id$
32 *
33 * @ingroup ModulesIliasLearningModule
34 */
36 {
42  var $root_id;
43  var $output;
44  var $ctrl;
45 
47  var $ref_id;
48 
56  function ilPublicSectionSelector($a_target,&$a_lm_obj,$a_gui_class)
57  {
58  global $ilCtrl;
59 
60  $this->ctrl =& $ilCtrl;
61  $this->gui_class = $a_gui_class;
62 
63  parent::ilLMExplorer($a_target, $a_lm_obj);
64  $this->forceExpandAll(true);
65  $this->setSessionExpandVariable("lmpublicselectorexpand");
66  }
67 
75  function formatHeader($tpl,$a_obj_id,$a_option)
76  {
77  global $lng, $ilias;
78 
79  return;
80 
81  /*
82  $tpl->setCurrentBlock("link");
83  $tpl->setVariable("TITLE", ilUtil::shortenText($this->lm_obj->getTitle(), $this->textwidth, true));
84  $tpl->setVariable("LINK_TARGET", $this->target);
85  $tpl->setVariable("TARGET", " target=\"".$this->frame_target."\"");
86  $tpl->parseCurrentBlock();
87 
88  $tpl->setCurrentBlock("element");
89  $tpl->parseCurrentBlock();
90 
91  //$this->output[] = $tpl->get();
92  */
93  }
94 
101  function getOutput()
102  {
103  global $ilBench, $tpl;
104 
105  $ilBench->start("Explorer", "getOutput");
106 
107  $this->format_options[0]["tab"] = array();
108 
109  $depth = $this->tree->getMaximumDepth();
110 
111  for ($i=0;$i<$depth;++$i)
112  {
113  $this->createLines($i);
114  }
115 
116  // set global body class
117  $tpl->setBodyClass("il_Explorer");
118 
119  $tpl_tree = new ilTemplate("tpl.tree_form.html", true, true, "Modules/LearningModule");
120 
121  $cur_depth = -1;
122  foreach ($this->format_options as $key => $options)
123  {
124 //echo "-".$options["depth"]."-";
125  if (!$options["visible"])
126  {
127  continue;
128  }
129 
130  // end tags
131  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
132 
133  // start tags
134  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
135 
136  $cur_depth = $options["depth"];
137 
138  if ($options["visible"] and $key != 0)
139  {
140  $this->formatObject($tpl_tree, $options["child"],$options,$options['obj_id']);
141  }
142  if ($key == 0)
143  {
144  $this->formatHeader($tpl_tree, $options["child"],$options);
145  }
146 
147  }
148 
149  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
150 
151  $ilBench->stop("Explorer", "getOutput");
152 
153  return $tpl_tree->get();
154  }
155 
164  function formatObject(&$tpl, $a_node_id,$a_option,$a_obj_id = 0)
165  {
166  global $lng;
167 
168  if (!isset($a_node_id) or !is_array($a_option))
169  {
170  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
171  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
172  }
173 
174  if ($this->output_icons)
175  {
176  $tpl->setCurrentBlock("icon");
177  $tpl->setVariable("ICON_IMAGE" ,ilUtil::getImagePath("icon_".$a_option["type"].".png"));
178  $tpl->setVariable("PAGE_ID" , $a_node_id);
179 
180  //$this->iconList[] = "iconid_".$a_node_id;
181 
182  $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
183  $tpl->parseCurrentBlock();
184  }
185 
186  if (!$a_option["container"])
187  {
188  $tpl->setCurrentBlock("checkbox");
189  $tpl->setVariable("PAGE_ID", $a_node_id);
190  if (ilLMObject::_isPagePublic($a_node_id))
191  {
192  $tpl->setVariable("CHECKED","checked=\"checked\"");
193  }
194 
195  $tpl->parseCurrentBlock();
196  }
197  else
198  {
199  $childs = $this->tree->getChilds($a_node_id);
200 
201  foreach ($childs as $node)
202  {
203  if ($node["type"] == "pg")
204  {
205  $pages[] = $node["child"];
206  }
207  }
208 
209  $js_pages = ilUtil::array_php2js($pages);
210  $tpl->setVariable("ONCLICK", " onclick=\"alterCheckboxes('PublicSelector','page_',$js_pages); return false;\"");
211  }
212 
213  $tpl->setCurrentBlock("text");
214  $tpl->setVariable("PAGE_ID", $a_node_id);
215  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
216  $tpl->parseCurrentBlock();
217 
218  $tpl->setCurrentBlock("element");
219  $tpl->parseCurrentBlock();
220 
221  //$this->output[] = $tpl->get();
222  }
223 } // END class ilPublicSectionSelector
224 ?>