ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
134  $ilCtrl = $DIC['ilCtrl'];
135 
136  $wtpl = new ilTemplate("tpl....html",
137  true, true, "Modules/Scorm2004");
138 
139  $wtpl->setVariable("PAGE", parent::preview());
140  return $wtpl->get();
141  }*/
142 
146  public function getQuestionHtmlOfPage()
147  {
148  $q_ids = $this->getPageObject()->getQuestionIds();
149 
150  $html = array();
151  if (count($q_ids) > 0) {
152  foreach ($q_ids as $q_id) {
153  include_once("./Modules/TestQuestionPool/classes/class.assQuestionGUI.php");
154  $q_gui = assQuestionGUI::_getQuestionGUI("", $q_id);
155  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
156  $q_gui->outAdditionalOutput();
157  $html[$q_id] = $q_gui->getPreview(true);
158  }
159  }
160 
161  return $html;
162  }
163 
164 
171  public function initSelfAssessmentRendering()
172  {
173  if ($this->scorm_mode == "preview") {
174  // parent::initSelfAssessmentRendering(); // todo: not called anymore
175  }
176  }
177 
184  public function selfAssessmentRendering($a_output)
185  {
186  if ($this->scorm_mode == "preview") {
187  $a_output = parent::selfAssessmentRendering($a_output);
188  }
189 
190  return $a_output;
191  }
192 
196  public function showPage($a_mode = "preview")
197  {
198  $tpl = $this->tpl;
200 
201  $this->scorm_mode = $a_mode;
202 
203  $this->setTemplateOutput(false);
204 
205  $output = parent::showPage();
206 
207  return $output;
208  }
209 
213  public function setDefaultLinkXml()
214  {
215  $int_links = $this->getPageObject()->getInternalLinks(true);
216  $this->glossary_links = $int_links;
217  //var_dump($int_links);
218 
219  // key is il__git_18:GlossaryItem:Glossary::4 => id is il__git_18_4,
220 
221  $link_info = "<IntLinkInfos>";
222  $targetframe = "None";
223  $ltarget = "";
224  foreach ($int_links as $int_link) {
225  $onclick = "";
226  $target = $int_link["Target"];
227  $targetframe = "None";
228  if (substr($target, 0, 4) == "il__") {
229  $target_arr = explode("_", $target);
230  $target_id = $target_arr[count($target_arr) - 1];
231  $type = $int_link["Type"];
232 
233  switch ($type) {
234  case "GlossaryItem":
235  $ltarget = "";
236  //$href = "./goto.php?target=git_".$target_id;
237  $href = "#";
238  $onclick = 'OnClick="return false;"';
239  $anc_par = 'Anchor=""';
240  $targetframe = "Glossary";
241  break;
242 
243  case "File":
244  $ltarget = "";
245  if ($this->getOutputMode() == "offline") {
246  if (ilObject::_lookupType($target_id) == "file") {
247  include_once("./Modules/File/classes/class.ilObjFile.php");
248  $href = "./files/file_" . $target_id . "/" . ilObjFile::_lookupFileName($target_id);
249  $ltarget = "_blank";
250  }
251  } else {
252  $href = str_replace("&", "&amp;", $this->determineFileDownloadLink()) . "&amp;file_id=il__file_" . $target_id;
253  //echo htmlentities($href);
254  }
255 
256  $anc_par = 'Anchor=""';
257  $targetframe = "None"; //???
258  break;
259 
260  }
261  $link_info .= "<IntLinkInfo $onclick Target=\"$target\" Type=\"$type\" " . $anc_par . " " .
262  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
263  }
264  }
265  $link_info .= "</IntLinkInfos>";
266  $this->setLinkXML($link_info);
267  //var_dump($link_info);
268  }
269 
274  public function postOutputProcessing($a_output)
275  {
276  //var_dump($this->glossary_links);
277  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
278 
279  if ($this->scorm_mode != "export") {
280  $tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
281  } else {
282  $tpl = self::$export_glo_tpl;
283  }
284  $glossary = false;
285 
286  $overlays = array();
287 
288  // overlay for sco glossary
289  if ($this->getGlossaryOverviewId() != "" && $this->getOutputMode() != "edit") {
290  $ovov = $overlays[$this->getGlossaryOverviewId()] = new ilOverlayGUI($this->getGlossaryOverviewId());
291  // $ovov->setFixedCenter(true);
292  $ovov->setAutoHide(false);
293  $ovov->setCloseElementId("glo_ov_close");
294  if ($this->getGlossaryOverviewId() != "") {
295  if ($this->scorm_mode != "export" ||
296  $this->getOutputMode() == IL_PAGE_PREVIEW) {
297  $overlays[$this->getGlossaryOverviewId()]->add();
298  } else {
299  $tpl->setCurrentBlock("add_script");
300  $tpl->setVariable("ADD_SCRIPT", "il.Util.addOnLoad(function () {" . $overlays[$this->getGlossaryOverviewId()]->getOnLoadCode() . "});");
301  $tpl->parseCurrentBlock();
302  }
303  }
304  }
305 
306  if ($this->getOutputMode() != "edit") {
307  if (is_array($this->glossary_links)) {
308  foreach ($this->glossary_links as $k => $e) {
309  // glossary link
310  if ($e["Type"] == "GlossaryItem") {
311  $karr = explode(":", $k);
312  $link_id = $karr[0] . "_" . $this->getPageObject()->getId() . "_" . $karr[4];
313  //$ov_id = "ov".$karr[0]."_".$karr[4];
314  $ov_id = "ov" . $karr[0];
315  $cl_id = "ov" . $karr[0] . "cl";
316  $glov_id = "ov" . $karr[0] . "ov";
317  $term_id_arr = explode("_", $karr[0]);
318  $term_id = $term_id_arr[count($term_id_arr) - 1];
319 
320  // get overlay html from glossary term
321  include_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
322  $id_arr = explode("_", $karr[0]);
323  $term_gui = new ilGlossaryTermGUI($id_arr[count($id_arr) - 1]);
324  $html = $term_gui->getOverlayHTML(
325  $cl_id,
326  ($this->getGlossaryOverviewId() != "")
327  ? $glov_id
328  : "",
330  );
331  $tpl->setCurrentBlock("entry");
332  $tpl->setVariable("CONTENT", $html);
333  $tpl->setVariable("OVERLAY_ID", $ov_id);
334 
335  $glossary = true;
336 
337  // first time the term is used
338  if (!isset($overlays[$ov_id])) {
339  $overlays[$ov_id] = new ilOverlayGUI($ov_id);
340  $overlays[$ov_id]->setAnchor($link_id);
341  $overlays[$ov_id]->setTrigger($link_id, "click", $link_id);
342  $overlays[$ov_id]->setAutoHide(false);
343  $overlays[$ov_id]->setCloseElementId($cl_id);
344  if ($this->scorm_mode != "export" ||
345  $this->getOutputMode() == IL_PAGE_PREVIEW) {
346  $overlays[$ov_id]->add();
347  } else {
348  $tpl->setVariable("SCRIPT", "il.Util.addOnLoad(function () {" . $overlays[$ov_id]->getOnLoadCode() . "});");
349  }
350  } else {
351  if ($this->scorm_mode != "export" ||
352  $this->getOutputMode() == IL_PAGE_PREVIEW) {
353  $overlays[$ov_id]->addTrigger($link_id, "click", $link_id);
354  } else {
355  $tpl->setVariable(
356  "SCRIPT",
357  "il.Util.addOnLoad(function () {" . $overlays[$ov_id]->getTriggerOnLoadCode($link_id, "click", $link_id) . "});"
358  );
359  }
360  }
361 
362  if ($this->getGlossaryOverviewId() != "") {
363  if ($this->scorm_mode != "export" ||
364  $this->getOutputMode() == IL_PAGE_PREVIEW) {
365  //$overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", null);
366  $overlays[$this->getGlossaryOverviewId()]->addTrigger($glov_id, "click", $ov_id, false, "tl", "tl");
367  //$overlays[$ov_id]->addTrigger("glo_ov_t".$term_id, "click", null, true);
368  $overlays[$ov_id]->addTrigger("glo_ov_t" . $term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl");
369  } else {
370  $tpl->setVariable(
371  "SCRIPT2",
372  "il.Util.addOnLoad(function () {" .
373  $overlays[$this->getGlossaryOverviewId()]->getTriggerOnLoadCode($glov_id, "click", $ov_id, false, "tl", "tl") . "});"
374  );
375  $tpl->setVariable(
376  "SCRIPT3",
377  "il.Util.addOnLoad(function () {" .
378  $overlays[$ov_id]->getTriggerOnLoadCode("glo_ov_t" . $term_id, "click", $this->getGlossaryOverviewId(), false, "tl", "tl") . "});"
379  );
380  }
381  }
382 
383  $tpl->parseCurrentBlock();
384  }
385  }
386  }
387 
388  if ($glossary && $this->scorm_mode != "export") {
389  $ret = $a_output . $tpl->get();
390  if ($this->getGlossaryOverviewId() != "") {
392  }
393  return $ret;
394  }
395  }
396 
397  return $a_output;
398  }
399 
403  public static function initExport()
404  {
405  self::$export_glo_tpl = new ilTemplate("tpl.glossary_entries.html", true, true, "Modules/Scorm2004");
406  }
407 
411  public static function getGlossaryHTML($a_sco)
412  {
413  $ret = self::$export_glo_tpl->get();
414 
416 
417  return $ret;
418  }
419 }
$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
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.
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.
$target
Definition: test.php:19
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.