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