ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMNavigationRendererGUI.php
Go to the documentation of this file.
1<?php
2
23{
25 protected \ILIAS\DI\UIServices $ui;
26 protected string $requested_frame;
27 protected int $requested_back_pg;
28 protected int $requested_obj_id;
30 protected bool $deactivated_page;
32 protected ilObjUser $user;
33 protected ?int $current_page;
35 protected ilLanguage $lng;
36 protected bool $offline;
38 protected ilLMTree $lm_tree;
40 protected ilSetting $lm_set;
42 protected string $lang;
44
45 public function __construct(
52 string $requested_back_pg,
53 string $requested_frame,
55 \ILIAS\DI\UIServices $ui
56 ) {
57 $this->user = $user;
58 $this->toolbar = $toolbar;
59 $this->ui = $ui;
60 $this->lm_tree = $service->getLMTree();
61 $this->current_page = $service->getNavigationStatus()->getCurrentPage();
62 $this->lm = $service->getLearningModule();
63 $this->lm_set = $service->getSettings();
64 $this->lng = $lng;
65 $this->offline = $service->getPresentationStatus()->offline();
66 $this->tracker = $service->getTracker();
67 $this->parent_gui = $parent_gui;
68 $this->chapter_has_no_active_page = $service->getNavigationStatus()->isChapterWithoutActivePage();
69 $this->deactivated_page = $service->getNavigationStatus()->isDeactivatedPage();
70 $this->linker = $service->getLinker();
71 $this->navigation_status = $service->getNavigationStatus();
72 $this->requested_obj_id = $requested_obj_id;
73 $back_pg = explode(":", $requested_back_pg);
74 $this->requested_back_pg = (int) $back_pg[0];
75 $this->requested_frame = $requested_frame;
76 $this->main_tpl = $main_tpl;
77 $this->lang = $service->getPresentationStatus()->getLang();
78 }
79
80 public function renderTop(): string
81 {
82 return $this->render();
83 }
84
85 public function renderBottom(): string
86 {
87 return $this->render(false);
88 }
89
90 protected function render(bool $top = true): string
91 {
92 $page_id = $this->current_page;
93
94 $tpl = new ilTemplate("tpl.lm_navigation.html", true, true, "components/ILIAS/LearningModule/Presentation");
95
96 if (empty($page_id)) {
97 return "";
98 }
99
100 // process navigation for free page
101 $back_pg = $this->navigation_status->getBackPageId();
102 if ($back_pg > 0) {
103 $back_href =
104 $this->linker->getLink(
105 "layout",
106 $back_pg,
107 "",
108 "",
109 "reduce"
110 );
111 $back_img =
112 ilUtil::getImagePath("nav/nav_arr2_L.png", false, "output", $this->offline);
113 $tpl->setCurrentBlock("ilLMNavigation_Prev");
114 $tpl->setVariable("IMG_PREV", $back_img);
115 $tpl->setVariable("HREF_PREV", $back_href);
116 $tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
117 $tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
118 $tpl->setVariable("SPACER_PREV", $this->offline
119 ? "images/media/spacer.png"
120 : ilUtil::getImagePath("media/spacer.png"));
121 $tpl->parseCurrentBlock();
122 if ($top) {
123 $b = $this->ui->factory()->button()->standard(
124 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
125 $back_href
126 );
127 $this->toolbar->addStickyItem($b);
128 }
129 } else {
130 $pre_id = $this->navigation_status->getPredecessorPageId();
131 if ($pre_id > 0) {
132 // get presentation title
134 $pre_id,
135 $this->lm->getPageHeader(),
136 $this->lm->isActiveNumbering(),
137 (bool) $this->lm_set->get("time_scheduled_page_activation"),
138 false,
139 0,
140 $this->lang,
141 true
142 );
143 $prev_title = ilStr::shortenTextExtended($prev_title, 50, true);
144 $prev_img =
145 ilUtil::getImagePath("nav/nav_arr_L.png", false, "output", $this->offline);
146
147 if (!$this->lm->cleanFrames()) {
148 $prev_href =
149 $this->linker->getLink(
150 "layout",
151 $pre_id,
152 $this->requested_frame
153 );
154 $prev_target = "";
155 } else {
156 if (!$this->offline) {
157 $prev_href =
158 $this->linker->getLink("layout", $pre_id);
159 } else {
160 $prev_href =
161 $this->linker->getLink("layout", $pre_id);
162 }
163 }
164
165 $tpl->setCurrentBlock("ilLMNavigation_Prev");
166 $tpl->setVariable("IMG_PREV", $prev_img);
167 $tpl->setVariable("HREF_PREV", $prev_href);
168 $tpl->setVariable("TXT_PREV", $prev_title);
169 $tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
170 $tpl->setVariable("SPACER_PREV", $this->offline
171 ? "images/media/spacer.png"
172 : ilUtil::getImagePath("media/spacer.png"));
173
174 if ($top) {
175 $b = $this->ui->factory()->button()->standard(
176 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
177 $prev_href
178 );
179 $this->toolbar->addStickyItem($b);
180 }
181 } else {
182 if ($top) {
183 $b = $this->ui->factory()->button()->standard(
184 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
185 "#"
186 )->withUnavailableAction();
187 $this->toolbar->addStickyItem($b);
188 }
189 }
190
191 $this->addDropdown();
192
193 $succ_id = $this->navigation_status->getSuccessorPageId();
194 if ($succ_id > 0) {
195 // get presentation title
197 $succ_id,
198 $this->lm->getPageHeader(),
199 $this->lm->isActiveNumbering(),
200 (bool) $this->lm_set->get("time_scheduled_page_activation"),
201 false,
202 0,
203 $this->lang,
204 true
205 );
206 $succ_title = ilStr::shortenTextExtended($succ_title, 50, true);
207 $succ_img =
208 ilUtil::getImagePath("nav/nav_arr_R.png", false, "output", $this->offline);
209 if (!$this->lm->cleanFrames()) {
210 $succ_href =
211 $this->linker->getLink(
212 "layout",
213 $succ_id,
214 $this->requested_frame
215 );
216 $succ_target = "";
217 } else {
218 if (!$this->offline) {
219 $succ_href =
220 $this->linker->getLink("layout", $succ_id);
221 } else {
222 $succ_href =
223 $this->linker->getLink("layout", $succ_id);
224 }
225 }
226
227 $tpl->setCurrentBlock("ilLMNavigation_Next");
228 $tpl->setVariable("IMG_SUCC", $succ_img);
229 $tpl->setVariable("HREF_SUCC", $succ_href);
230 $tpl->setVariable("TXT_SUCC", $succ_title);
231 $tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
232 $tpl->setVariable("SPACER_SUCC", $this->offline
233 ? "images/media/spacer.png"
234 : ilUtil::getImagePath("media/spacer.png"));
235 $tpl->parseCurrentBlock();
236
237 // check if successor page is not restricted
238 if (!$this->offline) {
239 if ($this->lm->getRestrictForwardNavigation()) {
240 if ($this->tracker->hasPredIncorrectAnswers($succ_id)) {
241 $this->main_tpl->addOnLoadCode("il.LearningModule.hideNextNavigation();");
242 }
243 }
244 }
245 if ($top) {
246 $b = $this->ui->factory()->button()->standard(
247 "<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
248 $succ_href
249 );
250 $this->toolbar->addStickyItem($b);
251 }
252 } else {
253 if ($top) {
254 $b = $this->ui->factory()->button()->standard(
255 "<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
256 "#"
257 )->withUnavailableAction();
258 $this->toolbar->addStickyItem($b);
259 }
260 }
261 }
262 $tpl->setVariable("CLASS", ($top) ? "tnav_Top" : "bnav_Bottom");
263
264 return $tpl->get();
265 }
266
267 protected function addDropdown()
268 {
269 $nodes = $this->lm_tree->getSubTree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
270 //$nodes = $this->filterNonAccessibleNode($nodes);
271
272 foreach ($nodes as $node) {
273 $disabled = false;
274
275 // check page activation
276 $active = ilLMPage::_lookupActive(
277 $node["obj_id"],
278 $this->lm->getType(),
279 (bool) $this->lm_set->get("time_scheduled_page_activation")
280 );
281
282 if ($node["type"] === "pg" &&
283 !$active) {
284 continue;
285 }
286
287 $text = "";
288 $checked = false;
289
290 switch ($node["type"]) {
291 // page
292 case "pg":
293 if ($this->lm->getTOCMode() !== "pages") {
294 continue 2;
295 }
296 $text =
298 $node["obj_id"],
299 $this->lm->getPageHeader(),
300 $this->lm->isActiveNumbering(),
301 (bool) $this->lm_set->get("time_scheduled_page_activation"),
302 false,
303 $this->lm->getId(),
304 $this->lang,
305 true
306 );
307
308 break;
309
310 // learning module
311 case "du":
312 $text = "";
313 break;
314
315 // chapter
316 case "st":
317 $text =
319 $node["obj_id"],
321 $this->lm->isActiveNumbering(),
322 (bool) $this->lm_set->get("time_scheduled_page_activation"),
323 false,
324 $this->lm->getId(),
325 $this->lang,
326 true
327 );
328 break;
329 }
330
332 $this->lm->getRefId(),
333 $this->lm->getId(),
334 $node["obj_id"]
335 )) {
336 $disabled = true;
337 $text .= " (" . $this->lng->txt("cont_no_access") . ")";
338 }
339
340 $href = $this->linker->getLink("layout", $node["obj_id"]);
341
342 if ($text !== "") {
343 if ($this->lm->getTOCMode() === "pages" && $this->current_page == $node["obj_id"]) {
344 $text = "» " . $text;
345 }
346 if ($this->lm->getTOCMode() !== "pages") {
347 if ($this->lm_tree->getParentId($this->current_page) == $node["obj_id"]) {
348 $text = "» " . $text;
349 }
350 }
351 $text = str_pad("", ($node["depth"] - 1) * 12, "&nbsp;") . $text;
352 $actions[] = $this->ui->factory()->button()->shy(
353 $text,
354 $href
355 );
356 }
357 }
358
359 if ($this->lm->getTOCMode() === "pages") {
361 $this->current_page,
362 $this->lm->getPageHeader(),
363 $this->lm->isActiveNumbering(),
364 (bool) $this->lm_set->get("time_scheduled_page_activation"),
365 false,
366 $this->lm->getId(),
367 $this->lang,
368 true
369 );
370 } else {
371 $st_id = $this->lm_tree->getParentId($this->current_page);
372 if ($st_id > 0) {
374 $st_id,
376 $this->lm->isActiveNumbering(),
377 (bool) $this->lm_set->get("time_scheduled_page_activation"),
378 false,
379 $this->lm->getId(),
380 $this->lang,
381 true
382 );
383 }
384 }
385
386 $title = "<span style='vertical-align: bottom; max-width:60px; display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>" . $title . "</span>";
387
388
389 $this->toolbar->addStickyItem(
390 $this->ui->factory()->dropdown()->standard($actions)->withLabel($title)
391 );
392 }
393}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilLMPresentationService $service, ilLMPresentationGUI $parent_gui, ilLanguage $lng, ilObjUser $user, ilGlobalTemplateInterface $main_tpl, int $requested_obj_id, string $requested_back_pg, string $requested_frame, ilToolbarGUI $toolbar, \ILIAS\DI\UIServices $ui)
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...
Class ilLMPresentationGUI GUI class for learning module presentation.
Learning module presentation linker.
Main service init and factory.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
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...
User class.
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
ILIAS Setting Class.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
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)
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 getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$service
Definition: ltiresult.php:36
Class HTTPServicesTest.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.