ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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;
20
29 function __construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang = "-",
30 $a_focus_id = 0, $export_all_languages = false)
31 {
32 $this->lm_pres = $a_lm_pres;
33 $this->lm = $this->lm_pres->lm;
34 $exp_id = (!$this->getOfflineMode() && $this->lm->getProgressIcons())
35 ? "ilLMProgressTree"
36 : "";
37 parent::__construct($a_parent_obj, $a_parent_cmd, $this->lm, $exp_id);
38 $this->lm_set = new ilSetting("lm");
39 $this->lang = $a_lang;
40 if ($a_focus_id > 0)
41 {
42 $this->setSecondaryHighlightedNodes(array($a_focus_id));
43 }
44 if ($this->lm->getTOCMode() != "pages")
45 {
46 $this->setTypeWhiteList(array("st", "du"));
47 }
48 $this->focus_id = $a_focus_id;
49 $this->export_all_languages = $export_all_languages;
50 }
51
55 function getRootNode()
56 {
57 $root_id = $this->getTree()->readRootId();
58 if ($this->focus_id > 0 && $this->getTree()->isInTree($this->focus_id) &&
59 ilLMObject::_lookupType($this->focus_id) == "st")
60 {
61// $root_id = $this->focus_id;
62 }
63 return $this->getTree()->getNodeData($root_id);
64 }
65
71 function setTracker($a_val)
72 {
73 $this->tracker = $a_val;
74 }
75
81 function getTracker()
82 {
83 return $this->tracker;
84 }
85
91 function setHighlightNode($a_val)
92 {
93 $this->highlight_node = $a_val;
94 }
95
102 {
104 }
105
112 function isNodeHighlighted($a_node)
113 {
114 if ($a_node["child"] == $this->getHighlightNode())
115 {
116 return true;
117 }
118 return false;
119 }
120
127 function getNodeContent($a_node)
128 {
129 if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
130 {
131 return $this->lm_pres->getLMPresentationTitle();
132 }
133
134 if ($a_node["type"] == "st")
135 {
136 return ilStructureObject::_getPresentationTitle($a_node["child"],
137 $this->lm->isActiveNumbering(), false, $this->lm->getId(), $this->lang);
138 }
139 else if ($a_node["type"] == "pg")
140 {
141 return ilLMPageObject::_getPresentationTitle($a_node["child"],
142 $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
143 $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm->getId(), $this->lang);
144 }
145 else if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
146 {
147 return $this->lm->getTitle();
148 }
149
150 if ($a_node["type"] == "pg")
151 {
152 return ilLMPageObject::_getPresentationTitle($a_node["child"],
153 $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
154 $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm->getId(), $this->lang);
155 }
156
157 return $a_node["title"];
158 }
159
160
167 function getNodeIcon($a_node)
168 {
169 // overwrite chapter icons with lp info?
170 if(!$this->getOfflineMode() && $a_node["type"] == "st")
171 {
172 $icon = $this->checkLPIcon($a_node["child"]);
173 if ($icon != "")
174 {
175 return $icon;
176 }
177 }
178
179 // use progress icons (does not depend on lp mode)
180 if(!$this->getOfflineMode() && $this->lm->getProgressIcons())
181 {
182 return $this->tracker->getIconForLMObject($a_node, $this->highlight_node);
183 }
184
185 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
186
187 if ($a_node["type"] == "du")
188 {
189 $a_node["type"] = "lm";
190 }
191 $a_name = "icon_".$a_node["type"].".svg";
192 if ($a_node["type"] == "pg")
193 {
194 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
195 $lm_set = new ilSetting("lm");
196 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
197 $lm_set->get("time_scheduled_page_activation"));
198
199 // is page scheduled?
200 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
201 ilLMPage::_isScheduledActivation($a_node["child"], $this->lm->getType()) && !$active
202 && !$this->getOfflineMode())
203 ? "_sc"
204 : "";
205
206 $a_name = "icon_pg".$img_sc.".svg";
207
208 if (!$active && !$this->getOfflineMode())
209 {
210 $a_name = "icon_pg_d".$img_sc.".svg";
211 }
212 }
213
214 return ilUtil::getImagePath($a_name, false, "output", $this->getOfflineMode());
215 }
216
223 function isNodeClickable($a_node)
224 {
225 global $ilUser;
226
227 $orig_node_id = $a_node["child"];
228
229 // if navigation is restricted based on correct answered questions
230 // check if we have preceeding pages including unsanswered/incorrect answered questions
231 if (!$this->getOfflineMode())
232 {
233 if ($this->lm->getRestrictForwardNavigation())
234 {
235 if ($this->getTracker()->hasPredIncorrectAnswers($orig_node_id))
236 {
237 return false;
238 }
239 }
240 }
241
242 if ($a_node["type"] == "st")
243 {
244 if (!$this->getOfflineMode())
245 {
246 if ($this->lm->getTOCMode() != "pages")
247 {
248 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
249 }
250 else
251 {
252 // faster, but needs pages to be in explorer
253 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
254 }
255 if ($a_node["child"] == 0)
256 {
257 return false;
258 }
259 }
260 else
261 {
262 // get next activated page
263 $found = false;
264 while (!$found)
265 {
266 if ($this->lm->getTOCMode() != "pages")
267 {
268 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
269 }
270 else
271 {
272 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
273 }
274 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
275 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
276 $this->lm_set->get("time_scheduled_page_activation"));
277
278 if ($a_node["child"] > 0 && !$active)
279 {
280 $found = false;
281 }
282 else
283 {
284 $found = true;
285 }
286 }
287 if ($a_node["child"] <= 0)
288 {
289 return false;
290 }
291 else
292 {
293 $path = $this->getTree()->getPathId($a_node["child"]);
294 if (!in_array($orig_node_id, $path))
295 {
296 return false;
297 }
298 }
299 }
300 }
301
302 if ($a_node["type"] == "pg")
303 {
304 // check public area mode
305 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
306 include_once 'Services/Payment/classes/class.ilPaymentObject.php';
307 if (($ilUser->getId() == ANONYMOUS_USER_ID ||
308 ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm->getRefId())) &&
309 !ilLMObject::_isPagePublic($a_node["child"], true))
310 {
311 return false;
312 }
313 }
314
315 return true;
316
317 }
318
319
326 function getNodeIconAlt($a_node)
327 {
328 }
329
336 function getNodeHref($a_node)
337 {
338 if (!$this->getOfflineMode())
339 {
340 return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
341 //return parent::buildLinkTarget($a_node_id, $a_type);
342 }
343 else
344 {
345 if ($a_node["type"] != "pg")
346 {
347 // get next activated page
348 $found = false;
349 while (!$found)
350 {
351 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
352 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
353 $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
354 $this->lm_set->get("time_scheduled_page_activation"));
355
356 if ($a_node["child"] > 0 && !$active)
357 {
358 $found = false;
359 }
360 else
361 {
362 $found = true;
363 }
364 }
365 }
366
367 $lang_suffix = "";
368 if ($this->export_all_languages)
369 {
370 if ($this->lang != "" && $this->lang != "-")
371 {
372 $lang_suffix = "_".$this->lang;
373 }
374 }
375
376 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
377 if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"]))
378 {
379 return "lm_pg_".$nid.$lang_suffix.".html";
380 }
381 return "lm_pg_".$a_node["child"].$lang_suffix.".html";
382 }
383
384 }
385
392 function isNodeVisible($a_node)
393 {
394 include_once("./Modules/LearningModule/classes/class.ilLMTracker.php");
395 return ilLMTracker::_isNodeVisible($a_node);
396 }
397}
398
399?>
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.
__construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang="-", $a_focus_id=0, $export_all_languages=false)
Constructor.
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.
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