ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_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 
101  function getHighlightNode()
102  {
103  return $this->highlight_node;
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  {
137  $this->lm->isActiveNumbering(), false, 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  if($ilUser->getId() == ANONYMOUS_USER_ID && !ilLMObject::_isPagePublic($a_node["child"], true))
307  {
308  return false;
309  }
310  }
311 
312  return true;
313 
314  }
315 
316 
323  function getNodeIconAlt($a_node)
324  {
325  }
326 
333  function getNodeHref($a_node)
334  {
335  if (!$this->getOfflineMode())
336  {
337  return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
338  //return parent::buildLinkTarget($a_node_id, $a_type);
339  }
340  else
341  {
342  if ($a_node["type"] != "pg")
343  {
344  // get next activated page
345  $found = false;
346  while (!$found)
347  {
348  $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
349  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
350  $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
351  $this->lm_set->get("time_scheduled_page_activation"));
352 
353  if ($a_node["child"] > 0 && !$active)
354  {
355  $found = false;
356  }
357  else
358  {
359  $found = true;
360  }
361  }
362  }
363 
364  $lang_suffix = "";
365  if ($this->export_all_languages)
366  {
367  if ($this->lang != "" && $this->lang != "-")
368  {
369  $lang_suffix = "_".$this->lang;
370  }
371  }
372 
373  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
374  if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"]))
375  {
376  return "lm_pg_".$nid.$lang_suffix.".html";
377  }
378  return "lm_pg_".$a_node["child"].$lang_suffix.".html";
379  }
380 
381  }
382 
389  function isNodeVisible($a_node)
390  {
391  include_once("./Modules/LearningModule/classes/class.ilLMTracker.php");
392  return ilLMTracker::_isNodeVisible($a_node);
393  }
394 }
395 
396 ?>
getSuccessorNode($a_node_id, $a_type="")
Get successor node (currently only(!) based on lft/rgt tree values)
isNodeHighlighted($a_node)
Is node highlighted?
ILIAS Setting Class.
LM presentation (left frame) explorer GUI class.
$path
Definition: aliased.php:25
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
__construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang="-", $a_focus_id=0, $export_all_languages=false)
Constructor.
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="-")
get presentation title
isNodeVisible($a_node)
Is node visible?
setTracker($a_val)
Set tracker.
getHighlightNode()
Get highlighted node.
setSecondaryHighlightedNodes($a_val)
Set secondary (background) highlighted nodes.
setTypeWhiteList($a_val)
Set type white list.
setHighlightNode($a_val)
Set highlighted node.
Class ilLMPresentationGUI.
checkLPIcon($a_id)
Check learning progress icon.
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getNodeHref($a_node)
Get href for node.
LM editor explorer GUI class.
$ilUser
Definition: imgupload.php:18
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
getNodeId($a_node)
Get id for node.
Create styles array
The data for the language used.
getOfflineMode()
Get offline mode.
static _isScheduledActivation($a_id, $a_parent_type, $a_lang="-")
Check whether page is activated by time schedule.
isNodeClickable($a_node)
Is node clickable.
getNodeIcon($a_node)
Get node icon.
$lm_set
getNodeIconAlt($a_node)
Get node icon alt text.
const IL_CHAPTER_TITLE
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...
static _isNodeVisible($a_node)
Is node visible for the learner.
static _isPagePublic($a_node_id, $a_check_public_mode=false)
getNodeContent($a_node)
Get node content.