ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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";
25  public static $export_glo_tpl;
26 
30  public function __construct(
31  $a_parent_type,
32  $a_id = 0,
33  $a_old_nr = 0,
34  $a_slm_id = 0,
35  $a_glo_id = 0
36  ) {
37  global $DIC;
38 
39  $this->tpl = $DIC["tpl"];
40  $this->ctrl = $DIC->ctrl();
41  $ilCtrl = $DIC->ctrl();
42 
43  $this->glo_id = $a_glo_id;
44  $this->slm_id = $a_slm_id;
45 
46  $a_parent_type = "sahs";
47 
48  parent::__construct($a_parent_type, $a_id, $a_old_nr);
49  $this->getPageObject()->setGlossaryId($this->glo_id);
50 
51  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
52  $this->enableNotes(true, $this->slm_id);
53  }
54 
60  public function setGlossaryOverviewInfo($a_ov_id, $a_sco)
61  {
62  $this->glossary_ov_id = $a_ov_id;
63  $this->sco = $a_sco;
64  }
65 
71  public function getGlossaryOverviewId()
72  {
73  return $this->glossary_ov_id;
74  }
75 
79  public function executeCommand()
80  {
82 
83  $this->setIntLinkReturn(
84  $ilCtrl->getLinkTargetByClass(
85  "ilobjscorm2004learningmodulegui",
86  "showTree",
87  "",
88  false,
89  false
90  )
91  );
92 
93  $next_class = $this->ctrl->getNextClass($this);
94  $cmd = $this->ctrl->getCmd();
95 
96  switch ($next_class) {
97  case 'ilmdeditorgui':
98  return parent::executeCommand();
99  break;
100 
101  case "ilpageobjectgui":
102 die("ilSCORM2004PageGUI forwarding to ilpageobjectgui error.");
103  return;
104 
105  default:
106  $html = parent::executeCommand();
107  return $html;
108  }
109  }
110 
116  public function setSCORM2004Page($a_scpage)
117  {
118  $this->setPageObject($a_scpage);
119  }
120 
126  public function getSCORM2004Page()
127  {
128  return $this->getPageObject();
129  }
130 
131  /*function preview()
132  {
133  global $ilCtrl;
134 
135  $wtpl = new ilTemplate("tpl....html",
136  true, true, "Modules/Scorm2004");
137 
138  $wtpl->setVariable("PAGE", parent::preview());
139  return $wtpl->get();
140  }*/
141 
145  public function getQuestionHtmlOfPage()
146  {
147  $q_ids = $this->getPageObject()->getQuestionIds();
148 
149  $html = array();
150  if (count($q_ids) > 0) {
151  foreach ($q_ids as $q_id) {
152  include_once("./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
153  $q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
154  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
155  $q_gui->outAdditionalOutput();
156  $html[$q_id] = $q_gui->getPreview(true);
157  }
158  }
159 
160  return $html;
161  }
162 
163 
170  public function initSelfAssessmentRendering()
171  {
172  if ($this->scorm_mode == "preview") {
173  // parent::initSelfAssessmentRendering(); // todo: not called anymore
174  }
175  }
176 
183  public function selfAssessmentRendering($a_output)
184  {
185  if ($this->scorm_mode == "preview") {
186  $a_output = parent::selfAssessmentRendering($a_output);
187  }
188 
189  return $a_output;
190  }
191 
195  public function showPage($a_mode = "preview")
196  {
197  $tpl = $this->tpl;
199 
200  $this->scorm_mode = $a_mode;
201 
202  $this->setTemplateOutput(false);
203 
204  $output = parent::showPage();
205 
206  return $output;
207  }
208 
212  public function setDefaultLinkXml()
213  {
214  $int_links = $this->getPageObject()->getInternalLinks(true);
215  $this->glossary_links = $int_links;
216  //var_dump($int_links);
217 
218  // key is il__git_18:GlossaryItem:Glossary::4 => id is il__git_18_4,
219 
220  $link_info = "<IntLinkInfos>";
221  $targetframe = "None";
222  $ltarget = "";
223  foreach ($int_links as $int_link) {
224  $onclick = "";
225  $target = $int_link["Target"];
226  $targetframe = "None";
227  if (substr($target, 0, 4) == "il__") {
228  $target_arr = explode("_", $target);
229  $target_id = $target_arr[count($target_arr) - 1];
230  $type = $int_link["Type"];
231 
232  switch ($type) {
233  case "GlossaryItem":
234  $ltarget = "";
235  //$href = "./goto.php?target=git_".$target_id;
236  $href = "#";
237  $onclick = 'OnClick="return false;"';
238  $anc_par = 'Anchor=""';
239  $targetframe = "Glossary";
240  break;
241 
242  case "File":
243  $ltarget = "";
244  if ($this->getOutputMode() == "offline") {
245  if (ilObject::_lookupType($target_id) == "file") {
246  include_once("./Modules/File/classes/class.ilObjFile.php");
247  $href = "./files/file_" . $target_id . "/" . ilObjFile::_lookupFileName($target_id);
248  $ltarget = "_blank";
249  }
250  } else {
251  $href = str_replace("&", "&amp;", $this->determineFileDownloadLink()) . "&amp;file_id=il__file_" . $target_id;
252  //echo htmlentities($href);
253  }
254 
255  $anc_par = 'Anchor=""';
256  $targetframe = "None"; //???
257  break;
258 
259  }
260  $link_info.="<IntLinkInfo $onclick Target=\"$target\" Type=\"$type\" " . $anc_par . " " .
261  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
262  }
263  }
264  $link_info.= "</IntLinkInfos>";
265  $this->setLinkXML($link_info);
266  //var_dump($link_info);
267  }
268 
273  public function postOutputProcessing($a_output)
274  {
275  //var_dump($this->glossary_links);
276  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
277 
278  if ($this->scorm_mode != "export") {
279  $tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
280  } else {
281  $tpl = self::$export_glo_tpl;
282  }
283  $glossary = false;
284 
285  $overlays = array();
286 
287  // overlay for sco glossary
288  if ($this->getGlossaryOverviewId() != "" && $this->getOutputMode() != "edit") {
289  $ovov = $overlays[$this->getGlossaryOverviewId()] = new ilOverlayGUI($this->getGlossaryOverviewId());
290  // $ovov->setFixedCenter(true);
291  $ovov->setAutoHide(false);
292  $ovov->setCloseElementId("glo_ov_close");
293  if ($this->getGlossaryOverviewId() != "") {
294  if ($this->scorm_mode != "export" ||
295  $this->getOutputMode() == IL_PAGE_PREVIEW) {
296  $overlays[$this->getGlossaryOverviewId()]->add();
297  } else {
298  $tpl->setCurrentBlock("add_script");
299  $tpl->setVariable("ADD_SCRIPT", "il.Util.addOnLoad(function () {" . $overlays[$this->getGlossaryOverviewId()]->getOnLoadCode() . "});");
300  $tpl->parseCurrentBlock();
301  }
302  }
303  }
304 
305  if ($this->getOutputMode() != "edit") {
306  if (is_array($this->glossary_links)) {
307  foreach ($this->glossary_links as $k => $e) {
308  // glossary link
309  if ($e["Type"] == "GlossaryItem") {
310  $karr = explode(":", $k);
311  $link_id = $karr[0] . "_" . $this->getPageObject()->getId() . "_" . $karr[4];
312  //$ov_id = "ov".$karr[0]."_".$karr[4];
313  $ov_id = "ov" . $karr[0];
314  $cl_id = "ov" . $karr[0] . "cl";
315  $glov_id = "ov" . $karr[0] . "ov";
316  $term_id_arr = explode("_", $karr[0]);
317  $term_id = $term_id_arr[count($term_id_arr) - 1];
318 
319  // get overlay html from glossary term
320  include_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
321  $id_arr = explode("_", $karr[0]);
322  $term_gui = new ilGlossaryTermGUI($id_arr[count($id_arr) - 1]);
323  $html = $term_gui->getOverlayHTML(
324  $cl_id,
325  ($this->getGlossaryOverviewId() != "")
326  ? $glov_id
327  : "",
329  );
330  $tpl->setCurrentBlock("entry");
331  $tpl->setVariable("CONTENT", $html);
332  $tpl->setVariable("OVERLAY_ID", $ov_id);
333 
334  $glossary = true;
335 
336  // first time the term is used
337  if (!isset($overlays[$ov_id])) {
338  $overlays[$ov_id] = new ilOverlayGUI($ov_id);
339  $overlays[$ov_id]->setAnchor($link_id);
340  $overlays[$ov_id]->setTrigger($link_id, "click", $link_id);
341  $overlays[$ov_id]->setAutoHide(false);
342  $overlays[$ov_id]->setCloseElementId($cl_id);
343  if ($this->scorm_mode != "export" ||
344  $this->getOutputMode() == IL_PAGE_PREVIEW) {
345  $overlays[$ov_id]->add();
346  } else {
347  $tpl->setVariable("SCRIPT", "il.Util.addOnLoad(function () {" . $overlays[$ov_id]->getOnLoadCode() . "});");
348  }
349  } else {
350  if ($this->scorm_mode != "export" ||
351  $this->getOutputMode() == IL_PAGE_PREVIEW) {
352  $overlays[$ov_id]->addTrigger($link_id, "click", $link_id);
353  } else {
354  $tpl->setVariable(
355  "SCRIPT",
356  "il.Util.addOnLoad(function () {" . $overlays[$ov_id]->getTriggerOnLoadCode($link_id, "click", $link_id) . "});"
357  );
358  }
359  }
360 
361  if ($this->getGlossaryOverviewId() != "") {
362  if ($this->scorm_mode != "export" ||
363  $this->getOutputMode() == IL_PAGE_PREVIEW) {
364  //$overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", null);
365  $overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", $ov_id, false, "tl", "tl");
366  //$overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", null, true);
367  $overlays[$ov_id]->addTrigger("glo_ov_t" . $term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl");
368  } else {
369  $tpl->setVariable(
370  "SCRIPT2",
371  "il.Util.addOnLoad(function () {" .
372  $overlays[$this->getGlossaryOverviewId()]->getTriggerOnLoadCode($glov_id, "click", $ov_id, false, "tl", "tl") . "});"
373  );
374  $tpl->setVariable(
375  "SCRIPT3",
376  "il.Util.addOnLoad(function () {" .
377  $overlays[$ov_id]->getTriggerOnLoadCode("glo_ov_t" . $term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl") . "});"
378  );
379  }
380  }
381 
382  $tpl->parseCurrentBlock();
383  }
384  }
385  }
386 
387  if ($glossary && $this->scorm_mode != "export") {
388  $ret = $a_output . $tpl->get();
389  if ($this->getGlossaryOverviewId() != "") {
391  }
392  return $ret;
393  }
394  }
395 
396  return $a_output;
397  }
398 
402  public static function initExport()
403  {
404  self::$export_glo_tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
405  }
406 
410  public static function getGlossaryHTML($a_sco)
411  {
412  $ret = self::$export_glo_tpl->get();
413 
415 
416  return $ret;
417  }
418 }
$target_arr
Definition: goto.php:47
const IL_PAGE_PREVIEW
enableNotes($a_enabled, $a_parent_id)
getPageObject()
Get Page Object.
setTemplateOutput($a_output=true)
$type
global $DIC
Definition: saml.php:7
showPage($a_mode="preview")
Show the page.
setDefaultLinkXml()
Set standard link xml (currently only glossaries)
setGlossaryOverviewInfo($a_ov_id, $a_sco)
Set glossary overview id.
Class ilPageObjectGUI.
initSelfAssessmentRendering()
Init question handling.
static getGloOverviewOv($a_sco)
des
$target_id
Definition: goto.php:49
global $ilCtrl
Definition: ilias.php:18
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
static _lookupFileName($a_id)
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
getQuestionHtmlOfPage()
Get question html for page.
determineFileDownloadLink()
Determine file download link.
setPageObject(ilPageObject $a_pg_obj)
Set Page Object.
special template class to simplify handling of ITX/PEAR
This is a utility class for the yui overlays.
GUI class for glossary terms.
getSCORM2004Page()
Get SCORM2004 Page Object.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
selfAssessmentRendering($a_output)
Self assessment question rendering.
executeCommand()
execute command
setSCORM2004Page($a_scpage)
Set SCORM2004 Page Object.
Class ilSCORM2004Page GUI class.
$ret
Definition: parser.php:6
static getGlossaryHTML($a_sco)
Get glossary html (only in export mode)
static getAffectiveLocalization($a_id)
Get affective localization.
postOutputProcessing($a_output)
Post output processing:
__construct( $a_parent_type, $a_id=0, $a_old_nr=0, $a_slm_id=0, $a_glo_id=0)
Constructor.
$html
Definition: example_001.php:87
getGlossaryOverviewId()
Get glossary overview id.
static initExport()
Init export.