ILIAS  release_4-4 Revision
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 
27  function __construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang = "-")
28  {
29  $this->lm_pres = $a_lm_pres;
30  $this->lm = $this->lm_pres->lm;
31  parent::__construct($a_parent_obj, $a_parent_cmd, $this->lm);
32  $this->lm_set = new ilSetting("lm");
33  $this->lang = $a_lang;
34  if ($this->lm->getTOCMode() != "pages")
35  {
36  $this->setTypeWhiteList(array("st", "du"));
37  }
38 
39  }
40 
46  function setHighlightNode($a_val)
47  {
48  $this->highlight_node = $a_val;
49  }
50 
56  function getHighlightNode()
57  {
58  return $this->highlight_node;
59  }
60 
67  function isNodeHighlighted($a_node)
68  {
69  if ($a_node["child"] == $this->getHighlightNode())
70  {
71  return true;
72  }
73  return false;
74  }
75 
82  function getNodeContent($a_node)
83  {
84  if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
85  {
86  return $this->lm->getTitle();
87  }
88 
89  if ($a_node["type"] == "st")
90  {
91  return ilStructureObject::_getPresentationTitle($a_node["child"],
92  $this->lm->isActiveNumbering(), false, $this->lm->getId(), $this->lang);
93  }
94 
95  if ($a_node["type"] == "pg")
96  {
97  return ilLMPageObject::_getPresentationTitle($a_node["child"],
98  $this->lm->getPageHeader(), $this->lm->isActiveNumbering(),
99  $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm->getId(), $this->lang);
100  }
101 
102  return $a_node["title"];
103  }
104 
105 
112  function getNodeIcon($a_node)
113  {
114  // overwrite chapter icons with lp info?
115  if(!$this->getOfflineMode() && $a_node["type"] == "st")
116  {
117  $icon = $this->checkLPIcon($a_node["child"]);
118  if ($icon != "")
119  {
120  return $icon;
121  }
122  }
123 
124  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
125 
126  if ($a_node["type"] == "du")
127  {
128  $a_node["type"] = "lm";
129  }
130  $a_name = "icon_".$a_node["type"]."_s.png";
131  if ($a_node["type"] == "pg")
132  {
133  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
134  $lm_set = new ilSetting("lm");
135  $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
136  $lm_set->get("time_scheduled_page_activation"));
137 
138  // is page scheduled?
139  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
140  ilLMPage::_isScheduledActivation($a_node["child"], $this->lm->getType()) && !$active
141  && !$this->getOfflineMode())
142  ? "_sc"
143  : "";
144 
145  $a_name = "icon_pg".$img_sc."_s.png";
146 
147  if (!$active && !$this->getOfflineMode())
148  {
149  $a_name = "icon_pg_d".$img_sc."_s.png";
150  }
151  }
152 
153  return ilUtil::getImagePath($a_name, false, "output", $this->getOfflineMode());
154  }
155 
162  function isNodeClickable($a_node)
163  {
164  global $ilUser;
165 
166  $orig_node_id = $a_node["child"];
167 
168  if ($a_node["type"] == "st")
169  {
170  if (!$this->getOfflineMode())
171  {
172  if ($this->lm->getTOCMode() != "pages")
173  {
174  $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
175  }
176  else
177  {
178  // faster, but needs pages to be in explorer
179  $a_node = $this->getSuccessorNode($a_node["child"], "pg");
180  }
181  if ($a_node["child"] == 0)
182  {
183  return false;
184  }
185  }
186  else
187  {
188  // get next activated page
189  $found = false;
190  while (!$found)
191  {
192  if ($this->lm->getTOCMode() != "pages")
193  {
194  $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
195  }
196  else
197  {
198  $a_node = $this->getSuccessorNode($a_node["child"], "pg");
199  }
200  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
201  $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
202  $this->lm_set->get("time_scheduled_page_activation"));
203 
204  if ($a_node["child"] > 0 && !$active)
205  {
206  $found = false;
207  }
208  else
209  {
210  $found = true;
211  }
212  }
213  if ($a_node["child"] <= 0)
214  {
215  return false;
216  }
217  else
218  {
219  $path = $this->getTree()->getPathId($a_node["child"]);
220  if (!in_array($orig_node_id, $path))
221  {
222  return false;
223  }
224  }
225  }
226  }
227 
228  if ($a_node["type"] == "pg")
229  {
230  // check public area mode
231  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
232  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
233  if (($ilUser->getId() == ANONYMOUS_USER_ID ||
234  ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm->getRefId())) &&
235  !ilLMObject::_isPagePublic($a_node["child"], true))
236  {
237  return false;
238  }
239  }
240 
241  return true;
242 
243  }
244 
245 
252  function getNodeIconAlt($a_node)
253  {
254  }
255 
262  function getNodeHref($a_node)
263  {
264  if (!$this->getOfflineMode())
265  {
266  return $this->lm_pres->getLink($this->lm->getRefId(), "", $a_node["child"]);
267  //return parent::buildLinkTarget($a_node_id, $a_type);
268  }
269  else
270  {
271  if ($a_node["type"] != "pg")
272  {
273  // get next activated page
274  $found = false;
275  while (!$found)
276  {
277  $a_node = $this->getTree()->fetchSuccessorNode($a_node["child"], "pg");
278  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
279  $active = ilLMPage::_lookupActive($a_node["child"], $this->lm->getType(),
280  $this->lm_set->get("time_scheduled_page_activation"));
281 
282  if ($a_node["child"] > 0 && !$active)
283  {
284  $found = false;
285  }
286  else
287  {
288  $found = true;
289  }
290  }
291  }
292  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
293  if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_node["child"]))
294  {
295  return "lm_pg_".$nid.".html";
296  }
297  return "lm_pg_".$a_node["child"].".html";
298  }
299 
300  }
301 
308  function isNodeVisible($a_node)
309  {
310  include_once("./Services/COPage/classes/class.ilPageObject.php");
311 
312  if ($a_node["type"] != "pg")
313  {
314  return true;
315  }
316 
317  $active = ilPageObject::_lookupActive($a_node["child"], "lm",
318  $this->lm_set->get("time_scheduled_page_activation"));
319 
320  if(!$active)
321  {
322  $act_data = ilPageObject::_lookupActivationData((int) $a_node["child"], "lm");
323  if ($act_data["show_activation_info"] &&
324  (ilUtil::now() < $act_data["activation_start"]))
325  {
326  return true;
327  }
328  else
329  {
330  return false;
331  }
332  }
333  else
334  {
335  return true;
336  }
337  }
338 
339 }
340 
341 ?>
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 editor explorer GUI class.
static _getPresentationTitle($a_st_id, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_lm_id=0, $a_lang="-")
get presentation title
isNodeVisible($a_node)
Is node visible?
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
static now()
Return current timestamp in Y-m-d H:i:s format.
getHighlightNode()
Get highlighted node.
_lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
setTypeWhiteList($a_val)
Set type white list.
setHighlightNode($a_val)
Set highlighted node.
__construct($a_parent_obj, $a_parent_cmd, ilLMPresentationGUI $a_lm_pres, $a_lang="-")
Constructor.
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.
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
getNodeId($a_node)
Get id for node.
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.
getRootNode()
Get root node.
global $ilUser
Definition: imgupload.php:15
getNodeIcon($a_node)
Get node icon.
$lm_set
$path
Definition: index.php:22
getNodeIconAlt($a_node)
Get node icon alt text.
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 _isPagePublic($a_node_id, $a_check_public_mode=false)
getNodeContent($a_node)
Get node content.