ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSCORM2004PageGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
6 include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
7 require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
8 
22 {
23  protected $glossary_links = array();
24  protected $scorm_mode = "preview";
26 
30  function __construct($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_slm_id = 0,
31  $a_glo_id = 0)
32  {
33  global $tpl, $ilCtrl;
34 
35  $this->glo_id = $a_glo_id;
36 
37  parent::__construct($a_parent_type, $a_id, $a_old_nr);
38 
39 
40  $this->setEnabledMaps(false);
41  $this->setEnablePCType("QuestionOverview", true);
42 
43  $this->setPreventHTMLUnmasking(false);
44  // $this->setEnabledInternalLinks(false);
45  //if ($this->glo_id > 0)
46  //{
47  $this->setEnabledInternalLinks(true);
48  //}
49  $this->setEnabledSelfAssessment(true);
50  $this->setEnabledPCTabs(true);
51 
52  $this->getPageConfig()->addIntLinkFilter(array("StructureObject",
53  "StructureObject_New", "PageObject", "PageObject_FAQ", "PageObject_New",
54  "GlossaryItem_New",
55  "Media", "Media_FAQ", "Media_Media", "Media_New",
56  "RepositoryItem"));
57  if ($a_glo_id <= 0)
58  {
59  $this->getPageConfig()->addIntLinkFilter(array("GlossaryItem"));
60  }
61  $this->setIntLinkHelpDefault("File", 0);
62  $this->setIntLinkReturn(
63  $ilCtrl->getLinkTargetByClass("ilobjscorm2004learningmodulegui", "showTree",
64  "", false, false));
65  $this->slm_id = $a_slm_id;
66  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
67  $this->getPageConfig()->setLocalizationLanguage(
69  $this->enableNotes(true, $this->slm_id);
70  }
71 
72  function initPageObject($a_parent_type, $a_id, $a_old_nr)
73  {
74  $page = new ilSCORM2004Page($a_id, $a_old_nr);
75  $page->setGlossaryId($this->glo_id);
76  $this->setPageObject($page);
77  }
78 
84  function setGlossaryOverviewInfo($a_ov_id, $a_sco)
85  {
86  $this->glossary_ov_id = $a_ov_id;
87  $this->sco = $a_sco;
88  }
89 
96  {
97  return $this->glossary_ov_id;
98  }
99 
103  function &executeCommand()
104  {
105  global $ilCtrl;
106 
107  $next_class = $this->ctrl->getNextClass($this);
108  $cmd = $this->ctrl->getCmd();
109 
110  switch($next_class)
111  {
112  case 'ilmdeditorgui':
113  return parent::executeCommand();
114  break;
115 
116  case "ilpageobjectgui":
117  $page_gui = new ilPageObjectGUI("sahs",
118  $this->getPageObject()->getId(), $this->getPageObject()->old_nr);
119  $page_gui->setEnabledPCTabs(true);
120  $html = $ilCtrl->forwardCommand($page_gui);
121  return $html;
122 
123  default:
124  $html = parent::executeCommand();
125  return $html;
126  }
127  }
128 
134  function setSCORM2004Page($a_scpage)
135  {
136  $this->setPageObject($a_scpage);
137  }
138 
144  function getSCORM2004Page()
145  {
146  return $this->getPageObject();
147  }
148 
149  /*function preview()
150  {
151  global $ilCtrl;
152 
153  $wtpl = new ilTemplate("tpl....html",
154  true, true, "Modules/Scorm2004");
155 
156  $wtpl->setVariable("PAGE", parent::preview());
157  return $wtpl->get();
158  }*/
159 
164  {
165  $q_ids = $this->getPageObject()->getQuestionIds();
166 
167  $html = array();
168  if (count($q_ids) > 0)
169  {
170  foreach ($q_ids as $q_id)
171  {
172  include_once("./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
173  $q_gui =& assQuestionGUI::_getQuestionGUI("", $q_id);
174  $q_gui->outAdditionalOutput();
175  $html[$q_id] = $q_gui->getPreview(TRUE);
176  }
177  }
178 
179  return $html;
180  }
181 
182 
183  // moved to parent
184  //function getQuestionJsOfPage($a_no_interaction = false)
185 
193  {
194  if ($this->scorm_mode == "preview")
195  {
197  }
198  }
199 
206  function selfAssessmentRendering($a_output)
207  {
208  if ($this->scorm_mode == "preview")
209  {
210  $a_output = parent::selfAssessmentRendering($a_output);
211  }
212 
213  return $a_output;
214  }
215 
219  function showPage($a_mode = "preview")
220  {
221  global $tpl, $ilCtrl;
222 
223  $this->scorm_mode = $a_mode;
224 
225  $this->setTemplateOutput(false);
226 
227  $output = parent::showPage();
228 
229  return $output;
230  }
231 
235  function setDefaultLinkXml()
236  {
237  $int_links = $this->getPageObject()->getInternalLinks(true);
238  $this->glossary_links = $int_links;
239 //var_dump($int_links);
240 
241 // key is il__git_18:GlossaryItem:Glossary::4 => id is il__git_18_4,
242 
243  $link_info = "<IntLinkInfos>";
244  $targetframe = "None";
245  $ltarget = "";
246  foreach ($int_links as $int_link)
247  {
248  $onclick = "";
249  $target = $int_link["Target"];
250  $targetframe = "None";
251  if (substr($target, 0, 4) == "il__")
252  {
253  $target_arr = explode("_", $target);
254  $target_id = $target_arr[count($target_arr) - 1];
255  $type = $int_link["Type"];
256 
257  switch($type)
258  {
259  case "GlossaryItem":
260  $ltarget = "";
261  //$href = "./goto.php?target=git_".$target_id;
262  $href = "#";
263  $onclick = 'OnClick="return false;"';
264  $anc_par = 'Anchor=""';
265  $targetframe = "Glossary";
266  break;
267 
268  case "File":
269  $ltarget = "";
270  if ($this->getOutputMode() == "offline")
271  {
272  if (ilObject::_lookupType($target_id) == "file")
273  {
274  include_once("./Modules/File/classes/class.ilObjFile.php");
275  $href = "./files/file_".$target_id."/".ilObjFile::_lookupFileName($target_id);
276  $ltarget = "_blank";
277  }
278  }
279  else
280  {
281  $href = str_replace("&", "&amp;", $this->determineFileDownloadLink())."&amp;file_id=il__file_".$target_id;
282 //echo htmlentities($href);
283  }
284 
285  $anc_par = 'Anchor=""';
286  $targetframe = "None"; //???
287  break;
288 
289  }
290  $link_info.="<IntLinkInfo $onclick Target=\"$target\" Type=\"$type\" ".$anc_par." ".
291  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
292  }
293  }
294  $link_info.= "</IntLinkInfos>";
295  $this->setLinkXML($link_info);
296 //var_dump($link_info);
297  }
298 
303  function postOutputProcessing($a_output)
304  {
305 //var_dump($this->glossary_links);
306  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
307 
308  if ($this->scorm_mode != "export")
309  {
310  $tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
311  }
312  else
313  {
315  }
316  $glossary = false;
317 
318  $overlays = array();
319 
320  // overlay for sco glossary
321  if ($this->getGlossaryOverviewId() != "" && $this->getOutputMode() != "edit")
322  {
323  $ovov = $overlays[$this->getGlossaryOverviewId()] = new ilOverlayGUI($this->getGlossaryOverviewId());
324 // $ovov->setFixedCenter(true);
325  $ovov->setAutoHide(false);
326  $ovov->setCloseElementId("glo_ov_close");
327  if ($this->getGlossaryOverviewId() != "")
328  {
329  if ($this->scorm_mode != "export" ||
330  $this->getOutputMode() == IL_PAGE_PREVIEW)
331  {
332  $overlays[$this->getGlossaryOverviewId()]->add();
333  }
334  else
335  {
336  $tpl->setCurrentBlock("add_script");
337  $tpl->setVariable("ADD_SCRIPT", "il.Util.addOnLoad(function () {".$overlays[$this->getGlossaryOverviewId()]->getOnLoadCode()."});");
338  $tpl->parseCurrentBlock();
339  }
340  }
341  }
342 
343  if ($this->getOutputMode() != "edit")
344  {
345  if (is_array($this->glossary_links))
346  {
347  foreach ($this->glossary_links as $k => $e)
348  {
349  // glossary link
350  if ($e["Type"] == "GlossaryItem")
351  {
352  $karr = explode(":", $k);
353  $link_id = $karr[0]."_".$this->getPageObject()->getId()."_".$karr[4];
354  //$ov_id = "ov".$karr[0]."_".$karr[4];
355  $ov_id = "ov".$karr[0];
356  $cl_id = "ov".$karr[0]."cl";
357  $glov_id = "ov".$karr[0]."ov";
358  $term_id_arr = explode("_", $karr[0]);
359  $term_id = $term_id_arr[count($term_id_arr) - 1];
360 
361  // get overlay html from glossary term
362  include_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
363  $id_arr = explode("_", $karr[0]);
364  $term_gui =& new ilGlossaryTermGUI($id_arr[count($id_arr) - 1]);
365  $html = $term_gui->getOverlayHTML($cl_id, ($this->getGlossaryOverviewId() != "")
366  ? $glov_id
367  : "",
369  $tpl->setCurrentBlock("entry");
370  $tpl->setVariable("CONTENT", $html);
371  $tpl->setVariable("OVERLAY_ID", $ov_id);
372 
373  $glossary = true;
374 
375  // first time the term is used
376  if (!isset($overlays[$ov_id]))
377  {
378  $overlays[$ov_id] = new ilOverlayGUI($ov_id);
379  $overlays[$ov_id]->setAnchor($link_id);
380  $overlays[$ov_id]->setTrigger($link_id, "click", $link_id);
381  $overlays[$ov_id]->setAutoHide(false);
382  $overlays[$ov_id]->setCloseElementId($cl_id);
383  if ($this->scorm_mode != "export" ||
384  $this->getOutputMode() == IL_PAGE_PREVIEW)
385  {
386  $overlays[$ov_id]->add();
387  }
388  else
389  {
390  $tpl->setVariable("SCRIPT", "il.Util.addOnLoad(function () {".$overlays[$ov_id]->getOnLoadCode()."});");
391  }
392  }
393  else
394  {
395  if ($this->scorm_mode != "export" ||
396  $this->getOutputMode() == IL_PAGE_PREVIEW)
397  {
398  $overlays[$ov_id]->addTrigger($link_id, "click", $link_id);
399  }
400  else
401  {
402  $tpl->setVariable("SCRIPT",
403  "il.Util.addOnLoad(function () {".$overlays[$ov_id]->getTriggerOnLoadCode($link_id, "click", $link_id)."});");
404  }
405  }
406 
407  if ($this->getGlossaryOverviewId() != "")
408  {
409  if ($this->scorm_mode != "export" ||
410  $this->getOutputMode() == IL_PAGE_PREVIEW)
411  {
412  //$overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", null);
413  $overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", $ov_id, false, "tl", "tl");
414  //$overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", null, true);
415  $overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl");
416  }
417  else
418  {
419  $tpl->setVariable("SCRIPT2",
420  "il.Util.addOnLoad(function () {".
421  $overlays[$this->getGlossaryOverviewId()]->getTriggerOnLoadCode($glov_id, "click", $ov_id, false, "tl", "tl")."});");
422  $tpl->setVariable("SCRIPT3",
423  "il.Util.addOnLoad(function () {".
424  $overlays[$ov_id]->getTriggerOnLoadCode("glo_ov_t".$term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl")."});");
425  }
426  }
427 
428  $tpl->parseCurrentBlock();
429  }
430  }
431  }
432 
433  if ($glossary && $this->scorm_mode != "export")
434  {
435  $ret = $a_output.$tpl->get();
436  if ($this->getGlossaryOverviewId() != "")
437  {
439  }
440  return $ret;
441  }
442  }
443 
444  return $a_output;
445  }
446 
450  static function initExport()
451  {
452  self::$export_glo_tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
453  }
454 
458  static function getGlossaryHTML($a_sco)
459  {
460  $ret = self::$export_glo_tpl->get();
461 
463 
464  return $ret;
465  }
466 
467 }
468 ?>