ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilLMTableOfContentsExplorer.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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.ilStructureObject.php");
26 
27 /*
28 * Table of Contents Explorer
29 *
30 * @author Alex Killing <alex.killing@gmx.de>
31 * @version $Id$
32 *
33 * @ingroup ModulesIliasLearningModule
34 */
36 {
37 
43  var $root_id;
44  var $output;
45  var $offline;
46 
53  function ilTableOfContentsExplorer($a_target,&$a_lm_obj, $a_export_format = "")
54  {
55  parent::ilLMExplorer($a_target, $a_lm_obj);
56  $this->setSessionExpandVariable("lmtocexpand");
57  $this->export_format = $a_export_format;
58  $this->lm_obj =& $a_lm_obj;
59 
60  $this->addFilter("du");
61  $this->addFilter("st");
62  if ($a_lm_obj->getTOCMode() == "pages")
63  {
64  $this->addFilter("pg");
65  }
66  $this->setFiltered(true);
68  $this->lm_set = new ilSetting("lm");
69 
70  // Determine whether the view of a learning resource should
71  // be shown in the frameset of ilias, or in a separate window.
72  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
73  $showViewInFrameset = true;
74 
75  if ($showViewInFrameset)
76  {
77  $this->setFrameTarget(ilFrameTargetInfo::_getFrame("MainContent"));
78  }
79  else
80  {
81  $this->setFrameTarget("_top");
82  }
83 
84  }
85 
89  function setOfflineMode($a_offline = true)
90  {
91  $this->offline = $a_offline;
92 
93  if ($a_offline)
94  {
95  if ($this->export_format == "scorm")
96  {
97  $this->setFrameTarget("");
98  }
99  }
100 
101  }
102 
106  function offlineMode()
107  {
108  return $this->offline;
109  }
110 
114  function buildTitle($a_title, $a_id, $a_type)
115  {
116  global $lng;
117 
118  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
119  $access_str = "";
121  $_GET['ref_id'],ilObject::_lookupObjId($_GET["ref_id"]), $a_id))
122  {
123  $access_str = " (".$lng->txt("cont_no_access").")";
124  }
125 
126  if ($a_type == "st")
127  {
129  $this->lm_obj->isActiveNumbering()).$access_str;
130  }
131 
132  if ($this->lm_obj->getTOCMode() == "chapters" || $a_type != "pg")
133  {
134  return $a_title.$access_str;
135  }
136  else
137  {
138  if ($a_type == "pg")
139  {
141  $this->lm_obj->getPageHeader(), $this->lm_obj->isActiveNumbering(),
142  $this->lm_set->get("time_scheduled_page_activation")).$access_str;
143  }
144  }
145 
146  }
147 
151  function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
152  {
153  // Determine whether the view of a learning resource should
154  // be shown in the frameset of ilias, or in a separate window.
155  //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame";
156  $showViewInFrameset = true;
157 
158  if ($this->offlineMode() &&
159  $this->export_format == "scorm")
160  {
161  return "";
162  }
163 
164  if ($showViewInFrameset && !$this->offlineMode())
165  {
166  return ilFrameTargetInfo::_getFrame("MainContent");
167  }
168  else
169  {
170  return "_top";
171  }
172  }
173 
177  function buildLinkTarget($a_node_id, $a_type)
178  {
179  if (!$this->offlineMode())
180  {
181  return parent::buildLinkTarget($a_node_id, $a_type);
182  }
183  else
184  {
185  if ($a_node_id < 1)
186  {
187  $a_node_id = $this->tree->getRootId();
188  }
189  if ($a_type != "pg")
190  {
191  // get next activated page
192  $found = false;
193  while (!$found)
194  {
195  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
196  $a_node_id = $a_node["child"];
197  include_once("./Services/COPage/classes/class.ilPageObject.php");
198  $active = ilPageObject::_lookupActive($a_node_id, $this->lm_obj->getType(),
199  $this->lm_set->get("time_scheduled_page_activation"));
200  if ($a_node_id > 0 && !$active)
201  {
202  $found = false;
203  }
204  else
205  {
206  $found = true;
207  }
208  }
209  }
210 
211  if ($nid = ilLMPageObject::getExportId($this->lm_obj->getId(), $a_node_id))
212  {
213  return "lm_pg_".$nid.".html";
214  }
215  else
216  {
217  return "lm_pg_".$a_node_id.".html";
218  }
219  }
220  }
221 
222  function isClickable($a_type, $a_node_id)
223  {
224  global $ilUser;
225 
226  $orig_node_id = $a_node_id;
227 
228  if ($a_type == "st")
229  {
230  if (!$this->offlineMode())
231  {
232  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
233  $a_node_id = $a_node["child"];
234  if ($a_node_id == 0)
235  {
236  return false;
237  }
238  }
239  else
240  {
241  // get next activated page
242  $found = false;
243  while (!$found)
244  {
245  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
246  $a_node_id = $a_node["child"];
247  include_once("./Services/COPage/classes/class.ilPageObject.php");
248  $active = ilPageObject::_lookupActive($a_node_id, $this->lm_obj->getType(),
249  $this->lm_set->get("time_scheduled_page_activation"));
250  if ($a_node_id > 0 && !$active)
251  {
252  $found = false;
253  }
254  else
255  {
256  $found = true;
257  }
258  }
259  if ($a_node_id <= 0)
260  {
261  return false;
262  }
263  else
264  {
265  $path = $this->tree->getPathId($a_node_id);
266  if (!in_array($orig_node_id, $path))
267  {
268  return false;
269  }
270  }
271  }
272  }
273 
274  if ($a_type == "pg")
275  {
276  // check public area mode
277  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
278  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
279  if (($ilUser->getId() == ANONYMOUS_USER_ID ||
280  ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm_obj->getRefId())) &&
281  !ilLMObject::_isPagePublic($a_node_id, true))
282  {
283  return false;
284  }
285  }
286 
287  return true;
288  }
289 
293  function getImage($a_name, $a_type = "", $a_id = "")
294  {
295  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
296 
297  if ($a_type == "pg")
298  {
299  include_once("./Services/COPage/classes/class.ilPageObject.php");
300  $lm_set = new ilSetting("lm");
301  $active = ilPageObject::_lookupActive($a_id, $this->lm_obj->getType(),
302  $lm_set->get("time_scheduled_page_activation"));
303 
304  // is page scheduled?
305  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
306  ilPageObject::_isScheduledActivation($a_id, $this->lm_obj->getType()))
307  ? "_sc"
308  : "";
309 
310  $a_name = "icon_pg".$img_sc."_s.png";
311 
312  if (!$active)
313  {
314  $a_name = "icon_pg_d".$img_sc."_s.png";
315  }
316  else
317  {
318  include_once("./Services/COPage/classes/class.ilPageObject.php");
320  $this->lm_obj->getType());
321  if ($contains_dis)
322  {
323  $a_name = "icon_pg_del".$img_sc."_s.png";
324  }
325  }
326  }
327  return ilUtil::getImagePath($a_name, false, "output", $this->offlineMode());
328  }
329 
333  function forceExpanded($a_obj_id)
334  {
335  if ($this->offlineMode())
336  {
337  return true;
338  }
339  else
340  {
341  return true;
342  }
343  }
344 
345  function isVisible($a_id, $a_type)
346  {
347  include_once("./Services/COPage/classes/class.ilPageObject.php");
348  $active = ilPageObject::_lookupActive($a_id, $this->lm_obj->getType(),
349  $this->lm_set->get("time_scheduled_page_activation"));
350 
351  if(!$active && $a_type == "pg")
352  {
353  $act_data = ilPageObject::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
354  if ($act_data["show_activation_info"] &&
355  (ilUtil::now() < $act_data["activation_start"]))
356  {
357  return true;
358  }
359  else
360  {
361  return false;
362  }
363  }
364  else
365  {
366  return true;
367  }
368  }
369 
370 } // END class ilTableOfContentsExplorer
371 ?>