ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilLMPresentationGUI.php
Go to the documentation of this file.
1 <?php
2 
29 {
30  protected \ILIAS\COPage\Dom\DomUtil $dom_util;
31  protected \ILIAS\COPage\Xsl\XslManager $xsl;
32  protected \ILIAS\Notes\GUIService $notes_gui;
33  protected \ILIAS\GlobalScreen\Services $global_screen;
34  protected \ILIAS\Notes\DomainService $notes;
35  protected \ILIAS\LearningModule\ReadingTime\ReadingTimeManager $reading_time_manager;
36  protected string $requested_url;
37  protected string $requested_type;
38  protected ilLMTracker $tracker;
39  protected ilTabsGUI $tabs;
41  protected ilSetting $lm_set;
43  protected bool $fill_on_load_code;
44  protected ilLMTree $lm_tree;
45  protected array $frames;
46  protected string $export_format;
47  public string $lang;
49  protected ilObjUser $user;
51  protected ilCtrl $ctrl;
54  protected ilSetting $settings;
56  protected ilTree $tree;
57  protected ilHelpGUI $help;
60  public ilLanguage $lng;
62  public bool $offline;
63  public string $offline_directory;
64  protected bool $embed_mode = false;
65  protected int $current_page_id = 0;
66  protected ?int $focus_id = 0; // focus id is set e.g. from learning objectives course, we focus on a chapter/page
67  protected bool $export_all_languages = false;
68  public bool $chapter_has_no_active_page = false;
69  public bool $deactivated_page = false;
70  protected string $requested_back_pg;
71  protected string $requested_search_string;
72  protected string $requested_focus_return;
73  protected int $requested_ref_id;
74  protected int $requested_obj_id;
75  protected string $requested_obj_type;
76  protected string $requested_transl;
77  protected string $requested_frame;
80  protected \ILIAS\DI\UIServices $ui;
82  protected array $additional_content = [];
83  protected string $requested_cmd = "";
84  protected int $requested_pg_id = 0;
85  protected string $requested_pg_type = "";
86  protected int $requested_mob_id = 0;
87  protected int $requested_notification_switch = 0;
88  protected bool $abstract = false;
90  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
91  protected \ILIAS\Style\Content\GUIService $content_style_gui;
92  protected ?\ILIAS\Style\Content\Service $cs = null;
93 
94  public function __construct(
95  string $a_export_format = "",
96  bool $a_all_languages = false,
97  string $a_export_dir = "",
98  bool $claim_repo_context = true,
99  array $query_params = null,
100  bool $embed_mode = false
101  ) {
102  global $DIC;
103 
104  $this->offline = ($a_export_format != "");
105  $this->export_all_languages = $a_all_languages;
106  $this->export_format = $a_export_format; // html/scorm
107  $this->offline_directory = $a_export_dir;
108 
109  $this->tabs = $DIC->tabs();
110  $this->toolbar = $DIC->toolbar();
111  $this->user = $DIC->user();
112  $this->rbacsystem = $DIC->rbac()->system();
113  $this->nav_history = $DIC["ilNavigationHistory"];
114  $this->access = $DIC->access();
115  $this->settings = $DIC->settings();
116  $this->locator = $DIC["ilLocator"];
117  $this->tree = $DIC->repositoryTree();
118  $this->help = $DIC["ilHelp"];
119  $this->global_screen = $DIC->globalScreen();
120 
121  $lng = $DIC->language();
122  $rbacsystem = $DIC->rbac()->system();
123  $ilCtrl = $DIC->ctrl();
124  $ilErr = $DIC["ilErr"];
125 
126  // load language vars
127  $lng->loadLanguageModule("content");
128 
129  $this->lng = $lng;
130  $this->ui = $DIC->ui();
131  $this->tpl = $DIC->ui()->mainTemplate();
132  $this->frames = array();
133  $this->ctrl = $ilCtrl;
134  $this->ctrl->saveParameter($this, array("ref_id", "transl", "focus_id", "focus_return"));
135 
136  $this->cs = $DIC->contentStyle();
137 
138  $this->initByRequest($query_params, $embed_mode);
139 
140  // check, if learning module is online
141  if (!$rbacsystem->checkAccess("write", $this->requested_ref_id)) {
142  if ($this->lm->getOfflineStatus()) {
143  $ilErr->raiseError($lng->txt("permission_denied"), $ilErr->WARNING);
144  }
145  }
146 
147  if ($claim_repo_context) {
148  $DIC->globalScreen()->tool()->context()->claim()->repository();
149  }
150 
151  if (!$ilCtrl->isAsynch()) {
152  // moved this into the if due to #0027200
153  if (!$embed_mode) {
154  if ($this->service->getPresentationStatus()->isTocNecessary()) {
155  $DIC->globalScreen()->tool()->context()->current()->addAdditionalData(
157  true
158  );
159  }
160  }
161  $DIC->globalScreen()->tool()->context()->current()->addAdditionalData(
163  true
164  );
165  }
166 
167  if ($embed_mode) {
168  $ilCtrl->setParameter($this, "embed_mode", 1);
169  $params = [
170  "obj_id" => $this->requested_obj_id,
171  "ref_id" => $this->lm->getRefId(),
172  "frame" => ""
173  ];
174  $DIC->globalScreen()->tool()->context()->current()->addAdditionalData(
176  $params
177  );
178  }
179  $this->reading_time_manager = new \ILIAS\LearningModule\ReadingTime\ReadingTimeManager();
180  $this->notes = $DIC->notes()->domain();
181  $this->xsl = $DIC->copage()->internal()->domain()->xsl();
182  $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
183  $this->notes_gui = $DIC->notes()->gui();
184  }
185 
186  public function getUnsafeGetCommands(): array
187  {
188  return [];
189  }
190 
191  public function getSafePostCommands(): array
192  {
193  return [
194  "showPrintView",
195  ];
196  }
197 
204  public function initByRequest(
205  ?array $query_params = null,
206  bool $embed_mode = false
207  ): void {
208  global $DIC;
209 
210  $this->service = new ilLMPresentationService(
211  $this->user,
212  $query_params,
213  $this->offline,
214  $this->export_all_languages,
215  $this->export_format,
216  null,
217  $embed_mode
218  );
219 
220  $post = is_null($query_params)
221  ? null
222  : [];
223 
224  $request = $DIC->learningModule()
225  ->internal()
226  ->gui()
227  ->presentation()
228  ->request(
229  $query_params,
230  $post
231  );
232 
233  $this->requested_obj_type = $request->getObjType();
234  $this->requested_ref_id = $request->getRefId();
235  $this->requested_transl = $request->getTranslation(); // handled by presentation status
236  $this->requested_obj_id = $request->getObjId(); // handled by navigation status
237  $this->requested_back_pg = $request->getBackPage();
238  $this->requested_frame = $request->getFrame();
239  $this->requested_search_string = $request->getSearchString();
240  $this->requested_focus_return = $request->getFocusReturn();
241  $this->requested_mob_id = $request->getMobId();
242  $this->requested_cmd = $request->getCmd();
243  $this->requested_pg_id = $request->getPgId();
244  $this->requested_pg_type = $request->getPgType();
245  $this->requested_notification_switch = $request->getNotificationSwitch();
246  $this->requested_type = $request->getType();
247  $this->requested_url = $request->getUrl();
248 
249  $this->lm_set = $this->service->getSettings();
250  $this->lm_gui = $this->service->getLearningModuleGUI();
251  $this->lm = $this->service->getLearningModule();
252  $this->tracker = $this->service->getTracker();
253  $this->linker = $this->service->getLinker();
254  $this->embed_mode = $embed_mode;
255  if ($request->getEmbedMode()) {
256  $this->embed_mode = true;
257  }
258 
259  // language translation
260  $this->lang = $this->service->getPresentationStatus()->getLang();
261 
262  $this->lm_tree = $this->service->getLMTree();
263  $this->focus_id = $this->service->getPresentationStatus()->getFocusId();
264  $this->ot = ilObjectTranslation::getInstance($this->lm->getId());
265  $this->content_style_gui = $this->cs->gui();
266  $this->content_style_domain = $this->cs->domain()->styleForRefId($this->lm->getRefId());
267  }
268 
270  {
271  return $this->service;
272  }
273 
274  public function injectTemplate(ilGlobalTemplateInterface $tpl): void
275  {
276  $this->tpl = $tpl;
277  }
278 
279  protected function getTracker(): ilLMTracker
280  {
281  return $this->service->getTracker();
282  }
283 
289  public function executeCommand(): void
290  {
291  $ilNavigationHistory = $this->nav_history;
292  $ilAccess = $this->access;
293  $lng = $this->lng;
294  $ilCtrl = $this->ctrl;
295  $ilUser = $this->user;
296 
297  // check read permission and parent conditions
298  // todo: replace all this by ilAccess call
299  if (!$ilAccess->checkAccess("read", "", $this->requested_ref_id) &&
300  (!(($this->ctrl->getCmd() == "infoScreen" || $this->ctrl->getNextClass() == "ilinfoscreengui")
301  && $ilAccess->checkAccess("visible", "", $this->requested_ref_id)))) {
302  throw new ilPermissionException($lng->txt("permission_denied"));
303  }
304 
305  $next_class = $this->ctrl->getNextClass($this);
306  $cmd = $this->ctrl->getCmd("layout");
307 
308  $obj_id = $this->requested_obj_id;
309  $this->ctrl->setParameter($this, "obj_id", $this->requested_obj_id);
310  $ilNavigationHistory->addItem($this->requested_ref_id, $this->ctrl->getLinkTarget($this), "lm");
311  $this->ctrl->setParameter($this, "obj_id", $obj_id);
312 
313  switch ($next_class) {
314  case "ilcommentgui":
315  $ret = $this->layout();
316  break;
317 
318  case "ilinfoscreengui":
319  $ret = $this->outputInfoScreen();
320  break;
321 
322  case "ilcommonactiondispatchergui":
324  $gui->enableCommentsSettings(false);
325  $this->ctrl->forwardCommand($gui);
326  break;
327 
328  case "illmpagegui":
329  $page_gui = $this->getLMPageGUI($this->requested_obj_id);
330  $this->basicPageGuiInit($page_gui);
331  $ret = $ilCtrl->forwardCommand($page_gui);
332  break;
333 
334  case "ilassgenfeedbackpagegui":
335  $page_gui = new ilAssGenFeedbackPageGUI($this->requested_pg_id);
336  //$this->basicPageGuiInit($page_gui);
337  $ret = $ilCtrl->forwardCommand($page_gui);
338  break;
339 
340  case "ilglossarydefpagegui":
341  // see #32198
342  //$page_gui = new ilGlossaryDefPageGUI($this->requested_obj_id);
343  $page_gui = new ilGlossaryDefPageGUI($this->requested_pg_id);
344  $this->basicPageGuiInit($page_gui);
345  $ret = $ilCtrl->forwardCommand($page_gui);
346  break;
347 
348  case "illearningprogressgui":
349  $this->initScreenHead("learning_progress");
350  $new_gui = new ilLearningProgressGUI(
352  $this->requested_ref_id,
353  $ilUser->getId()
354  );
355  $this->ctrl->forwardCommand($new_gui);
356  // this is nasty, but the LP classes do "sometimes" a printToStdout
357  // sometimes not, (here editManual does, other commands not)
358  if ($this->ctrl->getCmd() !== "editManual") {
359  $this->tpl->printToStdout();
360  }
361  break;
362 
363  case "ilratinggui":
364  $rating_gui = new ilRatingGUI();
365  $rating_gui->setObject($this->lm->getId(), "lm", $this->requested_obj_id, "lm");
366  $this->ctrl->forwardCommand($rating_gui);
367  break;
368 
369  default:
370  if ($this->requested_notification_switch > 0) {
371  switch ($this->requested_notification_switch) {
372  case 1:
375  $this->user->getId(),
376  $this->lm->getId(),
377  false
378  );
379  break;
380 
381  case 2:
384  $this->user->getId(),
385  $this->lm->getId(),
386  true
387  );
388  break;
389 
390  case 3:
393  $this->user->getId(),
394  $this->getCurrentPageId(),
395  false
396  );
397  break;
398 
399  case 4:
402  $this->user->getId(),
403  $this->getCurrentPageId(),
404  true
405  );
406  break;
407  }
408  $ilCtrl->redirect($this, "layout");
409  }
410  $ret = $this->$cmd();
411  break;
412  }
413  }
414 
418  public function offlineMode(): bool
419  {
420  return $this->offline;
421  }
422 
423  public function getExportFormat(): string
424  {
425  return $this->export_format;
426  }
427 
431  public function nop(): void
432  {
433  }
434 
435  public function attrib2arr(?DOMNamedNodeMap $a_attributes): array
436  {
437  $attr = array();
438  if (!is_null($a_attributes)) {
439  foreach ($a_attributes as $attribute) {
440  $attr[$attribute->name] = $attribute->value;
441  }
442  }
443  return $attr;
444  }
445 
449  public function getCurrentFrameSet(): array
450  {
451  return $this->frames;
452  }
453 
457  public function determineLayout(): string
458  {
459  return "standard";
460  }
461 
465  public function resume(): void
466  {
467  $this->layout();
468  }
469 
470  public function layout(
471  string $a_xml = "main.xml",
472  bool $doShow = true
473  ): string {
474  $content = "";
475  $tpl = $this->tpl;
476  $ilUser = $this->user;
477  $layout = $this->determineLayout();
478 
479  // xmldocfile is deprecated! Use domxml_open_file instead.
480  // But since using relative pathes with domxml under windows don't work,
481  // we need another solution:
482  $xmlfile = file_get_contents("./Modules/LearningModule/layouts/lm/" . $layout . "/" . $a_xml);
483 
484  $error = null;
485  $doc = $this->dom_util->docFromString($xmlfile, $error);
486  $this->layout_doc = $doc;
487 
488  // get current frame node
489  $path = (empty($this->requested_frame) || ($this->requested_frame == "_blank"))
490  ? "/ilLayout/ilFrame[1]"
491  : "//ilFrame[@name='" . $this->requested_frame . "']";
492  $nodes = $this->dom_util->path($doc, $path);
493  if (count($nodes) != 1) {
494  throw new ilLMPresentationException("ilLMPresentation: XML File invalid. Found " . count($nodes) . " nodes for " .
495  " path " . $path . " in " . $layout . "/" . $a_xml . ". LM Layout is " . $this->lm->getLayout());
496  }
497  $node = $nodes->item(0);
498 
499  // ProcessFrameset
500  // node is frameset, if it has cols or rows attribute
501  $attributes = $this->attrib2arr($node->attributes);
502 
503  $this->frames = array();
504 
505  // ProcessContentTag
506  if ((empty($attributes["template"]) || !empty($this->requested_obj_type))
507  && ($this->requested_frame != "_blank" || $this->requested_obj_type != "MediaObject")) {
508  // we got a variable content frame (can display different
509  // object types (PageObject, MediaObject, GlossarItem)
510  // and contains elements for them)
511 
512  // determine object type
513  if (empty($this->requested_obj_type)) {
514  $obj_type = "PageObject";
515  } else {
516  $obj_type = $this->requested_obj_type;
517  }
518 
519  // get object specific node
520  $found = false;
521  foreach ($node->childNodes as $child) {
522  if ($child->nodeName == $obj_type) {
523  $found = true;
524  $attributes = $this->attrib2arr($child->attributes);
525  $node = $child;
526  //echo "<br>2node:".$node->node_name();
527  break;
528  }
529  }
530  if (!$found) {
531  throw new ilLMPresentationException("ilLMPresentation: No template specified for frame '" .
532  $this->requested_frame . "' and object type '" . $obj_type . "'.");
533  }
534  }
535 
536  // set style sheets
537  if (!$this->offlineMode()) {
538  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
539  } else {
540  $style_name = $ilUser->getPref("style") . ".css";
541  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
542  }
543 
544  // to make e.g. advanced seletions lists work:
545  // $GLOBALS["tpl"] = $this->tpl;
546 
547  foreach ($node->childNodes as $child) {
548  $child_attr = $this->attrib2arr($child->attributes);
549 
550  switch ($child->nodeName) {
551  case "ilPage":
552  $this->renderPageTitle();
553  $this->setHeader();
554  $this->addHeaderAction();
555  $content = $this->getContent();
556  $this->ilLMMenu();
557  $content .= $this->ilLMNotes();
558  $additional = $this->ui->renderer()->render($this->additional_content);
559  $this->tpl->setContent($content . $additional);
560  break;
561 
562  case "ilGlossary":
563  $this->ilGlossary();
564  break;
565 
566  case "ilLMNavigation":
567  // @todo 6.0
568  // $this->ilLMNavigation();
569  break;
570 
571  case "ilMedia":
572  $this->media();
573  break;
574 
575  case "ilLocator":
576  $this->ilLocator();
577  break;
578 
579  case "ilJavaScript":
580  $this->ilJavaScript(
581  $child_attr["inline"],
582  $child_attr["file"],
583  $child_attr["location"]
584  );
585  break;
586 
587  case "ilLMMenu":
588  //$this->ilLMMenu();
589  break;
590 
591  case "ilLMHead":
592  // @todo 6.0
593  // $this->ilLMHead();
594  break;
595 
596  case "ilLMSubMenu":
597  $this->ilLMSubMenu();
598  break;
599 
600  case "ilLMNotes":
601  $this->ilLMNotes();
602  break;
603  }
604  }
605 
606  $this->addResourceFiles();
607 
608  if ($doShow) {
609  $tpl->printToStdout();
610  } else {
611  $content = $tpl->printToString();
612  }
613 
614  return ($content);
615  }
616 
617  protected function addResourceFiles(): void
618  {
619  iljQueryUtil::initjQuery($this->tpl);
620  iljQueryUtil::initjQueryUI($this->tpl);
621  ilUIFramework::init($this->tpl);
622 
623  if (!$this->offlineMode()) {
626 
627  $this->tpl->addJavaScript("./Modules/LearningModule/js/LearningModule.js");
628 
629  // handle initial content
630  if ($this->requested_frame == "") {
631  $store = new ilSessionIStorage("lm");
632  $last_frame_url = $store->get("cf_" . $this->lm->getId());
633  if ($last_frame_url != "") {
634  $this->tpl->addOnLoadCode("il.LearningModule.setLastFrameUrl('" . $last_frame_url . "', 'center_bottom');");
635  }
636 
637  $this->tpl->addOnLoadCode("il.LearningModule.setSaveUrl('" .
638  $this->ctrl->getLinkTarget($this, "saveFrameUrl", "", false, false) . "');
639  il.LearningModule.openInitFrames();
640  ");
641 
642  $this->tpl->addOnLoadCode("il.LearningModule.setTocRefreshUrl('" .
643  $this->ctrl->getLinkTarget($this, "refreshToc", "", false, false) . "');
644  ");
645  }
646 
647  // from main menu
648  // $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
649  ilYuiUtil::initConnection($this->tpl);
650  }
651  }
652 
653  public function saveFrameUrl(): void
654  {
655  $store = new ilSessionIStorage("lm");
656  $store->set("cf_" . $this->lm->getId(), $this->requested_url);
657  }
658 
659  public function fullscreen(): string
660  {
661  return $this->media();
662  }
663 
664  public function media(): string
665  {
666  $this->tpl = new ilGlobalTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
667 
668  // set style sheets
669  $this->setContentStyles();
670  $this->setSystemStyle();
671 
672  $this->ilMedia();
673  if (!$this->offlineMode()) {
674  $this->tpl->printToStdout();
675  } else {
676  return $this->tpl->printToString();
677  }
678  return "";
679  }
680 
681  public function glossary(): string
682  {
683  $this->tpl = new ilGlobalTemplate("tpl.glossary_term_output.html", true, true, "Modules/LearningModule");
684  $this->renderPageTitle();
685 
686  iljQueryUtil::initjQuery($this->tpl);
687  iljQueryUtil::initjQueryUI($this->tpl);
688  ilUIFramework::init($this->tpl);
689  ilAccordionGUI::addJavaScript($this->tpl);
690  ilAccordionGUI::addCss($this->tpl);
691 
692  // set style sheets
693  $this->setContentStyles();
694  $this->setSystemStyle();
695 
696  $this->ilGlossary();
697 
698  $js = $this->global_screen->layout()->meta()->getJs();
699  foreach ($js->getItemsInOrderOfDelivery() as $item) {
700  $this->tpl->addJavaScript($item->getContent());
701  }
702 
703  if (!$this->offlineMode()) {
704  $this->tpl->printToStdout();
705  } else {
706  return $this->tpl->printToString();
707  }
708 
709  return "";
710  }
711 
712  public function page(): string
713  {
714  $ilUser = $this->user;
715  $this->tpl = new ilGlobalTemplate("tpl.page_fullscreen.html", true, true, "Modules/LearningModule");
716  $GLOBALS["tpl"] = $this->tpl;
717  $this->renderPageTitle();
718 
719  $this->setContentStyles();
720 
721  // set style sheets
722  if (!$this->offlineMode()) {
723  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
724  } else {
725  $style_name = $ilUser->getPref("style") . ".css";
726  $this->tpl->setVariable("LOCATION_STYLESHEET", "./style/" . $style_name);
727  }
728 
729  $this->tpl->setVariable("PAGE_CONTENT", $this->getPageContent());
730  if (!$this->offlineMode()) {
731  $this->tpl->printToStdout();
732  } else {
733  return $this->tpl->get();
734  }
735  return "";
736  }
737 
741  public function ilTOC(): ilLMTOCExplorerGUI
742  {
743  $fac = new ilLMTOCExplorerGUIFactory();
744  $exp = $fac->getExplorer($this->service, "ilTOC");
745  $exp->handleCommand();
746  return $exp;
747  }
748 
749  public function getLMPresentationTitle(): string
750  {
751  return $this->service->getPresentationStatus()->getLMPresentationTitle();
752  }
753 
754  public function ilLMMenu(): void
755  {
756  $this->renderTabs("content", $this->getCurrentPageId());
757  }
758 
759  public function setHeader(): void
760  {
761  $this->tpl->setTitle($this->getLMPresentationTitle());
762  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_lm.svg"));
763  }
764 
768  public function ilLMSubMenu(): void
769  {
770  $rbacsystem = $this->rbacsystem;
771  if ($this->abstract) {
772  return;
773  }
774 
775  $buttonTarget = ilFrameTargetInfo::_getFrame("MainContent");
776 
777  $tpl_menu = new ilTemplate("tpl.lm_sub_menu.html", true, true, "Modules/LearningModule");
778 
779  $pg_id = $this->getCurrentPageId();
780  if ($pg_id == 0) {
781  return;
782  }
783 
784  // edit learning module
785  if (!$this->offlineMode()) {
786  if ($rbacsystem->checkAccess("write", $this->requested_ref_id)) {
787  $tpl_menu->setCurrentBlock("edit_page");
788  $page_id = $this->getCurrentPageId();
789  $tpl_menu->setVariable(
790  "EDIT_LINK",
791  ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id .
792  "&obj_id=" . $page_id . "&to_page=1"
793  );
794  $tpl_menu->setVariable("EDIT_TXT", $this->lng->txt("edit_page"));
795  $tpl_menu->setVariable("EDIT_TARGET", $buttonTarget);
796  $tpl_menu->parseCurrentBlock();
797  }
798 
799  $page_id = $this->getCurrentPageId();
800 
801  // permanent link
802  $this->tpl->setPermanentLink("pg", null, $page_id . "_" . $this->lm->getRefId());
803  }
804 
805  $this->tpl->setVariable("SUBMENU", $tpl_menu->get());
806  }
807 
808  public function redrawHeaderAction(): void
809  {
810  echo $this->getHeaderAction(true);
811  exit;
812  }
813 
814  public function addHeaderAction(): void
815  {
816  //$this->tpl->setVariable("HEAD_ACTION", $this->getHeaderAction());
817  $this->tpl->setHeaderActionMenu($this->getHeaderAction());
818  }
819 
820  public function getHeaderAction(
821  bool $a_redraw = false
822  ): string {
823  if ($this->offline) {
824  return "";
825  }
826  $ilAccess = $this->access;
828  $tpl = $this->tpl;
829 
830  $lm_id = $this->lm->getId();
831  $pg_id = $this->getCurrentPageId();
832 
833  $this->lng->loadLanguageModule("content");
834 
835  $dispatcher = new ilCommonActionDispatcherGUI(
837  $ilAccess,
838  $this->lm->getType(),
839  $this->lm->getRefId(),
840  $this->lm->getId()
841  );
842  $dispatcher->setSubObject("pg", $this->getCurrentPageId());
843 
844  $this->ctrl->setParameter($this, "embed_mode", (int) $this->embed_mode);
845  $this->ctrl->setParameterByClass("ilcommentgui", "embed_mode", (int) $this->embed_mode);
846  $this->ctrl->setParameterByClass("iltagginggui", "embed_mode", (int) $this->embed_mode);
848  $this->ctrl->getLinkTarget($this, "redrawHeaderAction", "", true),
849  "",
850  $this->ctrl->getLinkTargetByClass(
851  array("ilcommonactiondispatchergui", "iltagginggui"),
852  "",
853  "",
854  true,
855  false
856  ),
857  $this->tpl
858  );
859 
860  $lg = $dispatcher->initHeaderAction();
861  if (!$ilSetting->get("disable_notes")) {
862  $lg->enableNotes(true);
863  if (!$this->embed_mode) {
864  $lg->enableComments($this->lm->publicNotes(), false);
865  }
866  }
867 
868  if ($this->lm->hasRating() && !$this->offlineMode()) {
869  $lg->enableRating(
870  true,
871  $this->lng->txt("lm_rating"),
872  false,
873  array("ilcommonactiondispatchergui", "ilratinggui"),
874  true
875  );
876  }
877 
878  // notification
879  if ($this->user->getId() != ANONYMOUS_USER_ID && !$this->embed_mode) {
880  if (ilNotification::hasNotification(ilNotification::TYPE_LM, $this->user->getId(), $lm_id)) {
881  $this->ctrl->setParameter($this, "ntf", 1);
882  if (ilNotification::hasOptOut($lm_id)) {
883  $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_deactivate_lm");
884  }
885 
886  $lg->addHeaderIcon(
887  "not_icon",
888  ilUtil::getImagePath("object/notification_on.svg"),
889  $this->lng->txt("cont_notification_activated")
890  );
891  } else {
892  $this->ctrl->setParameter($this, "ntf", 2);
893  $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_activate_lm");
894 
895  if (ilNotification::hasNotification(ilNotification::TYPE_LM_PAGE, $this->user->getId(), $pg_id)) {
896  $this->ctrl->setParameter($this, "ntf", 3);
897  $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_deactivate_page");
898 
899  $lg->addHeaderIcon(
900  "not_icon",
901  ilUtil::getImagePath("object/notification_on.svg"),
902  $this->lng->txt("cont_page_notification_activated")
903  );
904  } else {
905  $this->ctrl->setParameter($this, "ntf", 4);
906  $lg->addCustomCommand($this->ctrl->getLinkTarget($this), "cont_notification_activate_page");
907 
908  $lg->addHeaderIcon(
909  "not_icon",
910  ilUtil::getImagePath("object/notification_off.svg"),
911  $this->lng->txt("cont_notification_deactivated")
912  );
913  }
914  }
915  $this->ctrl->setParameter($this, "ntf", "");
916  }
917 
918  if (!$this->offline) {
919  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
920  if ($this->getCurrentPageId() <= 0) {
921  $link = $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "chapters");
922  } else {
923  $link = ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id .
924  "&obj_id=" . $this->getCurrentPageId() . "&to_page=1";
925  }
926  $lg->addCustomCommand($link, "edit_page");
927  }
928  }
929 
930  if (!$a_redraw) {
931  return $lg->getHeaderAction($this->tpl);
932  } else {
933  // we need to add onload code manually (rating, comments, etc.)
934  return $lg->getHeaderAction() .
935  $tpl->getOnLoadCodeForAsynch();
936  }
937  }
938 
942  public function ilLMNotes(): string
943  {
944  $ilAccess = $this->access;
946 
947  // no notes in offline (export) mode
948  if ($this->offlineMode()) {
949  return "";
950  }
951 
952  // now output comments
953 
954  if ($ilSetting->get("disable_comments")) {
955  return "";
956  }
957  if (!$this->lm->publicNotes()) {
958  return "";
959  }
960 
961  $next_class = $this->ctrl->getNextClass($this);
962 
963  $pg_id = $this->getCurrentPageId();
964 
965  if ($pg_id == 0) {
966  return "";
967  }
968  $notes_gui = $this->notes_gui->getCommentsGUI($this->lm->getId(), $this->getCurrentPageId(), "pg");
969  $notes_gui->setUseObjectTitleHeader(false);
970 
971  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id) &&
972  $ilSetting->get("comments_del_tutor", '1')) {
973  $notes_gui->enablePublicNotesDeletion(true);
974  }
975 
976  $this->ctrl->setParameter($this, "frame", $this->requested_frame);
977  $this->ctrl->setParameter($this, "obj_id", $this->requested_obj_id);
978 
979  $notes_gui->enablePrivateNotes();
980  if ($this->lm->publicNotes()) {
981  $notes_gui->enablePublicNotes();
982  }
983 
984  $callback = array($this, "observeNoteAction");
985  $notes_gui->addObserver($callback);
986 
987  if ($next_class == "ilcommentgui") {
988  $html = $this->ctrl->forwardCommand($notes_gui);
989  } else {
990  $html = $notes_gui->getListHTML();
991  }
992  return $html;
993  }
994 
995  public function ilLocator(): void
996  {
997  global $DIC;
998  $ltiview = $DIC["lti"];
999  $ilLocator = $this->locator;
1000 
1001  if (empty($this->requested_obj_id)) {
1002  $a_id = $this->lm_tree->getRootId();
1003  } else {
1004  $a_id = $this->requested_obj_id;
1005  }
1006 
1007  if (!$this->lm->cleanFrames()) {
1008  $frame_param = $this->requested_frame;
1009  $frame_target = "";
1010  } elseif (!$this->offlineMode()) {
1011  $frame_param = "";
1012  $frame_target = ilFrameTargetInfo::_getFrame("MainContent");
1013  } else {
1014  $frame_param = "";
1015  $frame_target = "_top";
1016  }
1017 
1018  if (!$this->offlineMode()) {
1019  // LTI
1020  if ($ltiview->isActive()) {
1021  // Do nothing, its complicated...
1022  } else {
1023  $ilLocator->addRepositoryItems();
1024  }
1025  } else {
1026  $ilLocator->setOffline(true);
1027  }
1028 
1029  if ($this->lm_tree->isInTree($a_id)) {
1030  $path = $this->lm_tree->getPathFull($a_id);
1031 
1032  foreach ($path as $key => $row) {
1033  if ($row["type"] != "pg") {
1034  if ($row["child"] != $this->lm_tree->getRootId()) {
1035  $ilLocator->addItem(
1038  $row["child"],
1040  $this->lm->isActiveNumbering(),
1041  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1042  false,
1043  0,
1044  $this->lang
1045  ),
1046  50,
1047  true
1048  ),
1049  $this->linker->getLink("layout", $row["child"], $frame_param, "StructureObject"),
1050  $frame_target
1051  );
1052  } else {
1053  $ilLocator->addItem(
1055  $this->linker->getLink("layout", 0, $frame_param),
1056  $frame_target,
1058  );
1059  }
1060  }
1061  }
1062  } else { // lonely page
1063  $ilLocator->addItem(
1064  $this->getLMPresentationTitle(),
1065  $this->linker->getLink("layout", 0, $this->requested_frame)
1066  );
1067 
1068  $lm_obj = ilLMObjectFactory::getInstance($this->lm, $a_id);
1069 
1070  $ilLocator->addItem(
1071  $lm_obj->getTitle(),
1072  $this->linker->getLink("layout", $a_id, $frame_param),
1073  $frame_target
1074  );
1075  }
1076 
1077  $this->tpl->setLocator();
1078  }
1079 
1083  public function getCurrentPageId(): ?int
1084  {
1085  return $this->service->getNavigationStatus()->getCurrentPage();
1086  }
1087 
1091  protected function setContentStyles(): void
1092  {
1093  // content style
1094  $this->content_style_gui->addCss(
1095  $this->tpl,
1096  $this->lm->getRefId()
1097  );
1098  $this->tpl->addCss(ilObjStyleSheet::getSyntaxStylePath());
1099  }
1100 
1104  protected function setSystemStyle(): void
1105  {
1106  $this->tpl->addCss(ilUtil::getStyleSheetLocation());
1107  }
1108 
1109  public function getContent(
1110  bool $skip_nav = false
1111  ): string {
1112  $this->fill_on_load_code = true;
1113  $this->setContentStyles();
1114 
1115  $tpl = new ilTemplate("tpl.lm_content.html", true, true, "Modules/LearningModule/Presentation");
1116 
1117  if (!$skip_nav) {
1118  $navigation_renderer = new ilLMNavigationRendererGUI(
1119  $this->service,
1120  $this,
1121  $this->lng,
1122  $this->user,
1123  $this->tpl,
1124  $this->requested_obj_id,
1125  $this->requested_back_pg,
1126  $this->requested_frame,
1127  $this->toolbar,
1128  $this->ui
1129  );
1130 
1131  $navigation_renderer->renderTop();
1132  //$tpl->setVariable("TOP_NAVIGATION", $navigation_renderer->renderTop());
1133  //$tpl->setVariable("BOTTOM_NAVIGATION", $navigation_renderer->renderBottom());
1134  }
1135  $tpl->setVariable("PAGE_CONTENT", $this->getPageContent());
1136  $tpl->setVariable("RATING", $this->renderRating());
1137 
1138  return $tpl->get();
1139  }
1140 
1141  protected function getPageContent(): string
1142  {
1143  $content_renderer = new ilLMContentRendererGUI(
1144  $this->service,
1145  $this,
1146  $this->lng,
1147  $this->ctrl,
1148  $this->access,
1149  $this->user,
1150  $this->help,
1151  $this->requested_obj_id
1152  );
1153 
1154  return $content_renderer->render();
1155  }
1156 
1157  protected function renderRating(): string
1158  {
1159  // rating
1160  $rating = "";
1161  if ($this->lm->hasRatingPages() && !$this->offlineMode()) {
1162  $rating_gui = new ilRatingGUI();
1163  $rating_gui->setObject($this->lm->getId(), "lm", $this->getCurrentPageId(), "lm");
1164  $rating_gui->setYourRatingText($this->lng->txt("lm_rate_page"));
1165 
1166  $this->ctrl->setParameter($this, "pg_id", $this->getCurrentPageId());
1167  $this->tpl->addOnLoadCode("il.LearningModule.setRatingUrl('" .
1168  $this->ctrl->getLinkTarget($this, "updatePageRating", "", true, false) .
1169  "')");
1170  $this->ctrl->setParameter($this, "pg_id", "");
1171 
1172  $rating = '<div id="ilrtrpg" style="text-align:right">' .
1173  $rating_gui->getHTML(true, true, "il.LearningModule.saveRating(%rating%);") .
1174  "</div>";
1175  }
1176  return $rating;
1177  }
1178 
1179  public function updatePageRating(): void
1180  {
1181  $ilUser = $this->user;
1182  $pg_id = $this->service->getRequest()->getPgId();
1183  if (!$this->ctrl->isAsynch() || !$pg_id) {
1184  exit();
1185  }
1186 
1187  $rating = $this->service->getRequest()->getRating();
1188  if ($rating) {
1190  $this->lm->getId(),
1191  "lm",
1192  $pg_id,
1193  "lm",
1194  $ilUser->getId(),
1195  $rating
1196  );
1197  } else {
1199  $this->lm->getId(),
1200  "lm",
1201  $pg_id,
1202  "lm",
1203  $ilUser->getId()
1204  );
1205  }
1206 
1207  $rating = new ilRatingGUI();
1208  $rating->setObject($this->lm->getId(), "lm", $pg_id, "lm");
1209  $rating->setYourRatingText($this->lng->txt("lm_rate_page"));
1210 
1211  echo $rating->getHTML(true, true, "il.LearningModule.saveRating(%rating%);");
1212 
1213  echo $this->tpl->getOnLoadCodeForAsynch();
1214  exit();
1215  }
1216 
1217  public function basicPageGuiInit(\ilPageObjectGUI $a_page_gui): void
1218  {
1219  $a_page_gui->setStyleId(
1220  $this->content_style_domain->getEffectiveStyleId()
1221  );
1222  if (!$this->offlineMode()) {
1223  $a_page_gui->setOutputMode("presentation");
1224  $this->fill_on_load_code = true;
1225  } else {
1226  $a_page_gui->setOutputMode("offline");
1227  $a_page_gui->setOfflineDirectory($this->getOfflineDirectory());
1228  $this->fill_on_load_code = false;
1229  }
1230  if (!$this->offlineMode()) {
1231  $this->ctrl->setParameter($this, "obj_id", $this->getCurrentPageId()); // see #22403
1232  }
1233  $a_page_gui->setFileDownloadLink($this->linker->getLink("downloadFile"));
1234  $a_page_gui->setSourcecodeDownloadScript($this->linker->getLink(
1235  "sourcecodeDownload",
1236  $this->getCurrentPageId()
1237  ));
1238  if (!$this->offlineMode()) {
1239  $this->ctrl->setParameter($this, "obj_id", $this->requested_obj_id);
1240  }
1241  $a_page_gui->setFullscreenLink($this->linker->getLink("fullscreen"));
1242  $a_page_gui->setSourcecodeDownloadScript($this->linker->getLink("download_paragraph"));
1243  }
1244 
1245  public function ilGlossary(): void
1246  {
1247  $ilCtrl = $this->ctrl;
1248 
1249  $term_gui = new ilGlossaryTermGUI($this->requested_obj_id);
1250 
1251  // content style
1252  $this->setContentStyles();
1253 
1254  $term_gui->setPageLinker($this->linker);
1255 
1256  $term_gui->setOfflineDirectory($this->getOfflineDirectory());
1257  if (!$this->offlineMode()) {
1258  $ilCtrl->setParameter($this, "pg_type", "glo");
1259  }
1260  $term_gui->output($this->offlineMode(), $this->tpl);
1261 
1262  if (!$this->offlineMode()) {
1263  $ilCtrl->setParameter($this, "pg_type", "");
1264  }
1265  }
1266 
1267  public function ilMedia(): void
1268  {
1269  $pg_frame = "";
1270  $this->setContentStyles();
1271 
1272  $this->renderPageTitle();
1273 
1274  $this->tpl->setCurrentBlock("ilMedia");
1275  $med_links = ilMediaItem::_getMapAreasIntLinks($this->requested_mob_id);
1276  $link_xml = $this->linker->getLinkXML($med_links);
1277 
1278  $media_obj = new ilObjMediaObject($this->requested_mob_id);
1279  if (!empty($this->requested_pg_id)) {
1280  $pg_obj = $this->getLMPage($this->requested_pg_id, $this->requested_pg_type);
1281  $pg_obj->buildDom();
1282 
1283  $xml = "<dummy>";
1284  // todo: we get always the first alias now (problem if mob is used multiple
1285  // times in page)
1286  $xml .= $pg_obj->getMediaAliasElement($this->requested_mob_id);
1287  } else {
1288  $xml = "<dummy>";
1289  // todo: we get always the first alias now (problem if mob is used multiple
1290  // times in page)
1291  $xml .= $media_obj->getXML(IL_MODE_ALIAS);
1292  }
1293  $xml .= $media_obj->getXML(IL_MODE_OUTPUT);
1294  $xml .= $link_xml;
1295  $xml .= "</dummy>";
1296 
1297  if (!$this->offlineMode()) {
1298  $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
1299  } else {
1300  $wb_path = "";
1301  }
1302 
1303  $mode = ($this->requested_cmd == "fullscreen")
1304  ? "fullscreen"
1305  : "media";
1306  $enlarge_path = ilUtil::getImagePath("media/enlarge.svg", false, "output", $this->offlineMode());
1307  $fullscreen_link =
1308  $this->linker->getLink("fullscreen");
1309  $params = array('mode' => $mode,
1310  'enlarge_path' => $enlarge_path,
1311  'link_params' => "ref_id=" . $this->lm->getRefId(),
1312  'fullscreen_link' => $fullscreen_link,
1313  'enable_html_mob' => ilObjMediaObject::isTypeAllowed("html") ? "y" : "n",
1314  'ref_id' => $this->lm->getRefId(),
1315  'pg_frame' => $pg_frame,
1316  'webspace_path' => $wb_path
1317  );
1318  $output = $this->xsl->process($xml, $params);
1319 
1320  // unmask user html
1321  $this->tpl->setVariable("MEDIA_CONTENT", $output);
1322 
1323  // add js
1325  }
1326 
1327  public function ilJavaScript(
1328  string $a_inline = "",
1329  string $a_file = "",
1330  string $a_location = ""
1331  ): void {
1332  if ($a_inline != "") {
1333  $js_tpl = new ilTemplate($a_inline, true, false, $a_location);
1334  $js = $js_tpl->get();
1335  $this->tpl->setVariable("INLINE_JS", $js);
1336  }
1337  }
1338 
1344  public function infoScreen(): void
1345  {
1346  $this->ctrl->setCmd("showSummary");
1347  $this->ctrl->setCmdClass("ilinfoscreengui");
1348  $this->outputInfoScreen();
1349  }
1350 
1354  public function showInfoScreen(): void
1355  {
1356  $this->outputInfoScreen();
1357  }
1358 
1359  protected function initScreenHead(
1360  string $a_active_tab = "info"
1361  ): void {
1362  $ilAccess = $this->access;
1363  $ilLocator = $this->locator;
1364 
1365  $this->renderPageTitle();
1366 
1367  $this->tpl->loadStandardTemplate();
1368  $this->tpl->setTitle($this->getLMPresentationTitle());
1369  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_lm.svg"));
1370 
1371  $this->renderTabs($a_active_tab, 0);
1372 
1373  // Full locator, if read permission is given
1374  if ($ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
1375  $this->ilLocator();
1376  } else {
1377  $ilLocator->addRepositoryItems();
1378  $this->tpl->setLocator();
1379  }
1380  }
1381 
1385  public function outputInfoScreen(): string
1386  {
1387  $ilAccess = $this->access;
1388 
1389  if (!$this->lm->isInfoEnabled()) {
1390  return "";
1391  }
1392 
1393  $this->initScreenHead();
1394 
1395  $this->lng->loadLanguageModule("meta");
1396 
1397  $info = new ilInfoScreenGUI($this->lm_gui);
1398  $info->enablePrivateNotes();
1399  //$info->enableLearningProgress();
1400  $info->enableNews();
1401  if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
1402  $news_set = new ilSetting("news");
1403  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
1404 
1405  $info->enableNewsEditing();
1406 
1407  if ($enable_internal_rss) {
1408  $info->setBlockProperty("news", "settings", true);
1409  }
1410  }
1411 
1412  // show standard meta data section
1413  $info->addMetaDataSections($this->lm->getId(), 0, $this->lm->getType());
1414 
1415  $this->lng->loadLanguageModule("copg");
1416  $est_reading_time = $this->reading_time_manager->getReadingTime($this->lm->getId());
1417  if (!is_null($est_reading_time)) {
1418  $info->addProperty(
1419  $this->lng->txt("copg_est_reading_time"),
1420  sprintf($this->lng->txt("copg_x_minutes"), $est_reading_time)
1421  );
1422  }
1423 
1424  if ($this->offlineMode()) {
1425  $this->tpl->setContent($info->getHTML());
1426  return $this->tpl->get();
1427  } else {
1428  // forward the command
1429  $this->ctrl->forwardCommand($info);
1430  //$this->tpl->setContent("aa");
1431  $this->tpl->printToStdout();
1432  }
1433  return "";
1434  }
1435 
1439  public function showPrintViewSelection(): void
1440  {
1441  $ilUser = $this->user;
1442  $lng = $this->lng;
1443 
1444  if (!$this->lm->isActivePrintView() || !$this->lm->isActiveLMMenu()) {
1445  return;
1446  }
1447 
1448  $disabled = false;
1449  $img_alt = "";
1450 
1451  $tpl = new ilTemplate("tpl.lm_print_selection.html", true, true, "Modules/LearningModule");
1452 
1453  $this->ctrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
1454  $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1455 
1456  $nodes = $this->lm_tree->getSubTree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
1457  $nodes = $this->filterNonAccessibleNode($nodes);
1458 
1459  $this->initPrintViewSelectionForm();
1460 
1461  foreach ($nodes as $node) {
1462  $img_src = "";
1463  $disabled = false;
1464  $img_alt = "";
1465 
1466  // check page activation
1467  $active = ilLMPage::_lookupActive(
1468  $node["obj_id"],
1469  $this->lm->getType(),
1470  (bool) $this->lm_set->get("time_scheduled_page_activation")
1471  );
1472 
1473  if ($node["type"] == "pg" &&
1474  !$active) {
1475  continue;
1476  }
1477 
1478  $text = "";
1479  $img_alt = "";
1480  $checked = false;
1481 
1482  switch ($node["type"]) {
1483  // page
1484  case "pg":
1485  $text =
1487  $node["obj_id"],
1488  $this->lm->getPageHeader(),
1489  $this->lm->isActiveNumbering(),
1490  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1491  false,
1492  0,
1493  $this->lang
1494  );
1495 
1496  if ($ilUser->getId() === ANONYMOUS_USER_ID &&
1497  $this->lm_gui->getObject()->getPublicAccessMode() == "selected") {
1498  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
1499  $disabled = true;
1500  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
1501  }
1502  }
1503  $img_src = ilUtil::getImagePath("standard/icon_pg.svg");
1504  $img_alt = $lng->txt("icon") . " " . $lng->txt("pg");
1505  break;
1506 
1507  // learning module
1508  case "du":
1509  $text = $this->getLMPresentationTitle();
1510  $img_src = ilUtil::getImagePath("standard/icon_lm.svg");
1511  $img_alt = $lng->txt("icon") . " " . $lng->txt("obj_lm");
1512  break;
1513 
1514  // chapter
1515  case "st":
1516  $text =
1518  $node["obj_id"],
1520  $this->lm->isActiveNumbering(),
1521  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1522  false,
1523  0,
1524  $this->lang
1525  );
1526  if ($ilUser->getId() === ANONYMOUS_USER_ID &&
1527  $this->lm_gui->getObject()->getPublicAccessMode() == "selected") {
1528  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
1529  $disabled = true;
1530  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
1531  }
1532  }
1533  $img_src = ilUtil::getImagePath("standard/icon_st.svg");
1534  $img_alt = $lng->txt("icon") . " " . $lng->txt("st");
1535  break;
1536  }
1537 
1539  $this->lm->getRefId(),
1540  $this->lm->getId(),
1541  $node["obj_id"]
1542  )) {
1543  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
1544  }
1545 
1546  $this->nl->addListNode(
1547  $node["obj_id"],
1548  $text,
1549  $node["parent"],
1550  $checked,
1551  $disabled,
1552  $img_src,
1553  $img_alt
1554  );
1555  }
1556 
1557  // check for free page
1558  if ($this->requested_obj_id > 0 && !$this->lm_tree->isInTree($this->requested_obj_id)) {
1559  $text =
1561  $this->requested_obj_id,
1562  $this->lm->getPageHeader(),
1563  $this->lm->isActiveNumbering(),
1564  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1565  false,
1566  0,
1567  $this->lang
1568  );
1569 
1570  if ($ilUser->getId() === ANONYMOUS_USER_ID &&
1571  $this->lm_gui->getObject()->getPublicAccessMode() == "selected") {
1572  if (!ilLMObject::_isPagePublic($this->requested_obj_id)) {
1573  $disabled = true;
1574  $text .= " (" . $this->lng->txt("cont_no_access") . ")";
1575  }
1576  }
1577  $img_src = ilUtil::getImagePath("standard/icon_pg.svg");
1579 
1580  $checked = true;
1581 
1582  $this->nl->addListNode(
1583  $id,
1584  $text,
1585  0,
1586  $checked,
1587  $disabled,
1588  $img_src,
1589  $img_alt
1590  );
1591  }
1592 
1593  $f = $this->form->getHTMLAsync();
1594 
1595  $tpl->setVariable("ITEM_SELECTION", $f);
1596 
1597  $modal = $this->ui->factory()->modal()->roundtrip(
1598  $this->lng->txt("cont_print_view"),
1599  $this->ui->factory()->legacy($tpl->get())
1600  );
1601  echo $this->ui->renderer()->render($modal);
1602  exit();
1603  }
1604 
1605  protected function filterNonAccessibleNode(
1606  array $nodes
1607  ): array {
1608  $tracker = $this->getTracker();
1609  // if navigation is restricted based on correct answered questions
1610  // check if we have preceeding pages including unsanswered/incorrect answered questions
1611  if (!$this->offlineMode()) {
1612  if ($this->lm->getRestrictForwardNavigation()) {
1613  $nodes = array_filter($nodes, function ($node) use ($tracker) {
1614  return !$tracker->hasPredIncorrectAnswers($node["child"]);
1615  });
1616  }
1617  }
1618  return $nodes;
1619  }
1620 
1621  public function initPrintViewSelectionForm(): void
1622  {
1623  $lng = $this->lng;
1624  $ilCtrl = $this->ctrl;
1625 
1626  $this->form = new ilPropertyFormGUI();
1627  $this->form->setForceTopButtons(true);
1628 
1629  // selection type
1630  $radg = new ilRadioGroupInputGUI($lng->txt("cont_selection"), "sel_type");
1631  $radg->setValue("page");
1632  $op1 = new ilRadioOption($lng->txt("cont_current_page"), "page");
1633  $radg->addOption($op1);
1634  $op2 = new ilRadioOption($lng->txt("cont_current_chapter"), "chapter");
1635  $radg->addOption($op2);
1636  $op3 = new ilRadioOption($lng->txt("cont_selected_pg_chap"), "selection");
1637  $radg->addOption($op3);
1638 
1639  $nl = new ilNestedListInputGUI("", "obj_id");
1640  $this->nl = $nl;
1641  $op3->addSubItem($nl);
1642 
1643  $this->form->addItem($radg);
1644 
1645  $this->form->addCommandButton("showPrintView", $lng->txt("cont_show_print_view"));
1646  $this->form->setOpenTag(false);
1647  $this->form->setCloseTag(false);
1648 
1649  $this->form->setTitle(" ");
1650  $this->form->setFormAction($ilCtrl->getFormAction($this));
1651  }
1652 
1653  public function showPrintView(): void
1654  {
1655  $ilUser = $this->user;
1656  $lng = $this->lng;
1657  $ilCtrl = $this->ctrl;
1658  $tabs = $this->tabs;
1659  $header_page_content = "";
1660  $footer_page_content = "";
1661  $chapter_title = "";
1662  $did_chap_page_header = false;
1663  $description = "";
1664 
1665  if (!$this->lm->isActivePrintView() || !$this->lm->isActiveLMMenu()) {
1666  return;
1667  }
1668 
1669  $this->renderPageTitle();
1670 
1671  $tabs->setBackTarget(
1672  $lng->txt("back"),
1673  $ilCtrl->getLinkTarget($this, "layout")
1674  );
1675 
1676  $c_obj_id = $this->getCurrentPageId();
1677  // set values according to selection
1678  $sel_type = $this->service->getRequest()->getSelectedType();
1679  $sel_obj_ids = $this->service->getRequest()->getSelectedObjIds();
1680  if ($sel_type == "page") {
1681  if (!in_array($c_obj_id, $sel_obj_ids)) {
1682  $sel_obj_ids[] = $c_obj_id;
1683  }
1684  }
1685  if ($sel_type == "chapter" && $c_obj_id > 0) {
1686  $path = $this->lm_tree->getPathFull($c_obj_id);
1687  $chap_id = $path[1]["child"];
1688  if ($chap_id > 0) {
1689  $sel_obj_ids[] = $chap_id;
1690  }
1691  }
1692 
1693  $this->setContentStyles();
1694  $this->tpl->addCss(ilObjStyleSheet::getContentPrintStyle());
1695 
1696  $tpl = new ilTemplate("tpl.lm_print_view.html", true, true, "Modules/LearningModule");
1697 
1698  // set title header
1699  $this->tpl->setTitle($this->getLMPresentationTitle());
1700 
1701  $nodes = $this->lm_tree->getSubTree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
1702 
1703  $act_level = 99999;
1704  $activated = false;
1705 
1706  $glossary_links = array();
1707  $output_header = false;
1708  $media_links = array();
1709  $last_page_title = "";
1710 
1711  // get header and footer
1712  if ($this->lm->getFooterPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
1713  if (ilLMObject::_exists($this->lm->getFooterPage())) {
1714  $page_object_gui = $this->getLMPageGUI($this->lm->getFooterPage());
1715  $page_object_gui->setStyleId(
1716  $this->content_style_domain->getEffectiveStyleId()
1717  );
1718 
1719  // determine target frames for internal links
1720  $page_object_gui->setLinkFrame($this->requested_frame);
1721  $page_object_gui->setOutputMode("print");
1722  $page_object_gui->setPresentationTitle("");
1723  $page_object_gui->setFileDownloadLink("#");
1724  $page_object_gui->setFullscreenLink("#");
1725  $page_object_gui->setSourcecodeDownloadScript("#");
1726  $footer_page_content = $page_object_gui->showPage();
1727  }
1728  }
1729  if ($this->lm->getHeaderPage() > 0 && !$this->lm->getHideHeaderFooterPrint()) {
1730  if (ilLMObject::_exists($this->lm->getHeaderPage())) {
1731  $page_object_gui = $this->getLMPageGUI($this->lm->getHeaderPage());
1732  $page_object_gui->setStyleId(
1733  $this->content_style_domain->getEffectiveStyleId()
1734  );
1735 
1736  // determine target frames for internal links
1737  $page_object_gui->setLinkFrame($this->requested_frame);
1738  $page_object_gui->setOutputMode("print");
1739  $page_object_gui->setPresentationTitle("");
1740  $page_object_gui->setFileDownloadLink("#");
1741  $page_object_gui->setFullscreenLink("#");
1742  $page_object_gui->setSourcecodeDownloadScript("#");
1743  $header_page_content = $page_object_gui->showPage();
1744  }
1745  }
1746 
1747  // add free selected pages
1748  if (count($sel_obj_ids) > 0) {
1749  foreach ($sel_obj_ids as $k) {
1750  if ($k > 0 && !$this->lm_tree->isInTree($k)) {
1751  if (ilLMObject::_lookupType($k) == "pg") {
1752  $nodes[] = array("obj_id" => $k, "type" => "pg", "free" => true);
1753  }
1754  }
1755  }
1756  } else {
1757  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_print_no_page_selected"), true);
1758  $ilCtrl->redirect($this, "showPrintViewSelection");
1759  }
1760 
1761  foreach ($nodes as $node_key => $node) {
1762  // check page activation
1763  $active = ilLMPage::_lookupActive(
1764  $node["obj_id"],
1765  $this->lm->getType(),
1766  (bool) $this->lm_set->get("time_scheduled_page_activation")
1767  );
1768  if ($node["type"] == "pg" && !$active) {
1769  continue;
1770  }
1771 
1772  // print all subchapters/subpages if higher chapter
1773  // has been selected
1774  if ($node["depth"] <= $act_level) {
1775  if (in_array($node["obj_id"], $sel_obj_ids)) {
1776  $act_level = $node["depth"];
1777  $activated = true;
1778  } else {
1779  $act_level = 99999;
1780  $activated = false;
1781  }
1782  }
1783  if ($this->lm->getRestrictForwardNavigation()) {
1784  if ($this->getTracker()->hasPredIncorrectAnswers($node["obj_id"])) {
1785  continue;
1786  }
1787  }
1788  if ($activated &&
1790  $this->lm->getRefId(),
1791  $this->lm->getId(),
1792  $node["obj_id"]
1793  )) {
1794  // output learning module header
1795  if ($node["type"] == "du") {
1796  $output_header = true;
1797  }
1798 
1799  // output chapter title
1800  if ($node["type"] == "st") {
1801  if ($ilUser->getId() === ANONYMOUS_USER_ID &&
1802  $this->lm_gui->getObject()->getPublicAccessMode() == "selected") {
1803  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
1804  continue;
1805  }
1806  }
1807 
1808  $chap = new ilStructureObject($this->lm, $node["obj_id"]);
1809  $tpl->setCurrentBlock("print_chapter");
1810 
1811  $chapter_title = $chap->_getPresentationTitle(
1812  $node["obj_id"],
1814  $this->lm->isActiveNumbering(),
1815  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1816  false,
1817  0,
1818  $this->lang
1819  );
1820  $tpl->setVariable(
1821  "CHAP_TITLE",
1822  $chapter_title
1823  );
1824 
1825  if ($this->lm->getPageHeader() == ilLMObject::CHAPTER_TITLE) {
1826  if ($nodes[$node_key + 1]["type"] == "pg") {
1827  $tpl->setVariable(
1828  "CHAP_HEADER",
1829  $header_page_content
1830  );
1831  $did_chap_page_header = true;
1832  }
1833  }
1834 
1835  $tpl->parseCurrentBlock();
1836  $tpl->setCurrentBlock("print_block");
1837  $tpl->parseCurrentBlock();
1838  }
1839 
1840  // output page
1841  if ($node["type"] === "pg") {
1842  if ($ilUser->getId() === ANONYMOUS_USER_ID &&
1843  $this->lm_gui->getObject()->getPublicAccessMode() === "selected") {
1844  if (!ilLMObject::_isPagePublic($node["obj_id"])) {
1845  continue;
1846  }
1847  }
1848 
1849  $tpl->setCurrentBlock("print_item");
1850 
1851  // get page
1852  $page_id = $node["obj_id"];
1853  $page_object_gui = $this->getLMPageGUI($page_id);
1854  $page_object = $page_object_gui->getPageObject();
1855  $page_object_gui->setStyleId(
1856  $this->content_style_domain->getEffectiveStyleId()
1857  );
1858 
1859  // get lm page
1860  $lm_pg_obj = new ilLMPageObject($this->lm, $page_id);
1861  $lm_pg_obj->setLMId($this->lm->getId());
1862 
1863  // determine target frames for internal links
1864  $page_object_gui->setLinkFrame($this->requested_frame);
1865  $page_object_gui->setOutputMode("print");
1866  $page_object_gui->setPresentationTitle("");
1867 
1868  // if ($this->lm->getPageHeader() == ilLMObject::PAGE_TITLE || ($node["free"] ?? false) === true) {
1869  if (true) {
1871  $lm_pg_obj->getId(),
1872  $this->lm->getPageHeader(),
1873  $this->lm->isActiveNumbering(),
1874  (bool) $this->lm_set->get("time_scheduled_page_activation"),
1875  false,
1876  0,
1877  $this->lang
1878  );
1879 
1880  if ($this->lm->getPageHeader() === ilLMObject::CHAPTER_TITLE) {
1881  // remove the suffic (x/n)
1882  $page_title = trim(substr($page_title, 0, strrpos($page_title, " ")));
1883  }
1884 
1885  // prevent page title after chapter title
1886  // that have the same content
1887  if ($this->lm->isActiveNumbering()) {
1888  $chapter_title = trim(substr(
1889  $chapter_title,
1890  strpos($chapter_title, " ")
1891  ));
1892  }
1893 
1894  if ($page_title != $chapter_title && $page_title !== $last_page_title) {
1895  $page_object_gui->setPresentationTitle($page_title);
1896  }
1897  $last_page_title = $page_title;
1898  }
1899 
1900  // handle header / footer
1901  $hcont = $header_page_content;
1902  $fcont = $footer_page_content;
1903 
1904  if ($this->lm->getPageHeader() == ilLMObject::CHAPTER_TITLE) {
1905  if ($did_chap_page_header) {
1906  $hcont = "";
1907  }
1908  if (($nodes[$node_key + 1]["type"] ?? "") == "pg" &&
1909  !($nodes[$node_key + 1]["depth"] <= $act_level
1910  && !in_array($nodes[$node_key + 1]["obj_id"], $sel_obj_ids))) {
1911  $fcont = "";
1912  }
1913  }
1914 
1915  $page_object_gui->setFileDownloadLink("#");
1916  $page_object_gui->setFullscreenLink("#");
1917  $page_object_gui->setSourcecodeDownloadScript("#");
1918  $page_content = $page_object_gui->showPage();
1919  if ($this->lm->getPageHeader() != ilLMObject::PAGE_TITLE) {
1920  $tpl->setVariable(
1921  "CONTENT",
1922  $hcont . $page_content . $fcont
1923  );
1924  } else {
1925  $tpl->setVariable(
1926  "CONTENT",
1927  $hcont . $page_content . $fcont . "<br />"
1928  );
1929  }
1930  $chapter_title = "";
1931  $tpl->parseCurrentBlock();
1932  $tpl->setCurrentBlock("print_block");
1933  $tpl->parseCurrentBlock();
1934 
1935  // get internal links
1936  $int_links = ilInternalLink::_getTargetsOfSource($this->lm->getType() . ":pg", $node["obj_id"]);
1937 
1938  $got_mobs = false;
1939 
1940  foreach ($int_links as $key => $link) {
1941  if ($link["type"] == "git" &&
1942  ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
1943  $glossary_links[$key] = $link;
1944  }
1945  if ($link["type"] == "mob" &&
1946  ($link["inst"] == IL_INST_ID || $link["inst"] == 0)) {
1947  $got_mobs = true;
1948  $mob_links[$key] = $link;
1949  }
1950  }
1951 
1952  // this is not cool because of performance reasons
1953  // unfortunately the int link table does not
1954  // store the target frame (we want to append all linked
1955  // images but not inline images (i.e. mobs with no target
1956  // frame))
1957  if ($got_mobs) {
1958  $page_object->buildDom();
1959  $links = $page_object->getInternalLinks();
1960  $tf = $link["TargetFrame"] ?? "";
1961  foreach ($links as $link) {
1962  if ($link["Type"] === "MediaObject"
1963  && $tf !== ""
1964  && $tf !== "None") {
1965  $media_links[] = $link;
1966  }
1967  }
1968  }
1969  }
1970  }
1971  }
1972 
1973  $annex_cnt = 0;
1974  $annexes = array();
1975 
1976  // glossary
1977  if (count($glossary_links) > 0 && !$this->lm->isActivePreventGlossaryAppendix()) {
1978  // sort terms
1979  $terms = array();
1980 
1981  foreach ($glossary_links as $key => $link) {
1982  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"]);
1983  $terms[$term . ":" . $key] = array("key" => $key, "link" => $link, "term" => $term);
1984  }
1985  $terms = ilArrayUtil::sortArray($terms, "term", "asc");
1986  //ksort($terms);
1987 
1988  foreach ($terms as $t) {
1989  $link = $t["link"];
1990  $key = $t["key"];
1991 
1992  try {
1993  // output definition of term
1994  $page_gui = new ilGlossaryDefPageGUI($link["id"]);
1995  $page_gui->setTemplateOutput(false);
1996  $page_gui->setOutputMode("print");
1997 
1998  $tpl->setCurrentBlock("definition");
1999  $page_gui->setFileDownloadLink("#");
2000  $page_gui->setFullscreenLink("#");
2001  $page_gui->setSourcecodeDownloadScript("#");
2002  $output = $page_gui->showPage();
2003  $tpl->setVariable("VAL_DEFINITION", $output);
2004  $tpl->parseCurrentBlock();
2005 
2006  // output term
2007  $tpl->setCurrentBlock("term");
2008  $tpl->setVariable(
2009  "VAL_TERM",
2010  $term = ilGlossaryTerm::_lookGlossaryTerm($link["id"])
2011  );
2012  $tpl->parseCurrentBlock();
2013  } catch (Exception $e) {
2014 
2015  }
2016  }
2017 
2018  // output glossary header
2019  $annex_cnt++;
2020  $tpl->setCurrentBlock("glossary");
2021  $annex_title = $this->lng->txt("cont_annex") . " " .
2022  chr(64 + $annex_cnt) . ": " . $this->lng->txt("glo");
2023  $tpl->setVariable("TXT_GLOSSARY", $annex_title);
2024  $tpl->parseCurrentBlock();
2025 
2026  $annexes[] = $annex_title;
2027  }
2028 
2029  // referenced images
2030  if (count($media_links) > 0) {
2031  foreach ($media_links as $media) {
2032  if (substr($media["Target"], 0, 4) == "il__") {
2033  $arr = explode("_", $media["Target"]);
2034  $id = $arr[count($arr) - 1];
2035 
2036  $med_obj = new ilObjMediaObject($id);
2037  $med_item = $med_obj->getMediaItem("Standard");
2038  if (is_object($med_item)) {
2039  if (is_int(strpos($med_item->getFormat(), "image"))) {
2040  $tpl->setCurrentBlock("ref_image");
2041 
2042  // image source
2043  if ($med_item->getLocationType() == "LocalFile") {
2044  $tpl->setVariable(
2045  "IMG_SOURCE",
2046  ilFileUtils::getWebspaceDir("output") . "/mobs/mm_" . $id .
2047  "/" . $med_item->getLocation()
2048  );
2049  } else {
2050  $tpl->setVariable(
2051  "IMG_SOURCE",
2052  $med_item->getLocation()
2053  );
2054  }
2055 
2056  if ($med_item->getCaption() != "") {
2057  $tpl->setVariable("IMG_TITLE", $med_item->getCaption());
2058  } else {
2059  $tpl->setVariable("IMG_TITLE", $med_obj->getTitle());
2060  }
2061  $tpl->parseCurrentBlock();
2062  }
2063  }
2064  }
2065  }
2066 
2067  // output glossary header
2068  $annex_cnt++;
2069  $tpl->setCurrentBlock("ref_images");
2070  $annex_title = $this->lng->txt("cont_annex") . " " .
2071  chr(64 + $annex_cnt) . ": " . $this->lng->txt("cont_ref_images");
2072  $tpl->setVariable("TXT_REF_IMAGES", $annex_title);
2073  $tpl->parseCurrentBlock();
2074 
2075  $annexes[] = $annex_title;
2076  }
2077 
2078  // output learning module title and toc
2079  if ($output_header) {
2080  $tpl->setCurrentBlock("print_header");
2081  $tpl->setVariable("LM_TITLE", $this->getLMPresentationTitle());
2082  if ($this->lm->getDescription() != "none") {
2083  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
2084  $md_gen = $md->getGeneral();
2085  foreach ($md_gen->getDescriptionIds() as $id) {
2086  $md_des = $md_gen->getDescription($id);
2087  $description = $md_des->getDescription();
2088  }
2089 
2090  $tpl->setVariable(
2091  "LM_DESCRIPTION",
2092  $description
2093  );
2094  }
2095  $tpl->parseCurrentBlock();
2096 
2097  // output toc
2098  $nodes2 = $nodes;
2099  foreach ($nodes2 as $node2) {
2100  if ($node2["type"] == "st"
2102  $this->lm->getRefId(),
2103  $this->lm->getId(),
2104  $node2["obj_id"]
2105  )) {
2106  for ($j = 1; $j < $node2["depth"]; $j++) {
2107  $tpl->setCurrentBlock("indent");
2108  $tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
2109  $tpl->parseCurrentBlock();
2110  }
2111  $tpl->setCurrentBlock("toc_entry");
2112  $tpl->setVariable(
2113  "TXT_TOC_TITLE",
2115  $node2["obj_id"],
2117  $this->lm->isActiveNumbering(),
2118  (bool) $this->lm_set->get("time_scheduled_page_activation"),
2119  false,
2120  0,
2121  $this->lang
2122  )
2123  );
2124  $tpl->parseCurrentBlock();
2125  }
2126  }
2127 
2128  // annexes
2129  foreach ($annexes as $annex) {
2130  $tpl->setCurrentBlock("indent");
2131  $tpl->setVariable("IMG_BLANK", ilUtil::getImagePath("browser/blank.png"));
2132  $tpl->parseCurrentBlock();
2133  $tpl->setCurrentBlock("toc_entry");
2134  $tpl->setVariable("TXT_TOC_TITLE", $annex);
2135  $tpl->parseCurrentBlock();
2136  }
2137 
2138  $tpl->setCurrentBlock("toc");
2139  $tpl->setVariable("TXT_TOC", $this->lng->txt("cont_toc"));
2140  $tpl->parseCurrentBlock();
2141 
2142  $tpl->setCurrentBlock("print_start_block");
2143  $tpl->parseCurrentBlock();
2144  }
2145 
2146  // output author information
2147  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
2148  if (is_object($lifecycle = $md->getLifecycle())) {
2149  $sep = $author = "";
2150  foreach (($ids = $lifecycle->getContributeIds()) as $con_id) {
2151  $md_con = $lifecycle->getContribute($con_id);
2152  if ($md_con->getRole() == "Author") {
2153  foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
2154  $md_ent = $md_con->getEntity($ent_id);
2155  $author = $author . $sep . $md_ent->getEntity();
2156  $sep = ", ";
2157  }
2158  }
2159  }
2160  if ($author != "") {
2161  $this->lng->loadLanguageModule("meta");
2162  $tpl->setCurrentBlock("author");
2163  $tpl->setVariable("TXT_AUTHOR", $this->lng->txt("meta_author"));
2164  $tpl->setVariable("LM_AUTHOR", $author);
2165  $tpl->parseCurrentBlock();
2166  }
2167  }
2168 
2169  // output copyright information
2170  if (is_object($md_rights = $md->getRights())) {
2171  $copyright = $md_rights->getDescription();
2172  $copyright = ilMDUtils::_parseCopyright($copyright);
2173 
2174  if ($copyright != "") {
2175  $this->lng->loadLanguageModule("meta");
2176  $tpl->setCurrentBlock("copyright");
2177  $tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
2178  $tpl->setVariable("LM_COPYRIGHT", $copyright);
2179  $tpl->parseCurrentBlock();
2180  }
2181  }
2182  $this->tpl->setContent($tpl->get());
2183  $this->tpl->addOnLoadCode("il.Util.print();");
2184  $this->tpl->printToStdout();
2185  }
2186 
2190  public function downloadFile(): void
2191  {
2192  $page_gui = $this->getLMPageGUI($this->getCurrentPageId());
2193  $page_gui->downloadFile();
2194  }
2195 
2199  public function showDownloadList(): void
2200  {
2201  if (!$this->lm->isActiveDownloads() || !$this->lm->isActiveLMMenu()) {
2202  return;
2203  }
2204  $tpl = new ilTemplate("tpl.lm_download_list.html", true, true, "Modules/LearningModule");
2205 
2206  // output copyright information
2207  $md = new ilMD($this->lm->getId(), 0, $this->lm->getType());
2208  if (is_object($md_rights = $md->getRights())) {
2209  $copyright = $md_rights->getDescription();
2210 
2211  $copyright = ilMDUtils::_parseCopyright($copyright);
2212 
2213  if ($copyright != "") {
2214  $this->lng->loadLanguageModule("meta");
2215  $tpl->setCurrentBlock("copyright");
2216  $tpl->setVariable("TXT_COPYRIGHT", $this->lng->txt("meta_copyright"));
2217  $tpl->setVariable("LM_COPYRIGHT", $copyright);
2218  $tpl->parseCurrentBlock();
2219  }
2220  }
2221 
2222  $download_table = new ilLMDownloadTableGUI($this, "showDownloadList", $this->lm);
2223  $tpl->setVariable("DOWNLOAD_TABLE", $download_table->getHTML());
2224  //$this->tpl->printToStdout();
2225 
2226  $modal = $this->ui->factory()->modal()->roundtrip(
2227  $this->lng->txt("download"),
2228  $this->ui->factory()->legacy($tpl->get())
2229  );
2230  echo $this->ui->renderer()->render($modal);
2231  exit();
2232  }
2233 
2237  public function downloadExportFile(): void
2238  {
2239  if (!$this->lm->isActiveDownloads() || !$this->lm->isActiveLMMenu()) {
2240  return;
2241  }
2242 
2243  $type = $this->requested_type;
2244  $base_type = explode("_", $type);
2245  $base_type = $base_type[0];
2246  $file = $this->lm->getPublicExportFile($base_type);
2247  if ($this->lm->getPublicExportFile($base_type) != "") {
2248  $dir = $this->lm->getExportDirectory($type);
2249  if (is_file($dir . "/" . $file)) {
2250  ilFileDelivery::deliverFileLegacy($dir . "/" . $file, $file);
2251  exit;
2252  }
2253  }
2254  }
2255 
2262  public function getFocusLink(
2263  int $a_ref_id,
2264  int $a_obj_id,
2265  int $a_return_ref_id
2266  ): string {
2267  return "ilias.php?baseClass=ilLMPresentationGUI&amp;ref_id=" . $a_ref_id . "&amp;obj_id=" . $a_obj_id . "&amp;focus_id=" .
2268  $a_obj_id . "&amp;focus_return=" . $a_return_ref_id;
2269  }
2270 
2271  public function showMessageScreen(
2272  string $a_content
2273  ): void {
2274  // content style
2275  $this->setContentStyles();
2276 
2277  $tpl = new ilTemplate("tpl.page_message_screen.html", true, true, "Modules/LearningModule");
2278  $tpl->setVariable("TXT_PAGE_NO_PUBLIC_ACCESS", $a_content);
2279 
2280  $this->tpl->setVariable("PAGE_CONTENT", $tpl->get());
2281  }
2282 
2286  public function showNoPublicAccess(): void
2287  {
2288  $this->showMessageScreen($this->lng->txt("msg_page_no_public_access"));
2289  }
2290 
2294  public function showNoPageAccess(): void
2295  {
2296  $this->showMessageScreen($this->lng->txt("msg_no_page_access"));
2297  }
2298 
2303  public function showNavRestrictionDueToQuestions(): void
2304  {
2305  $this->showMessageScreen($this->lng->txt("cont_no_page_access_unansw_q"));
2306  }
2307 
2308  public function getSourcecodeDownloadLink(): string
2309  {
2310  if (!$this->offlineMode()) {
2311  return $this->ctrl->getLinkTarget($this, "");
2312  } else {
2313  return "";
2314  }
2315  }
2316 
2317  public function getOfflineDirectory(): string
2318  {
2319  return $this->offline_directory;
2320  }
2321 
2326  public function handleCodeParagraph(
2327  int $page_id,
2328  int $paragraph_id,
2329  string $title,
2330  string $text
2331  ): void {
2332  $directory = $this->getOfflineDirectory() . "/codefiles/" . $page_id . "/" . $paragraph_id;
2333  ilFileUtils::makeDirParents($directory);
2334  $file = $directory . "/" . $title;
2335  if (!($fp = fopen($file, "w+"))) {
2336  die("<strong>Error</strong>: Could not open \"" . $file . "\" for writing" .
2337  " in <strong>" . __FILE__ . "</strong> on line <strong>" . __LINE__ . "</strong><br />");
2338  }
2339  chmod($file, 0770);
2340  fwrite($fp, $text);
2341  fclose($fp);
2342  }
2343 
2344  // #8613
2345  protected function renderPageTitle(): void
2346  {
2347  $this->tpl->setHeaderPageTitle($this->getLMPresentationTitle());
2348  }
2349 
2350  public function getLMPageGUI(int $a_id): ilLMPageGUI
2351  {
2352  $concrete_lang = $this->service->getPresentationStatus()->getConcreteLang();
2353  if ($this->lang != "-" && ilPageObject::_exists("lm", $a_id, $this->lang)) {
2354  return new ilLMPageGUI($a_id, 0, false, $this->lang, $concrete_lang);
2355  }
2356  if ($this->lang != "-" && ilPageObject::_exists("lm", $a_id, $this->ot->getFallbackLanguage())) {
2357  return new ilLMPageGUI($a_id, 0, false, $this->ot->getFallbackLanguage(), $concrete_lang);
2358  }
2359  return new ilLMPageGUI($a_id, 0, false, "", $concrete_lang);
2360  }
2361 
2362  public function getLMPage(
2363  int $a_id,
2364  string $a_type = ""
2365  ): ilPageObject {
2366  $type = ($a_type == "mep")
2367  ? "mep"
2368  : "lm";
2369 
2370  $lang = $this->lang;
2371  if (!ilPageObject::_exists($type, $a_id, $lang)) {
2372  $lang = "-";
2373  if ($this->lang != "-" && ilPageObject::_exists($type, $a_id, $this->ot->getFallbackLanguage())) {
2374  $lang = $this->ot->getFallbackLanguage();
2375  }
2376  }
2377 
2378  switch ($type) {
2379  case "mep":
2380  return new ilMediaPoolPage($a_id, 0, $lang);
2381  default:
2382  return new ilLMPage($a_id, 0, $lang);
2383  }
2384  }
2385 
2389  public function refreshToc(): void
2390  {
2391  $exp = $this->ilTOC();
2392 
2393  echo $exp->getHTML() .
2394  "<script>" . $exp->getOnLoadCode() . "</script>";
2395  exit;
2396  }
2397 
2402  public function observeNoteAction(
2403  int $a_lm_id,
2404  int $a_page_id,
2405  string $a_type,
2406  string $a_action,
2407  int $a_note_id
2408  ): void {
2409  $note = $this->notes->getById($a_note_id);
2410  $text = $note->getText();
2411 
2412  $notification = new ilLearningModuleNotification(
2415  $this->lm,
2416  $a_page_id,
2417  $text
2418  );
2419 
2420  $notification->send();
2421  }
2422 
2423  // render menu
2424  protected function renderTabs(
2425  string $active_tab,
2426  int $current_page_id
2427  ): void {
2428  $menu_editor = new ilLMMenuEditor();
2429  $menu_editor->setObjId($this->lm->getId());
2430 
2431  $navigation_renderer = new ilLMMenuRendererGUI(
2432  $this->getService(),
2433  $this->tabs,
2434  $this->toolbar,
2435  $current_page_id,
2436  $active_tab,
2437  $this->getExportFormat(),
2438  $this->export_all_languages,
2439  $this->lm,
2440  $this->offlineMode(),
2441  $menu_editor,
2442  $this->lang,
2443  $this->ctrl,
2444  $this->access,
2445  $this->user,
2446  $this->lng,
2447  $this->tpl,
2448  function ($additional_content) {
2449  $this->additional_content[] = $additional_content;
2450  }
2451  );
2452  $navigation_renderer->render();
2453  }
2454 
2458  public function getHTML(array $pars): string
2459  {
2460  $this->addResourceFiles();
2461  switch ($pars["cmd"]) {
2462  case "layout":
2463  $tpl = new ilTemplate("tpl.embedded_view.html", true, true, "Modules/LearningModule");
2464  $tpl->setVariable("HEAD_ACTION", $this->getHeaderAction());
2465  $tpl->setVariable("PAGE_RATING", $this->renderRating());
2466  $tpl->setVariable("PAGE", $this->getContent(true));
2467  $tpl->setVariable("COMMENTS", $this->ilLMNotes());
2468  return $tpl->get();
2469  }
2470  return "";
2471  }
2472 }
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
static getWebspaceDir(string $mode="filesystem")
get webspace directory
showMessageScreen(string $a_content)
determineLayout()
Determine layout.
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getPresentationTitle(int $a_st_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isPagePublic(int $a_node_id, bool $a_check_public_mode=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
Definition: login.php:29
downloadFile()
download file of file lists
ilLMPresentationService $service
static _parseCopyright(string $a_copyright)
Returns an empty string if copyright selection is not active, regardless of input.
Class ilInfoScreenGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilObjLearningModuleGUI $lm_gui
const IL_INST_ID
Definition: constants.php:40
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getHeaderAction(bool $a_redraw=false)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
special template class to simplify handling of ITX/PEAR
getSafePostCommands()
This method must return a list of safe POST commands.
setOutputMode(string $a_mode=self::PRESENTATION)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
hasPredIncorrectAnswers(int $a_obj_id, bool $a_ignore_unlock=false)
Has predecessing incorrect answers.
static prepareJsLinks(string $redraw_url, string $notes_url, string $tags_url, ilGlobalTemplateInterface $tpl=null)
Insert js/ajax links into template.
ILIAS Style Content Service $cs
static includePresentationJS(ilGlobalTemplateInterface $a_tpl=null)
Include media object presentation JS.
showDownloadList()
show download list
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
Class ilPageObjectGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSystemStyle()
Set system style.
static getInstance(ilObjLearningModule $a_content_obj, int $a_id=0, bool $a_halt=true)
ILIAS GlobalScreen Services $global_screen
showNavRestrictionDueToQuestions()
Show message if navigation to page is not allowed due to unanswered questions.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
ILIAS COPage Xsl XslManager $xsl
ILIAS Notes DomainService $notes
printToString()
Use this method to get the finally rendered page as string.
loadLanguageModule(string $a_module)
Load language module.
ILIAS COPage Dom DomUtil $dom_util
setOfflineDirectory(string $offdir)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
attrib2arr(?DOMNamedNodeMap $a_attributes)
handleCodeParagraph(int $page_id, int $paragraph_id, string $title, string $text)
store paragraph into file directory files/codefile_$pg_id_$paragraph_id/downloadtitle ...
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
initScreenHead(string $a_active_tab="info")
ilNavigationHistory $nav_history
ILIAS Style Content GUIService $content_style_gui
static resetRatingForUserAndObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id)
Reset rating for a user and an object.
showInfoScreen()
info screen call from inside learning module
setStyleId(int $a_styleid)
refreshToc()
Refresh toc (called if questions have been answered correctly)
$ilErr
Definition: raiseError.php:17
$path
Definition: ltiservices.php:32
ilLMSubMenu()
output learning module submenu
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static deliverFileLegacy(string $a_file, ?string $a_filename=null, ?string $a_mime=null, ?bool $isInline=false, ?bool $removeAfterDelivery=false, ?bool $a_exit_after=true)
static writeRatingForUserAndObject(int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id, ?string $a_sub_obj_type, int $a_user_id, int $a_rating, int $a_category_id=0)
Write rating for a user and an object.
Interface ilCtrlBaseClassInterface describes ilCtrl base classes.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
getCurrentFrameSet()
get frames of current frame set
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initByRequest(?array $query_params=null, bool $embed_mode=false)
Init services and this class by request params.
This class represents a property in a property form.
getLMPage(int $a_id, string $a_type="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static addCss()
Add required css.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$GLOBALS["DIC"]
Definition: wac.php:31
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
static _checkPreconditionsOfPage(int $cont_ref_id, int $cont_obj_id, int $page_id)
checks whether the preconditions of a page are fulfilled or not
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
observeNoteAction(int $a_lm_id, int $a_page_id, string $a_type, string $a_action, int $a_note_id)
Generate new ilNote and send Notifications to the users informing that there are new comments in the ...
static isTypeAllowed(string $a_type)
layout(string $a_xml="main.xml", bool $doShow=true)
Extension of ilPageObjectGUI for learning modules.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static _lookGlossaryTerm(int $term_id)
get glossary term
static getInstance(int $obj_id)
setBackTarget(string $a_title, string $a_target, string $a_frame="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
__construct(string $a_export_format="", bool $a_all_languages=false, string $a_export_dir="", bool $claim_repo_context=true, array $query_params=null, bool $embed_mode=false)
offlineMode()
checks whether offline content generation is activated
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
downloadExportFile()
send download file (xml/html)
ilLMPresentationLinker $linker
static _getMapAreasIntLinks(int $a_mob_id)
get all internal links of map areas of a mob
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
setFullscreenLink(string $a_fullscreen_link)
ilJavaScript(string $a_inline="", string $a_file="", string $a_location="")
getCurrentPageId()
Get the current page id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSourcecodeDownloadScript(string $script_name)
$lifecycle
showPrintViewSelection()
show selection screen for print view
ILIAS Notes GUIService $notes_gui
const IL_MODE_ALIAS
Last visited history for repository items.
getFocusLink(int $a_ref_id, int $a_obj_id, int $a_return_ref_id)
Get focused link (used in learning objectives courses)
ILIAS LearningModule ReadingTime ReadingTimeManager $reading_time_manager
nop()
this dummy function is needed for offline package creation
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
basicPageGuiInit(\ilPageObjectGUI $a_page_gui)
setFileDownloadLink(string $a_download_link)
static init(ilGlobalTemplateInterface $template=null)
showNoPageAccess()
Show info message, if page is not accessible in public area.
getUnsafeGetCommands()
This method must return a list of unsafe GET commands.
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
form( $class_path, string $cmd, string $submit_caption="")
showNoPublicAccess()
Show info message, if page is not accessible in public area.
getContent(bool $skip_nav=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderTabs(string $active_tab, int $current_page_id)
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static _getPresentationTitle(int $a_pg_id, string $a_mode=self::CHAPTER_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-", bool $a_include_short=false)
presentation title doesn&#39;t have to be page title, it may be chapter title + page title or chapter tit...
getHTML(array $pars)
Get HTML (called by kiosk mode through ilCtrl)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $ilSetting
Definition: privfeed.php:18
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
getGeneral()
Definition: class.ilMD.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $a_obj_id, int $a_lm_id=0)
ILIAS Style Content Object ObjectFacade $content_style_domain
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static hasNotification(int $type, int $user_id, int $id)
Check notification status for object and user.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_MODE_OUTPUT
getOnLoadCodeForAsynch()
Get js onload code for ajax calls.
static _getFrame(string $a_class)
ilLMNotes()
output notes of page
setSubObject(?string $sub_obj_type, ?int $sub_obj_id)
Set sub object attributes.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
$post
Definition: ltitoken.php:49
Interface ilCtrlSecurityInterface provides ilCtrl security information.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContentStyles()
Set content style.
Main service init and factory.
injectTemplate(ilGlobalTemplateInterface $tpl)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static hasOptOut(int $obj_id)
Is opt out (disable notification) allowed?