ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLMPresentationGUI.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.ilObjLearningModule.php");
5 require_once("./Services/MainMenu/classes/class.ilMainMenuGUI.php");
6 require_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
7 require_once 'Modules/LearningModule/classes/class.ilLMPageObject.php';
8 
9 
26 {
30  protected $user;
31 
35  protected $rbacsystem;
36 
40  protected $ctrl;
41 
45  protected $error;
46 
50  protected $nav_history;
51 
55  protected $access;
56 
60  protected $settings;
61 
65  protected $main_menu;
66 
70  protected $locator;
71 
75  protected $tree;
76 
80  protected $help;
81 
82  public $lm;
83  public $tpl;
84  public $lng;
85  public $layout_doc;
86  public $offline;
88  protected $current_page_id = false;
89  protected $focus_id = 0; // focus id is set e.g. from learning objectives course, we focus on a chapter/page
90  protected $export_all_languages = false;
91 
92  public function __construct()
93  {
94  global $DIC;
95 
96  $this->user = $DIC->user();
97  $this->rbacsystem = $DIC->rbac()->system();
98  $this->error = $DIC["ilErr"];
99  $this->nav_history = $DIC["ilNavigationHistory"];
100  $this->access = $DIC->access();
101  $this->settings = $DIC->settings();
102  $this->locator = $DIC["ilLocator"];
103  $this->tree = $DIC->repositoryTree();
104  $this->help = $DIC["ilHelp"];
105  $ilUser = $DIC->user();
106  $lng = $DIC->language();
107  $tpl = $DIC["tpl"];
108  $rbacsystem = $DIC->rbac()->system();
109  $ilCtrl = $DIC->ctrl();
110  $ilErr = $DIC["ilErr"];
111 
112  // load language vars
113  $lng->loadLanguageModule("content");
114 
115  $this->lng = $lng;
116  $this->tpl = $tpl;
117  $this->offline = false;
118  $this->frames = array();
119  $this->ctrl = $ilCtrl;
120  $this->ctrl->saveParameter($this, array("ref_id", "transl", "focus_id", "focus_return"));
121  $this->lm_set = new ilSetting("lm");
122 
123  include_once("./Modules/LearningModule/classes/class.ilObjLearningModuleGUI.php");
124  $this->lm_gui = new ilObjLearningModuleGUI($data, $_GET["ref_id"], true, false);
125  $this->lm = $this->lm_gui->object;
126 
127  // language translation
128  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
129  $this->ot = ilObjectTranslation::getInstance($this->lm->getId());
130  //include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
131  //$this->ml = new ilPageMultiLang("lm", $this->lm->getId());
132  $this->lang = "-";
133  if ($this->ot->getContentActivated()) {
134  $langs = $this->ot->getLanguages();
135  if (isset($langs[$_GET["transl"]]) || $_GET["transl"] == $this->ot->getMasterLanguage()) {
136  $this->lang = $_GET["transl"];
137  } elseif (isset($langs[$ilUser->getCurrentLanguage()])) {
138  $this->lang = $ilUser->getCurrentLanguage();
139  }
140  if ($this->lang == $this->ot->getMasterLanguage()) {
141  $this->lang = "-";
142  }
143  }
144 
145  // check, if learning module is online
146  if (!$rbacsystem->checkAccess("write", $_GET["ref_id"])) {
147  if ($this->lm->getOfflineStatus()) {
148  $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->WARNING);
149  }
150  }
151 
152  include_once("./Modules/LearningModule/classes/class.ilLMTree.php");
153  $this->lm_tree = ilLMTree::getInstance($this->lm->getId());
154 
155  /*$this->lm_tree = new ilTree($this->lm->getId());
156  $this->lm_tree->setTableNames('lm_tree','lm_data');
157  $this->lm_tree->setTreeTablePK("lm_id");*/
158 
159  if ((int) $_GET["focus_id"] > 0 && $this->lm_tree->isInTree((int) $_GET["focus_id"])) {
160  $this->focus_id = (int) $_GET["focus_id"];
161  }
162  }
163 
164 
168  public function executeCommand()
169  {
170  $ilNavigationHistory = $this->nav_history;
171  $ilAccess = $this->access;
172  $lng = $this->lng;
176 
177  // check read permission and parent conditions
178  // todo: replace all this by ilAccess call
179  if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) &&
180  (!(($this->ctrl->getCmd() == "infoScreen" || $this->ctrl->getNextClass() == "ilinfoscreengui")
181  && $ilAccess->checkAccess("visible", "", $_GET["ref_id"])))) {
182  $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->WARNING);
183  }
184 
185  $next_class = $this->ctrl->getNextClass($this);
186  $cmd = $this->ctrl->getCmd("layout", array("showPrintView"));
187 
188  $cmd = (isset($_POST['cmd']['citation']))
189  ? "ilCitation"
190  : $cmd;
191 
192  $obj_id = $_GET["obj_id"];
193  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
194  $ilNavigationHistory->addItem($_GET["ref_id"], $this->ctrl->getLinkTarget($this), "lm");
195  $this->ctrl->setParameter($this, "obj_id", $obj_id);
196 
197  switch ($next_class) {
198  case "ilnotegui":
199  $ret = $this->layout();
200  break;
201 
202  case "ilinfoscreengui":
203  $ret = $this->outputInfoScreen();
204  break;
205 
206  case "ilcommonactiondispatchergui":
207  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
209  $gui->enableCommentsSettings(false);
210  $this->ctrl->forwardCommand($gui);
211  break;
212 
213  case "illmpagegui":
214  include_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
215  $page_gui = $this->getLMPageGUI($_GET["obj_id"]);
216  $this->basicPageGuiInit($page_gui);
217  $ret = $ilCtrl->forwardCommand($page_gui);
218  break;
219 
220  case "ilglossarydefpagegui":
221  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php");
222  $page_gui = new ilGlossaryDefPageGUI($_GET["obj_id"]);
223  $this->basicPageGuiInit($page_gui);
224  $ret = $ilCtrl->forwardCommand($page_gui);
225  break;
226 
227  case "illearningprogressgui":
228  $this->initScreenHead("learning_progress");
229  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
231  $this->ctrl->forwardCommand($new_gui);
232  break;
233 
234  case "ilratinggui":
235  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
236  $rating_gui = new ilRatingGUI();
237  $rating_gui->setObject($this->lm->getId(), "lm", $_GET["obj_id"], "lm");
238  $this->ctrl->forwardCommand($rating_gui);
239  break;
240 
241  default:
242  $ret = $this->$cmd();
243  break;
244  }
245  }
246 
247 
251  public function setOfflineMode($a_offline = true, $a_all_languages = false)
252  {
253  $this->offline = $a_offline;
254  $this->export_all_languages = $a_all_languages;
255  }
256 
257 
261  public function offlineMode()
262  {
263  return $this->offline;
264  }
265 
271  public function setExportFormat($a_format)
272  {
273  $this->export_format = $a_format;
274  }
275 
281  public function getExportFormat()
282  {
283  return $this->export_format;
284  }
285 
289  public function nop()
290  {
291  }
292 
301  public function export()
302  {
303  }
304 
310  public function getTracker()
311  {
312  include_once("./Modules/LearningModule/classes/class.ilLMTracker.php");
313  $tracker = ilLMTracker::getInstance($this->lm->getRefId());
314  $tracker->setCurrentPage($this->getCurrentPageId());
315  return $tracker;
316  }
317 
318  public function attrib2arr($a_attributes)
319  {
320  $attr = array();
321  if (!is_array($a_attributes)) {
322  return $attr;
323  }
324  foreach ($a_attributes as $attribute) {
325  $attr[$attribute->name()] = $attribute->value();
326  }
327  return $attr;
328  }
329 
333  public function getCurrentFrameSet()
334  {
335  return $this->frames;
336  }
337 
341  public function determineLayout()
342  {
343  if ($this->getExportFormat() == "scorm") {
344  $layout = "1window";
345  } else {
346  $layout = $this->lm->getLayout();
347  if ($this->lm->getLayoutPerPage()) {
348  $pg_id = $this->getCurrentPageId();
349  if (!in_array($_GET["frame"], array("", "_blank")) && $_GET["from_page"] > 0) {
350  $pg_id = (int) $_GET["from_page"];
351  }
352 
353  // this is needed, e.g. lm is toc2win, page is 3window and media linked to media frame
354  if (in_array($_GET["cmd"], array("media", "glossary")) && $_GET["back_pg"] > 0) {
355  $pg_id = (int) $_GET["back_pg"];
356  }
357 
358  if ($pg_id > 0) {
359  $lay = ilLMObject::lookupLayout($pg_id);
360  if ($lay != "") {
361  $layout = $lay;
362  }
363  }
364  }
365  }
366 
367  return $layout;
368  }
369 
370  public function resume()
371  {
373 
374  if ($ilUser->getId() != ANONYMOUS_USER_ID && $_GET["focus_id"] == "") {
375  include_once("./Modules/LearningModule/classes/class.ilObjLearningModuleAccess.php");
376  $last_accessed_page = ilObjLearningModuleAccess::_getLastAccessedPage((int) $_GET["ref_id"], $ilUser->getId());
377 
378  // if last accessed page was final page do nothing, start over
379  if ($last_accessed_page &&
380  $last_accessed_page != $this->lm_tree->getLastActivePage()) {
381  $_GET["obj_id"] = $last_accessed_page;
382  }
383  }
384 
385  $this->layout();
386  }
387 
391  public function layout($a_xml = "main.xml", $doShow = true)
392  {
393  global $DIC;
394 
395  $tpl = $this->tpl;
399 
400  $layout = $this->determineLayout();
401 
402  // xmldocfile is deprecated! Use domxml_open_file instead.
403  // But since using relative pathes with domxml under windows don't work,
404  // we need another solution:
405  $xmlfile = file_get_contents("./Modules/LearningModule/layouts/lm/" . $layout . "/" . $a_xml);
406 
407  if (!$doc = domxml_open_mem($xmlfile)) {
408  include_once("./Modules/LearningModule/exceptions/class.ilLMPresentationException.php");
409  throw new ilLMPresentationException("ilLMPresentation: XML File invalid. Error reading " .
410  $layout . "/" . $a_xml . ".");
411  }
412  $this->layout_doc = $doc;
413  //echo ":".htmlentities($xmlfile).":$layout:$a_xml:";
414 
415  // get current frame node
416  $xpc = xpath_new_context($doc);
417  $path = (empty($_GET["frame"]) || ($_GET["frame"] == "_blank"))
418  ? "/ilLayout/ilFrame[1]"
419  : "//ilFrame[@name='" . $_GET["frame"] . "']";
420  $result = xpath_eval($xpc, $path);
421  $found = $result->nodeset;
422  if (count($found) != 1) {
423  include_once("./Modules/LearningModule/exceptions/class.ilLMPresentationException.php");
424  throw new ilLMPresentationException("ilLMPresentation: XML File invalid. Found " . count($found) . " nodes for " .
425  " path " . $path . " in " . $layout . "/" . $a_xml . ". LM Layout is " . $this->lm->getLayout());
426  }
427  $node = $found[0];
428 
429  // ProcessFrameset
430  // node is frameset, if it has cols or rows attribute
431  $attributes = $this->attrib2arr($node->attributes());
432 
433  $this->frames = array();
434  if ((!empty($attributes["rows"])) || (!empty($attributes["cols"]))) {
435  $content .= $this->buildTag("start", "frameset", $attributes);
436  //$this->frames = array();
437  $this->processNodes($content, $node);
438  $content .= $this->buildTag("end", "frameset");
439  $this->tpl = new ilTemplate("tpl.frameset.html", true, true, "Modules/LearningModule");
440  $this->renderPageTitle();
441  $this->tpl->setVariable("FS_CONTENT", $content);
442  if (!$doshow) {
443  $content = $this->tpl->get();
444  }
445  } else { // node is frame -> process the content tags
446  // ProcessContentTag
447  //if ((empty($attributes["template"]) || !empty($_GET["obj_type"])))
448  if ((empty($attributes["template"]) || !empty($_GET["obj_type"]))
449  && ($_GET["frame"] != "_blank" || $_GET["obj_type"] != "MediaObject")) {
450  // we got a variable content frame (can display different
451  // object types (PageObject, MediaObject, GlossarItem)
452  // and contains elements for them)
453 
454  // determine object type
455  if (empty($_GET["obj_type"])) {
456  $obj_type = "PageObject";
457  } else {
458  $obj_type = $_GET["obj_type"];
459  }
460 
461  // get object specific node
462  $childs = $node->child_nodes();
463  $found = false;
464  foreach ($childs as $child) {
465  if ($child->node_name() == $obj_type) {
466  $found = true;
467  $attributes = $this->attrib2arr($child->attributes());
468  $node = $child;
469  //echo "<br>2node:".$node->node_name();
470  break;
471  }
472  }
473  if (!$found) {
474  include_once("./Modules/LearningModule/exceptions/class.ilLMPresentationException.php");
475  throw new ilLMPresentationException("ilLMPresentation: No template specified for frame '" .
476  $_GET["frame"] . "' and object type '" . $obj_type . "'.");
477  }
478  }
479 
480  // get template
481  $in_module = ($attributes["template_location"] == "module")
482  ? true
483  : false;
484  if ($in_module) {
485  $this->tpl = new ilTemplate($attributes["template"], true, true, $in_module);
486  $this->tpl->setBodyClass("");
487  } else {
488  $this->tpl = $tpl;
489  }
490 
491  // set style sheets
492  if (!$this->offlineMode()) {
493  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
494  } else {
495  $style_name = $ilUser->getPref("style") . ".css";
496  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
497  }
498 
499  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
500 
501  iljQueryUtil::initjQuery($this->tpl);
502  iljQueryUtil::initjQueryUI($this->tpl);
503 
504  include_once("./Services/UICore/classes/class.ilUIFramework.php");
505  ilUIFramework::init($this->tpl);
506 
507  // to make e.g. advanced seletions lists work:
508  $GLOBALS["tpl"] = $this->tpl;
509 
510  $childs = $node->child_nodes();
511 
512  foreach ($childs as $child) {
513  $child_attr = $this->attrib2arr($child->attributes());
514 
515  switch ($child->node_name()) {
516  case "ilMainMenu":
517  $this->ilMainMenu();
518  //$this->renderPageTitle();
519  break;
520 
521  case "ilTOC":
522  $this->ilTOC($child_attr["target_frame"]);
523  break;
524 
525  case "ilPage":
526  $this->renderPageTitle();
527  switch ($this->lm->getType()) {
528  case "lm":
529  unset($_SESSION["tr_id"]);
530  unset($_SESSION["bib_id"]);
531  unset($_SESSION["citation"]);
532  $content = $this->ilPage($child);
533  break;
534  }
535  break;
536 
537  case "ilGlossary":
538  $content = $this->ilGlossary($child);
539  break;
540 
541  case "ilLMNavigation":
542  $this->ilLMNavigation();
543  break;
544 
545  case "ilMedia":
546  $this->ilMedia();
547  break;
548 
549  case "ilLocator":
550  $this->ilLocator();
551  break;
552 
553  case "ilJavaScript":
554  $this->ilJavaScript(
555  $child_attr["inline"],
556  $child_attr["file"],
557  $child_attr["location"]
558  );
559  break;
560 
561  case "ilLMMenu":
562  $this->ilLMMenu();
563  break;
564 
565  case "ilLMHead":
566  $this->ilLMHead();
567  break;
568 
569  case "ilLMSubMenu":
570  $this->ilLMSubMenu();
571  break;
572 
573  case "ilLMNotes":
574  $this->ilLMNotes();
575  break;
576  }
577  }
578 
579  // TODO: Very dirty hack to force the import of JavaScripts in learning content in the FAQ frame (e.g. if jsMath is in the content)
580  // Unfortunately there is no standardized way to do this somewhere else. Calling fillJavaScripts always in ilTemplate causes multiple additions of the the js files.
581  // 19.7.2014: outcommented, since fillJavaScriptFiles is called in the next blocks, and the
582  // following lines would add the js files two times
583  // if (strcmp($_GET["frame"], "topright") == 0) $this->tpl->fillJavaScriptFiles();
584  // if (strcmp($_GET["frame"], "right") == 0) $this->tpl->fillJavaScriptFiles();
585  // if (strcmp($_GET["frame"], "botright") == 0) $this->tpl->fillJavaScriptFiles();
586 
587  if (!$this->offlineMode()) {
588  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
591 
592 
593  $this->tpl->addJavascript("./Modules/LearningModule/js/LearningModule.js");
594  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
595  $close_call = "il.LearningModule.setCloseHTML('" . ilGlyphGUI::get(ilGlyphGUI::CLOSE) . "');";
596  $this->tpl->addOnLoadCode($close_call);
597 
598  //$store->set("cf_".$this->lm->getId());
599 
600  // handle initial content
601  if ($_GET["frame"] == "") {
602  include_once("./Services/Authentication/classes/class.ilSessionIStorage.php");
603  $store = new ilSessionIStorage("lm");
604  $last_frame_url = $store->get("cf_" . $this->lm->getId());
605  if ($last_frame_url != "") {
606  $this->tpl->addOnLoadCode("il.LearningModule.setLastFrameUrl('" . $last_frame_url . "', 'center_bottom');");
607  }
608 
609  if (in_array($layout, array("toc2windyn"))) {
610  $this->tpl->addOnLoadCode("il.LearningModule.setSaveUrl('" .
611  $ilCtrl->getLinkTarget($this, "saveFrameUrl", "", false, false) . "');
612  il.LearningModule.openInitFrames();
613  ");
614  }
615  $this->tpl->addOnLoadCode("il.LearningModule.setTocRefreshUrl('" .
616  $ilCtrl->getLinkTarget($this, "refreshToc", "", false, false) . "');
617  ");
618  }
619 
620  // from main menu
621  // $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
622  $this->tpl->addJavascript("./Services/Navigation/js/ServiceNavigation.js");
623  ilYuiUtil::initConnection($this->tpl);
624  $this->tpl->fillJavaScriptFiles();
625  $this->tpl->fillScreenReaderFocus();
626 
627  $this->tpl->fillCssFiles();
628  } else {
629  // reset standard css files
630  $this->tpl->resetJavascript();
631  $this->tpl->resetCss();
632  $this->tpl->setBodyClass("ilLMNoMenu");
633 
634  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
636  if ($f["type"] == "js") {
637  $this->tpl->addJavascript($f["target"]);
638  }
639  if ($f["type"] == "css") {
640  $this->tpl->addCSS($f["target"]);
641  }
642  }
643  $this->tpl->fillJavaScriptFiles(true);
644  $this->tpl->fillCssFiles(true);
645  }
646 
647 
648  $this->tpl->fillBodyClass();
649  }
650 
651  if ($doShow) {
652  // (horrible) workaround for preventing template engine
653  // from hiding paragraph text that is enclosed
654  // in curly brackets (e.g. "{a}", see ilPageObjectGUI::showPage())
655 
656  $this->tpl->fillTabs();
657  if ($this->fill_on_load_code) {
658  $this->tpl->fillOnLoadCode();
659  //$this->tpl->fillViewAppendInlineCss();
660  }
661  $content = $this->tpl->get();
662  $content = str_replace("&#123;", "{", $content);
663  $content = str_replace("&#125;", "}", $content);
664 
665  header('Content-type: text/html; charset=UTF-8');
666  echo $content;
667  } else {
668  $this->tpl->fillLeftNav();
669  $this->tpl->fillOnLoadCode();
670  //$this->tpl->fillViewAppendInlineCss();
671  $content = $this->tpl->get();
672  }
673 
674  return($content);
675  }
676 
683  public function saveFrameUrl()
684  {
685  include_once("./Services/Authentication/classes/class.ilSessionIStorage.php");
686  $store = new ilSessionIStorage("lm");
687  if ($_GET["url"] != "") {
688  $store->set("cf_" . $this->lm->getId(), $_GET["url"]);
689  } else {
690  $store->set("cf_" . $this->lm->getId(), $_GET["url"]);
691  }
692  }
693 
694 
695  public function fullscreen()
696  {
697  return $this->layout("fullscreen.xml", !$this->offlineMode());
698  }
699 
700  public function media()
701  {
702  if ($_GET["frame"] != "_blank") {
703  return $this->layout("main.xml", !$this->offlineMode());
704  } else {
705  return $this->layout("fullscreen.xml", !$this->offlineMode());
706  }
707  }
708 
709  public function glossary()
710  {
711  global $DIC;
712 
714 
715  if ($_GET["frame"] != "_blank") {
716  $this->layout();
717  } else {
718  $this->tpl = new ilTemplate("tpl.glossary_term_output.html", true, true, true);
719  $GLOBALS["tpl"] = $this->tpl;
720  $this->renderPageTitle();
721 
722  // set style sheets
723  if (!$this->offlineMode()) {
724  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
725  } else {
726  $style_name = $ilUser->getPref("style") . ".css";
727  ;
728  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
729  }
730 
731  $this->ilGlossary($child);
732  if (!$this->offlineMode()) {
733  $this->tpl->show();
734  } else {
735  return $this->tpl->get();
736  }
737  }
738  }
739 
743  public function ilMainMenu()
744  {
745  // LTI
746  global $DIC;
747  $ltiview = $DIC["lti"];
748  if ($ltiview->isActive()) {
749  include_once './Services/LTI/classes/class.ilMainMenuGUI.php';
750  $ilMainMenu = new LTI\ilMainMenuGUI("_top", false, $this->tpl);
751  } else {
752  include_once './Services/MainMenu/classes/class.ilMainMenuGUI.php';
753  $ilMainMenu = new ilMainMenuGUI("_top", false, $this->tpl);
754  }
755 
756  if ($this->offlineMode()) {
757  $this->tpl->touchBlock("pg_intro");
758  $this->tpl->touchBlock("pg_outro");
759  return;
760  }
761 
762  $page_id = $this->getCurrentPageId();
763  if ($page_id > 0) {
764  $ilMainMenu->setLoginTargetPar("pg_" . $page_id . "_" . $this->lm->getRefId());
765  }
766 
767  //$this->tpl->touchBlock("mm_intro");
768  //$this->tpl->touchBlock("mm_outro");
769  $this->tpl->touchBlock("pg_intro");
770  $this->tpl->touchBlock("pg_outro");
771  $this->tpl->setBodyClass("std");
772  $this->tpl->setVariable("MAINMENU", $ilMainMenu->getHTML());
773  // LTI
774  $this->tpl->setVariable("MAINMENU_SPACER", $ilMainMenu->getSpacerClass());
775  }
776 
780  public function ilTOC($a_get_explorer = false)
781  {
782  include_once("./Modules/LearningModule/classes/class.ilLMTOCExplorerGUI.php");
783  $exp = new ilLMTOCExplorerGUI($this, "ilTOC", $this, $this->lang, $this->focus_id, $this->export_all_languages);
784  $exp->setMainTemplate($this->tpl);
785  $exp->setTracker($this->getTracker());
786  // determine highlighted and force open nodes
787  $page_id = $this->getCurrentPageId();
788  if ($this->deactivated_page) {
789  $page_id = $_GET["obj_id"];
790  }
791  if ($page_id > 0) {
792  $exp->setPathOpen((int) $page_id);
793  }
794  // empty chapter
795  if ($this->chapter_has_no_active_page &&
796  ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
797  $exp->setHighlightNode($_GET["obj_id"]);
798  } else {
799  if ($this->lm->getTOCMode() == "pages") {
800  if ($this->deactivated_page) {
801  $exp->setHighlightNode($_GET["obj_id"]);
802  } else {
803  $exp->setHighlightNode($page_id);
804  }
805  } else {
806  $exp->setHighlightNode($this->lm_tree->getParentId($page_id));
807  }
808  }
809  if ($this->offlineMode()) {
810  $exp->setOfflineMode(true);
811  }
812  if (!$exp->handleCommand()) {
813  if ($a_get_explorer) {
814  return $exp;
815  } else {
816  $this->tpl->setCurrentBlock("il_toc");
817  $this->tpl->setVariable("EXPLORER", $exp->getHTML());
818  $this->tpl->parseCurrentBlock();
819  }
820  }
821  }
822 
829  public function getLMPresentationTitle()
830  {
831  if ($this->offlineMode() && $this->lang != "" && $this->lang != "-") {
832  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
833  $ot = ilObjectTranslation::getInstance($this->lm->getId());
834  $data = $ot->getLanguages();
835  $ltitle = $data[$this->lang]["title"];
836  if ($ltitle != "") {
837  return $ltitle;
838  }
839  }
840  return $this->lm->getTitle();
841  }
842 
843 
847  public function ilLMMenu()
848  {
849  $this->tpl->setVariable("MENU", $this->lm_gui->setilLMMenu(
850  $this->offlineMode(),
851  $this->getExportFormat(),
852  "content",
853  false,
854  true,
855  $this->getCurrentPageId(),
856  $this->lang,
858  ));
859  }
860 
864  public function ilLMHead()
865  {
866  $this->tpl->setCurrentBlock("header_image");
867  if ($this->offlineMode()) {
868  $this->tpl->setVariable("IMG_HEADER", "./images/icon_lm.svg");
869  } else {
870  $this->tpl->setVariable("IMG_HEADER", ilUtil::getImagePath("icon_lm.svg"));
871  }
872  $this->tpl->parseCurrentBlock();
873  $this->tpl->setCurrentBlock("lm_head");
874  $this->tpl->setVariable("HEADER", $this->getLMPresentationTitle());
875  $this->tpl->parseCurrentBlock();
876  }
877 
881  public function ilLMSubMenu()
882  {
884 
885  if ($this->abstract) {
886  return;
887  }
888 
889  $showViewInFrameset = true;
890 
891  if ($showViewInFrameset) {
892  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
893  } else {
894  $buttonTarget = "_top";
895  }
896 
897 
898  include_once("./Services/UICore/classes/class.ilTemplate.php");
899  $tpl_menu = new ilTemplate("tpl.lm_sub_menu.html", true, true, true);
900 
901  $pg_id = $this->getCurrentPageId();
902  if ($pg_id == 0) {
903  return;
904  }
905 
906  // edit learning module
907  if (!$this->offlineMode()) {
908  if ($rbacsystem->checkAccess("write", $_GET["ref_id"])) {
909  $tpl_menu->setCurrentBlock("edit_page");
910  $page_id = $this->getCurrentPageId();
911  $tpl_menu->setVariable("EDIT_LINK", ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $_GET["ref_id"] .
912  "&obj_id=" . $page_id . "&to_page=1");
913  $tpl_menu->setVariable("EDIT_TXT", $this->lng->txt("edit_page"));
914  $tpl_menu->setVariable("EDIT_TARGET", $buttonTarget);
915  $tpl_menu->parseCurrentBlock();
916  }
917 
918  $page_id = $this->getCurrentPageId();
919 
920  include_once("./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php");
921  $plinkgui = new ilPermanentLinkGUI(
922  "pg",
923  $page_id . "_" . $this->lm->getRefId(),
924  "",
925  "_top"
926  );
927 
928  $title = $this->getLMPresentationTitle();
930  $page_id,
931  $this->lm->getPageHeader(),
932  $this->lm->isActiveNumbering(),
933  $this->lm_set->get("time_scheduled_page_activation"),
934  false,
935  0,
937  );
938  if ($pg_title != "") {
939  $title .= ": " . $pg_title;
940  }
941 
942  $plinkgui->setTitle($title);
943 
944  $tpl_menu->setCurrentBlock("perma_link");
945  $tpl_menu->setVariable("PERMA_LINK", $plinkgui->getHTML());
946  $tpl_menu->parseCurrentBlock();
947  }
948 
949  $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
950  }
951 
952 
956  public function redrawHeaderAction()
957  {
958  echo $this->addHeaderAction(true);
959  exit;
960  }
961 
965  public function addHeaderAction($a_redraw = false)
966  {
967  $ilAccess = $this->access;
968  $tpl = $this->tpl;
969 
970  include_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
971  $dispatcher = new ilCommonActionDispatcherGUI(
973  $ilAccess,
974  $this->lm->getType(),
975  $_GET["ref_id"],
976  $this->lm->getId()
977  );
978  $dispatcher->setSubObject("pg", $this->getCurrentPageId());
979 
980  include_once "Services/Object/classes/class.ilObjectListGUI.php";
981  ilObjectListGUI::prepareJSLinks(
982  $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
983  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "ilnotegui"), "", "", true, false),
984  $this->ctrl->getLinkTargetByClass(array("ilcommonactiondispatchergui", "iltagginggui"), "", "", true, false),
985  $this->tpl
986  );
987 
988  $lg = $dispatcher->initHeaderAction();
989  $lg->enableNotes(true);
990  $lg->enableComments($this->lm->publicNotes(), false);
991 
992  if ($this->lm->hasRating() && !$this->offlineMode()) {
993  $lg->enableRating(
994  true,
995  $this->lng->txt("lm_rating"),
996  false,
997  array("ilcommonactiondispatchergui", "ilratinggui")
998  );
999  }
1000 
1001  if (!$a_redraw) {
1002  $this->tpl->setVariable("HEAD_ACTION", $lg->getHeaderAction($this->tpl));
1003  } else {
1004  // we need to add onload code manually (rating, comments, etc.)
1005  return $lg->getHeaderAction() .
1006  $tpl->getOnLoadCodeForAsynch();
1007  }
1008  }
1009 
1013  public function ilLMNotes()
1014  {
1015  $ilAccess = $this->access;
1017 
1018 
1019  // no notes in offline (export) mode
1020  if ($this->offlineMode()) {
1021  return;
1022  }
1023 
1024  // output notes (on top)
1025 
1026  if (!$ilSetting->get("disable_notes")) {
1027  $this->addHeaderAction();
1028  }
1029 
1030  // now output comments
1031 
1032  if ($ilSetting->get("disable_comments")) {
1033  return;
1034  }
1035 
1036  if (!$this->lm->publicNotes()) {
1037  return;
1038  }
1039 
1040  $next_class = $this->ctrl->getNextClass($this);
1041 
1042  include_once("Services/Notes/classes/class.ilNoteGUI.php");
1043  $pg_id = $this->getCurrentPageId();
1044  if ($pg_id == 0) {
1045  return;
1046  }
1047 
1048  $notes_gui = new ilNoteGUI($this->lm->getId(), $this->getCurrentPageId(), "pg");
1049 
1050  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) &&
1051  $ilSetting->get("comments_del_tutor", 1)) {
1052  $notes_gui->enablePublicNotesDeletion(true);
1053  }
1054 
1055  $this->ctrl->setParameter($this, "frame", $_GET["frame"]);
1056  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1057 
1058  $notes_gui->enablePrivateNotes();
1059  if ($this->lm->publicNotes()) {
1060  $notes_gui->enablePublicNotes();
1061  }
1062 
1063  if ($next_class == "ilnotegui") {
1064  $html = $this->ctrl->forwardCommand($notes_gui);
1065  } else {
1066  $html = $notes_gui->getNotesHTML();
1067  }
1068  $this->tpl->setVariable("NOTES", $html);
1069  }
1070 
1071 
1075  public function ilLocator($a_std_templ_loaded = false)
1076  {
1077  global $DIC;
1078  $ltiview = $DIC["lti"];
1079  $ilLocator = $this->locator;
1080  $tree = $this->tree;
1081  $ilCtrl = $this->ctrl;
1082 
1083  require_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
1084 
1085  if (empty($_GET["obj_id"])) {
1086  $a_id = $this->lm_tree->getRootId();
1087  } else {
1088  $a_id = $_GET["obj_id"];
1089  }
1090 
1091  if (!$a_std_templ_loaded) {
1092  $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1093  }
1094 
1095  if (!$this->lm->cleanFrames()) {
1096  $frame_param = $_GET["frame"];
1097  $frame_target = "";
1098  } elseif (!$this->offlineMode()) {
1099  $frame_param = "";
1100  $frame_target = ilFrameTargetInfo::_getFrame("MainContent");
1101  } else {
1102  $frame_param = "";
1103  $frame_target = "_top";
1104  }
1105 
1106  if (!$this->offlineMode()) {
1107  // LTI
1108  if ($ltiview->isActive()) {
1109  // Do nothing, its complicated...
1110  } else {
1111  $ilLocator->addItem("...", "");
1112 
1113  $par_id = $tree->getParentId($_GET["ref_id"]);
1114  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $par_id);
1115  $ilLocator->addItem(
1117  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"),
1118  ilFrameTargetInfo::_getFrame("MainContent"),
1119  $par_id
1120  );
1121  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
1122  }
1123  } else {
1124  $ilLocator->setOffline(true);
1125  }
1126 
1127  if ($this->lm_tree->isInTree($a_id)) {
1128  $path = $this->lm_tree->getPathFull($a_id);
1129 
1130  foreach ($path as $key => $row) {
1131  if ($row["type"] != "pg") {
1132  if ($row["child"] != $this->lm_tree->getRootId()) {
1133  $ilLocator->addItem(
1136  $row["child"],
1138  $this->lm->isActiveNumbering(),
1139  $this->lm_set->get("time_scheduled_page_activation"),
1140  false,
1141  0,
1142  $this->lang
1143  ),
1144  50,
1145  true
1146  ),
1147  $this->getLink($_GET["ref_id"], "layout", $row["child"], $frame_param, "StructureObject"),
1148  $frame_target
1149  );
1150  } else {
1151  $ilLocator->addItem(
1152  ilUtil::shortenText($this->getLMPresentationTitle(), 50, true),
1153  $this->getLink($_GET["ref_id"], "layout", "", $frame_param),
1154  $frame_target,
1155  $_GET["ref_id"]
1156  );
1157  }
1158  }
1159  }
1160  } else { // lonely page
1161  $ilLocator->addItem(
1162  $this->getLMPresentationTitle(),
1163  $this->getLink($_GET["ref_id"], "layout", "", $_GET["frame"])
1164  );
1165 
1166  require_once("./Modules/LearningModule/classes/class.ilLMObjectFactory.php");
1167  $lm_obj = ilLMObjectFactory::getInstance($this->lm, $a_id);
1168 
1169  $ilLocator->addItem(
1170  $lm_obj->getTitle(),
1171  $this->getLink($_GET["ref_id"], "layout", $a_id, $frame_param),
1172  $frame_target
1173  );
1174  }
1175 
1176  if (DEBUG) {
1177  $debug = "DEBUG: <font color=\"red\">" . $this->type . "::" . $this->id . "::" . $_GET["cmd"] . "</font><br/>";
1178  }
1179 
1180  //$prop_name = $this->objDefinition->getPropertyName($_GET["cmd"],$this->type);
1181 
1182 
1183  $this->tpl->setLocator();
1184  }
1185 
1191  public function getCurrentPageId()
1192  {
1193  $ilUser = $this->user;
1194 
1195  if (!$this->offlineMode() && $this->current_page_id !== false) {
1196  return $this->current_page_id;
1197  }
1198 
1199  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
1200 
1201  $this->chapter_has_no_active_page = false;
1202  $this->deactivated_page = false;
1203 
1204  // determine object id
1205  if (empty($_GET["obj_id"])) {
1206  $obj_id = $this->lm_tree->getRootId();
1207  } else {
1208  $obj_id = $_GET["obj_id"];
1209  $active = ilLMPage::_lookupActive(
1210  $obj_id,
1211  $this->lm->getType(),
1212  $this->lm_set->get("time_scheduled_page_activation")
1213  );
1214 
1215  if (!$active &&
1216  ilLMPageObject::_lookupType($obj_id) == "pg") {
1217  $this->deactivated_page = true;
1218  }
1219  }
1220 
1221  // obj_id not in tree -> it is a unassigned page -> return page id
1222  if (!$this->lm_tree->isInTree($obj_id)) {
1223  return $obj_id;
1224  }
1225 
1226  $curr_node = $this->lm_tree->getNodeData($obj_id);
1227 
1228  $active = ilLMPage::_lookupActive(
1229  $obj_id,
1230  $this->lm->getType(),
1231  $this->lm_set->get("time_scheduled_page_activation")
1232  );
1233 
1234  if ($curr_node["type"] == "pg" &&
1235  $active) { // page in tree -> return page id
1236  $page_id = $curr_node["obj_id"];
1237  } else { // no page -> search for next page and return its id
1238  $succ_node = true;
1239  $active = false;
1240  $page_id = $obj_id;
1241  while ($succ_node && !$active) {
1242  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, "pg");
1243  $page_id = $succ_node["obj_id"];
1244  $active = ilLMPage::_lookupActive(
1245  $page_id,
1246  $this->lm->getType(),
1247  $this->lm_set->get("time_scheduled_page_activation")
1248  );
1249  }
1250 
1251  if ($succ_node["type"] != "pg") {
1252  $this->chapter_has_no_active_page = true;
1253  return 0;
1254  }
1255 
1256  // if public access get first public page in chapter
1257  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
1258  $this->lm_gui->object->getPublicAccessMode() == 'selected') {
1259  $public = ilLMObject::_isPagePublic($page_id);
1260 
1261  while ($public === false && $page_id > 0) {
1262  $succ_node = $this->lm_tree->fetchSuccessorNode($page_id, 'pg');
1263  $page_id = $succ_node['obj_id'];
1264  $public = ilLMObject::_isPagePublic($page_id);
1265  }
1266  }
1267 
1268  // check whether page found is within "clicked" chapter
1269  if ($this->lm_tree->isInTree($page_id)) {
1270  $path = $this->lm_tree->getPathId($page_id);
1271  if (!in_array($_GET["obj_id"], $path)) {
1272  $this->chapter_has_no_active_page = true;
1273  }
1274  }
1275  }
1276 
1277  $this->current_page_id = $page_id;
1278  return $page_id;
1279  }
1280 
1281  public function ilCitation()
1282  {
1283  $page_id = $this->getCurrentPageId();
1284  $this->tpl = new ilTemplate("tpl.page.html", true, true, true);
1285  $this->ilLocator();
1286  $this->tpl->setVariable("MENU", $this->lm_gui->setilCitationMenu());
1287 
1288  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
1289 
1290  $this->pg_obj = $this->getLMPage($page_id);
1291  $xml = $this->pg_obj->getXMLContent();
1292  $this->lm_gui->showCitation($xml);
1293  $this->tpl->show();
1294  }
1295 
1296 
1297  public function getLayoutLinkTargets()
1298  {
1299  if (!is_object($this->layout_doc)) {
1300  return array();
1301  }
1302 
1303  $xpc = xpath_new_context($this->layout_doc);
1304 
1305  $path = "/ilLayout/ilLinkTargets/LinkTarget";
1306  $res = xpath_eval($xpc, $path);
1307  $targets = array();
1308  for ($i = 0; $i < count($res->nodeset); $i++) {
1309  $type = $res->nodeset[$i]->get_attribute("Type");
1310  $frame = $res->nodeset[$i]->get_attribute("Frame");
1311  $onclick = $res->nodeset[$i]->get_attribute("OnClick");
1312  $targets[$type] = array("Type" => $type, "Frame" => $frame, "OnClick" => $onclick);
1313  }
1314 
1315  return $targets;
1316  }
1317 
1325  public function ilPage(&$a_page_node, $a_page_id = 0)
1326  {
1328 
1329  $ilUser = $this->user;
1330  $ilHelp = $this->help;
1331 
1332 
1333  $ilHelp = $this->help;
1334  $ilHelp->setScreenIdComponent("lm");
1335  $ilHelp->setScreenId("content");
1336  $ilHelp->setSubScreenId("content");
1337 
1338  $this->fill_on_load_code = true;
1339 
1340 
1341  // check page id
1342  $requested_page_lm = ilLMPage::lookupParentId($this->getCurrentPageId(), "lm");
1343  if ($requested_page_lm != $this->lm->getId()) {
1344  if ($_REQUEST["frame"] == "") {
1345  $this->showNoPageAccess();
1346  return "";
1347  } else {
1348  $read_access = false;
1349  foreach (ilObject::_getAllReferences($requested_page_lm) as $ref_id) {
1350  if ($access->checkAccess("read", "", $ref_id)) {
1351  $read_access = true;
1352  }
1353  }
1354  if (!$read_access) {
1355  $this->showNoPageAccess();
1356  return "";
1357  }
1358  }
1359  }
1360 
1361  // check if page is (not) visible in public area
1362  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
1363  $this->lm_gui->object->getPublicAccessMode() == 'selected') {
1364  $public = ilLMObject::_isPagePublic($this->getCurrentPageId());
1365 
1366  if (!$public) {
1367  return $this->showNoPublicAccess($this->getCurrentPageId());
1368  }
1369  }
1370 
1371  if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId())) {
1372  return $this->showPreconditionsOfPage($this->getCurrentPageId());
1373  }
1374 
1375  // if navigation is restricted based on correct answered questions
1376  // check if we have preceeding pages including unsanswered/incorrect answered questions
1377  if (!$this->offlineMode()) {
1378  if ($this->lm->getRestrictForwardNavigation()) {
1379  if ($this->getTracker()->hasPredIncorrectAnswers($this->getCurrentPageId())) {
1381  return;
1382  }
1383  }
1384  }
1385 
1386 
1387  require_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
1388  require_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
1389 
1390  // page id is e.g. > 0 when footer or header page is processed
1391  if ($a_page_id == 0) {
1392  $page_id = $this->getCurrentPageId();
1393  //echo ":".$page_id.":";
1394  // highlighting?
1395 
1396  if ($_GET["srcstring"] != "" && !$this->offlineMode()) {
1397  include_once './Services/Search/classes/class.ilUserSearchCache.php';
1398  $cache = ilUserSearchCache::_getInstance($ilUser->getId());
1399  $cache->switchSearchType(ilUserSearchCache::LAST_QUERY);
1400  $search_string = $cache->getQuery();
1401 
1402  // advanced search?
1403  if (is_array($search_string)) {
1404  $search_string = $search_string["lom_content"];
1405  }
1406 
1407  include_once("./Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php");
1408  include_once("./Services/Search/classes/class.ilQueryParser.php");
1409  $p = new ilQueryParser($search_string);
1410  $p->parse();
1411 
1412  $words = $p->getQuotedWords();
1413  if (is_array($words)) {
1414  foreach ($words as $w) {
1415  ilTextHighlighterGUI::highlight("ilLMPageContent", $w, $this->tpl);
1416  }
1417  }
1418 
1419  $this->fill_on_load_code = true;
1420  }
1421  } else {
1422  $page_id = $a_page_id;
1423  }
1424 
1425  // content style
1426  $this->tpl->setCurrentBlock("ContentStyle");
1427  if (!$this->offlineMode()) {
1428  $this->tpl->setVariable(
1429  "LOCATION_CONTENT_STYLESHEET",
1430  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
1431  );
1432  } else {
1433  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
1434  }
1435  $this->tpl->parseCurrentBlock();
1436 
1437  // no active page found in chapter
1438  if ($this->chapter_has_no_active_page &&
1439  ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
1440  $mtpl = new ilTemplate(
1441  "tpl.no_content_message.html",
1442  true,
1443  true,
1444  "Modules/LearningModule"
1445  );
1446  $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_no_page_in_chapter"));
1447  //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_st.svg",
1448  // false, "output", $this->offlineMode()));
1449  $mtpl->setVariable(
1450  "ITEM_TITLE",
1451  ilLMObject::_lookupTitle($_GET["obj_id"])
1452  );
1453  $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
1454  return $mtpl->get();
1455  }
1456 
1457  // current page is deactivated
1458  if ($this->deactivated_page) {
1459  $mtpl = new ilTemplate(
1460  "tpl.no_content_message.html",
1461  true,
1462  true,
1463  "Modules/LearningModule"
1464  );
1465  $m = $this->lng->txt("cont_page_currently_deactivated");
1466  $act_data = ilLMPage::_lookupActivationData((int) $_GET["obj_id"], $this->lm->getType());
1467  if ($act_data["show_activation_info"] &&
1468  (ilUtil::now() < $act_data["activation_start"])) {
1469  $m .= "<p>" . sprintf(
1470  $this->lng->txt("cont_page_activation_on"),
1472  new ilDateTime($act_data["activation_start"], IL_CAL_DATETIME)
1473  )
1474  ) .
1475  "</p>";
1476  }
1477  $mtpl->setVariable("MESSAGE", $m);
1478  //$mtpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_pg.svg",
1479  // false, "output", $this->offlineMode()));
1480  $mtpl->setVariable(
1481  "ITEM_TITLE",
1482  ilLMObject::_lookupTitle($_GET["obj_id"])
1483  );
1484  $this->tpl->setVariable("PAGE_CONTENT", $mtpl->get());
1485  return $mtpl->get();
1486  }
1487 
1488  // check if page is out of focus
1489  $focus_mess = "";
1490  if ($this->focus_id > 0) {
1491  $path = $this->lm_tree->getPathId($page_id);
1492 
1493  // out of focus
1494  if (!in_array($this->focus_id, $path)) {
1495  $mtpl = new ilTemplate(
1496  "tpl.out_of_focus_message.html",
1497  true,
1498  true,
1499  "Modules/LearningModule"
1500  );
1501  $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_out_of_focus_message"));
1502  $mtpl->setVariable("TXT_SHOW_CONTENT", $this->lng->txt("cont_show_content_after_focus"));
1503 
1504  if ($_GET["focus_return"] == "" || ilObject::_lookupType((int) $_GET["focus_return"], true) != "crs") {
1505  $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_beginning"));
1506  $this->ctrl->setParameter($this, "obj_id", $this->focus_id);
1507  $mtpl->setVariable("LINK_BACK_TO_BEGINNING", $this->ctrl->getLinkTarget($this, "layout"));
1508  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1509  } else {
1510  $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_return_crs"));
1511  include_once("./Services/Link/classes/class.ilLink.php");
1512  $mtpl->setVariable("LINK_BACK_TO_BEGINNING", ilLink::_getLink((int) $_GET["focus_return"]));
1513  }
1514 
1515  $this->ctrl->setParameter($this, "focus_id", "");
1516  $mtpl->setVariable("LINK_SHOW_CONTENT", $this->ctrl->getLinkTarget($this, "layout"));
1517  $this->ctrl->setParameter($this, "focus_id", $_GET["focus_id"]);
1518 
1519  $focus_mess = $mtpl->get();
1520  } else {
1521  $sp = $this->getSuccessorPage();
1522  $path2 = array();
1523  if ($sp > 0) {
1524  $path2 = $this->lm_tree->getPathId($this->getSuccessorPage());
1525  }
1526  if ($sp == 0 || !in_array($this->focus_id, $path2)) {
1527  $mtpl = new ilTemplate(
1528  "tpl.out_of_focus_message.html",
1529  true,
1530  true,
1531  "Modules/LearningModule"
1532  );
1533  $mtpl->setVariable("MESSAGE", $this->lng->txt("cont_out_of_focus_message_last_page"));
1534  $mtpl->setVariable("TXT_SHOW_CONTENT", $this->lng->txt("cont_show_content_after_focus"));
1535 
1536  if ($_GET["focus_return"] == "" || ilObject::_lookupType((int) $_GET["focus_return"], true) != "crs") {
1537  $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_beginning"));
1538  $this->ctrl->setParameter($this, "obj_id", $this->focus_id);
1539  $mtpl->setVariable("LINK_BACK_TO_BEGINNING", $this->ctrl->getLinkTarget($this, "layout"));
1540  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1541  } else {
1542  $mtpl->setVariable("TXT_BACK_BEGINNING", $this->lng->txt("cont_to_focus_return_crs"));
1543  include_once("./Services/Link/classes/class.ilLink.php");
1544  $mtpl->setVariable("LINK_BACK_TO_BEGINNING", ilLink::_getLink((int) $_GET["focus_return"]));
1545  }
1546 
1547  $this->ctrl->setParameter($this, "focus_id", "");
1548  $mtpl->setVariable("LINK_SHOW_CONTENT", $this->ctrl->getLinkTarget($this, "layout"));
1549  $this->ctrl->setParameter($this, "focus_id", $_GET["focus_id"]);
1550 
1551  $focus_mess = $mtpl->get();
1552  }
1553  }
1554  }
1555 
1556  // no page found
1557  if ($page_id == 0) {
1558  $cont = $this->lng->txt("cont_no_page");
1559  $this->tpl->setVariable("PAGE_CONTENT", $cont);
1560  return $cont;
1561  }
1562 
1563 
1564  $page_object_gui = $this->getLMPageGUI($page_id);
1565  $this->basicPageGuiInit($page_object_gui);
1566  $page_object = $page_object_gui->getPageObject();
1567  $page_object->buildDom();
1568  $page_object->registerOfflineHandler($this);
1569 
1570  $int_links = $page_object->getInternalLinks();
1571 
1572 
1573 
1574  $page_object_gui->setTemplateOutput(false);
1575 
1576  // Update personal desktop items
1577  $ilUser->setDesktopItemParameters($this->lm->getRefId(), $this->lm->getType(), $page_id);
1578 
1579  // Update course items
1580  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
1581  ilCourseLMHistory::_updateLastAccess($ilUser->getId(), $this->lm->getRefId(), $page_id);
1582 
1583  // read link targets
1584  $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
1585  $link_xml .= $this->getLinkTargetsXML();
1586 
1587  // get lm page object
1588  $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
1589  $lm_pg_obj->setLMId($this->lm->getId());
1590  //$pg_obj->setParentId($this->lm->getId());
1591  $page_object_gui->setLinkXML($link_xml);
1592 
1593  // determine target frames for internal links
1594  //$pg_frame = $_GET["frame"];
1595  $page_object_gui->setLinkFrame($_GET["frame"]);
1596 
1597  // page title and tracking (not for header or footer page)
1598  if ($page_id == 0 || ($page_id != $this->lm->getHeaderPage() &&
1599  $page_id != $this->lm->getFooterPage())) {
1600  $page_object_gui->setPresentationTitle(
1602  $lm_pg_obj->getId(),
1603  $this->lm->getPageHeader(),
1604  $this->lm->isActiveNumbering(),
1605  $this->lm_set->get("time_scheduled_page_activation"),
1606  false,
1607  0,
1608  $this->lang
1609  )
1610  );
1611 
1612  // track access
1613  if ($page_id != 0 && !$this->offlineMode()) {
1614  $this->getTracker()->trackAccess($page_id, $ilUser->getId());
1615  }
1616  } else {
1617  $page_object_gui->setEnabledPageFocus(false);
1618  $page_object_gui->getPageConfig()->setEnableSelfAssessment(false);
1619  }
1620 
1621  // ADDED FOR CITATION
1622  $page_object_gui->setLinkParams("ref_id=" . $this->lm->getRefId());
1623  $page_object_gui->setTemplateTargetVar("PAGE_CONTENT");
1624  $page_object_gui->setSourcecodeDownloadScript($this->getSourcecodeDownloadLink());
1625 
1626  // syntax style
1627  $this->tpl->setCurrentBlock("SyntaxStyle");
1628  if (!$this->offlineMode()) {
1629  $this->tpl->setVariable(
1630  "LOCATION_SYNTAX_STYLESHEET",
1632  );
1633  } else {
1634  $this->tpl->setVariable(
1635  "LOCATION_SYNTAX_STYLESHEET",
1636  "syntaxhighlight.css"
1637  );
1638  }
1639  $this->tpl->parseCurrentBlock();
1640 
1641 
1642  $ret = $page_object_gui->presentation($page_object_gui->getOutputMode());
1643 
1644  // process header
1645  if ($this->lm->getHeaderPage() > 0 &&
1646  $page_id != $this->lm->getHeaderPage() &&
1647  ($page_id == 0 || $page_id != $this->lm->getFooterPage())) {
1648  if (ilLMObject::_exists($this->lm->getHeaderPage())) {
1649  $head = $this->ilPage($a_page_node, $this->lm->getHeaderPage());
1650  }
1651  }
1652 
1653  // process footer
1654  if ($this->lm->getFooterPage() > 0 &&
1655  $page_id != $this->lm->getFooterPage() &&
1656  ($page_id == 0 || $page_id != $this->lm->getHeaderPage())) {
1657  if (ilLMObject::_exists($this->lm->getFooterPage())) {
1658  $foot = $this->ilPage($a_page_node, $this->lm->getFooterPage());
1659  }
1660  }
1661 
1662  // rating
1663  $rating = "";
1664  if ($this->lm->hasRatingPages() && !$this->offlineMode()) {
1665  include_once("./Services/Rating/classes/class.ilRatingGUI.php");
1666  $rating_gui = new ilRatingGUI();
1667  $rating_gui->setObject($this->lm->getId(), "lm", $page_id, "lm");
1668  $rating_gui->setYourRatingText($this->lng->txt("lm_rate_page"));
1669 
1670  /*
1671  $this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, true,
1672  "il.ExcPeerReview.saveComments(".$a_set["peer_id"].", %rating%)"));
1673  */
1674 
1675  $this->ctrl->setParameter($this, "pgid", $page_id);
1676  $this->tpl->addOnLoadCode("il.LearningModule.setRatingUrl('" .
1677  $this->ctrl->getLinkTarget($this, "updatePageRating", "", true, false) .
1678  "')");
1679  $this->ctrl->setParameter($this, "pgid", "");
1680 
1681  $rating = '<div id="ilrtrpg" style="text-align:right">' .
1682  $rating_gui->getHtml(true, true, "il.LearningModule.saveRating(%rating%);") .
1683  "</div>";
1684  }
1685 
1686  $this->tpl->setVariable("PAGE_CONTENT", $rating . $head . $focus_mess . $ret . $foot);
1687  //echo htmlentities("-".$ret."-");
1688  return $head . $focus_mess . $ret . $foot;
1689  }
1690 
1691  public function updatePageRating()
1692  {
1693  $ilUser = $this->user;
1694 
1695  $pg_id = $_GET["pgid"];
1696  if (!$this->ctrl->isAsynch() || !$pg_id) {
1697  exit();
1698  }
1699 
1700  include_once './Services/Rating/classes/class.ilRating.php';
1701  $rating = (int) $_POST["rating"];
1702  if ($rating) {
1704  $this->lm->getId(),
1705  "lm",
1706  $pg_id,
1707  "lm",
1708  $ilUser->getId(),
1709  $_POST["rating"]
1710  );
1711  } else {
1713  $this->lm->getId(),
1714  "lm",
1715  $pg_id,
1716  "lm",
1717  $ilUser->getId()
1718  );
1719  }
1720 
1721  include_once './Services/Rating/classes/class.ilRatingGUI.php';
1722  $rating = new ilRatingGUI();
1723  $rating->setObject($this->lm->getId(), "lm", $pg_id, "lm", $ilUser->getId());
1724  $rating->setYourRatingText($this->lng->txt("lm_rate_page"));
1725 
1726  echo $rating->getHtml(true, true, "il.LearningModule.saveRating(%rating%);");
1727 
1728  echo $this->tpl->getOnLoadCodeForAsynch();
1729  exit();
1730  }
1731 
1738  public function basicPageGuiInit($a_page_gui)
1739  {
1740  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
1741  $a_page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
1742  $this->lm->getStyleSheetId(),
1743  "lm"
1744  ));
1745  if (!$this->offlineMode()) {
1746  $a_page_gui->setOutputMode("presentation");
1747  $this->fill_on_load_code = true;
1748  } else {
1749  $a_page_gui->setOutputMode("offline");
1750  $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
1751  $this->fill_on_load_code = false;
1752  }
1753  if (!$this->offlineMode()) {
1754  $this->ctrl->setParameter($this, "obj_id", $this->getCurrentPageId()); // see #22403
1755  }
1756  $a_page_gui->setFileDownloadLink($this->getLink($_GET["ref_id"], "downloadFile"));
1757  if (!$this->offlineMode()) {
1758  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1759  }
1760  $a_page_gui->setFullscreenLink($this->getLink($_GET["ref_id"], "fullscreen"));
1761  }
1762 
1766  public function showPreconditionsOfPage()
1767  {
1768  $conds = ilObjContentObject::_getMissingPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId());
1769  $topchap = ilObjContentObject::_getMissingPreconditionsTopChapter($this->lm->getRefId(), $this->lm->getId(), $this->getCurrentPageId());
1770 
1771  $page_id = $this->getCurrentPageId();
1772 
1773  // content style
1774  $this->tpl->setCurrentBlock("ContentStyle");
1775  if (!$this->offlineMode()) {
1776  $this->tpl->setVariable(
1777  "LOCATION_CONTENT_STYLESHEET",
1778  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
1779  );
1780  } else {
1781  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
1782  }
1783  $this->tpl->parseCurrentBlock();
1784 
1785  $this->tpl->addBlockFile("PAGE_CONTENT", "pg_content", "tpl.page_preconditions.html", true);
1786 
1787  // list all missing preconditions
1788  include_once("./Services/Repository/classes/class.ilRepositoryExplorer.php");
1789  foreach ($conds as $cond) {
1790  include_once("./Services/Link/classes/class.ilLink.php");
1791  $obj_link = ilLink::_getLink($cond["trigger_ref_id"]);
1792  $this->tpl->setCurrentBlock("condition");
1793  $this->tpl->setVariable("VAL_ITEM", ilObject::_lookupTitle($cond["trigger_obj_id"]));
1794  $this->tpl->setVariable("LINK_ITEM", $obj_link);
1795  if ($cond["operator"] == "passed") {
1796  $cond_str = $this->lng->txt("passed");
1797  } else {
1798  $cond_str = $this->lng->txt("condition_" . $cond["operator"]);
1799  }
1800  $this->tpl->setVariable("VAL_CONDITION", $cond_str . " " . $cond["value"]);
1801  $this->tpl->parseCurrentBlock();
1802  }
1803  $this->tpl->setCurrentBlock("pg_content");
1804 
1805  $this->tpl->setVariable(
1806  "TXT_MISSING_PRECONDITIONS",
1807  sprintf(
1808  $this->lng->txt("cont_missing_preconditions"),
1809  ilLMObject::_lookupTitle($topchap)
1810  )
1811  );
1812  $this->tpl->setVariable("TXT_ITEM", $this->lng->txt("object"));
1813  $this->tpl->setVariable("TXT_CONDITION", $this->lng->txt("condition"));
1814 
1815  // output skip chapter link
1816  $parent = $this->lm_tree->getParentId($topchap);
1817  $childs = $this->lm_tree->getChildsByType($parent, "st");
1818  $next = "";
1819  $j = -2;
1820  $i = 1;
1821  foreach ($childs as $child) {
1822  if ($child["child"] == $topchap) {
1823  $j = $i;
1824  }
1825  if ($i++ == ($j + 1)) {
1826  $succ_node = $this->lm_tree->fetchSuccessorNode($child["child"], "pg");
1827  }
1828  }
1829  if ($succ_node != "") {
1830  $framestr = (!empty($_GET["frame"]))
1831  ? "frame=" . $_GET["frame"] . "&"
1832  : "";
1833 
1834  $showViewInFrameset = true;
1835  $link = "<br /><a href=\"" .
1836  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]) .
1837  "\">" . $this->lng->txt("cont_skip_chapter") . "</a>";
1838  $this->tpl->setVariable("LINK_SKIP_CHAPTER", $link);
1839  }
1840 
1841  $this->tpl->parseCurrentBlock();
1842  }
1843 
1847  public function getLinkXML($a_int_links, $a_layoutframes)
1848  {
1849  $ilCtrl = $this->ctrl;
1850 
1851  // Determine whether the view of a learning resource should
1852  // be shown in the frameset of ilias, or in a separate window.
1853  $showViewInFrameset = true;
1854 
1855  if ($a_layoutframes == "") {
1856  $a_layoutframes = array();
1857  }
1858  $link_info = "<IntLinkInfos>";
1859  foreach ($a_int_links as $int_link) {
1860  $target = $int_link["Target"];
1861  if (substr($target, 0, 4) == "il__") {
1862  $target_arr = explode("_", $target);
1863  $target_id = $target_arr[count($target_arr) - 1];
1864  $type = $int_link["Type"];
1865  $targetframe = ($int_link["TargetFrame"] != "")
1866  ? $int_link["TargetFrame"]
1867  : "None";
1868 
1869  // anchor
1870  $anc = $anc_add = "";
1871  if ($int_link["Anchor"] != "") {
1872  $anc = $int_link["Anchor"];
1873  $anc_add = "_" . rawurlencode($int_link["Anchor"]);
1874  }
1875  $lcontent = "";
1876  switch ($type) {
1877  case "PageObject":
1878  case "StructureObject":
1880  if ($lm_id == $this->lm->getId() ||
1881  ($targetframe != "None" && $targetframe != "New")) {
1882  $ltarget = $a_layoutframes[$targetframe]["Frame"];
1883  //$nframe = ($ltarget == "")
1884  // ? $_GET["frame"]
1885  // : $ltarget;
1886  $nframe = ($ltarget == "")
1887  ? ""
1888  : $ltarget;
1889  if ($ltarget == "") {
1890  if ($showViewInFrameset) {
1891  $ltarget = "_parent";
1892  } else {
1893  $ltarget = "_top";
1894  }
1895  }
1896  // scorm always in 1window view and link target
1897  // is always same frame
1898  if ($this->getExportFormat() == "scorm" &&
1899  $this->offlineMode()) {
1900  $ltarget = "";
1901  }
1902  $href =
1903  $this->getLink(
1904  $_GET["ref_id"],
1905  "layout",
1906  $target_id,
1907  $nframe,
1908  $type,
1909  "append",
1910  $anc
1911  );
1912  if ($lm_id == "") {
1913  $href = "";
1914  }
1915  } else {
1916  if (!$this->offlineMode()) {
1917  if ($type == "PageObject") {
1918  $href = "./goto.php?target=pg_" . $target_id . $anc_add;
1919  } else {
1920  $href = "./goto.php?target=st_" . $target_id;
1921  }
1922  } else {
1923  if ($type == "PageObject") {
1924  $href = ILIAS_HTTP_PATH . "/goto.php?target=pg_" . $target_id . $anc_add . "&amp;client_id=" . CLIENT_ID;
1925  } else {
1926  $href = ILIAS_HTTP_PATH . "/goto.php?target=st_" . $target_id . "&amp;client_id=" . CLIENT_ID;
1927  }
1928  }
1929  if ($targetframe != "New") {
1930  $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
1931  } else {
1932  $ltarget = "_blank";
1933  }
1934  }
1935  break;
1936 
1937  case "GlossaryItem":
1938  if ($targetframe == "None") {
1939  $targetframe = "Glossary";
1940  }
1941  $ltarget = $a_layoutframes[$targetframe]["Frame"];
1942  $nframe = ($ltarget == "")
1943  ? $_GET["frame"]
1944  : $ltarget;
1945  $href =
1946  $this->getLink($_GET["ref_id"], $a_cmd = "glossary", $target_id, $nframe, $type);
1947  break;
1948 
1949  case "MediaObject":
1950  $ltarget = $a_layoutframes[$targetframe]["Frame"];
1951  $nframe = ($ltarget == "")
1952  ? $_GET["frame"]
1953  : $ltarget;
1954  $href =
1955  $this->getLink($_GET["ref_id"], $a_cmd = "media", $target_id, $nframe, $type);
1956  break;
1957 
1958  case "RepositoryItem":
1959  $obj_type = ilObject::_lookupType($target_id, true);
1961  if (!$this->offlineMode()) {
1962  $href = "./goto.php?target=" . $obj_type . "_" . $target_id;
1963  } else {
1964  $href = ILIAS_HTTP_PATH . "/goto.php?target=" . $obj_type . "_" . $target_id . "&amp;client_id=" . CLIENT_ID;
1965  }
1966  $ltarget = ilFrameTargetInfo::_getFrame("MainContent");
1967  break;
1968 
1969  case "WikiPage":
1970  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
1972  break;
1973 
1974  case "File":
1975  if (!$this->offlineMode()) {
1976  $ilCtrl->setParameter($this, "obj_id", $this->getCurrentPageId());
1977  $ilCtrl->setParameter($this, "file_id", "il__file_" . $target_id);
1978  $href = $ilCtrl->getLinkTarget($this, "downloadFile");
1979  $ilCtrl->setParameter($this, "file_id", "");
1980  $ilCtrl->setParameter($this, "obj_id", $_GET["obj_id"]);
1981  }
1982  break;
1983 
1984  case "User":
1985  $obj_type = ilObject::_lookupType($target_id);
1986  if ($obj_type == "usr") {
1987  include_once("./Services/User/classes/class.ilUserUtil.php");
1988  $back = $this->ctrl->getLinkTarget($this, "layout");
1989  //var_dump($back); exit;
1990  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", $target_id);
1991  $this->ctrl->setParameterByClass(
1992  "ilpublicuserprofilegui",
1993  "back_url",
1994  rawurlencode($back)
1995  );
1996  $href = "";
1997  include_once("./Services/User/classes/class.ilUserUtil.php");
1999  $href = $this->ctrl->getLinkTargetByClass("ilpublicuserprofilegui", "getHTML");
2000  }
2001  $this->ctrl->setParameterByClass("ilpublicuserprofilegui", "user_id", "");
2002  $lcontent = ilUserUtil::getNamePresentation($target_id, false, false);
2003  }
2004  break;
2005 
2006  }
2007 
2008  $anc_par = 'Anchor="' . $anc . '"';
2009 
2010  if ($href != "") {
2011  $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " .
2012  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" LinkContent=\"$lcontent\" $anc_par/>";
2013  }
2014 
2015  // set equal link info for glossary links of target "None" and "Glossary"
2016  /*
2017  if ($targetframe=="None" && $type=="GlossaryItem")
2018  {
2019  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
2020  "TargetFrame=\"Glossary\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
2021  }*/
2022  }
2023  }
2024  $link_info .= "</IntLinkInfos>";
2025  return $link_info;
2026  }
2027 
2031  public function getLinkTargetsXML()
2032  {
2033  $link_info = "<LinkTargets>";
2034  foreach ($this->getLayoutLinkTargets() as $k => $t) {
2035  $link_info .= "<LinkTarget TargetFrame=\"" . $t["Type"] . "\" LinkTarget=\"" . $t["Frame"] . "\" OnClick=\"" . $t["OnClick"] . "\" />";
2036  }
2037  $link_info .= "</LinkTargets>";
2038  return $link_info;
2039  }
2040 
2044  public function ilGlossary()
2045  {
2046  $ilCtrl = $this->ctrl;
2047 
2048  require_once("./Modules/Glossary/classes/class.ilGlossaryTermGUI.php");
2049  $term_gui = new ilGlossaryTermGUI($_GET["obj_id"]);
2050 
2051  // content style
2052  $this->tpl->setCurrentBlock("ContentStyle");
2053  if (!$this->offlineMode()) {
2054  $this->tpl->setVariable(
2055  "LOCATION_CONTENT_STYLESHEET",
2056  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
2057  );
2058  } else {
2059  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2060  }
2061  $this->tpl->parseCurrentBlock();
2062 
2063  // syntax style
2064  $this->tpl->setCurrentBlock("SyntaxStyle");
2065 
2066  if (!$this->offlineMode()) {
2067  $this->tpl->setVariable(
2068  "LOCATION_SYNTAX_STYLESHEET",
2070  );
2071  } else {
2072  $this->tpl->setVariable(
2073  "LOCATION_SYNTAX_STYLESHEET",
2074  "syntaxhighlight.css"
2075  );
2076  }
2077  $this->tpl->parseCurrentBlock();
2078 
2079  $int_links = $term_gui->getInternalLinks();
2080  $link_xml = $this->getLinkXML($int_links, $this->getLayoutLinkTargets());
2081  $link_xml .= $this->getLinkTargetsXML();
2082  $term_gui->setLinkXML($link_xml);
2083 
2084  $term_gui->setOfflineDirectory($this->getOfflineDirectory());
2085  if (!$this->offlineMode()) {
2086  $ilCtrl->setParameter($this, "pg_type", "glo");
2087  }
2088  $term_gui->output($this->offlineMode(), $this->tpl);
2089 
2090 
2091 
2092  if (!$this->offlineMode()) {
2093  $ilCtrl->setParameter($this, "pg_type", "");
2094  }
2095  }
2096 
2100  public function ilMedia()
2101  {
2102  $ilUser = $this->user;
2103 
2104  $this->tpl->setCurrentBlock("ContentStyle");
2105  if (!$this->offlineMode()) {
2106  $this->tpl->setVariable(
2107  "LOCATION_CONTENT_STYLESHEET",
2108  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
2109  );
2110  } else {
2111  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2112  }
2113  $this->tpl->parseCurrentBlock();
2114 
2115  $this->renderPageTitle();
2116 
2117  // set style sheets
2118  if (!$this->offlineMode()) {
2119  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2120  } else {
2121  $style_name = $ilUser->getPref("style") . ".css";
2122  ;
2123  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
2124  }
2125 
2126  $this->tpl->setCurrentBlock("ilMedia");
2127 
2128  //$int_links = $page_object->getInternalLinks();
2129  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
2130  $link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
2131  $link_xml .= $this->getLinkTargetsXML();
2132  //echo "<br><br>".htmlentities($link_xml);
2133  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2134  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
2135  if (!empty($_GET["pg_id"])) {
2136  require_once("./Modules/LearningModule/classes/class.ilLMPage.php");
2137  $pg_obj = $this->getLMPage($_GET["pg_id"]);
2138  $pg_obj->buildDom();
2139 
2140  $xml = "<dummy>";
2141  // todo: we get always the first alias now (problem if mob is used multiple
2142  // times in page)
2143  $xml .= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2144  $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
2145  $xml .= $link_xml;
2146  $xml .= "</dummy>";
2147  } else {
2148  $xml = "<dummy>";
2149  // todo: we get always the first alias now (problem if mob is used multiple
2150  // times in page)
2151  $xml .= $media_obj->getXML(IL_MODE_ALIAS);
2152  $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
2153  $xml .= $link_xml;
2154  $xml .= "</dummy>";
2155  }
2156 
2157  //echo htmlentities($xml); exit;
2158 
2159  // todo: utf-header should be set globally
2160  //header('Content-type: text/html; charset=UTF-8');
2161 
2162  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2163  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2164  $xh = xslt_create();
2165 
2166  //echo "<b>XML:</b>".htmlentities($xml);
2167  // determine target frames for internal links
2168  //$pg_frame = $_GET["frame"];
2169  if (!$this->offlineMode()) {
2170  $wb_path = ilUtil::getWebspaceDir("output") . "/";
2171  } else {
2172  $wb_path = "";
2173  }
2174 
2175  $mode = ($_GET["cmd"] == "fullscreen")
2176  ? "fullscreen"
2177  : "media";
2178  $enlarge_path = ilUtil::getImagePath("enlarge.svg", false, "output", $this->offlineMode());
2179  $fullscreen_link =
2180  $this->getLink($this->lm->getRefId(), "fullscreen");
2181  $params = array('mode' => $mode, 'enlarge_path' => $enlarge_path,
2182  'link_params' => "ref_id=" . $this->lm->getRefId(),'fullscreen_link' => $fullscreen_link,
2183  'ref_id' => $this->lm->getRefId(), 'pg_frame' => $pg_frame, 'webspace_path' => $wb_path);
2184  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
2185  echo xslt_error($xh);
2186  xslt_free($xh);
2187 
2188  // unmask user html
2189  $this->tpl->setVariable("MEDIA_CONTENT", $output);
2190 
2191  // add js
2192  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
2194  }
2195 
2199  public function ilJavaScript($a_inline = "", $a_file = "", $a_location = "")
2200  {
2201  if ($a_inline != "") {
2202  $js_tpl = new ilTemplate($a_inline, true, false, $a_location);
2203  $js = $js_tpl->get();
2204  $this->tpl->setVariable("INLINE_JS", $js);
2205  }
2206  }
2207 
2214  public function getSuccessorPage()
2215  {
2216  $ilUser = $this->user;
2217 
2218  $page_id = $this->getCurrentPageId();
2219 
2220  if (empty($page_id)) {
2221  return 0;
2222  }
2223 
2224  // determine successor page_id
2225  $found = false;
2226 
2227  // empty chapter
2228  if ($this->chapter_has_no_active_page &&
2229  ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
2230  $c_id = $_GET["obj_id"];
2231  } else {
2232  if ($this->deactivated_page) {
2233  $c_id = $_GET["obj_id"];
2234  } else {
2235  $c_id = $page_id;
2236  }
2237  }
2238  while (!$found) {
2239  $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
2240  $c_id = $succ_node["obj_id"];
2241 
2242  $active = ilLMPage::_lookupActive(
2243  $c_id,
2244  $this->lm->getType(),
2245  $this->lm_set->get("time_scheduled_page_activation")
2246  );
2247 
2248  if ($succ_node["obj_id"] > 0 &&
2249  $ilUser->getId() == ANONYMOUS_USER_ID &&
2250  ($this->lm->getPublicAccessMode() == "selected" &&
2251  !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
2252  $found = false;
2253  } elseif ($succ_node["obj_id"] > 0 && !$active) {
2254  // look, whether activation data should be shown
2255  $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
2256  if ($act_data["show_activation_info"] &&
2257  (ilUtil::now() < $act_data["activation_start"])) {
2258  $found = true;
2259  } else {
2260  $found = false;
2261  }
2262  } else {
2263  $found = true;
2264  }
2265  }
2266 
2267  if ($found) {
2268  return $succ_node["obj_id"];
2269  }
2270  return 0;
2271  }
2272 
2273 
2278  public function ilLMNavigation()
2279  {
2280  $ilUser = $this->user;
2281 
2282  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
2283 
2284  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
2285 
2286  $page_id = $this->getCurrentPageId();
2287 
2288  if (empty($page_id)) {
2289  return;
2290  }
2291 
2292  // process navigation for free page
2293  if (!$this->lm_tree->isInTree($page_id)) {
2294  if ($this->offlineMode() || $_GET["back_pg"] == "") {
2295  return;
2296  }
2297  $limpos = strpos($_GET["back_pg"], ":");
2298  if ($limpos > 0) {
2299  $back_pg = substr($_GET["back_pg"], 0, $limpos);
2300  } else {
2301  $back_pg = $_GET["back_pg"];
2302  }
2303  if (!$this->lm->cleanFrames()) {
2304  $back_href =
2305  $this->getLink(
2306  $this->lm->getRefId(),
2307  "layout",
2308  $back_pg,
2309  $_GET["frame"],
2310  "",
2311  "reduce"
2312  );
2313  $back_target = "";
2314  } else {
2315  $back_href =
2316  $this->getLink(
2317  $this->lm->getRefId(),
2318  "layout",
2319  $back_pg,
2320  "",
2321  "",
2322  "reduce"
2323  );
2324  $back_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
2325  }
2326  $back_img =
2327  ilUtil::getImagePath("nav_arr2_L.png", false, "output", $this->offlineMode());
2328  $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
2329  $this->tpl->setVariable("IMG_PREV", $back_img);
2330  $this->tpl->setVariable("HREF_PREV", $back_href);
2331  $this->tpl->setVariable("FRAME_PREV", $back_target);
2332  $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
2333  $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
2334  $this->tpl->setVariable(
2335  "PREV_ACC_KEY",
2337  );
2338  $this->tpl->setVariable("SPACER_PREV", $this->offlineMode()
2339  ? "images/spacer.png"
2340  : ilUtil::getImagePath("spacer.png"));
2341  $this->tpl->parseCurrentBlock();
2342  $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
2343  $this->tpl->setVariable("IMG_PREV2", $back_img);
2344  $this->tpl->setVariable("HREF_PREV2", $back_href);
2345  $this->tpl->setVariable("FRAME_PREV2", $back_target);
2346  $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
2347  $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
2348  $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode()
2349  ? "images/spacer.png"
2350  : ilUtil::getImagePath("spacer.png"));
2351  $this->tpl->parseCurrentBlock();
2352  return;
2353  }
2354 
2355  // determine successor page_id
2356  $found = false;
2357 
2358  // empty chapter
2359  if ($this->chapter_has_no_active_page &&
2360  ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
2361  $c_id = $_GET["obj_id"];
2362  } else {
2363  if ($this->deactivated_page) {
2364  $c_id = $_GET["obj_id"];
2365  } else {
2366  $c_id = $page_id;
2367  }
2368  }
2369  while (!$found) {
2370  $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
2371  $c_id = $succ_node["obj_id"];
2372 
2373  $active = ilLMPage::_lookupActive(
2374  $c_id,
2375  $this->lm->getType(),
2376  $this->lm_set->get("time_scheduled_page_activation")
2377  );
2378 
2379  if ($succ_node["obj_id"] > 0 &&
2380  $ilUser->getId() == ANONYMOUS_USER_ID &&
2381  ($this->lm->getPublicAccessMode() == "selected" &&
2382  !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
2383  $found = false;
2384  } elseif ($succ_node["obj_id"] > 0 && !$active) {
2385  // look, whether activation data should be shown
2386  $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
2387  if ($act_data["show_activation_info"] &&
2388  (ilUtil::now() < $act_data["activation_start"])) {
2389  $found = true;
2390  } else {
2391  $found = false;
2392  }
2393  } else {
2394  $found = true;
2395  }
2396  }
2397 
2398  $succ_str = ($succ_node !== false)
2399  ? " -> " . $succ_node["obj_id"] . "_" . $succ_node["type"]
2400  : "";
2401 
2402  // determine predecessor page id
2403  $found = false;
2404  if ($this->deactivated_page) {
2405  $c_id = $_GET["obj_id"];
2406  } else {
2407  $c_id = $page_id;
2408  }
2409  while (!$found) {
2410  $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
2411  $c_id = $pre_node["obj_id"];
2412  $active = ilLMPage::_lookupActive(
2413  $c_id,
2414  $this->lm->getType(),
2415  $this->lm_set->get("time_scheduled_page_activation")
2416  );
2417  if ($pre_node["obj_id"] > 0 &&
2418  $ilUser->getId() == ANONYMOUS_USER_ID &&
2419  ($this->lm->getPublicAccessMode() == "selected" &&
2420  !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
2421  $found = false;
2422  } elseif ($pre_node["obj_id"] > 0 && !$active) {
2423  // look, whether activation data should be shown
2424  $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
2425  if ($act_data["show_activation_info"] &&
2426  (ilUtil::now() < $act_data["activation_start"])) {
2427  $found = true;
2428  } else {
2429  $found = false;
2430  }
2431  } else {
2432  $found = true;
2433  }
2434  }
2435 
2436  $pre_str = ($pre_node !== false)
2437  ? $pre_node["obj_id"] . "_" . $pre_node["type"] . " -> "
2438  : "";
2439 
2440  // determine target frame
2441  $framestr = (!empty($_GET["frame"]))
2442  ? "frame=" . $_GET["frame"] . "&"
2443  : "";
2444 
2445 
2446  // Determine whether the view of a learning resource should
2447  // be shown in the frameset of ilias, or in a separate window.
2448  $showViewInFrameset = true;
2449 
2450  if ($pre_node != "") {
2451  // get presentation title
2453  $pre_node["obj_id"],
2454  $this->lm->getPageHeader(),
2455  $this->lm->isActiveNumbering(),
2456  $this->lm_set->get("time_scheduled_page_activation"),
2457  false,
2458  0,
2459  $this->lang,
2460  true
2461  );
2462  $prev_title = ilUtil::shortenText($prev_title, 50, true);
2463  $prev_img =
2464  ilUtil::getImagePath("nav_arr_L.png", false, "output", $this->offlineMode());
2465 
2466  if (!$this->lm->cleanFrames()) {
2467  $prev_href =
2468  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
2469  $prev_target = "";
2470  } elseif ($showViewInFrameset && !$this->offlineMode()) {
2471  $prev_href =
2472  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
2473  $prev_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
2474  } else {
2475  $prev_href =
2476  $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
2477  $prev_target = 'target="_top" ';
2478  }
2479 
2480  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
2481  ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
2482  $output = $this->lng->txt("msg_page_not_public");
2483  }
2484 
2485  $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
2486  $this->tpl->setVariable("IMG_PREV", $prev_img);
2487  $this->tpl->setVariable("HREF_PREV", $prev_href);
2488  $this->tpl->setVariable("FRAME_PREV", $prev_target);
2489  $this->tpl->setVariable("TXT_PREV", $prev_title);
2490  $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
2491  $this->tpl->setVariable("SPACER_PREV", $this->offlineMode()
2492  ? "images/spacer.png"
2493  : ilUtil::getImagePath("spacer.png"));
2494  $this->tpl->setVariable(
2495  "PREV_ACC_KEY",
2497  );
2498  $this->tpl->parseCurrentBlock();
2499  $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
2500  $this->tpl->setVariable("IMG_PREV2", $prev_img);
2501  $this->tpl->setVariable("HREF_PREV2", $prev_href);
2502  $this->tpl->setVariable("FRAME_PREV2", $prev_target);
2503  $this->tpl->setVariable("TXT_PREV2", $prev_title);
2504  $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
2505  $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode()
2506  ? "images/spacer.png"
2507  : ilUtil::getImagePath("spacer.png"));
2508  $this->tpl->parseCurrentBlock();
2509  }
2510  if ($succ_node != "") {
2511  // get presentation title
2513  $succ_node["obj_id"],
2514  $this->lm->getPageHeader(),
2515  $this->lm->isActiveNumbering(),
2516  $this->lm_set->get("time_scheduled_page_activation"),
2517  false,
2518  0,
2519  $this->lang,
2520  true
2521  );
2522  $succ_title = ilUtil::shortenText($succ_title, 50, true);
2523  $succ_img =
2524  ilUtil::getImagePath("nav_arr_R.png", false, "output", $this->offlineMode());
2525  if (!$this->lm->cleanFrames()) {
2526  $succ_href =
2527  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
2528  $succ_target = "";
2529  } elseif ($showViewInFrameset && !$this->offlineMode()) {
2530  $succ_href =
2531  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
2532  $succ_target = ' target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
2533  } else {
2534  $succ_href =
2535  $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
2536  $succ_target = ' target="_top" ';
2537  }
2538 
2539  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
2540  ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
2541  $output = $this->lng->txt("msg_page_not_public");
2542  }
2543 
2544  $this->tpl->setCurrentBlock("ilLMNavigation_Next");
2545  $this->tpl->setVariable("IMG_SUCC", $succ_img);
2546  $this->tpl->setVariable("HREF_SUCC", $succ_href);
2547  $this->tpl->setVariable("FRAME_SUCC", $succ_target);
2548  $this->tpl->setVariable("TXT_SUCC", $succ_title);
2549  $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
2550  $this->tpl->setVariable("SPACER_SUCC", $this->offlineMode()
2551  ? "images/spacer.png"
2552  : ilUtil::getImagePath("spacer.png"));
2553  $this->tpl->setVariable(
2554  "NEXT_ACC_KEY",
2556  );
2557  $this->tpl->parseCurrentBlock();
2558  $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
2559  $this->tpl->setVariable("IMG_SUCC2", $succ_img);
2560  $this->tpl->setVariable("HREF_SUCC2", $succ_href);
2561  $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
2562  $this->tpl->setVariable("TXT_SUCC2", $succ_title);
2563  $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
2564  $this->tpl->setVariable("SPACER_SUCC2", $this->offlineMode()
2565  ? "images/spacer.png"
2566  : ilUtil::getImagePath("spacer.png"));
2567  $this->tpl->parseCurrentBlock();
2568 
2569  // check if successor page is not restricted
2570  if (!$this->offlineMode()) {
2571  if ($this->lm->getRestrictForwardNavigation()) {
2572  if ($this->getTracker()->hasPredIncorrectAnswers($succ_node["obj_id"])) {
2573  $this->tpl->addOnLoadCode("$('.ilc_page_rnav_RightNavigation').addClass('ilNoDisplay');");
2574  }
2575  }
2576  }
2577  }
2578  }
2579 
2580 
2581  public function processNodes(&$a_content, &$a_node)
2582  {
2583  $child_nodes = $a_node->child_nodes();
2584  foreach ($child_nodes as $child) {
2585  if ($child->node_name() == "ilFrame") {
2586  $attributes = $this->attrib2arr($child->attributes());
2587  // node is frameset, if it has cols or rows attribute
2588  if ((!empty($attributes["rows"])) || (!empty($attrubtes["cols"]))) {
2589  // if framset has name, another http request is necessary
2590  // (html framesets don't have names, so we need a wrapper frame)
2591  if (!empty($attributes["name"])) {
2592  unset($attributes["template"]);
2593  unset($attributes["template_location"]);
2594  $attributes["src"] =
2595  $this->getLink(
2596  $this->lm->getRefId(),
2597  "layout",
2598  $_GET["obj_id"],
2599  $attributes["name"],
2600  "",
2601  "keep",
2602  "",
2603  $_GET["srcstring"]
2604  );
2605  $attributes["title"] = $this->lng->txt("cont_frame_" . $attributes["name"]);
2606  $a_content .= $this->buildTag("", "frame", $attributes);
2607  $this->frames[$attributes["name"]] = $attributes["name"];
2608  //echo "<br>processNodes:add1 ".$attributes["name"];
2609  } else { // ok, no name means that we can easily output the frameset tag
2610  $a_content .= $this->buildTag("start", "frameset", $attributes);
2611  $this->processNodes($a_content, $child);
2612  $a_content .= $this->buildTag("end", "frameset");
2613  }
2614  } else { // frame with
2615  unset($attributes["template"]);
2616  unset($attributes["template_location"]);
2617  $attributes["src"] =
2618  $this->getLink(
2619  $this->lm->getRefId(),
2620  "layout",
2621  $_GET["obj_id"],
2622  $attributes["name"],
2623  "",
2624  "keep",
2625  "",
2626  $_GET["srcstring"]
2627  );
2628  $attributes["title"] = $this->lng->txt("cont_frame_" . $attributes["name"]);
2629  if ($attributes["name"] == "toc") {
2630  $attributes["src"] .= "#" . $_GET["obj_id"];
2631  } else {
2632  // Handle Anchors
2633  if ($_GET["anchor"] != "") {
2634  $attributes["src"] .= "#" . rawurlencode($_GET["anchor"]);
2635  }
2636  }
2637  $a_content .= $this->buildTag("", "frame", $attributes);
2638  $this->frames[$attributes["name"]] = $attributes["name"];
2639  }
2640  }
2641  }
2642  }
2643 
2651  public function buildTag($type, $name, $attr = "")
2652  {
2653  $tag = "<";
2654 
2655  if ($type == "end") {
2656  $tag .= "/";
2657  }
2658 
2659  $tag .= $name;
2660 
2661  if (is_array($attr)) {
2662  foreach ($attr as $k => $v) {
2663  $tag .= " " . $k . "=\"$v\"";
2664  }
2665  }
2666 
2667  if ($type == "") {
2668  $tag .= "/";
2669  }
2670 
2671  $tag .= ">\n";
2672 
2673  return $tag;
2674  }
2675 
2676 
2680  public function showTableOfContents()
2681  {
2682  $ilUser = $this->user;
2683 
2684  if (!$this->lm->isActiveTOC() || !$this->lm->isActiveLMMenu()) {
2685  return;
2686  }
2687 
2688  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
2689  $this->tpl->setCurrentBlock("ContentStyle");
2690  if (!$this->offlineMode()) {
2691  $this->tpl->setVariable(
2692  "LOCATION_CONTENT_STYLESHEET",
2693  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
2694  );
2695  } else {
2696  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2697  }
2698  $this->tpl->parseCurrentBlock();
2699 
2700  $this->renderPageTitle();
2701 
2702  // set style sheets
2703  if (!$this->offlineMode()) {
2704  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2705  } else {
2706  $style_name = $ilUser->getPref("style") . ".css";
2707  ;
2708  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
2709  }
2710 
2711  //$this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_toc.html", true);
2712  //var_dump($GLOBALS["tpl"]); echo "<br><br>";
2713  //exit;
2714  $this->tpl->getStandardTemplate();
2715  $this->ilLocator(true);
2716 
2717  $a_global_tabs = !$this->offlineMode();
2718 
2719  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu(
2720  $this->offlineMode(),
2721  $this->getExportFormat(),
2722  "toc",
2723  $a_global_tabs,
2724  false,
2725  0,
2726  $this->lang,
2728  ));
2729 
2730  // set title header
2731  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
2732  $this->tpl->setTitle($this->getLMPresentationTitle());
2733  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
2734 
2735  include_once("./Modules/LearningModule/classes/class.ilLMTableOfContentsExplorerGUI.php");
2736  $exp = new ilLMTableOfContentsExplorerGUI($this, "showTableOfContents", $this, $this->lang, $this->export_all_languages);
2737  $exp->setMainTemplate($this->tpl);
2738  $exp->setTracker($this->getTracker());
2739  if (!$exp->handleCommand()) {
2740  // determine highlighted and force open nodes
2741  $page_id = $this->getCurrentPageId();
2742  if ($this->deactivated_page) {
2743  $page_id = $_GET["obj_id"];
2744  }
2745 
2746  // highlight current node
2747  if (!$this->offlineMode()) {
2748  // empty chapter
2749  if ($this->chapter_has_no_active_page &&
2750  ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
2751  $exp->setHighlightNode($_GET["obj_id"]);
2752  } else {
2753  if ($this->lm->getTOCMode() == "pages") {
2754  if ($this->deactivated_page) {
2755  $exp->setHighlightNode($_GET["obj_id"]);
2756  } else {
2757  $exp->setHighlightNode($page_id);
2758  }
2759  } else {
2760  $exp->setHighlightNode($this->lm_tree->getParentId($page_id));
2761  }
2762  }
2763  }
2764  if ($this->offlineMode()) {
2765  $exp->setOfflineMode(true);
2766  }
2767  // var_dump($exp->getHTML()."_");
2768  $this->tpl->setVariable("ADM_CONTENT", $exp->getHTML());
2769  }
2770  if ($this->offlineMode()) {
2771  // reset standard css files
2772  $this->tpl->resetJavascript();
2773  $this->tpl->resetCss();
2774  $this->tpl->setBodyClass("ilLMNoMenu");
2775 
2776  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
2778  if ($f["type"] == "js") {
2779  $this->tpl->addJavascript($f["target"]);
2780  }
2781  if ($f["type"] == "css") {
2782  $this->tpl->addCSS($f["target"]);
2783  }
2784  }
2785  $this->tpl->fillJavaScriptFiles(true);
2786  $this->tpl->fillOnLoadCode();
2787  //var_dump(htmlentities($this->tpl->get())); exit;
2788  return $this->tpl->get();
2789  } else {
2790  $this->tpl->show();
2791  }
2792  }
2793 
2794 
2800  public function infoScreen()
2801  {
2802  $this->ctrl->setCmd("showSummary");
2803  $this->ctrl->setCmdClass("ilinfoscreengui");
2804  $this->outputInfoScreen();
2805  }
2806 
2810  public function showInfoScreen()
2811  {
2812  $this->outputInfoScreen(true);
2813  }
2814 
2815  protected function initScreenHead($a_active_tab = "info")
2816  {
2817  $ilAccess = $this->access;
2818  $ilLocator = $this->locator;
2819  $ilUser = $this->user;
2820 
2821  $this->renderPageTitle();
2822 
2823  // set style sheets
2824  if (!$this->offlineMode()) {
2825  $this->tpl->setStyleSheetLocation(ilUtil::getStyleSheetLocation());
2826  } else {
2827  $style_name = $ilUser->getPref("style") . ".css";
2828  ;
2829  $this->tpl->setStyleSheetLocation("./" . $style_name);
2830  }
2831 
2832  $this->tpl->getStandardTemplate();
2833  $this->tpl->setTitle($this->getLMPresentationTitle());
2834  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
2835 
2836  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu(
2837  $this->offlineMode(),
2838  $this->getExportFormat(),
2839  $a_active_tab,
2840  true,
2841  false,
2842  0,
2843  $this->lang,
2845  ));
2846 
2847  // Full locator, if read permission is given
2848  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
2849  $this->ilLocator(true);
2850  } else {
2851  $ilLocator->addRepositoryItems();
2852  $this->tpl->setLocator();
2853  }
2854  }
2855 
2859  public function outputInfoScreen($a_standard_locator = false)
2860  {
2861  $ilAccess = $this->access;
2862 
2863  $this->initScreenHead();
2864 
2865  $this->lng->loadLanguageModule("meta");
2866 
2867  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2868 
2869  $info = new ilInfoScreenGUI($this->lm_gui);
2870  $info->enablePrivateNotes();
2871  $info->enableLearningProgress();
2872 
2873  $info->enableNews();
2874  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
2875  $news_set = new ilSetting("news");
2876  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
2877 
2878  $info->enableNewsEditing();
2879 
2880  if ($enable_internal_rss) {
2881  $info->setBlockProperty("news", "settings", true);
2882  }
2883  }
2884 
2885  // add read / back button
2886  /*
2887  if ($ilAccess->checkAccess("read", "", $_GET["ref_id"]))
2888  {
2889  if ($_GET["obj_id"] > 0)
2890  {
2891  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
2892  $info->addButton($this->lng->txt("back"),
2893  $this->ctrl->getLinkTarget($this, "layout"));
2894  }
2895  else
2896  {
2897  $info->addButton($this->lng->txt("view"),
2898  $this->ctrl->getLinkTarget($this, "layout"));
2899  }
2900  }*/
2901 
2902  // show standard meta data section
2903  $info->addMetaDataSections($this->lm->getId(), 0, $this->lm->getType());
2904 
2905  if ($this->offlineMode()) {
2906  $this->tpl->setContent($info->getHTML());
2907  return $this->tpl->get();
2908  } else {
2909  // forward the command
2910  $this->ctrl->forwardCommand($info);
2911  //$this->tpl->setContent("aa");
2912  $this->tpl->show();
2913  }
2914  }
2915 
2919  public function showPrintViewSelection()
2920  {
2921  $ilUser = $this->user;
2922  $lng = $this->lng;
2923 
2924  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
2925  if (!$this->lm->isActivePrintView() || !$this->lm->isActiveLMMenu()) {
2926  return;
2927  }
2928 
2929  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
2930 
2931  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
2932  $this->tpl->setCurrentBlock("ContentStyle");
2933  if (!$this->offlineMode()) {
2934  $this->tpl->setVariable(
2935  "LOCATION_CONTENT_STYLESHEET",
2936  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
2937  );
2938  } else {
2939  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
2940  }
2941  $this->tpl->parseCurrentBlock();
2942 
2943  $this->renderPageTitle();
2944  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2945  $this->tpl->getStandardTemplate();
2946 
2947  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu(
2948  $this->offlineMode(),
2949  $this->getExportFormat(),
2950  "print",
2951  true,
2952  false,
2953  0,
2954  $this->lang,
2956  ));
2957 
2958  $this->ilLocator(true);
2959  $this->tpl->addBlockFile(
2960  "ADM_CONTENT",
2961  "adm_content",
2962  "tpl.lm_print_selection.html",
2963  "Modules/LearningModule"
2964  );
2965 
2966  // set title header
2967  $this->tpl->setTitle($this->getLMPresentationTitle());
2968  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
2969 
2970  /*$this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
2971  $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2972  $this->tpl->setVariable("LINK_BACK",
2973  $this->ctrl->getLinkTargetByClass("illmpresentationgui", ""));*/
2974 
2975  $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $_GET["obj_id"]);
2976  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormaction($this));
2977 
2978  $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
2980 
2981  if (!is_array($_POST["item"])) {
2982  if ($_GET["obj_id"] != "") {
2983  $_POST["item"][$_GET["obj_id"]] = "y";
2984  } else {
2985  $_POST["item"][1] = "y";
2986  }
2987  }
2988 
2989  $this->initPrintViewSelectionForm();
2990 
2991  foreach ($nodes as $node) {
2992 
2993  // check page activation
2994  $active = ilLMPage::_lookupActive(
2995  $node["obj_id"],
2996  $this->lm->getType(),
2997  $this->lm_set->get("time_scheduled_page_activation")
2998  );
2999 
3000  if ($node["type"] == "pg" &&
3001  !$active) {
3002  continue;
3003  }
3004 
3005  $text = $img_scr = $img_alt = "";
3006  $disabled = false;
3007  $checked = false;
3008 
3009  switch ($node["type"]) {
3010  // page
3011  case "pg":
3012  $text =
3014  $node["obj_id"],
3015  $this->lm->getPageHeader(),
3016  $this->lm->isActiveNumbering(),
3017  $this->lm_set->get("time_scheduled_page_activation"),
3018  false,
3019  0,
3020  $this->lang
3021  );
3022 
3023  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3024  $this->lm_gui->object->getPublicAccessMode() == "selected") {
3025  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
3026  $disabled = true;
3027  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
3028  }
3029  }
3030  $img_src = ilUtil::getImagePath("icon_pg.svg");
3031  $img_alt = $lng->txt("icon") . " " . $lng->txt("pg");
3032  break;
3033 
3034  // learning module
3035  case "du":
3036  $text = $this->getLMPresentationTitle();
3037  $img_src = ilUtil::getImagePath("icon_lm.svg");
3038  $img_alt = $lng->txt("icon") . " " . $lng->txt("obj_lm");
3039  break;
3040 
3041  // chapter
3042  case "st":
3043  $text =
3045  $node["obj_id"],
3047  $this->lm->isActiveNumbering(),
3048  $this->lm_set->get("time_scheduled_page_activation"),
3049  false,
3050  0,
3051  $this->lang
3052  );
3053  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3054  $this->lm_gui->object->getPublicAccessMode() == "selected") {
3055  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
3056  $disabled = true;
3057  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
3058  }
3059  }
3060  $img_src = ilUtil::getImagePath("icon_st.svg");
3061  $img_alt = $lng->txt("icon") . " " . $lng->txt("st");
3062  break;
3063  }
3064 
3065  if (!ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node["obj_id"])) {
3066  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
3067  }
3068 
3069  $this->nl->addListNode(
3070  $node["obj_id"],
3071  $text,
3072  $node["parent"],
3073  $checked,
3074  $disabled,
3075  $img_src,
3076  $img_alt
3077  );
3078  }
3079 
3080 
3081  // check for free page
3082  if ($_GET["obj_id"] > 0 && !$this->lm_tree->isInTree($_GET["obj_id"])) {
3083  $text =
3085  $_GET["obj_id"],
3086  $this->lm->getPageHeader(),
3087  $this->lm->isActiveNumbering(),
3088  $this->lm_set->get("time_scheduled_page_activation"),
3089  false,
3090  0,
3091  $this->lang
3092  );
3093 
3094  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3095  $this->lm_gui->object->getPublicAccessMode() == "selected") {
3096  if (!ilLMObject::_isPagePublic($_GET["obj_id"])) {
3097  $disabled = true;
3098  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
3099  }
3100  }
3101  $img_src = ilUtil::getImagePath("icon_pg.svg");
3102  $id = $_GET["obj_id"];
3103 
3104  $checked = true;
3105 
3106  $this->nl->addListNode(
3107  $id,
3108  $text,
3109  0,
3110  $checked,
3111  $disabled,
3112  $img_src,
3113  $img_alt
3114  );
3115  }
3116 
3117  $f = $this->form->getHTML();
3118 
3119  // submit toolbar
3120  $tb = new ilToolbarGUI();
3121  $tb->addFormButton($lng->txt("cont_show_print_view"), "showPrintView");
3122  $this->tpl->setVariable("TOOLBAR", $tb->getHTML());
3123 
3124  $this->tpl->setVariable("ITEM_SELECTION", $f);
3125  $this->tpl->show();
3126  }
3127 
3132  protected function filterNonAccessibleNode($nodes)
3133  {
3134  $tracker = $this->getTracker();
3135  // if navigation is restricted based on correct answered questions
3136  // check if we have preceeding pages including unsanswered/incorrect answered questions
3137  if (!$this->offlineMode()) {
3138  if ($this->lm->getRestrictForwardNavigation()) {
3139  $nodes = array_filter($nodes, function ($node) use ($tracker) {
3140  return !$tracker->hasPredIncorrectAnswers($node["child"]);
3141  });
3142  }
3143  }
3144  return $nodes;
3145  }
3146 
3147 
3151  public function initPrintViewSelectionForm()
3152  {
3153  $lng = $this->lng;
3154  $ilCtrl = $this->ctrl;
3155 
3156  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3157  $this->form = new ilPropertyFormGUI();
3158 
3159  // selection type
3160  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
3161  $radg->setValue("page");
3162  $op1 = new ilRadioOption($lng->txt("cont_current_page"), "page");
3163  $radg->addOption($op1);
3164  $op2 = new ilRadioOption($lng->txt("cont_current_chapter"), "chapter");
3165  $radg->addOption($op2);
3166  $op3 = new ilRadioOption($lng->txt("cont_selected_pg_chap"), "selection");
3167  $radg->addOption($op3);
3168 
3169  include_once("./Services/Form/classes/class.ilNestedListInputGUI.php");
3170  $nl = new ilNestedListInputGUI("", "obj_id");
3171  $this->nl = $nl;
3172  $op3->addSubItem($nl);
3173 
3174 
3175  $this->form->addItem($radg);
3176 
3177  $this->form->addCommandButton("showPrintView", $lng->txt("cont_show_print_view"));
3178  $this->form->setOpenTag(false);
3179  $this->form->setCloseTag(false);
3180 
3181  $this->form->setTitle($lng->txt("cont_print_selection"));
3182  $this->form->setFormAction($ilCtrl->getFormAction($this));
3183  }
3184 
3188  public function showPrintView()
3189  {
3190  $ilUser = $this->user;
3191  $lng = $this->lng;
3192  $ilCtrl = $this->ctrl;
3193 
3194  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3195 
3196  if (!$this->lm->isActivePrintView() || !$this->lm->isActiveLMMenu()) {
3197  return;
3198  }
3199 
3200  $this->renderPageTitle();
3201 
3202  $c_obj_id = $this->getCurrentPageId();
3203  // set values according to selection
3204  if ($_POST["sel_type"] == "page") {
3205  if (!is_array($_POST["obj_id"]) || !in_array($c_obj_id, $_POST["obj_id"])) {
3206  $_POST["obj_id"][] = $c_obj_id;
3207  }
3208  }
3209  if ($_POST["sel_type"] == "chapter" && $c_obj_id > 0) {
3210  $path = $this->lm_tree->getPathFull($c_obj_id);
3211  $chap_id = $path[1]["child"];
3212  if ($chap_id > 0) {
3213  $_POST["obj_id"][] = $chap_id;
3214  }
3215  }
3216 
3217  //var_dump($_GET);
3218  //var_dump($_POST);
3219  // set style sheets
3220  if (!$this->offlineMode()) {
3221  $this->tpl->setVariable("LOCATION_STYLESHEET", ilObjStyleSheet::getContentPrintStyle());
3222  } else {
3223  $style_name = $ilUser->getPref("style") . ".css";
3224  ;
3225  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
3226  }
3227 
3228  // content style
3229  $this->tpl->setCurrentBlock("ContentStyle");
3230  if (!$this->offlineMode()) {
3231  $this->tpl->setVariable(
3232  "LOCATION_CONTENT_STYLESHEET",
3233  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
3234  );
3235  } else {
3236  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
3237  }
3238  $this->tpl->parseCurrentBlock();
3239 
3240  // syntax style
3241  $this->tpl->setCurrentBlock("SyntaxStyle");
3242  $this->tpl->setVariable(
3243  "LOCATION_SYNTAX_STYLESHEET",
3245  );
3246  $this->tpl->parseCurrentBlock();
3247 
3248  //$this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3249  $this->tpl->addBlockFile("CONTENT", "content", "tpl.lm_print_view.html", true);
3250 
3251  // set title header
3252  $this->tpl->setVariable("HEADER", $this->getLMPresentationTitle());
3253 
3254  $nodes = $this->lm_tree->getSubtree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
3255 
3256  include_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
3257  include_once("./Modules/LearningModule/classes/class.ilLMPageObject.php");
3258  include_once("./Modules/LearningModule/classes/class.ilStructureObject.php");
3259 
3260  $act_level = 99999;
3261  $activated = false;
3262 
3263  $glossary_links = array();
3264  $output_header = false;
3265  $media_links = array();
3266 
3267  // get header and footer
3268  if ($this->lm->getFooterPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
3269  if (ilLMObject::_exists($this->lm->getFooterPage())) {
3270  $page_object_gui = $this->getLMPageGUI($this->lm->getFooterPage());
3271  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3272  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3273  $this->lm->getStyleSheetId(),
3274  "lm"
3275  ));
3276 
3277 
3278  // determine target frames for internal links
3279  $page_object_gui->setLinkFrame($_GET["frame"]);
3280  $page_object_gui->setOutputMode("print");
3281  $page_object_gui->setPresentationTitle("");
3282  $page_object_gui->setFileDownloadLink("#");
3283  $page_object_gui->setFullscreenLink("#");
3284  $page_object_gui->setSourceCodeDownloadScript("#");
3285  $footer_page_content = $page_object_gui->showPage();
3286  }
3287  }
3288  if ($this->lm->getHeaderPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
3289  if (ilLMObject::_exists($this->lm->getHeaderPage())) {
3290  $page_object_gui = $this->getLMPageGUI($this->lm->getHeaderPage());
3291  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3292  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3293  $this->lm->getStyleSheetId(),
3294  "lm"
3295  ));
3296 
3297 
3298  // determine target frames for internal links
3299  $page_object_gui->setLinkFrame($_GET["frame"]);
3300  $page_object_gui->setOutputMode("print");
3301  $page_object_gui->setPresentationTitle("");
3302  $page_object_gui->setFileDownloadLink("#");
3303  $page_object_gui->setFullscreenLink("#");
3304  $page_object_gui->setSourceCodeDownloadScript("#");
3305  $header_page_content = $page_object_gui->showPage();
3306  }
3307  }
3308 
3309  // add free selected pages
3310  if (is_array($_POST["obj_id"])) {
3311  foreach ($_POST["obj_id"] as $k) {
3312  if ($k > 0 && !$this->lm_tree->isInTree($k)) {
3313  if (ilLMObject::_lookupType($k) == "pg") {
3314  $nodes[] = array("obj_id" => $k, "type" => "pg", "free" => true);
3315  }
3316  }
3317  }
3318  } else {
3319  ilUtil::sendFailure($lng->txt("cont_print_no_page_selected"), true);
3320  $ilCtrl->redirect($this, "showPrintViewSelection");
3321  }
3322 
3323  foreach ($nodes as $node_key => $node) {
3324  // check page activation
3325  $active = ilLMPage::_lookupActive(
3326  $node["obj_id"],
3327  $this->lm->getType(),
3328  $this->lm_set->get("time_scheduled_page_activation")
3329  );
3330  if ($node["type"] == "pg" && !$active) {
3331  continue;
3332  }
3333 
3334  // print all subchapters/subpages if higher chapter
3335  // has been selected
3336  if ($node["depth"] <= $act_level) {
3337  if (is_array($_POST["obj_id"]) && in_array($node["obj_id"], $_POST["obj_id"])) {
3338  $act_level = $node["depth"];
3339  $activated = true;
3340  } else {
3341  $act_level = 99999;
3342  $activated = false;
3343  }
3344  }
3345  if ($this->lm->getRestrictForwardNavigation()) {
3346  if ($this->getTracker()->hasPredIncorrectAnswers($node["obj_id"])) {
3347  continue;
3348  }
3349  }
3350  if ($activated &&
3351  ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node["obj_id"])) {
3352  // output learning module header
3353  if ($node["type"] == "du") {
3354  $output_header = true;
3355  }
3356 
3357  // output chapter title
3358  if ($node["type"] == "st") {
3359  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3360  $this->lm_gui->object->getPublicAccessMode() == "selected") {
3361  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
3362  continue;
3363  }
3364  }
3365 
3366  $chap = new ilStructureObject($this->lm, $node["obj_id"]);
3367  $this->tpl->setCurrentBlock("print_chapter");
3368 
3369  $chapter_title = $chap->_getPresentationTitle(
3370  $node["obj_id"],
3371  $this->lm->isActiveNumbering(),
3372  $this->lm_set->get("time_scheduled_page_activation"),
3373  0,
3374  $this->lang
3375  );
3376  $this->tpl->setVariable(
3377  "CHAP_TITLE",
3378  $chapter_title
3379  );
3380 
3381  if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) {
3382  if ($nodes[$node_key + 1]["type"] == "pg") {
3383  $this->tpl->setVariable(
3384  "CHAP_HEADER",
3385  $header_page_content
3386  );
3387  $did_chap_page_header = true;
3388  }
3389  }
3390 
3391  $this->tpl->parseCurrentBlock();
3392  $this->tpl->setCurrentBlock("print_block");
3393  $this->tpl->parseCurrentBlock();
3394  }
3395 
3396  // output page
3397  if ($node["type"] == "pg") {
3398  if ($ilUser->getId() == ANONYMOUS_USER_ID &&
3399  $this->lm_gui->object->getPublicAccessMode() == "selected") {
3400  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
3401  continue;
3402  }
3403  }
3404 
3405  $this->tpl->setCurrentBlock("print_item");
3406 
3407  // get page
3408  $page_id = $node["obj_id"];
3409  $page_object_gui = $this->getLMPageGUI($page_id);
3410  $page_object = $page_object_gui->getPageObject();
3411  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
3412  $page_object_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(
3413  $this->lm->getStyleSheetId(),
3414  "lm"
3415  ));
3416 
3417 
3418  // get lm page
3419  $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
3420  $lm_pg_obj->setLMId($this->lm->getId());
3421 
3422  // determine target frames for internal links
3423  $page_object_gui->setLinkFrame($_GET["frame"]);
3424  $page_object_gui->setOutputMode("print");
3425  $page_object_gui->setPresentationTitle("");
3426 
3427  if ($this->lm->getPageHeader() == IL_PAGE_TITLE || $node["free"] === true) {
3429  $lm_pg_obj->getId(),
3430  $this->lm->getPageHeader(),
3431  $this->lm->isActiveNumbering(),
3432  $this->lm_set->get("time_scheduled_page_activation"),
3433  false,
3434  0,
3435  $this->lang
3436  );
3437 
3438  // prevent page title after chapter title
3439  // that have the same content
3440  if ($this->lm->isActiveNumbering()) {
3441  $chapter_title = trim(substr(
3442  $chapter_title,
3443  strpos($chapter_title, " ")
3444  ));
3445  }
3446 
3447  if ($page_title != $chapter_title) {
3448  $page_object_gui->setPresentationTitle($page_title);
3449  }
3450  }
3451 
3452  // handle header / footer
3453  $hcont = $header_page_content;
3454  $fcont = $footer_page_content;
3455 
3456  if ($this->lm->getPageHeader() == IL_CHAPTER_TITLE) {
3457  if ($did_chap_page_header) {
3458  $hcont = "";
3459  }
3460  if ($nodes[$node_key + 1]["type"] == "pg" &&
3461  !($nodes[$node_key + 1]["depth"] <= $act_level
3462  && !in_array($nodes[$node_key + 1]["obj_id"], $_POST["obj_id"]))) {
3463  $fcont = "";
3464  }
3465  }
3466 
3467  $page_object_gui->setFileDownloadLink("#");
3468  $page_object_gui->setFullscreenLink("#");
3469  $page_object_gui->setSourceCodeDownloadScript("#");
3470  $page_content = $page_object_gui->showPage();
3471  if ($this->lm->getPageHeader() != IL_PAGE_TITLE) {
3472  $this->tpl->setVariable(
3473  "CONTENT",
3474  $hcont . $page_content . $fcont
3475  );
3476  } else {
3477  $this->tpl->setVariable(
3478  "CONTENT",
3479  $hcont . $page_content . $fcont . "<br />"
3480  );
3481  }
3482  $chapter_title = "";
3483  $this->tpl->parseCurrentBlock();
3484  $this->tpl->setCurrentBlock("print_block");
3485  $this->tpl->parseCurrentBlock();
3486 
3487  // get internal links
3488  $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType() . ":pg", $node["obj_id"]);
3489 
3490  $got_mobs = false;
3491 
3492  foreach ($int_links as $key => $link) {
3493  if ($link["type"] == "git" &&
3494  ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
3495  $glossary_links[$key] = $link;
3496  }
3497  if ($link["type"] == "mob" &&
3498  ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
3499  $got_mobs = true;
3500  $mob_links[$key] = $link;
3501  }
3502  }
3503 
3504  // this is not cool because of performance reasons
3505  // unfortunately the int link table does not
3506  // store the target frame (we want to append all linked
3507  // images but not inline images (i.e. mobs with no target
3508  // frame))
3509  if ($got_mobs) {
3510  $page_object->buildDom();
3511  $links = $page_object->getInternalLinks();
3512  foreach ($links as $link) {
3513  if ($link["Type"] == "MediaObject"
3514  && $link["TargetFrame"] != ""
3515  && $link["TargetFrame"] != "None") {
3516  $media_links[] = $link;
3517  }
3518  }
3519  }
3520  }
3521  }
3522  }
3523 
3524  $annex_cnt = 0;
3525  $annexes = array();
3526 
3527  // glossary
3528  if (count($glossary_links) > 0 && !$this->lm->isActivePreventGlossaryAppendix()) {
3529  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
3530  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
3531 
3532  // sort terms
3533  $terms = array();
3534 
3535  foreach ($glossary_links as $key => $link) {
3536  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
3537  $terms[$term . ":" . $key] = array("key" => $key, "link" => $link, "term" => $term);
3538  }
3539  $terms = ilUtil::sortArray($terms, "term", "asc");
3540  //ksort($terms);
3541 
3542  foreach ($terms as $t) {
3543  $link = $t["link"];
3544  $key = $t["key"];
3545  $defs = ilGlossaryDefinition::getDefinitionList($link["id"]);
3546  $def_cnt = 1;
3547 
3548  // output all definitions of term
3549  foreach ($defs as $def) {
3550  // definition + number, if more than 1 definition
3551  if (count($defs) > 1) {
3552  $this->tpl->setCurrentBlock("def_title");
3553  $this->tpl->setVariable(
3554  "TXT_DEFINITION",
3555  $this->lng->txt("cont_definition") . " " . ($def_cnt++)
3556  );
3557  $this->tpl->parseCurrentBlock();
3558  }
3559  include_once("./Modules/Glossary/classes/class.ilGlossaryDefPageGUI.php");
3560  $page_gui = new ilGlossaryDefPageGUI($def["id"]);
3561  $page_gui->setTemplateOutput(false);
3562  $page_gui->setOutputMode("print");
3563 
3564  $this->tpl->setCurrentBlock("definition");
3565  $page_gui->setFileDownloadLink("#");
3566  $page_gui->setFullscreenLink("#");
3567  $page_gui->setSourceCodeDownloadScript("#");
3568  $output = $page_gui->showPage();
3569  $this->tpl->setVariable("VAL_DEFINITION", $output);
3570  $this->tpl->parseCurrentBlock();
3571  }
3572 
3573  // output term
3574  $this->tpl->setCurrentBlock("term");
3575  $this->tpl->setVariable(
3576  "VAL_TERM",
3577  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"])
3578  );
3579  $this->tpl->parseCurrentBlock();
3580  }
3581 
3582  // output glossary header
3583  $annex_cnt++;
3584  $this->tpl->setCurrentBlock("glossary");
3585  $annex_title = $this->lng->txt("cont_annex") . " " .
3586  chr(64 + $annex_cnt) . ": " . $this->lng->txt("glo");
3587  $this->tpl->setVariable("TXT_GLOSSARY", $annex_title);
3588  $this->tpl->parseCurrentBlock();
3589 
3590  $annexes[] = $annex_title;
3591  }
3592 
3593  // referenced images
3594  if (count($media_links) > 0) {
3595  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
3596  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
3597 
3598  foreach ($media_links as $media) {
3599  if (substr($media["Target"], 0, 4) == "il__") {
3600  $arr = explode("_", $media["Target"]);
3601  $id = $arr[count($arr) - 1];
3602 
3603  $med_obj = new ilObjMediaObject($id);
3604  $med_item = $med_obj->getMediaItem("Standard");
3605  if (is_object($med_item)) {
3606  if (is_int(strpos($med_item->getFormat(), "image"))) {
3607  $this->tpl->setCurrentBlock("ref_image");
3608 
3609  // image source
3610  if ($med_item->getLocationType() == "LocalFile") {
3611  $this->tpl->setVariable(
3612  "IMG_SOURCE",
3613  ilUtil::getWebspaceDir("output") . "/mobs/mm_" . $id .
3614  "/" . $med_item->getLocation()
3615  );
3616  } else {
3617  $this->tpl->setVariable(
3618  "IMG_SOURCE",
3619  $med_item->getLocation()
3620  );
3621  }
3622 
3623  if ($med_item->getCaption() != "") {
3624  $this->tpl->setVariable("IMG_TITLE", $med_item->getCaption());
3625  } else {
3626  $this->tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
3627  }
3628  $this->tpl->parseCurrentBlock();
3629  }
3630  }
3631  }
3632  }
3633 
3634  // output glossary header
3635  $annex_cnt++;
3636  $this->tpl->setCurrentBlock("ref_images");
3637  $annex_title = $this->lng->txt("cont_annex") . " " .
3638  chr(64 + $annex_cnt) . ": " . $this->lng->txt("cont_ref_images");
3639  $this->tpl->setVariable("TXT_REF_IMAGES", $annex_title);
3640  $this->tpl->parseCurrentBlock();
3641 
3642  $annexes[] = $annex_title;
3643  }
3644 
3645  // output learning module title and toc
3646  if ($output_header) {
3647  $this->tpl->setCurrentBlock("print_header");
3648  $this->tpl->setVariable("LM_TITLE", $this->getLMPresentationTitle());
3649  if ($this->lm->getDescription() != "none") {
3650  include_once("Services/MetaData/classes/class.ilMD.php");
3651  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
3652  $md_gen = $md->getGeneral();
3653  foreach ($md_gen->getDescriptionIds() as $id) {
3654  $md_des = $md_gen->getDescription($id);
3655  $description = $md_des->getDescription();
3656  }
3657 
3658  $this->tpl->setVariable(
3659  "LM_DESCRIPTION",
3660  $description
3661  );
3662  }
3663  $this->tpl->parseCurrentBlock();
3664 
3665  // output toc
3666  $nodes2 = $nodes;
3667  foreach ($nodes2 as $node2) {
3668  if ($node2["type"] == "st"
3669  && ilObjContentObject::_checkPreconditionsOfPage($this->lm->getRefId(), $this->lm->getId(), $node2["obj_id"])) {
3670  for ($j = 1; $j < $node2["depth"]; $j++) {
3671  $this->tpl->setCurrentBlock("indent");
3672  $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
3673  $this->tpl->parseCurrentBlock();
3674  }
3675  $this->tpl->setCurrentBlock("toc_entry");
3676  $this->tpl->setVariable(
3677  "TXT_TOC_TITLE",
3679  $node2["obj_id"],
3681  $this->lm->isActiveNumbering(),
3682  $this->lm_set->get("time_scheduled_page_activation"),
3683  false,
3684  0,
3685  $this->lang
3686  )
3687  );
3688  $this->tpl->parseCurrentBlock();
3689  }
3690  }
3691 
3692  // annexes
3693  foreach ($annexes as $annex) {
3694  $this->tpl->setCurrentBlock("indent");
3695  $this->tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
3696  $this->tpl->parseCurrentBlock();
3697  $this->tpl->setCurrentBlock("toc_entry");
3698  $this->tpl->setVariable("TXT_TOC_TITLE", $annex);
3699  $this->tpl->parseCurrentBlock();
3700  }
3701 
3702  $this->tpl->setCurrentBlock("toc");
3703  $this->tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
3704  $this->tpl->parseCurrentBlock();
3705 
3706  $this->tpl->setCurrentBlock("print_start_block");
3707  $this->tpl->parseCurrentBlock();
3708  }
3709 
3710  // output author information
3711  include_once 'Services/MetaData/classes/class.ilMD.php';
3712  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
3713  if (is_object($lifecycle = $md->getLifecycle())) {
3714  $sep = $author = "";
3715  foreach (($ids = $lifecycle->getContributeIds()) as $con_id) {
3716  $md_con = $lifecycle->getContribute($con_id);
3717  if ($md_con->getRole() == "Author") {
3718  foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
3719  $md_ent = $md_con->getEntity($ent_id);
3720  $author = $author . $sep . $md_ent->getEntity();
3721  $sep = ", ";
3722  }
3723  }
3724  }
3725  if ($author != "") {
3726  $this->lng->loadLanguageModule("meta");
3727  $this->tpl->setCurrentBlock("author");
3728  $this->tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author"));
3729  $this->tpl->setVariable("LM_AUTHOR", $author);
3730  $this->tpl->parseCurrentBlock();
3731  }
3732  }
3733 
3734 
3735  // output copyright information
3736  if (is_object($md_rights = $md->getRights())) {
3737  $copyright = $md_rights->getDescription();
3738  include_once('Services/MetaData/classes/class.ilMDUtils.php');
3739  $copyright = ilMDUtils::_parseCopyright($copyright);
3740 
3741  if ($copyright != "") {
3742  $this->lng->loadLanguageModule("meta");
3743  $this->tpl->setCurrentBlock("copyright");
3744  $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
3745  $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
3746  $this->tpl->parseCurrentBlock();
3747  }
3748  }
3749 
3750  $this->tpl->show(false);
3751  }
3752 
3756  public function downloadFile()
3757  {
3758  $page_gui = $this->getLMPageGUI($this->getCurrentPageId());
3759  $page_gui->downloadFile();
3760  }
3761 
3762 
3766  public function download_paragraph()
3767  {
3768  require_once("./Modules/LearningModule/classes/class.ilLMPage.php");
3769  $pg_obj = $this->getLMPage($_GET["pg_id"]);
3770  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
3771  }
3772 
3776  public function showDownloadList()
3777  {
3778  if (!$this->lm->isActiveDownloads() || !$this->lm->isActiveLMMenu()) {
3779  return;
3780  }
3781 
3782  //$this->tpl = new ilTemplate("tpl.lm_toc.html", true, true, true);
3783  $this->tpl->setCurrentBlock("ContentStyle");
3784  if (!$this->offlineMode()) {
3785  $this->tpl->setVariable(
3786  "LOCATION_CONTENT_STYLESHEET",
3787  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
3788  );
3789  } else {
3790  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
3791  }
3792  $this->tpl->parseCurrentBlock();
3793 
3794  $this->renderPageTitle();
3795  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3796  $this->tpl->getStandardTemplate();
3797 
3798  $this->tpl->setVariable("TABS", $this->lm_gui->setilLMMenu(
3799  $this->offlineMode(),
3800  $this->getExportFormat(),
3801  "download",
3802  true,
3803  false,
3804  0,
3805  $this->lang,
3807  ));
3808 
3809  $this->ilLocator(true);
3810  //$this->tpl->stopTitleFloating();
3811  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lm_download_list.html", "Modules/LearningModule");
3812 
3813  // set title header
3814  $this->tpl->setTitle($this->getLMPresentationTitle());
3815  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lm.svg"));
3816 
3817  /*
3818  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
3819  $this->ctrl->setParameter($this, "obj_id", $_GET["obj_id"]);
3820  $this->tpl->setVariable("LINK_BACK",
3821  $this->ctrl->getLinkTarget($this, "")); */
3822 
3823  // output copyright information
3824  include_once 'Services/MetaData/classes/class.ilMD.php';
3825  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
3826  if (is_object($md_rights = $md->getRights())) {
3827  $copyright = $md_rights->getDescription();
3828 
3829  include_once('Services/MetaData/classes/class.ilMDUtils.php');
3830  $copyright = ilMDUtils::_parseCopyright($copyright);
3831 
3832  if ($copyright != "") {
3833  $this->lng->loadLanguageModule("meta");
3834  $this->tpl->setCurrentBlock("copyright");
3835  $this->tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
3836  $this->tpl->setVariable("LM_COPYRIGHT", $copyright);
3837  $this->tpl->parseCurrentBlock();
3838  }
3839  }
3840 
3841 
3842  include_once("./Modules/LearningModule/classes/class.ilLMDownloadTableGUI.php");
3843  $download_table = new ilLMDownloadTableGUI($this, "showDownloadList", $this->lm);
3844  $this->tpl->setVariable("DOWNLOAD_TABLE", $download_table->getHTML());
3845  $this->tpl->show();
3846  }
3847 
3848 
3852  public function downloadExportFile()
3853  {
3854  if (!$this->lm->isActiveDownloads() || !$this->lm->isActiveLMMenu()) {
3855  return;
3856  }
3857 
3858  $base_type = explode("_", $_GET["type"]);
3859  $base_type = $base_type[0];
3860  $file = $this->lm->getPublicExportFile($base_type);
3861  if ($this->lm->getPublicExportFile($base_type) != "") {
3862  $dir = $this->lm->getExportDirectory($_GET["type"]);
3863  if (is_file($dir . "/" . $file)) {
3864  ilUtil::deliverFile($dir . "/" . $file, $file);
3865  exit;
3866  }
3867  }
3868  }
3869 
3879  public function getFocusLink($a_ref_id, $a_obj_id, $a_return_ref_id)
3880  {
3881  return "ilias.php?baseClass=ilLMPresentationGUI&amp;ref_id=" . $a_ref_id . "&amp;obj_id=" . $a_obj_id . "&amp;focus_id=" .
3882  $a_obj_id . "&amp;focus_return=" . $a_return_ref_id;
3883  }
3884 
3885 
3889  public function getLink(
3890  $a_ref_id,
3891  $a_cmd = "",
3892  $a_obj_id = "",
3893  $a_frame = "",
3894  $a_type = "",
3895  $a_back_link = "append",
3896  $a_anchor = "",
3897  $a_srcstring = ""
3898  ) {
3899  $ilCtrl = $this->ctrl;
3900 
3901  if ($a_cmd == "") {
3902  $a_cmd = "layout";
3903  }
3904 
3905  // handling of free pages
3906  $cur_page_id = $this->getCurrentPageId();
3907  $back_pg = $_GET["back_pg"];
3908  if ($a_obj_id != "" && !$this->lm_tree->isInTree($a_obj_id) && $cur_page_id != "" &&
3909  $a_back_link == "append") {
3910  if ($back_pg != "") {
3911  $back_pg = $cur_page_id . ":" . $back_pg;
3912  } else {
3913  $back_pg = $cur_page_id;
3914  }
3915  } else {
3916  if ($a_back_link == "reduce") {
3917  $limpos = strpos($_GET["back_pg"], ":");
3918 
3919  if ($limpos > 0) {
3920  $back_pg = substr($back_pg, strpos($back_pg, ":") + 1);
3921  } else {
3922  $back_pg = "";
3923  }
3924  } elseif ($a_back_link != "keep") {
3925  $back_pg = "";
3926  }
3927  }
3928 
3929  // handle online links
3930  if (!$this->offlineMode()) {
3931  if ($_GET["from_page"] == "") {
3932  // added if due to #23216 (from page has been set in lots of usual navigation links)
3933  if (!in_array($a_frame, array("", "_blank"))) {
3934  $this->ctrl->setParameter($this, "from_page", $cur_page_id);
3935  }
3936  } else {
3937  // faq link on page (in faq frame) includes faq link on other page
3938  // if added due to bug #11007
3939  if (!in_array($a_frame, array("", "_blank"))) {
3940  $this->ctrl->setParameter($this, "from_page", $_GET["from_page"]);
3941  }
3942  }
3943 
3944  if ($a_anchor != "") {
3945  $this->ctrl->setParameter($this, "anchor", rawurlencode($a_anchor));
3946  }
3947  if ($a_srcstring != "") {
3948  $this->ctrl->setParameter($this, "srcstring", $a_srcstring);
3949  }
3950  switch ($a_cmd) {
3951  case "fullscreen":
3952  $link = $this->ctrl->getLinkTarget($this, "fullscreen", "", false, false);
3953  break;
3954 
3955  default:
3956 
3957  if ($back_pg != "") {
3958  $this->ctrl->setParameter($this, "back_pg", $back_pg);
3959  }
3960  if ($a_frame != "") {
3961  $this->ctrl->setParameter($this, "frame", $a_frame);
3962  }
3963  if ($a_obj_id != "") {
3964  switch ($a_type) {
3965  case "MediaObject":
3966  $this->ctrl->setParameter($this, "mob_id", $a_obj_id);
3967  break;
3968 
3969  default:
3970  $this->ctrl->setParameter($this, "obj_id", $a_obj_id);
3971  $link .= "&amp;obj_id=" . $a_obj_id;
3972  break;
3973  }
3974  }
3975  if ($a_type != "") {
3976  $this->ctrl->setParameter($this, "obj_type", $a_type);
3977  }
3978  $link = $this->ctrl->getLinkTarget($this, $a_cmd, $a_anchor);
3979 // $link = str_replace("&", "&amp;", $link);
3980 
3981  $this->ctrl->setParameter($this, "frame", "");
3982  $this->ctrl->setParameter($this, "obj_id", "");
3983  $this->ctrl->setParameter($this, "mob_id", "");
3984  break;
3985  }
3986  } else { // handle offline links
3987  $lang_suffix = "";
3988  if ($this->export_all_languages) {
3989  if ($this->lang != "" && $this->lang != "-") {
3990  $lang_suffix = "_" . $this->lang;
3991  }
3992  }
3993 
3994  switch ($a_cmd) {
3995  case "downloadFile":
3996  break;
3997 
3998  case "fullscreen":
3999  $link = "fullscreen.html"; // id is handled by xslt
4000  break;
4001 
4002  case "layout":
4003 
4004  if ($a_obj_id == "") {
4005  $a_obj_id = $this->lm_tree->getRootId();
4006  $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
4007  $a_obj_id = $pg_node["obj_id"];
4008  }
4009  if ($a_type == "StructureObject") {
4010  $pg_node = $this->lm_tree->fetchSuccessorNode($a_obj_id, "pg");
4011  $a_obj_id = $pg_node["obj_id"];
4012  }
4013  if ($a_frame != "" && $a_frame != "_blank") {
4014  if ($a_frame != "toc") {
4015  $link = "frame_" . $a_obj_id . "_" . $a_frame . $lang_suffix . ".html";
4016  } else { // don't save multiple toc frames (all the same)
4017  $link = "frame_" . $a_frame . $lang_suffix . ".html";
4018  }
4019  } else {
4020  //if ($nid = ilLMObject::_lookupNID($this->lm->getId(), $a_obj_id, "pg"))
4021  if ($nid = ilLMPageObject::getExportId($this->lm->getId(), $a_obj_id)) {
4022  $link = "lm_pg_" . $nid . $lang_suffix . ".html";
4023  } else {
4024  $link = "lm_pg_" . $a_obj_id . $lang_suffix . ".html";
4025  }
4026  }
4027  break;
4028 
4029  case "glossary":
4030  $link = "term_" . $a_obj_id . ".html";
4031  break;
4032 
4033  case "media":
4034  $link = "media_" . $a_obj_id . ".html";
4035  break;
4036 
4037  default:
4038  break;
4039  }
4040  }
4041 
4042  $this->ctrl->clearParameters($this);
4043 
4044  return $link;
4045  }
4046 
4054  {
4055  // content style
4056  $this->tpl->setCurrentBlock("ContentStyle");
4057  if (!$this->offlineMode()) {
4058  $this->tpl->setVariable(
4059  "LOCATION_CONTENT_STYLESHEET",
4060  ilObjStyleSheet::getContentStylePath($this->lm->getStyleSheetId())
4061  );
4062  } else {
4063  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "content_style/content.css");
4064  }
4065  $this->tpl->parseCurrentBlock();
4066 
4067  $tpl = new ilTemplate("tpl.page_message_screen.html", true, true, "Modules/LearningModule");
4068  $tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS", $a_content);
4069 
4070  $this->tpl->setVariable("PAGE_CONTENT", $tpl->get());
4071  }
4072 
4073 
4077  public function showNoPublicAccess()
4078  {
4079  $this->showMessageScreen($this->lng->txt("msg_page_no_public_access"));
4080  }
4081 
4085  public function showNoPageAccess()
4086  {
4087  $this->showMessageScreen($this->lng->txt("msg_no_page_access"));
4088  }
4089 
4095  {
4096  $this->showMessageScreen($this->lng->txt("cont_no_page_access_unansw_q"));
4097  }
4098 
4099 
4100  public function getSourcecodeDownloadLink()
4101  {
4102  if (!$this->offlineMode()) {
4103  //$this->ctrl->setParameter($this, session_name(), session_id());
4104  $target = $this->ctrl->getLinkTarget($this, "");
4105  $target = ilUtil::appendUrlParameterString($target, session_name() . "=" . session_id());
4106  return $this->ctrl->getLinkTarget($this, "");
4107  } else {
4108  return "";
4109  }
4110  }
4111 
4119  public function setOfflineDirectory($offdir)
4120  {
4121  $this->offline_directory = $offdir;
4122  }
4123 
4124 
4131  public function getOfflineDirectory()
4132  {
4133  return $this->offline_directory;
4134  }
4135 
4140  public function handleCodeParagraph($page_id, $paragraph_id, $title, $text)
4141  {
4142  $directory = $this->getOfflineDirectory() . "/codefiles/" . $page_id . "/" . $paragraph_id;
4143  ilUtil::makeDirParents($directory);
4144  $file = $directory . "/" . $title;
4145  if (!($fp = @fopen($file, "w+"))) {
4146  die("<b>Error</b>: Could not open \"" . $file . "\" for writing" .
4147  " in <b>" . __FILE__ . "</b> on line <b>" . __LINE__ . "</b><br />");
4148  }
4149  chmod($file, 0770);
4150  fwrite($fp, $text);
4151  fclose($fp);
4152  }
4153 
4154  // #8613
4155  protected function renderPageTitle()
4156  {
4157  $this->tpl->setHeaderPageTitle($this->getLMPresentationTitle());
4158  $this->tpl->fillWindowTitle();
4159  $this->tpl->fillContentLanguage();
4160  }
4161 
4162 
4169  public function getLMPageGUI($a_id)
4170  {
4171  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
4172  include_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
4173  if ($this->lang != "-" && ilPageObject::_exists("lm", $a_id, $this->lang)) {
4174  return new ilLMPageGUI($a_id, 0, false, $this->lang);
4175  }
4176  return new ilLMPageGUI($a_id);
4177  }
4178 
4185  public function getLMPage($a_id)
4186  {
4187  include_once("./Modules/LearningModule/classes/class.ilLMPage.php");
4188  if ($this->lang != "-" && ilPageObject::_exists("lm", $a_id, $this->lang)) {
4189  return new ilLMPage($a_id, 0, $this->lang);
4190  }
4191  return new ilLMPage($a_id);
4192  }
4193 
4197  public function refreshToc()
4198  {
4199  $exp = $this->ilTOC(true);
4200 
4201  echo $exp->getHTML() .
4202  "<script>" . $exp->getOnLoadCode() . "</script>";
4203  exit;
4204  }
4205 }
outputInfoScreen($a_standard_locator=false)
info screen
static _exists($a_parent_type, $a_id, $a_lang="", $a_no_cache=false)
Checks whether page exists.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
xslt_create()
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static _getMissingPreconditionsTopChapter($cont_obj_ref_id, $cont_obj_id, $page_id)
get top chapter of page for that any precondition is missing
determineLayout()
Determine layout.
static _parseCopyright($a_copyright)
Parse copyright.
This class represents an option in a radio group.
$target_arr
Definition: goto.php:47
$lg
Definition: example_018.php:62
static writeRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_rating, $a_category_id=0)
Write rating for a user and an object.
LM presentation (left frame) explorer GUI class.
$path
Definition: aliased.php:25
static getContentPrintStyle()
get content print style
Handles display of the main menu.
static getDefinitionList($a_term_id)
static
downloadFile()
download file of file lists
settings()
Definition: settings.php:2
Class ilInfoScreenGUI.
redrawHeaderAction()
Redraw header action.
static _getMapAreasIntLinks($a_mob_id)
get all internal links of map areas of a mob
static _lookupType($a_obj_id, $a_lm_id=0)
Lookup type.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
const IL_CAL_DATETIME
Class for permanent links.
$_SESSION["AccountId"]
$js
$result
static _updateLastAccess($a_user_id, $a_lm_ref_id, $a_page_id)
This class represents a property form user interface.
const IL_PAGE_TITLE
xpath_new_context($dom_document)
$type
getOfflineDirectory()
get offline directory
global $DIC
Definition: saml.php:7
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
setOfflineDirectory($offdir)
set offline directory to offdir
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
xslt_free(&$proc)
showDownloadList()
show download list
domxml_open_mem($str, $mode=0, &$error=null)
static _checkPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
checks wether the preconditions of a page are fulfilled or not
ilLMMenu()
output learning module menu
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getLMPageGUI($a_id)
Get lm page gui object.
if(!array_key_exists('StateId', $_REQUEST)) $id
static get($a_glyph, $a_text="")
Get glyph html.
showNavRestrictionDueToQuestions()
Show message if navigation to page is not allowed due to unanswered questions.
$target_id
Definition: goto.php:49
static _lookupTitle($a_id)
lookup object title
static includePresentationJS($a_tpl=null)
Include media object presentation JS.
ilPage(&$a_page_node, $a_page_id=0)
process <ilPage> content tag
ilGlossary()
show glossary term
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
static init($a_tpl=null)
Init.
static _lookupTitle($a_obj_id)
Lookup title.
getLinkXML($a_int_links, $a_layoutframes)
get xml for links
export()
calls export of digilib-object at this point other lm-objects can be exported
showInfoScreen()
info screen call from inside learning module
static now()
Return current timestamp in Y-m-d H:i:s format.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
$w
if(! $oauthconfig->getBoolean('getUserInfo.enable', FALSE)) $store
Definition: getUserInfo.php:11
user()
Definition: user.php:4
refreshToc()
Refresh toc (called if questions have been answered correctly)
static _getPresentationTitle( $a_st_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="-", $a_include_short=false)
get presentation title
static _getAllReferences($a_id)
get all reference ids of object
$ilErr
Definition: raiseError.php:18
ilLMSubMenu()
output learning module submenu
Base exception class for learning module presentation.
static addJavaScript(ilTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
addHeaderAction($a_redraw=false)
Add header action.
getLMPresentationTitle()
Get lm presentationtitle.
Class ilLearningModuleGUI.
ilJavaScript($a_inline="", $a_file="", $a_location="")
Puts JS into template.
Notes GUI class.
global $ilCtrl
Definition: ilias.php:18
showTableOfContents()
table of contents
const DEBUG
static lookupParentId($a_id, $a_type)
Lookup parent id.
Class ilLMPresentationGUI.
getFocusLink($a_ref_id, $a_obj_id, $a_return_ref_id)
Get focused link (used in learning objectives courses)
$a_type
Definition: workflow.php:92
xslt_error(&$proc)
getCurrentFrameSet()
get frames of current frame set
static _getInstance($a_usr_id)
Get singleton instance.
getLinkTargetsXML()
Get XMl for Link Targets.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
This class represents a property in a property form.
getLink( $a_ref_id, $a_cmd="", $a_obj_id="", $a_frame="", $a_type="", $a_back_link="append", $a_anchor="", $a_srcstring="")
handles links for learning module presentation
Class ilRatingGUI.
static addCss()
Add required css.
Class ilLMPageObject.
foreach($_POST as $key=> $value) $res
getExportFormat()
get export format
static _lookupActive($a_id, $a_parent_type, $a_check_scheduled_activation=false, $a_lang="-")
lookup activation status
$a_content
Definition: workflow.php:93
buildTag($type, $name, $attr="")
generate a tag with given name and attributes
static hasPublicProfile($a_user_id)
Has public profile.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
showMessageScreen($a_content)
Show message screen.
static resetRatingForUserAndObject( $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
Reset rating for a user and an object.
showPreconditionsOfPage()
show preconditions of the page
static _lookupObjId($a_id)
Extension of ilPageObjectGUI for learning modules.
special template class to simplify handling of ITX/PEAR
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getInstance($a_tree_id)
Get Instance.
$text
Definition: errorreport.php:18
ilLMNavigation()
inserts sequential learning module navigation at template variable LMNAVIGATION_CONTENT ...
ilTOC($a_get_explorer=false)
table of contents
TableGUI class for lm download files.
static getInstance(&$a_content_obj, $a_id=0, $a_halt=true)
processNodes(&$a_content, &$a_node)
offlineMode()
checks wether offline content generation is activated
GUI class for glossary terms.
downloadExportFile()
send download file (xml/html)
& getGeneral()
Definition: class.ilMD.php:40
Date and time handling
setExportFormat($a_format)
set export format
$ilUser
Definition: imgupload.php:18
ilLocator($a_std_templ_loaded=false)
locator
getCurrentPageId()
Get the current page id.
Class ilObjMediaObject.
static getExportId($a_lm_id, $a_lmobj_id, $a_type="pg")
Get export ID.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static lookupLayout($a_obj_id)
Lookup type.
showPrintViewSelection()
show selection screen for print view
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
basicPageGuiInit($a_page_gui)
Basic page gui initialisation.
getLMPage($a_id)
Get lm page object.
const IL_MODE_ALIAS
static _lookupType($a_id, $a_reference=false)
lookup object type
static getSupplyingExportFiles($a_target_dir=".")
Get supplying export files.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$row
nop()
this dummy function is needed for offline package creation
static _getMissingPreconditionsOfPage($cont_ref_id, $cont_obj_id, $page_id)
gets all missing preconditions of page
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
LM presentation (separate toc screen) explorer GUI class.
showNoPageAccess()
Show info message, if page is not accessible in public area.
exit
Definition: backend.php:16
static getInstance($a_ref_id, $a_user_id=0)
Get instance.
getSuccessorPage()
Get successor page.
initScreenHead($a_active_tab="info")
static _lookupActivationData($a_id, $a_parent_type, $a_lang="-")
Lookup activation data.
showNoPublicAccess()
Show info message, if page is not accessible in public area.
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="-", $a_include_short=false)
presentation title doesn&#39;t have to be page title, it may be chapter title + page title or chapter tit...
Class ilStructreObject.
enablePublicNotesDeletion($a_enable=true)
enable public notes
static _getFrame($a_class, $a_type='')
Get content frame name.
handleCodeParagraph($page_id, $paragraph_id, $title, $text)
store paragraph into file directory files/codefile_$pg_id_$paragraph_id/downloadtitle ...
This class represents a (nested) list of checkboxes (could be extended for radio items, too)
global $ilSetting
Definition: privfeed.php:17
static highlight($a_dom_node_id, $a_text, $a_tpl=null)
Searches for all occurences of a text (case-insensitive) and highlights it.
Glossary definition page GUI class.
static getInstance($a_obj_id)
Get instance.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
$ret
Definition: parser.php:6
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$i
Definition: disco.tpl.php:19
Session based immediate storage.
$def
Definition: croninfo.php:21
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
setOfflineMode($a_offline=true, $a_all_languages=false)
set offline mode (content is generated for offline package)
const IL_MODE_OUTPUT
const IL_CHAPTER_TITLE
static getAttribute($a_func_id)
Get accesskey HTML attribute.
$links
layout($a_xml="main.xml", $doShow=true)
generates frame layout
static _isPagePublic($a_node_id, $a_check_public_mode=false)
ilLMNotes()
output notes of page
$info
Definition: index.php:5
$target
Definition: test.php:19
static getWebspaceDir($mode="filesystem")
get webspace directory
$key
Definition: croninfo.php:18
Class ilObjUserTrackingGUI.
static _lookGlossaryTerm($term_id)
get glossary term
$_POST["username"]
$html
Definition: example_001.php:87
Class ilCommonActionDispatcherGUI.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
Extension of ilPageObject for learning modules.
static _getLastAccessedPage($a_ref_id, $a_user_id="")
get last accessed page
setSubObject($a_sub_obj_type, $a_sub_obj_id)
Set sub object attributes.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
download_paragraph()
download source code paragraph
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static getGotoForWikiPageTarget($a_target, $a_offline=false)
Get goto href for internal wiki page link target.
initPrintViewSelectionForm()
Init print view selection form.
$data
Definition: bench.php:6