ILIAS  release_8 Revision v8.24
class.ilLMMenuRendererGUI.php
Go to the documentation of this file.
1<?php
2
25{
26 protected ilLanguage $lng;
27 protected bool $export_all;
28 protected int $requested_ref_id;
29 protected int $requested_obj_id;
31 protected ilObjUser $user;
32 protected int $current_page;
34 protected bool $offline;
35 protected ilCtrl $ctrl;
36 protected string $lang;
37 protected string $active_tab;
38 protected string $export_format;
39 protected ilTabsGUI $tabs;
44 protected \ILIAS\UI\Factory $ui_factory;
46
47 public function __construct(
51 int $current_page,
52 string $active_tab,
53 string $export_format,
54 bool $export_all,
56 bool $offline,
58 string $lang,
65 ) {
67 global $DIC;
68
69 $this->ui_factory = $DIC->ui()->factory();
70 $this->active_tab = $active_tab;
71 $this->export_format = $export_format;
72 $this->export_all = $export_all;
73 $this->tabs = $tabs;
74 $this->menu_editor = $menu_editor;
75 $this->lng = $lng;
76 $this->lm_pres_service = $lm_pres_service;
77 $this->toolbar = $toolbar;
78 $this->main_tpl = $main_tpl;
79 $this->additional_content_collector = $additional_content_collector;
80 $this->access = $access;
81 $this->user = $user;
82 $this->ctrl = $ctrl;
83 $this->lang = $lang;
84 $this->current_page = $current_page;
85 $this->lm = $lm;
86 $this->offline = $offline;
87 $request = $lm_pres_service->getRequest();
88 $this->requested_obj_id = $request->getObjId();
89 $this->requested_ref_id = $request->getRefId();
90 $this->lng->loadLanguageModule("lm");
91 }
92
93 public function render(): string
94 {
95 $ilCtrl = $this->ctrl;
96 $ilAccess = $this->access;
97 $ilTabs = $this->tabs;
98
99 $getcmd = "getHTML";
100
101 $content_active = ($this->active_tab === "content");
102
103 if (!$this->lm->isActiveLMMenu()) {
104 return "";
105 }
106
107 $tabs_gui = $ilTabs;
108
109 // workaround for preventing tooltips in export
110 if ($this->offline) {
111 $tabs_gui->setSetupMode(true);
112 }
113
114 // content
115 if (!$this->offline && $ilAccess->checkAccess("read", "", $this->requested_ref_id)) {
116 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
117 if (!$content_active) {
118 $this->toolbar->addComponent(
119 $this->ui_factory->button()->standard($this->lng->txt("content"), $ilCtrl->getLinkTargetByClass("illmpresentationgui", "layout"))
120 );
121 }
122 } elseif ($this->offline) {
123 $tabs_gui->setForcePresentationOfSingleTab(true);
124 }
125
126 if (!$content_active) {
127 return "";
128 }
129
130 // info button
131 if ($this->lm->isInfoEnabled()) {
132 if (!$this->offline) {
133 $ilCtrl->setParameterByClass("illmpresentationgui", "obj_id", $this->requested_obj_id);
134 $link = $this->ctrl->getLinkTargetByClass(
135 array("illmpresentationgui", "ilinfoscreengui"),
136 "showSummary"
137 );
138 $this->toolbar->addComponent(
139 $this->ui_factory->button()->standard($this->lng->txt("info_short"), $link)
140 );
141 }
142 }
143 if (!$this->offline &&
144 $ilAccess->checkAccess("read", "", $this->requested_ref_id) && // #14075
145 ilLearningProgressAccess::checkAccess($this->requested_ref_id)) {
146 $olp = ilObjectLP::getInstance($this->lm->getId());
147 if ($olp->getCurrentMode() !== ilLPObjSettings::LP_MODE_COLLECTION_MANUAL) {
148 $this->toolbar->addComponent(
149 $this->ui_factory->button()->standard(
150 $this->lng->txt("learning_progress"),
151 $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "")
152 )
153 );
154 } else {
155 $this->toolbar->addComponent(
156 $this->ui_factory->button()->standard(
157 $this->lng->txt("learning_progress"),
158 $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "editManual")
159 )
160 );
161 } /* elseif ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
162 $this->toolbar->addComponent(
163 $this->ui_factory->button()->standard(
164 $this->lng->txt("learning_progress"),
165 $this->ctrl->getLinkTargetByClass(array("illmpresentationgui", "illearningprogressgui"), "showtlt")
166 )
167 );
168 }*/
169 }
170
171 // default entries (appearing in lsq and native mode)
172 $menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
173 foreach ($menu->getEntries() as $entry) {
174 if (is_object($entry["signal"])) {
175 $this->toolbar->addComponent(
176 $this->ui_factory->button()->standard($entry["label"], '')
177 ->withOnClick($entry["signal"])
178 );
179 }
180 if (is_object($entry["modal"])) {
181 ($this->additional_content_collector)($entry["modal"]);
182 }
183 if ($entry["on_load"] != "") {
184 $this->main_tpl->addOnLoadCode($entry["on_load"]);
185 }
186 }
187
188 // edit learning module
189 if (!$this->offline) {
190 if ($ilAccess->checkAccess("write", "", $this->requested_ref_id)) {
191 $actions = [];
192
193 if ($this->current_page > 0) {
194 $actions[] = $this->ui_factory->button()->shy(
195 $this->lng->txt("edit_page"),
196 ILIAS_HTTP_PATH . "/ilias.php?baseClass=ilLMEditorGUI&ref_id=" . $this->requested_ref_id .
197 "&obj_id=" . $this->current_page . "&to_page=1"
198 );
199 }
200 $actions[] = $this->ui_factory->button()->shy(
201 $this->lng->txt("lm_edit_chapters"),
202 $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "chapters")
203 );
204 $actions[] = $this->ui_factory->button()->shy(
205 $this->lng->txt("lm_edit_lm_settings"),
206 $this->ctrl->getLinkTargetByClass(["ilLMEditorGUI", "ilobjlearningmodulegui"], "properties")
207 );
208 $this->toolbar->addComponent(
209 $this->ui_factory->dropdown()->standard($actions)
210 );
211 }
212 }
213
214 return $tabs_gui->$getcmd();
215 }
216}
Class ilCtrl provides processing control methods.
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...
ilGlobalTemplateInterface $main_tpl
ilLMPresentationService $lm_pres_service
Main service init and factory.
language handling
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSetupMode(bool $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc