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