ILIAS  eassessment Revision 61809
 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: class.ilPublicSectionSelector.php 21088 2009-08-15 22:51:43Z akill $
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  //$tpl = new ilTemplate("tpl.tree_form.html", true, true);
80  return;
81  $tpl->setCurrentBlock("link");
82  $tpl->setVariable("TITLE", ilUtil::shortenText($this->lm_obj->getTitle(), $this->textwidth, true));
83  $tpl->setVariable("LINK_TARGET", $this->target);
84  $tpl->setVariable("TARGET", " target=\"".$this->frame_target."\"");
85  $tpl->parseCurrentBlock();
86 
87  $tpl->setCurrentBlock("element");
88  $tpl->parseCurrentBlock();
89 
90  //$this->output[] = $tpl->get();
91  }
92 
99  function getOutput()
100  {
101  global $ilBench, $tpl;
102 
103  $ilBench->start("Explorer", "getOutput");
104 
105  $this->format_options[0]["tab"] = array();
106 
107  $depth = $this->tree->getMaximumDepth();
108 
109  for ($i=0;$i<$depth;++$i)
110  {
111  $this->createLines($i);
112  }
113 
114  // set global body class
115  $tpl->setBodyClass("il_Explorer");
116 
117  $tpl_tree = new ilTemplate("tpl.tree_form.html", true, true);
118 
119  $cur_depth = -1;
120  foreach ($this->format_options as $key => $options)
121  {
122 //echo "-".$options["depth"]."-";
123  if (!$options["visible"])
124  {
125  continue;
126  }
127 
128  // end tags
129  $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
130 
131  // start tags
132  $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
133 
134  $cur_depth = $options["depth"];
135 
136  if ($options["visible"] and $key != 0)
137  {
138  $this->formatObject($tpl_tree, $options["child"],$options,$options['obj_id']);
139  }
140  if ($key == 0)
141  {
142  $this->formatHeader($tpl_tree, $options["child"],$options);
143  }
144 
145  }
146 
147  $this->handleListEndTags($tpl_tree, $cur_depth, -1);
148 
149  $ilBench->stop("Explorer", "getOutput");
150 
151  return $tpl_tree->get();
152  }
153 
162  function formatObject(&$tpl, $a_node_id,$a_option,$a_obj_id = 0)
163  {
164  global $lng;
165 
166  if (!isset($a_node_id) or !is_array($a_option))
167  {
168  $this->ilias->raiseError(get_class($this)."::formatObject(): Missing parameter or wrong datatype! ".
169  "node_id: ".$a_node_id." options:".var_dump($a_option),$this->ilias->error_obj->WARNING);
170  }
171 
172  if ($this->output_icons)
173  {
174  $tpl->setCurrentBlock("icon");
175  $tpl->setVariable("ICON_IMAGE" ,ilUtil::getImagePath("icon_".$a_option["type"].".gif"));
176  $tpl->setVariable("PAGE_ID" , $a_node_id);
177 
178  //$this->iconList[] = "iconid_".$a_node_id;
179 
180  $tpl->setVariable("TXT_ALT_IMG", $lng->txt($a_option["desc"]));
181  $tpl->parseCurrentBlock();
182  }
183 
184  if (!$a_option["container"])
185  {
186  $tpl->setCurrentBlock("checkbox");
187  $tpl->setVariable("PAGE_ID", $a_node_id);
188  if (ilLMObject::_isPagePublic($a_node_id))
189  {
190  $tpl->setVariable("CHECKED","checked=\"checked\"");
191  }
192 
193  $tpl->parseCurrentBlock();
194  }
195  else
196  {
197  $childs = $this->tree->getChilds($a_node_id);
198 
199  foreach ($childs as $node)
200  {
201  if ($node["type"] == "pg")
202  {
203  $pages[] = $node["child"];
204  }
205  }
206 
207  $js_pages = ilUtil::array_php2js($pages);
208  $tpl->setVariable("ONCLICK", " onclick=\"alterCheckboxes('PublicSelector','page_',$js_pages); return false;\"");
209  }
210 
211  $tpl->setCurrentBlock("text");
212  $tpl->setVariable("PAGE_ID", $a_node_id);
213  $tpl->setVariable("OBJ_TITLE", ilUtil::shortenText($a_option["title"], $this->textwidth, true));
214  $tpl->parseCurrentBlock();
215 
216  $tpl->setCurrentBlock("element");
217  $tpl->parseCurrentBlock();
218 
219  //$this->output[] = $tpl->get();
220  }
221 } // END class ilPublicSectionSelector
222 ?>