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