ILIAS  release_8 Revision v8.24
class.ilLMMenuGUI.php
Go to the documentation of this file.
1<?php
2
20
22
27{
28 protected bool $offline;
29 protected \ilLMPresentationService $service;
30 protected \ilCtrl $ctrl;
31 protected \ILIAS\DI\UIServices $ui;
32 protected \ilObjLearningModule $lm;
33 protected \ilLanguage $lng;
34 protected \ilAccessHandler $access;
35 protected \ilObjUser $user;
36
37 public function __construct(
38 \ilLMPresentationService $lm_pres_service
39 ) {
40 global $DIC;
41
42 $this->ui = $DIC->ui();
43 $this->ctrl = $DIC->ctrl();
44 $this->service = $lm_pres_service;
45 $this->lng = $DIC->language();
46 $this->access = $DIC->access();
47 $this->lm = $this->service->getLearningModule();
48 $this->offline = $lm_pres_service->getPresentationStatus()->offline();
49 $this->user = $DIC->user();
50 }
51
52 public function getEntries(): array
53 {
54 $ui = $this->ui;
59
60 $entries = [];
61
62 $ctrl->setParameterByClass("illmpresentationgui", 'ref_id', $this->lm->getRefId());
63
64 // print selection
65 if ($this->lm->isActivePrintView() && $access->checkAccess("read", "", $this->lm->getRefId())) {
66 if (!$this->offline) {
67 $ui->mainTemplate()->addJavaScript("./Services/Form/js/Form.js");
68 $modal = $ui->factory()->modal()->roundtrip(
69 $lng->txt("cont_print_view"),
70 $ui->factory()->legacy('some modal')
71 )->withAsyncRenderUrl($this->ctrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection"));
72
73 $entries[] = [
74 "label" => $this->lng->txt("cont_print_view"),
75 "signal" => $modal->getShowSignal(),
76 "modal" => $modal,
77 "on_load" => ""
78 ];
79 }
80 }
81
82 // download
83 if ($user->getId() == ANONYMOUS_USER_ID) {
84 $is_public = $this->lm->isActiveDownloadsPublic();
85 } else {
86 $is_public = true;
87 }
88
89 if ($this->lm->isActiveDownloads() && !$this->offline && $is_public &&
90 $access->checkAccess("read", "", $this->lm->getRefId())) {
91 $modal = $ui->factory()->modal()->roundtrip(
92 $lng->txt("download"),
93 $ui->factory()->legacy('some modal')
94 )->withAsyncRenderUrl($this->ctrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList"));
95 $entries[] = [
96 "label" => $this->lng->txt("download"),
97 "signal" => $modal->getShowSignal(),
98 "modal" => $modal,
99 "on_load" => ""
100 ];
101 }
102
103 // user defined menu entries
104 $menu_editor = new \ilLMMenuEditor();
105 $menu_editor->setObjId($this->lm->getId());
106
107 $cust_menu = $menu_editor->getMenuEntries(true);
108 $generator = new SignalGenerator();
109 if (count($cust_menu) > 0 && $access->checkAccess("read", "", $this->lm->getRefId())) {
110 foreach ($cust_menu as $entry) {
111 // build goto-link for internal resources
112 if ($entry["type"] == "intern") {
113 $entry["link"] = ILIAS_HTTP_PATH . "/goto.php?target=" . $entry["link"];
114 }
115
116 // add http:// prefix if not exist
117 if (!strstr($entry["link"], '://') && !strstr($entry["link"], 'mailto:')) {
118 $entry["link"] = "https://" . $entry["link"];
119 }
120
121 if (!strstr($entry["link"], 'mailto:')) {
122 $entry["link"] = \ilUtil::appendUrlParameterString($entry["link"], "ref_id=" . $this->lm->getRefId());
123 }
124
125 $signal = $generator->create();
126
127 $entries[] = [
128 "label" => $entry["title"],
129 "signal" => $signal,
130 "modal" => null,
131 "on_load" => "$(document).on('" .
132 $signal->getId() .
133 "', function(event, signalData) {il.LearningModule.openMenuLink('" . $entry["link"] . "');});"
134 ];
135 }
136 }
137
138
139 return $entries;
140 }
141}
__construct(\ilLMPresentationService $lm_pres_service)
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
Main service init and factory.
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...
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
const ANONYMOUS_USER_ID
Definition: constants.php:27
global $DIC
Definition: feed.php:28
checkAccess(string $a_permission, string $a_cmd, int $a_ref_id, string $a_type="", ?int $a_obj_id=null, ?int $a_tree_id=null)
check access for an object (provide $a_type and $a_obj_id if available for better performance)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...