ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules 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 = "", $a_lang = "-")
54  {
55  parent::ilLMExplorer($a_target, $a_lm_obj, $a_lang);
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(), false, $this->lm_obj->getId(), $this->lang).$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"), true, $this->lm_obj->getId(), $this->lang).$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("./Modules/LearningModule/classes/class.ilLMPage.php");
198  $active = ilLMPage::_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("./Modules/LearningModule/classes/class.ilLMPage.php");
248  $active = ilLMPage::_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  // overwrite chapter icons with lp info?
296  if(!$this->offlineMode() && $a_type == "st")
297  {
298  $icon = $this->checkLPIcon($a_id);
299  if($icon)
300  {
301  return $icon;
302  }
303  }
304 
305  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
306 
307  if ($a_type == "pg")
308  {
309  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
310  $lm_set = new ilSetting("lm");
311  $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(),
312  $lm_set->get("time_scheduled_page_activation"));
313 
314  // is page scheduled?
315  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
316  ilLMPage::_isScheduledActivation($a_id, $this->lm_obj->getType()))
317  ? "_sc"
318  : "";
319 
320  $a_name = "icon_pg".$img_sc."_s.png";
321 
322  if (!$active)
323  {
324  $a_name = "icon_pg_d".$img_sc."_s.png";
325  }
326  else
327  {
328  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
329  $contains_dis = ilLMPage::_lookupContainsDeactivatedElements($a_id,
330  $this->lm_obj->getType());
331  if ($contains_dis)
332  {
333  $a_name = "icon_pg_del".$img_sc."_s.png";
334  }
335  }
336  }
337  return ilUtil::getImagePath($a_name, false, "output", $this->offlineMode());
338  }
339 
343  function forceExpanded($a_obj_id)
344  {
345  if ($this->offlineMode())
346  {
347  return true;
348  }
349  else
350  {
351  return true;
352  }
353  }
354 
355  function isVisible($a_id, $a_type)
356  {
357  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
358  $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(),
359  $this->lm_set->get("time_scheduled_page_activation"));
360 
361  if(!$active && $a_type == "pg")
362  {
363  $act_data = ilLMPage::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
364  if ($act_data["show_activation_info"] &&
365  (ilUtil::now() < $act_data["activation_start"]))
366  {
367  return true;
368  }
369  else
370  {
371  return false;
372  }
373  }
374  else
375  {
376  return true;
377  }
378  }
379 
380 } // END class ilTableOfContentsExplorer
381 ?>
ILIAS Setting Class.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
get target frame
_checkPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
checks wether the preconditions of a page are fulfilled or not
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
static _getPresentationTitle($a_st_id, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_lm_id=0, $a_lang="-")
get presentation title
$_GET["client_id"]
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
const IL_FM_POSITIVE
buildLinkTarget($a_node_id, $a_type)
build link target
static now()
Return current timestamp in Y-m-d H:i:s format.
_lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
setFiltered($a_bool)
active/deactivate the filter public
getImage($a_name, $a_type="", $a_id="")
get image path (may be overwritten by derived classes)
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
forceExpanded($a_obj_id)
force expansion of node
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
buildTitle($a_title, $a_id, $a_type)
standard implementation for title, maybe overwritten by derived classes
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
setFrameTarget($a_target)
set target frame or not frame?
static _lookupContainsDeactivatedElements($a_id, $a_parent_type, $a_lang="-")
lookup whether page contains deactivated elements
static _isScheduledActivation($a_id, $a_parent_type, $a_lang="-")
Check whether page is activated by time schedule.
global $ilUser
Definition: imgupload.php:15
setOfflineMode($a_offline=true)
set offline mode
static _getFrame($a_class, $a_type='')
Get content frame name.
$lm_set
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
static _getPresentationTitle($a_pg_id, $a_mode=IL_CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-")
presentation title doesn&#39;t have to be page title, it may be chapter title + page title or chapter tit...
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter public
static _isPagePublic($a_node_id, $a_check_public_mode=false)
ilTableOfContentsExplorer($a_target, &$a_lm_obj, $a_export_format="", $a_lang="-")
Constructor public.