ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
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
 
ILIAS COPage Page PageManagerInterface $page_manager
 

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 46 of file class.ilLMNavigationRendererGUI.php.

57 {
58 $this->user = $user;
59 $this->toolbar = $toolbar;
60 $this->ui = $ui;
61 $this->lm_tree = $service->getLMTree();
62 $this->current_page = $service->getNavigationStatus()->getCurrentPage();
63 $this->lm = $service->getLearningModule();
64 $this->lm_set = $service->getSettings();
65 $this->lng = $lng;
66 $this->offline = $service->getPresentationStatus()->offline();
67 $this->tracker = $service->getTracker();
68 $this->parent_gui = $parent_gui;
69 $this->chapter_has_no_active_page = $service->getNavigationStatus()->isChapterWithoutActivePage();
70 $this->deactivated_page = $service->getNavigationStatus()->isDeactivatedPage();
71 $this->linker = $service->getLinker();
72 $this->navigation_status = $service->getNavigationStatus();
73 $this->page_manager = $service->getPageManager();
74 $this->requested_obj_id = $requested_obj_id;
75 $back_pg = explode(":", $requested_back_pg);
76 $this->requested_back_pg = (int) $back_pg[0];
77 $this->requested_frame = $requested_frame;
78 $this->main_tpl = $main_tpl;
79 $this->lang = $service->getPresentationStatus()->getLang();
80 }
$service
Definition: ltiresult.php:44

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 273 of file class.ilLMNavigationRendererGUI.php.

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

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

References Vendor\Package\$b, $current_page, ILIAS\News\Common\Table\$tpl, ilLMPageObject\_getPresentationTitle(), addDropdown(), ILIAS\UICore\GlobalTemplate\get(), ilUtil\getImagePath(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), ILIAS\UICore\GlobalTemplate\setVariable(), 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 87 of file class.ilLMNavigationRendererGUI.php.

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

References render().

+ Here is the call graph for this function:

◆ renderTop()

ilLMNavigationRendererGUI::renderTop ( )

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

82 : string
83 {
84 return $this->render();
85 }

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.

◆ $page_manager

ILIAS COPage Page PageManagerInterface ilLMNavigationRendererGUI::$page_manager
protected

Definition at line 44 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: