ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLMTOCExplorer.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Modules/LearningModule/classes/class.ilLMExplorer.php");
5 require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
6 
7 /*
8 * Explorer View for Learning Module Editor
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @version $Id$
12 *
13 * @ingroup ModulesIliasLearningModule
14 */
16 {
17  var $offline;
18 
25  function ilLMTOCExplorer($a_target, $a_lm_obj, $a_lang = "-")
26  {
27  $this->offline = false;
28  $this->force_open_path = array();
29  parent::ilLMExplorer($a_target, $a_lm_obj, $a_lang);
30  $this->lm_set = new ilSetting("lm");
31  }
32 
36  function setOfflineMode($a_offline = true)
37  {
38  $this->offline = $a_offline;
39  }
40 
44  function offlineMode()
45  {
46  return $this->offline;
47  }
48 
49 
53  function setForceOpenPath($a_path)
54  {
55  $this->force_open_path = $a_path;
56  }
57 
61  function buildTitle($a_title, $a_id, $a_type)
62  {
63  if ($a_type == "st")
64  {
66  $this->lm_obj->isActiveNumbering(), false, $this->lm_obj->getId(), $this->lang);
67  }
68 
69  if ($this->lm_obj->getTOCMode() == "chapters" || $a_type != "pg")
70  {
71  return $a_title;
72  }
73  else
74  {
75  if ($a_type == "pg")
76  {
78  $this->lm_obj->getPageHeader(), $this->lm_obj->isActiveNumbering(),
79  $this->lm_set->get("time_scheduled_page_activation"), true, $this->lm_obj->getId(), $this->lang);
80  }
81  }
82  }
83 
84 
88  function getImage($a_name, $a_type = "", $a_id = "")
89  {
90  // overwrite chapter icons with lp info?
91  if(!$this->offlineMode() && $a_type == "st")
92  {
93  $icon = $this->checkLPIcon($a_id);
94  if($icon)
95  {
96  return $icon;
97  }
98  }
99 
100  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
101 
102  if ($a_type == "pg")
103  {
104  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
105  $lm_set = new ilSetting("lm");
106  $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(),
107  $lm_set->get("time_scheduled_page_activation"));
108 
109  // is page scheduled?
110  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
111  ilLMPage::_isScheduledActivation($a_id, $this->lm_obj->getType()))
112  ? "_sc"
113  : "";
114 
115  $a_name = "icon_pg".$img_sc."_s.png";
116 
117  if (!$active)
118  {
119  $a_name = "icon_pg_d".$img_sc."_s.png";
120  }
121  else
122  {
123  $contains_dis = ilLMPage::_lookupContainsDeactivatedElements($a_id,
124  $this->lm_obj->getType());
125  if ($contains_dis)
126  {
127  $a_name = "icon_pg_del".$img_sc."_s.png";
128  }
129  }
130  }
131  return ilUtil::getImagePath($a_name, false, "output", $this->offlineMode());
132  }
133 
134 
135  function isClickable($a_type, $a_node_id)
136  {
137  global $ilUser;
138 
139  $orig_node_id = $a_node_id;
140 
141  if ($a_type == "st")
142  {
143  if (!$this->offlineMode())
144  {
145  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
146  $a_node_id = $a_node["child"];
147  if ($a_node_id == 0)
148  {
149  return false;
150  }
151  }
152  else
153  {
154  // get next activated page
155  $found = false;
156  while (!$found)
157  {
158  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
159  $a_node_id = $a_node["child"];
160  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
161  $active = ilLMPage::_lookupActive($a_node_id, $this->lm_obj->getType(),
162  $this->lm_set->get("time_scheduled_page_activation"));
163 
164  if ($a_node_id > 0 && !$active)
165  {
166  $found = false;
167  }
168  else
169  {
170  $found = true;
171  }
172  }
173  if ($a_node_id <= 0)
174  {
175  return false;
176  }
177  else
178  {
179  $path = $this->tree->getPathId($a_node_id);
180  if (!in_array($orig_node_id, $path))
181  {
182  return false;
183  }
184  }
185  }
186  }
187 
188  if ($a_type == "pg")
189  {
190  // check public area mode
191  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
192  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
193  if (($ilUser->getId() == ANONYMOUS_USER_ID ||
194  ilPaymentObject::_requiresPurchaseToAccess((int)$this->lm_obj->getRefId())) &&
195  !ilLMObject::_isPagePublic($a_node_id, true))
196  {
197  return false;
198  }
199  }
200 
201  return true;
202  }
203 
207  function buildLinkTarget($a_node_id, $a_type)
208  {
209  if (!$this->offlineMode())
210  {
211  return parent::buildLinkTarget($a_node_id, $a_type);
212  }
213  else
214  {
215  if ($a_node_id < 1)
216  {
217  $a_node_id = $this->tree->getRootId();
218  }
219  if ($a_type != "pg")
220  {
221  // get next activated page
222  $found = false;
223  while (!$found)
224  {
225  $a_node = $this->tree->fetchSuccessorNode($a_node_id, "pg");
226  $a_node_id = $a_node["child"];
227  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
228  $active = ilLMPage::_lookupActive($a_node_id, $this->lm_obj->getType(),
229  $this->lm_set->get("time_scheduled_page_activation"));
230 
231  if ($a_node_id > 0 && !$active)
232  {
233  $found = false;
234  }
235  else
236  {
237  $found = true;
238  }
239  }
240  }
241  if (!$this->lm_obj->cleanFrames())
242  {
243  return "frame_".$a_node_id."_maincontent.html";
244  }
245  else
246  {
247  return "lm_pg_".$a_node_id.".html";
248  }
249  }
250  }
251 
255  function forceExpanded($a_obj_id)
256  {
257  if ($this->offlineMode())
258  {
259  return true;
260  }
261  else
262  {
263  if (in_array($a_obj_id, $this->force_open_path))
264  {
265  return true;
266  }
267  return false;
268  }
269  }
270 
271  function isVisible($a_id, $a_type)
272  {
273  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
274  $active = ilLMPage::_lookupActive($a_id, $this->lm_obj->getType(),
275  $this->lm_set->get("time_scheduled_page_activation"));
276 
277  if(!$active && $a_type == "pg")
278  {
279  $act_data = ilLMPage::_lookupActivationData((int) $a_id, $this->lm_obj->getType());
280  if ($act_data["show_activation_info"] &&
281  (ilUtil::now() < $act_data["activation_start"]))
282  {
283  return true;
284  }
285  else
286  {
287  return false;
288  }
289  }
290  else
291  {
292  return true;
293  }
294  }
295 
296 } // END class.ilLMTOCExplorer
297 ?>
ilLMTOCExplorer($a_target, $a_lm_obj, $a_lang="-")
Constructor public.
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
static _requiresPurchaseToAccess($a_ref_id, $a_purchasetype='')
this function should be used by all buyable repository objects !!
isVisible($a_id, $a_type)
static now()
Return current timestamp in Y-m-d H:i:s format.
setOfflineMode($a_offline=true)
set offline mode
_lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
isClickable($a_type, $a_node_id)
buildTitle($a_title, $a_id, $a_type)
standard implementation for title, maybe overwritten by derived classes
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)
setForceOpenPath($a_path)
set force open path
static _lookupContainsDeactivatedElements($a_id, $a_parent_type, $a_lang="-")
lookup whether page contains deactivated elements
static _isScheduledActivation($a_id, $a_parent_type, $a_lang="-")
Check whether page is activated by time schedule.
getImage($a_name, $a_type="", $a_id="")
get image path (may be overwritten by derived classes)
buildLinkTarget($a_node_id, $a_type)
build link target
global $ilUser
Definition: imgupload.php:15
$lm_set
offlineMode()
get offline mode
$path
Definition: index.php:22
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...
forceExpanded($a_obj_id)
force expansion of node
static _isPagePublic($a_node_id, $a_check_public_mode=false)