ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMMenuGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
12{
16 protected $service;
17
21 protected $ctrl;
22
26 protected $ui;
27
31 protected $lm;
32
36 protected $lng;
37
41 protected $access;
42
46 protected $user;
47
51 public function __construct(\ilLMPresentationService $lm_pres_service)
52 {
53 global $DIC;
54
55 $this->ui = $DIC->ui();
56 $this->ctrl = $DIC->ctrl();
57 $this->service = $lm_pres_service;
58 $this->lng = $DIC->language();
59 $this->access = $DIC->access();
60 $this->lm = $this->service->getLearningModule();
61 $this->offline = $lm_pres_service->getPresentationStatus()->offline();
62 $this->user = $DIC->user();
63 }
64
69 public function getEntries()
70 {
71 $ui = $this->ui;
76
77 $entries = [];
78
79 $ctrl->setParameterByClass("illmpresentationgui", 'ref_id', $this->lm->getRefId());
80
81 // print selection
82 if ($this->lm->isActivePrintView() && $access->checkAccess("read", "", $this->lm->getRefId())) {
83 if (!$this->offline) {
84 $ui->mainTemplate()->addJavaScript("./Services/Form/js/Form.js");
85 $modal = $ui->factory()->modal()->roundtrip(
86 $lng->txt("cont_print_view"),
87 $ui->factory()->legacy('some modal')
88 )->withAsyncRenderUrl($this->ctrl->getLinkTargetByClass("illmpresentationgui", "showPrintViewSelection"));
89
90 $entries[] = [
91 "label" => $this->lng->txt("cont_print_view"),
92 "signal" => $modal->getShowSignal(),
93 "modal" => $modal,
94 "on_load" => ""
95 ];
96 }
97 }
98
99 // download
100 if ($user->getId() == ANONYMOUS_USER_ID) {
101 $is_public = $this->lm->isActiveDownloadsPublic();
102 } else {
103 $is_public = true;
104 }
105
106 if ($this->lm->isActiveDownloads() && !$this->offline && $is_public &&
107 $access->checkAccess("read", "", $this->lm->getRefId())) {
108 $modal = $ui->factory()->modal()->roundtrip(
109 $lng->txt("download"),
110 $ui->factory()->legacy('some modal')
111 )->withAsyncRenderUrl($this->ctrl->getLinkTargetByClass("illmpresentationgui", "showDownloadList"));
112 $entries[] = [
113 "label" => $this->lng->txt("download"),
114 "signal" => $modal->getShowSignal(),
115 "modal" => $modal,
116 "on_load" => ""
117 ];
118 }
119
120 // user defined menu entries
121 $menu_editor = new \ilLMMenuEditor();
122 $menu_editor->setObjId($this->lm->getId());
123
124 $cust_menu = $menu_editor->getMenuEntries(true);
125 $generator = new SignalGenerator();
126 if (count($cust_menu) > 0 && $access->checkAccess("read", "", $this->lm->getRefId())) {
127 foreach ($cust_menu as $entry) {
128 // build goto-link for internal resources
129 if ($entry["type"] == "intern") {
130 $entry["link"] = ILIAS_HTTP_PATH . "/goto.php?target=" . $entry["link"];
131 }
132
133 // add http:// prefix if not exist
134 if (!strstr($entry["link"], '://') && !strstr($entry["link"], 'mailto:')) {
135 $entry["link"] = "http://" . $entry["link"];
136 }
137
138 if (!strstr($entry["link"], 'mailto:')) {
139 $entry["link"] = \ilUtil::appendUrlParameterString($entry["link"], "ref_id=" . $this->lm->getRefId());
140 }
141
142 $signal = $generator->create();
143
144 $entries[] = [
145 "label" => $entry["title"],
146 "signal" => $signal,
147 "modal" => null,
148 "on_load" => "$(document).on('" .
149 $signal->getId() .
150 "', function(event, signalData) {il.LearningModule.openMenuLink('" . $entry["link"] . "');});"
151 ];
152 }
153 }
154
155
156 return $entries;
157 }
158}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
__construct(\ilLMPresentationService $lm_pres_service)
Constructor.
Main service init and factory.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5