ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLMTOCExplorer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Modules/LearningModule/classes/class.ilLMExplorer.php");
5 require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
6 
7 /*
8 * Explorer View for Learning Module Editor
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @version $Id$
12 *
13 * @ingroup ModulesIliasLearningModule
14 */
16 {
17  var $offline;
18 
25  function ilLMTOCExplorer($a_target,&$a_lm_obj)
26  {
27  $this->offline = false;
28  $this->force_open_path = array();
29  parent::ilLMExplorer($a_target, $a_lm_obj);
30  $this->lm_set = new ilSetting("lm");
31  }
32 
36  function setOfflineMode($a_offline = true)
37  {
38  $this->offline = $a_offline;
39  }
40 
44  function offlineMode()
45  {
46  return $this->offline;
47  }
48 
49 
53  function setForceOpenPath($a_path)
54  {
55  $this->force_open_path = $a_path;
56  }
57 
61  function buildTitle($a_title, $a_id, $a_type)
62  {
63 //echo "<br>-$a_title-$a_type-$a_id-";
64  if ($a_type == "st")
65  {
67  $this->lm_obj->isActiveNumbering());
68  }
69 
70  if ($this->lm_obj->getTOCMode() == "chapters" || $a_type != "pg")
71  {
72  return $a_title;
73  }
74  else
75  {
76  if ($a_type == "pg")
77  {
79  $this->lm_obj->getPageHeader(), $this->lm_obj->isActiveNumbering(),
80  $this->lm_set->get("time_scheduled_page_activation"), true);
81  }
82  }
83  }
84 
85 
89  function getImage($a_name, $a_type = "", $a_id = "")
90  {
91  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
92 
93  if ($a_type == "pg")
94  {
95  include_once("./Services/COPage/classes/class.ilPageObject.php");
96  $lm_set = new ilSetting("lm");
97  $active = ilPageObject::_lookupActive($a_id, $this->lm_obj->getType(),
98  $lm_set->get("time_scheduled_page_activation"));
99 
100  // is page scheduled?
101  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
102  ilPageObject::_isScheduledActivation($a_id, $this->lm_obj->getType()))
103  ? "_sc"
104  : "";
105 
106  $a_name = "icon_pg".$img_sc."_s.png";
107 
108  if (!$active)
109  {
110  $a_name = "icon_pg_d".$img_sc."_s.png";
111  }
112  else
113  {
114  include_once("./Services/COPage/classes/class.ilPageObject.php");
116  $this->lm_obj->getType());
117  if ($contains_dis)
118  {
119  $a_name = "icon_pg_del".$img_sc."_s.png";
120  }
121  }
122  }
123  return ilUtil::getImagePath($a_name, false, "output", $this->offlineMode());
124  }
125 
126 
127  function isClickable($a_type, $a_node_id)
128  {
129  global $ilUser;
130 
131  $orig_node_id = $a_node_id;
132 
133  if ($a_type == "st")
134  {
135  if (!$this->offlineMode())
136  {
137  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
138  $a_node_id = $a_node["child"];
139  if ($a_node_id == 0)
140  {
141  return false;
142  }
143  }
144  else
145  {
146  // get next activated page
147  $found = false;
148  while (!$found)
149  {
150  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
151  $a_node_id = $a_node["child"];
152  include_once("./Services/COPage/classes/class.ilPageObject.php");
153  $active = ilPageObject::_lookupActive($a_node_id, $this->lm_obj->getType(),
154  $this->lm_set->get("time_scheduled_page_activation"));
155 
156  if ($a_node_id > 0 && !$active)
157  {
158  $found = false;
159  }
160  else
161  {
162  $found = true;
163  }
164  }
165  if ($a_node_id <= 0)
166  {
167  return false;
168  }
169  else
170  {
171  $path = $this->tree->getPathId($a_node_id);
172  if (!in_array($orig_node_id, $path))
173  {
174  return false;
175  }
176  }
177  }
178  }
179 
180  if ($a_type == "pg")
181  {
182  // check public area mode
183  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
184  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
185  if (($ilUser->getId() == ANONYMOUS_USER_ID ||
186  ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm_obj->getRefId())) &&
187  !ilLMObject::_isPagePublic($a_node_id, true))
188  {
189  return false;
190  }
191  }
192 
193  return true;
194  }
195 
199  function buildLinkTarget($a_node_id, $a_type)
200  {
201  if (!$this->offlineMode())
202  {
203  return parent::buildLinkTarget($a_node_id, $a_type);
204  }
205  else
206  {
207  if ($a_node_id < 1)
208  {
209  $a_node_id = $this->tree->getRootId();
210  }
211  if ($a_type != "pg")
212  {
213  // get next activated page
214  $found = false;
215  while (!$found)
216  {
217  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
218  $a_node_id = $a_node["child"];
219  include_once("./Services/COPage/classes/class.ilPageObject.php");
220  $active = ilPageObject::_lookupActive($a_node_id, $this->lm_obj->getType(),
221  $this->lm_set->get("time_scheduled_page_activation"));
222 
223  if ($a_node_id > 0 && !$active)
224  {
225  $found = false;
226  }
227  else
228  {
229  $found = true;
230  }
231  }
232  }
233  if (!$this->lm_obj->cleanFrames())
234  {
235  return "frame_".$a_node_id."_maincontent.html";
236  }
237  else
238  {
239  return "lm_pg_".$a_node_id.".html";
240  }
241  }
242  }
243 
247  function forceExpanded($a_obj_id)
248  {
249  if ($this->offlineMode())
250  {
251  return true;
252  }
253  else
254  {
255  if (in_array($a_obj_id, $this->force_open_path))
256  {
257  return true;
258  }
259  return false;
260  }
261  }
262 
263  function isVisible($a_id, $a_type)
264  {
265  include_once("./Services/COPage/classes/class.ilPageObject.php");
266  $active = ilPageObject::_lookupActive($a_id, $this->lm_obj->getType(),
267  $this->lm_set->get("time_scheduled_page_activation"));
268 
269  if(!$active && $a_type == "pg")
270  {
271  $act_data = ilPageObject::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
272  if ($act_data["show_activation_info"] &&
273  (ilUtil::now() < $act_data["activation_start"]))
274  {
275  return true;
276  }
277  else
278  {
279  return false;
280  }
281  }
282  else
283  {
284  return true;
285  }
286  }
287 
288 } // END class.ilLMTOCExplorer
289 ?>