ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilLMNavigationRendererGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLMNavigationRendererGUI:

Public Member Functions

 __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)
 
 renderTop ()
 
 renderBottom ()
 

Protected Member Functions

 render (bool $top=true)
 
 addDropdown ()
 

Protected Attributes

ilToolbarGUI $toolbar
 
ILIAS DI UIServices $ui
 
string $requested_frame
 
int $requested_back_pg
 
int $requested_obj_id
 
ilLMPresentationLinker $linker
 
bool $deactivated_page
 
bool $chapter_has_no_active_page
 
ilObjUser $user
 
int $current_page
 
ilObjLearningModule $lm
 
ilLanguage $lng
 
bool $offline
 
ilLMTracker $tracker
 
ilLMTree $lm_tree
 
ilLMPresentationGUI $parent_gui
 
ilSetting $lm_set
 
ilGlobalTemplateInterface $main_tpl
 
string $lang
 
ilLMNavigationStatus $navigation_status
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 22 of file class.ilLMNavigationRendererGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilLMNavigationRendererGUI::__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 
)

Definition at line 45 of file class.ilLMNavigationRendererGUI.php.

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 }
$service
Definition: ltiresult.php:36

References $lng, $main_tpl, $parent_gui, $requested_back_pg, $requested_frame, $requested_obj_id, $service, $toolbar, $ui, $user, ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDropdown()

ilLMNavigationRendererGUI::addDropdown ( )
protected

Definition at line 269 of file class.ilLMNavigationRendererGUI.php.

269 : void
270 {
271 $nodes = $this->lm_tree->getSubTree($this->lm_tree->getNodeData($this->lm_tree->getRootId()));
272 //$nodes = $this->filterNonAccessibleNode($nodes);
273
274 $actions = [];
275
276 foreach ($nodes as $node) {
277 $disabled = false;
278
279 // check page activation
280 $active = ilLMPage::_lookupActive(
281 $node["obj_id"],
282 $this->lm->getType(),
283 (bool) $this->lm_set->get("time_scheduled_page_activation")
284 );
285
286 if ($node["type"] === "pg" &&
287 !$active) {
288 continue;
289 }
290
291 $text = "";
292 $checked = false;
293
294 switch ($node["type"]) {
295 // page
296 case "pg":
297 if ($this->lm->getTOCMode() !== "pages") {
298 continue 2;
299 }
300 $text =
302 $node["obj_id"],
303 $this->lm->getPageHeader(),
304 $this->lm->isActiveNumbering(),
305 (bool) $this->lm_set->get("time_scheduled_page_activation"),
306 false,
307 $this->lm->getId(),
308 $this->lang,
309 true
310 );
311
312 break;
313
314 // learning module
315 case "du":
316 $text = "";
317 break;
318
319 // chapter
320 case "st":
321 $text =
323 $node["obj_id"],
325 $this->lm->isActiveNumbering(),
326 (bool) $this->lm_set->get("time_scheduled_page_activation"),
327 false,
328 $this->lm->getId(),
329 $this->lang,
330 true
331 );
332 break;
333 }
334
336 $this->lm->getRefId(),
337 $this->lm->getId(),
338 $node["obj_id"]
339 )) {
340 $disabled = true;
341 $text .= " (" . $this->lng->txt("cont_no_access") . ")";
342 }
343
344 $href = $this->linker->getLink("layout", $node["obj_id"]);
345
346 if ($text !== "") {
347 if ($this->lm->getTOCMode() === "pages" && $this->current_page == $node["obj_id"]) {
348 $text = "» " . $text;
349 }
350 if ($this->lm->getTOCMode() !== "pages") {
351 if ($this->lm_tree->getParentId($this->current_page) == $node["obj_id"]) {
352 $text = "» " . $text;
353 }
354 }
355 $text = str_pad("", ($node["depth"] - 1) * 12, " ") . $text;
356 $button = $this->ui->factory()->button()->shy(
357 $text,
358 $href
359 );
360 if ($disabled) {
361 $button = $button->withUnavailableAction();
362 }
363 $actions[] = $button;
364 }
365 }
366
367 $title = "";
368 if ($this->lm->getTOCMode() === "pages") {
370 $this->current_page,
371 $this->lm->getPageHeader(),
372 $this->lm->isActiveNumbering(),
373 (bool) $this->lm_set->get("time_scheduled_page_activation"),
374 false,
375 $this->lm->getId(),
376 $this->lang,
377 true
378 );
379 } else {
380 $st_id = $this->lm_tree->getParentId($this->current_page);
381 if ($st_id > 0) {
383 $st_id,
385 $this->lm->isActiveNumbering(),
386 (bool) $this->lm_set->get("time_scheduled_page_activation"),
387 false,
388 $this->lm->getId(),
389 $this->lang,
390 true
391 );
392 }
393 }
394
395 $title = "<span style='vertical-align: bottom; max-width:60px; display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>" . $title . "</span>";
396
397 $this->toolbar->addStickyItem(
398 $this->ui->factory()->dropdown()->standard($actions)->withLabel($title)
399 );
400 }
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...
static _checkPreconditionsOfPage(int $cont_ref_id, int $cont_obj_id, int $page_id)
checks whether the preconditions of a page are fulfilled or not
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
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)
$text
Definition: xapiexit.php:21

