ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 public function __construct(
30 $a_parent_obj,
31 $a_parent_cmd,
32 ilLMPresentationGUI $a_lm_pres,
33 $a_lang = "-",
34 $a_focus_id = 0,
36 ) {
37 global $DIC;
38
39 $this->user = $DIC->user();
40 $this->lm_pres = $a_lm_pres;
41 $this->lm = $this->lm_pres->lm;
42 $exp_id = (!$this->getOfflineMode() && $this->lm->getProgressIcons())
43 ? "ilLMProgressTree"
44 : "";
45 parent::__construct($a_parent_obj, $a_parent_cmd, $this->lm, $exp_id);
46 $this->lm_set = new ilSetting("lm");
47 $this->lang = $a_lang;
48 if ($a_focus_id > 0) {
49 $this->setSecondaryHighlightedNodes(array($a_focus_id));
50 }
51 if ($this->lm->getTOCMode() != "pages") {
52 $this->setTypeWhiteList(array("st", "du"));
53 }
54 $this->focus_id = $a_focus_id;
55 $this->export_all_languages = $export_all_languages;
56 }
57
61 public function getRootNode()
62 {
63 $root_id = $this->getTree()->readRootId();
64 if ($this->focus_id > 0 && $this->getTree()->isInTree($this->focus_id) &&
65 ilLMObject::_lookupType($this->focus_id) == "st") {
66 // $root_id = $this->focus_id;
67 }
68 return $this->getTree()->getNodeData($root_id);
69 }
70
76 public function setTracker($a_val)
77 {
78 $this->tracker = $a_val;
79 }
80
86 public function getTracker()
87 {
88 return $this->tracker;
89 }
90
96 public function setHighlightNode($a_val)
97 {
98 $this->highlight_node = $a_val;
99 }
100
106 public function getHighlightNode()
107 {
109 }
110
117 public function isNodeHighlighted($a_node)
118 {
119 if ($a_node["child"] == $this->getHighlightNode()) {
120 return true;
121 }
122 return false;
123 }
124
131 public function getNodeContent($a_node)
132 {
133 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
134 return $this->lm_pres->getLMPresentationTitle();
135 }
136
137 if ($a_node["type"] == "st") {
139 $a_node["child"],
141 $this->lm->isActiveNumbering(),
142 false,
143 false,
144 $this->lm->getId(),
145 $this->lang,
146 true
147 );
148 } elseif ($a_node["type"] == "pg") {
150 $a_node["child"],
151 $this->lm->getPageHeader(),
152 $this->lm->isActiveNumbering(),
153 $this->lm_set->get("time_scheduled_page_activation"),
154 true,
155 $this->lm->getId(),
156 $this->lang,
157 true
158 );
159 } elseif ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
160 return $this->lm->getTitle();
161 }
162
163 return $a_node["title"];
164 }
165
166
173 public function getNodeIcon($a_node)
174 {
175 // overwrite chapter icons with lp info?
176 if (!$this->getOfflineMode() && $a_node["type"] == "st") {
177 $icon = $this->checkLPIcon($a_node["child"]);
178 if ($icon != "") {
179 return $icon;
180 }
181 }
182
183 // use progress icons (does not depend on lp mode)
184 if (!$this->getOfflineMode() && $this->lm->getProgressIcons()) {
185 return $this->tracker->getIconForLMObject($a_node, $this->highlight_node);
186 }
187
188 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
189
190 if ($a_node["type"] == "du") {
191 $a_node["type"] = "lm";
192 }
193 $a_name = "icon_" . $a_node["type"] . ".svg";
194 if ($a_node["type"] == "pg") {
195 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
196 $lm_set = new ilSetting("lm");
197 $active = ilLMPage::_lookupActive(
198 $a_node["child"],
199 $this->lm->getType(),
200 $lm_set->get("time_scheduled_page_activation")
201 );
202
203 // is page scheduled?
204 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
205 ilLMPage::_isScheduledActivation($a_node["child"], $this->lm->getType()) && !$active
206 && !$this->getOfflineMode())
207 ? "_sc"
208 : "";
209
210 $a_name = "icon_pg" . $img_sc . ".svg";
211
212 if (!$active && !$this->getOfflineMode()) {
213 $a_name = "icon_pg_d" . $img_sc . ".svg";
214 }
215 }
216
217 return ilUtil::getImagePath($a_name, false, "output", $this->getOfflineMode());
218 }
219
226 public function isNodeClickable($a_node)
227 {
229
230 $orig_node_id = $a_node["child"];
231
232 // if navigation is restricted based on correct answered questions
233 // check if we have preceeding pages including unsanswered/incorrect answered questions
234 if (!$this->getOfflineMode()) {
235 if ($this->lm->getRestrictForwardNavigation()) {
236 if ($this->getTracker()->hasPredIncorrectAnswers($orig_node_id)) {
237 return false;
238 }
239 }
240 }
241
242 if ($a_node["type"] == "st") {
243 if (!$this->getOfflineMode()) {
244 if ($this->lm->getTOCMode() != "pages") {
245 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
246 } else {
247 // faster, but needs pages to be in explorer
248 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
249 }
250 if ($a_node["child"] == 0) {
251 return false;
252 }
253 } else {
254 // get next activated page
255 $found = false;
256 while (!$found) {
257 if ($this->lm->getTOCMode() != "pages") {
258 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
259 } else {
260 $a_node = $this->getSuccessorNode($a_node["child"], "pg");
261 }
262 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
263 $active = ilLMPage::_lookupActive(
264 $a_node["child"],
265 $this->lm->getType(),
266 $this->lm_set->get("time_scheduled_page_activation")
267 );
268
269 if ($a_node["child"] > 0 && !$active) {
270 $found = false;
271 } else {
272 $found = true;
273 }
274 }
275 if ($a_node["child"] <= 0) {
276 return false;
277 } else {
278 $path = $this->getTree()->getPathId($a_node["child"]);
279 if (!in_array($orig_node_id, $path)) {
280 return false;
281 }
282 }
283 }
284 }
285
286 if ($a_node["type"] == "pg") {
287 // check public area mode
288 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
289 if ($ilUser->getId() == ANONYMOUS_USER_ID && !ilLMObject::_isPagePublic($a_node["child"], true)) {
290 return false;
291 }
292 }
293
294 return true;
295 }
296
297
304 public function getNodeIconAlt($a_node)
305 {
306 }
307
314 public function getNodeHref($a_node)
315 {
316 if (!$this->getOfflineMode()) {
317 return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
318 //return parent::buildLinkTarget($a_node_id, $a_type);
319 } else {
320 if ($a_node["type"] != "pg") {
321 // get next activated page
322 $found = false;
323 while (!$found) {
324 $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
325 include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
326 $active = ilLMPage::_lookupActive(
327 $a_node["child"],
328 $this->lm->getType(),
329 $this->lm_set->get("time_scheduled_page_activation")
330 );
331
332 if ($a_node["child"] > 0 && !$active) {
333 $found = false;
334 } else {
335 $found = true;
336 }
337 }
338 }
339
340 $lang_suffix = "";
341 if ($this->export_all_languages) {
342 if ($this->lang != "" && $this->lang != "-") {
343 $lang_suffix = "_" . $this->lang;
344 }
345 }
346
347 include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
348 if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"])) {
349 return "lm_pg_" . $nid . $lang_suffix . ".html";
350 }
351 return "lm_pg_" . $a_node["child"] . $lang_suffix . ".html";
352 }
353 }
354
361 public function isNodeVisible($a_node)
362 {
363 include_once("./Modules/LearningModule/classes/class.ilLMTracker.php");
364 return ilLMTracker::_isNodeVisible($a_node);
365 }
366}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
const IL_CHAPTER_TITLE
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="-", $a_include_short=false)
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, $export_all_languages=false)
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.
ILIAS Setting Class.
static _getPresentationTitle( $a_st_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="-", $a_include_short=false)
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)
global $DIC
Definition: saml.php:7
$lm_set
$ilUser
Definition: imgupload.php:18