ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilLMTOCExplorerGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Modules/LearningModule/classes/class.ilLMExplorerGUI.php");
5
15{
16 protected $lang;
17 protected $highlight_node;
18 protected $tracker;
19
28 function __construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang = "-",
29 $a_focus_id = 0)
30 {
31 $this->lm_pres = $a_lm_pres;
32 $this->lm = $this->lm_pres->lm;
33 $exp_id = (!$this->getOfflineMode() && $this->lm->getProgressIcons())
34 ? "ilLMProgressTree"
35 : "";
36 parent::__construct($a_parent_obj, $a_parent_cmd, $this->lm, $exp_id);
37 $this->lm_set = new ilSetting("lm");
38 $this->lang = $a_lang;
39 if ($a_focus_id > 0)
40 {
41 $this->setSecondaryHighlightedNodes(array($a_focus_id));
42 }
43 if ($this->lm->getTOCMode() != "pages")
44 {
45 $this->setTypeWhiteList(array("st", "du"));
46 }
47 $this->focus_id = $a_focus_id;
48 }
49
53 function getRootNode()
54 {
55 $root_id = $this->getTree()->readRootId();
56 if ($this->focus_id > 0 && $this->getTree()->isInTree($this->focus_id) &&
57 ilLMObject::_lookupType($this->focus_id) == "st")
58 {
59// $root_id = $this->focus_id;
60 }
61 return $this->getTree()->getNodeData($root_id);
62 }
63
69 function setTracker($a_val)
70 {
71 $this->tracker = $a_val;
72 }
73
79 function getTracker()
80 {
81 return $this->tracker;
82 }
83
89 function setHighlightNode($a_val)
90 {
91 $this->highlight_node = $a_val;
92 }
93
100 {
102 }
103
110 function isNodeHighlighted($a_node)
111 {
112 if ($a_node["child"] == $this->getHighlightNode())
113 {
114 return true;
115 }
116 return false;
117 }
118
125 function getNodeContent($a_node)
126 {
127 if ($a_node["type"] == "st")
128 {
129 return ilStructureObject::_getPresentationTitle($a_node["child"],
130 $this->lm->isActiveNumbering(), false, $this->lm->getId(), $this->lang);
131 }
132 else if ($a_node["type"] == "pg")
133 {
134 return ilLMPageObject::_getPresentationTitle($a_node["child"],
135 $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
136 $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm->getId(), $this->lang);
137 }
138 else if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
139 {
140 return $this->lm->getTitle();
141 }
142
143 if ($a_node["type"] == "pg")
144 {
145 return ilLMPageObject::_getPresentationTitle($a_node["child"],
146 $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
147 $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm->getId(), $this->lang);
148 }
149
150 return $a_node["title"];
151 }
152
153
160 function getNodeIcon($a_node)
161 {
162 // overwrite chapter icons with lp info?
163 if(!$this->getOfflineMode() && $a_node["type"] == "st")
164 {
165 $icon = $this->checkLPIcon($a_node["child"]);
166 if ($icon != "")
167 {
168 return $icon;
169 }
170 }
171
172 // use progress icons (does not depend on lp mode)
173 if(!$this->getOfflineMode() && $this->lm->getProgressIcons())
174 {
175 return $this->tracker->getIconForLMObject($a_node, $this->highlight_node);
176 }
177
178 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
179
180 if ($a_node["type"] == "du")
181 {
182 $a_node["type"] = "lm";
183 }
184 $a_name = "icon_".$a_node["type"].".svg";
185 if ($a_node["type"] == "pg")
186 {
187 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
188 $lm_set = new ilSetting("lm");
189 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
190 $lm_set->get("time_scheduled_page_activation"));
191
192 // is page scheduled?
193 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
194 ilLMPage::_isScheduledActivation($a_node["child"], $this->lm->getType()) && !$active
195 && !$this->getOfflineMode())
196 ? "_sc"
197 : "";
198
199 $a_name = "icon_pg".$img_sc.".svg";
200
201 if (!$active && !$this->getOfflineMode())
202 {
203 $a_name = "icon_pg_d".$img_sc.".svg";
204 }
205 }
206
207 return ilUtil::getImagePath($a_name, false, "output", $this->getOfflineMode());
208 }
209
216 function isNodeClickable($a_node)
217 {
218 global $ilUser;
219
220 $orig_node_id = $a_node["child"];
221
222 // if navigation is restricted based on correct answered questions
223 // check if we have preceeding pages including unsanswered/incorrect answered questions
224 if (!$this->getOfflineMode())
225 {
226 if ($this->lm->getRestrictForwardNavigation())
227 {
228 if ($this->getTracker()->hasPredIncorrectAnswers($orig_node_id))
229 {
230 return false;
231 }
232 }
233 }
234
235 if ($a_node["type"] == "st")
236 {
237 if (!$this->getOfflineMode())
238 {
239 if ($this->lm->getTOCMode() != "pages")
240 {
241 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
242 }
243 else
244 {
245 // faster, but needs pages to be in explorer
246 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
247 }
248 if ($a_node["child"] == 0)
249 {
250 return false;
251 }
252 }
253 else
254 {
255 // get next activated page
256 $found = false;
257 while (!$found)
258 {
259 if ($this->lm->getTOCMode() != "pages")
260 {
261 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
262 }
263 else
264 {
265 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
266 }
267 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
268 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
269 $this->lm_set->get("time_scheduled_page_activation"));
270
271 if ($a_node["child"] > 0 && !$active)
272 {
273 $found = false;
274 }
275 else
276 {
277 $found = true;
278 }
279 }
280 if ($a_node["child"] <= 0)
281 {
282 return false;
283 }
284 else
285 {
286 $path = $this->getTree()->getPathId($a_node["child"]);
287 if (!in_array($orig_node_id, $path))
288 {
289 return false;
290 }
291 }
292 }
293 }
294
295 if ($a_node["type"] == "pg")
296 {
297 // check public area mode
298 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
299 include_once 'Services/Payment/classes/class.ilPaymentObject.php';
300 if (($ilUser->getId() == ANONYMOUS_USER_ID ||
301 ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm->getRefId())) &&
302 !ilLMObject::_isPagePublic($a_node["child"], true))
303 {
304 return false;
305 }
306 }
307
308 return true;
309
310 }
311
312
319 function getNodeIconAlt($a_node)
320 {
321 }
322
329 function getNodeHref($a_node)
330 {
331 if (!$this->getOfflineMode())
332 {
333 return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
334 //return parent::buildLinkTarget($a_node_id, $a_type);
335 }
336 else
337 {
338 if ($a_node["type"] != "pg")
339 {
340 // get next activated page
341 $found = false;
342 while (!$found)
343 {
344 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
345 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
346 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
347 $this->lm_set->get("time_scheduled_page_activation"));
348
349 if ($a_node["child"] > 0 && !$active)
350 {
351 $found = false;
352 }
353 else
354 {
355 $found = true;
356 }
357 }
358 }
359 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
360 if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"]))
361 {
362 return "lm_pg_".$nid.".html";
363 }
364 return "lm_pg_".$a_node["child"].".html";
365 }
366
367 }
368
375 function isNodeVisible($a_node)
376 {
377 include_once("./Modules/LearningModule/classes/class.ilLMTracker.php");
378 return ilLMTracker::_isNodeVisible($a_node);
379 }
380}
381
382?>
setSecondaryHighlightedNodes($a_val)
Set secondary (background) highlighted nodes.
getOfflineMode()
Get offline mode.
LM editor explorer GUI class.
checkLPIcon($a_id)
Check learning progress icon.
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
static _isPagePublic($a_node_id, $a_check_public_mode=false)
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't have to be page title, it may be chapter title + page title or chapter tit...
Class ilLMPresentationGUI.
LM presentation (left frame) explorer GUI class.
setHighlightNode($a_val)
Set highlighted node.
isNodeClickable($a_node)
Is node clickable.
getNodeHref($a_node)
Get href for node.
isNodeVisible($a_node)
Is node visible?
isNodeHighlighted($a_node)
Is node highlighted?
getNodeIcon($a_node)
Get node icon.
getNodeContent($a_node)
Get node content.
getNodeIconAlt($a_node)
Get node icon alt text.
__construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang="-", $a_focus_id=0)
Constructor.
getHighlightNode()
Get highlighted node.
setTracker($a_val)
Set tracker.
static _isNodeVisible($a_node)
Is node visible for the learner.
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static _isScheduledActivation($a_id, $a_parent_type, $a_lang="-")
Check whether page is activated by time schedule.
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
ILIAS Setting Class.
static _getPresentationTitle($a_st_id, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_lm_id=0, $a_lang="-")
get presentation title
setTypeWhiteList($a_val)
Set type white list.
getNodeId($a_node)
Get id for node.
getSuccessorNode($a_node_id, $a_type="")
Get successor node (currently only(!) based on lft/rgt tree values)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$path
Definition: index.php:22
$lm_set
global $ilUser
Definition: imgupload.php:15