ILIAS  eassessment Revision 61809
 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: class.ilLMTableOfContentsExplorer.php 25692 2010-09-15 09:44:16Z mwarkus $
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 = ilLMObject::_lookupNID($this->lm_obj->getId(), $a_node_id, "pg"))
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)
294  {
295  return ilUtil::getImagePath($a_name, false, "output", $this->offlineMode());
296  }
297 
301  function forceExpanded($a_obj_id)
302  {
303  if ($this->offlineMode())
304  {
305  return true;
306  }
307  else
308  {
309  return true;
310  }
311  }
312 
313  function isVisible($a_id, $a_type)
314  {
315  include_once("./Services/COPage/classes/class.ilPageObject.php");
316  $active = ilPageObject::_lookupActive($a_id, $this->lm_obj->getType(),
317  $this->lm_set->get("time_scheduled_page_activation"));
318 
319  if(!$active && $a_type == "pg")
320  {
321  return false;
322  }
323  else
324  {
325  return true;
326  }
327  }
328 
329 } // END class ilTableOfContentsExplorer
330 ?>