References $text, ilObjContentObject\_checkPreconditionsOfPage(), ilLMPageObject\_getPresentationTitle(), ilStructureObject\_getPresentationTitle(), ilPageObject\_lookupActive(), ilLMObject\CHAPTER_TITLE, ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

Referenced by render().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

ilLMNavigationRendererGUI::render ( bool  $top = true)
protected

Definition at line 90 of file class.ilLMNavigationRendererGUI.php.

90 : string
91 {
92 $this->toolbar->setStickyItems([]);
93
94 $page_id = $this->current_page;
95
96 $tpl = new ilTemplate("tpl.lm_navigation.html", true, true, "components/ILIAS/LearningModule/Presentation");
97
98 if (empty($page_id)) {
99 return "";
100 }
101
102 // process navigation for free page
103 $back_pg = $this->navigation_status->getBackPageId();
104 if ($back_pg > 0) {
105 $back_href =
106 $this->linker->getLink(
107 "layout",
108 $back_pg,
109 "",
110 "",
111 "reduce"
112 );
113 $back_img =
114 ilUtil::getImagePath("nav/nav_arr2_L.png", false, "output", $this->offline);
115 $tpl->setCurrentBlock("ilLMNavigation_Prev");
116 $tpl->setVariable("IMG_PREV", $back_img);
117 $tpl->setVariable("HREF_PREV", $back_href);
118 $tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
119 $tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
120 $tpl->setVariable("SPACER_PREV", $this->offline
121 ? "images/media/spacer.png"
122 : ilUtil::getImagePath("media/spacer.png"));
123 $tpl->parseCurrentBlock();
124 if ($top) {
125 $b = $this->ui->factory()->button()->standard(
126 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
127 $back_href
128 );
129 $this->toolbar->addStickyItem($b);
130 }
131 } else {
132 $pre_id = $this->navigation_status->getPredecessorPageId();
133 if ($pre_id > 0) {
134 // get presentation title
136 $pre_id,
137 $this->lm->getPageHeader(),
138 $this->lm->isActiveNumbering(),
139 (bool) $this->lm_set->get("time_scheduled_page_activation"),
140 false,
141 0,
142 $this->lang,
143 true
144 );
145 $prev_title = ilStr::shortenTextExtended($prev_title, 50, true);
146 $prev_img =
147 ilUtil::getImagePath("nav/nav_arr_L.png", false, "output", $this->offline);
148
149 if (!$this->lm->cleanFrames()) {
150 $prev_href =
151 $this->linker->getLink(
152 "layout",
153 $pre_id,
154 $this->requested_frame
155 );
156 $prev_target = "";
157 } else {
158 if (!$this->offline) {
159 $prev_href =
160 $this->linker->getLink("layout", $pre_id);
161 } else {
162 $prev_href =
163 $this->linker->getLink("layout", $pre_id);
164 }
165 }
166
167 $tpl->setCurrentBlock("ilLMNavigation_Prev");
168 $tpl->setVariable("IMG_PREV", $prev_img);
169 $tpl->setVariable("HREF_PREV", $prev_href);
170 $tpl->setVariable("TXT_PREV", $prev_title);
171 $tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
172 $tpl->setVariable("SPACER_PREV", $this->offline
173 ? "images/media/spacer.png"
174 : ilUtil::getImagePath("media/spacer.png"));
175
176 if ($top) {
177 $b = $this->ui->factory()->button()->standard(
178 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
179 $prev_href
180 );
181 $this->toolbar->addStickyItem($b);
182 }
183 } else {
184 if ($top) {
185 $b = $this->ui->factory()->button()->standard(
186 "<span class=\"glyphicon glyphicon-chevron-left \" aria-hidden=\"true\"></span>",
187 "#"
188 )->withUnavailableAction();
189 $this->toolbar->addStickyItem($b);
190 }
191 }
192
193 $this->addDropdown();
194
195 $succ_id = $this->navigation_status->getSuccessorPageId();
196 if ($succ_id > 0) {
197 // get presentation title
199 $succ_id,
200 $this->lm->getPageHeader(),
201 $this->lm->isActiveNumbering(),
202 (bool) $this->lm_set->get("time_scheduled_page_activation"),
203 false,
204 0,
205 $this->lang,
206 true
207 );
208 $succ_title = ilStr::shortenTextExtended($succ_title, 50, true);
209 $succ_img =
210 ilUtil::getImagePath("nav/nav_arr_R.png", false, "output", $this->offline);
211 if (!$this->lm->cleanFrames()) {
212 $succ_href =
213 $this->linker->getLink(
214 "layout",
215 $succ_id,
216 $this->requested_frame
217 );
218 $succ_target = "";
219 } else {
220 if (!$this->offline) {
221 $succ_href =
222 $this->linker->getLink("layout", $succ_id);
223 } else {
224 $succ_href =
225 $this->linker->getLink("layout", $succ_id);
226 }
227 }
228
229 $tpl->setCurrentBlock("ilLMNavigation_Next");
230 $tpl->setVariable("IMG_SUCC", $succ_img);
231 $tpl->setVariable("HREF_SUCC", $succ_href);
232 $tpl->setVariable("TXT_SUCC", $succ_title);
233 $tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
234 $tpl->setVariable("SPACER_SUCC", $this->offline
235 ? "images/media/spacer.png"
236 : ilUtil::getImagePath("media/spacer.png"));
237 $tpl->parseCurrentBlock();
238
239 // check if successor page is not restricted
240 if (!$this->offline) {
241 if ($this->lm->getRestrictForwardNavigation()) {
242 if ($this->tracker->hasPredIncorrectAnswers($succ_id)) {
243 $this->main_tpl->addOnLoadCode("il.LearningModule.hideNextNavigation();");
244 }
245 }
246 }
247 if ($top) {
248 $b = $this->ui->factory()->button()->standard(
249 "<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
250 $succ_href
251 );
252 $this->toolbar->addStickyItem($b);
253 }
254 } else {
255 if ($top) {
256 $b = $this->ui->factory()->button()->standard(
257 "<span class=\"glyphicon glyphicon-chevron-right \" aria-hidden=\"true\"></span>",
258 "#"
259 )->withUnavailableAction();
260 $this->toolbar->addStickyItem($b);
261 }
262 }
263 }
264 $tpl->setVariable("CLASS", ($top) ? "tnav_Top" : "bnav_Bottom");
265
266 return $tpl->get();
267 }
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References Vendor\Package\$b, $current_page, ilLMPageObject\_getPresentationTitle(), addDropdown(), ilUtil\getImagePath(), ILIAS\Repository\lng(), ilStr\shortenTextExtended(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

Referenced by renderBottom(), and renderTop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderBottom()

ilLMNavigationRendererGUI::renderBottom ( )

Definition at line 85 of file class.ilLMNavigationRendererGUI.php.

85 : string
86 {
87 return $this->render(false);
88 }

References render().

+ Here is the call graph for this function:

◆ renderTop()

ilLMNavigationRendererGUI::renderTop ( )

Definition at line 80 of file class.ilLMNavigationRendererGUI.php.

80 : string
81 {
82 return $this->render();
83 }

References render().

+ Here is the call graph for this function:

Field Documentation

◆ $chapter_has_no_active_page

bool ilLMNavigationRendererGUI::$chapter_has_no_active_page
protected

Definition at line 31 of file class.ilLMNavigationRendererGUI.php.

◆ $current_page

int ilLMNavigationRendererGUI::$current_page
protected

Definition at line 33 of file class.ilLMNavigationRendererGUI.php.

Referenced by render().

◆ $deactivated_page

bool ilLMNavigationRendererGUI::$deactivated_page
protected

Definition at line 30 of file class.ilLMNavigationRendererGUI.php.

◆ $lang

string ilLMNavigationRendererGUI::$lang
protected

Definition at line 42 of file class.ilLMNavigationRendererGUI.php.

◆ $linker

ilLMPresentationLinker ilLMNavigationRendererGUI::$linker
protected

Definition at line 29 of file class.ilLMNavigationRendererGUI.php.

◆ $lm

ilObjLearningModule ilLMNavigationRendererGUI::$lm
protected

Definition at line 34 of file class.ilLMNavigationRendererGUI.php.

◆ $lm_set

ilSetting ilLMNavigationRendererGUI::$lm_set
protected

Definition at line 40 of file class.ilLMNavigationRendererGUI.php.

◆ $lm_tree

ilLMTree ilLMNavigationRendererGUI::$lm_tree
protected

Definition at line 38 of file class.ilLMNavigationRendererGUI.php.

◆ $lng

ilLanguage ilLMNavigationRendererGUI::$lng
protected

Definition at line 35 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $main_tpl

ilGlobalTemplateInterface ilLMNavigationRendererGUI::$main_tpl
protected

Definition at line 41 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $navigation_status

ilLMNavigationStatus ilLMNavigationRendererGUI::$navigation_status
protected

Definition at line 43 of file class.ilLMNavigationRendererGUI.php.

◆ $offline

bool ilLMNavigationRendererGUI::$offline
protected

Definition at line 36 of file class.ilLMNavigationRendererGUI.php.

◆ $parent_gui

ilLMPresentationGUI ilLMNavigationRendererGUI::$parent_gui
protected

Definition at line 39 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $requested_back_pg

int ilLMNavigationRendererGUI::$requested_back_pg
protected

Definition at line 27 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $requested_frame

string ilLMNavigationRendererGUI::$requested_frame
protected

Definition at line 26 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $requested_obj_id

int ilLMNavigationRendererGUI::$requested_obj_id
protected

Definition at line 28 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilLMNavigationRendererGUI::$toolbar
protected

Definition at line 24 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $tracker

ilLMTracker ilLMNavigationRendererGUI::$tracker
protected

Definition at line 37 of file class.ilLMNavigationRendererGUI.php.

◆ $ui

ILIAS DI UIServices ilLMNavigationRendererGUI::$ui
protected

Definition at line 25 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().

◆ $user

ilObjUser ilLMNavigationRendererGUI::$user
protected

Definition at line 32 of file class.ilLMNavigationRendererGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: