ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLMNavigationRendererGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $user;
17
21 protected $current_page;
22
26 protected $lm;
27
31 protected $lng;
32
36 protected $offline;
37
41 protected $tracker;
42
46 protected $lm_tree;
47
51 protected $parent_gui;
52
56 protected $lm_set;
57
61 protected $main_tpl;
62
66 protected $lang;
67
72
76 public function __construct(
82 int $requested_obj_id,
83 string $requested_back_pg,
84 string $requested_frame
85 ) {
86 global $DIC;
87
88 $this->user = $user;
89 $this->lm_tree = $service->getLMTree();
90 $this->current_page = $service->getNavigationStatus()->getCurrentPage();
91 $this->lm = $service->getLearningModule();
92 $this->lm_set = $service->getSettings();
93 $this->lng = $lng;
94 $this->offline = $service->getPresentationStatus()->offline();
95 $this->tracker = $service->getTracker();
96 $this->parent_gui = $parent_gui;
97 $this->chapter_has_no_active_page = $service->getNavigationStatus()->isChapterWithoutActivePage();
98 $this->deactivated_page = $service->getNavigationStatus()->isDeactivatedPage();
99 $this->linker = $service->getLinker();
100 $this->navigation_status = $service->getNavigationStatus();
101 $this->requested_obj_id = $requested_obj_id;
102 $back_pg = explode(":", $requested_back_pg);
103 $this->requested_back_pg = (int) $back_pg[0];
104 $this->requested_frame = $requested_frame;
105 $this->main_tpl = $main_tpl;
106 $this->lang = $service->getPresentationStatus()->getLang();
107 }
108
114 public function renderTop()
115 {
116 return $this->render();
117 }
118
124 public function renderBottom()
125 {
126 return $this->render(false);
127 }
128
129
135 protected function render($top = true)
136 {
138
139 $page_id = $this->current_page;
140
141 $tpl = new ilTemplate("tpl.lm_navigation.html", true, true, "Modules/LearningModule/Presentation");
142
143 if (empty($page_id)) {
144 return "";
145 }
146
147 // process navigation for free page
148 $back_pg = $this->navigation_status->getBackPageId();
149 if ($back_pg > 0) {
150 $back_href =
151 $this->linker->getLink(
152 "layout",
153 $back_pg,
154 "",
155 "",
156 "reduce"
157 );
158 $back_img =
159 ilUtil::getImagePath("nav_arr2_L.png", false, "output", $this->offline);
160 $tpl->setCurrentBlock("ilLMNavigation_Prev");
161 $tpl->setVariable("IMG_PREV", $back_img);
162 $tpl->setVariable("HREF_PREV", $back_href);
163 $tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
164 $tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
165 $tpl->setVariable(
166 "PREV_ACC_KEY",
168 );
169 $tpl->setVariable("SPACER_PREV", $this->offline
170 ? "images/spacer.png"
171 : ilUtil::getImagePath("spacer.png"));
172 $tpl->parseCurrentBlock();
173 } else {
174 $pre_id = $this->navigation_status->getPredecessorPageId();
175 if ($pre_id > 0) {
176 // get presentation title
178 $pre_id,
179 $this->lm->getPageHeader(),
180 $this->lm->isActiveNumbering(),
181 $this->lm_set->get("time_scheduled_page_activation"),
182 false,
183 0,
184 $this->lang,
185 true
186 );
187 $prev_title = ilUtil::shortenText($prev_title, 50, true);
188 $prev_img =
189 ilUtil::getImagePath("nav_arr_L.png", false, "output", $this->offline);
190
191 if (!$this->lm->cleanFrames()) {
192 $prev_href =
193 $this->linker->getLink(
194 "layout",
195 $pre_id,
196 $this->requested_frame
197 );
198 $prev_target = "";
199 } else {
200 if (!$this->offline) {
201 $prev_href =
202 $this->linker->getLink("layout", $pre_id);
203 $prev_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
204 } else {
205 $prev_href =
206 $this->linker->getLink("layout", $pre_id);
207 $prev_target = 'target="_top" ';
208 }
209 }
210
211 $tpl->setCurrentBlock("ilLMNavigation_Prev");
212 $tpl->setVariable("IMG_PREV", $prev_img);
213 $tpl->setVariable("HREF_PREV", $prev_href);
214 $tpl->setVariable("FRAME_PREV", $prev_target);
215 $tpl->setVariable("TXT_PREV", $prev_title);
216 $tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
217 $tpl->setVariable("SPACER_PREV", $this->offline
218 ? "images/spacer.png"
219 : ilUtil::getImagePath("spacer.png"));
220 $tpl->setVariable(
221 "PREV_ACC_KEY",
223 );
224 }
225
226 $succ_id = $this->navigation_status->getSuccessorPageId();
227 if ($succ_id > 0) {
228 // get presentation title
230 $succ_id,
231 $this->lm->getPageHeader(),
232 $this->lm->isActiveNumbering(),
233 $this->lm_set->get("time_scheduled_page_activation"),
234 false,
235 0,
236 $this->lang,
237 true
238 );
239 $succ_title = ilUtil::shortenText($succ_title, 50, true);
240 $succ_img =
241 ilUtil::getImagePath("nav_arr_R.png", false, "output", $this->offline);
242 if (!$this->lm->cleanFrames()) {
243 $succ_href =
244 $this->linker->getLink(
245 "layout",
246 $succ_id,
247 $this->requested_frame
248 );
249 $succ_target = "";
250 } else {
251 if (!$this->offline) {
252 $succ_href =
253 $this->linker->getLink("layout", $succ_id);
254 $succ_target = ' target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
255 } else {
256 $succ_href =
257 $this->linker->getLink("layout", $succ_id);
258 $succ_target = ' target="_top" ';
259 }
260 }
261
262 $tpl->setCurrentBlock("ilLMNavigation_Next");
263 $tpl->setVariable("IMG_SUCC", $succ_img);
264 $tpl->setVariable("HREF_SUCC", $succ_href);
265 $tpl->setVariable("FRAME_SUCC", $succ_target);
266 $tpl->setVariable("TXT_SUCC", $succ_title);
267 $tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
268 $tpl->setVariable("SPACER_SUCC", $this->offline
269 ? "images/spacer.png"
270 : ilUtil::getImagePath("spacer.png"));
271 $tpl->setVariable(
272 "NEXT_ACC_KEY",
274 );
275 $tpl->parseCurrentBlock();
276
277 // check if successor page is not restricted
278 if (!$this->offline) {
279 if ($this->lm->getRestrictForwardNavigation()) {
280 if ($this->tracker->hasPredIncorrectAnswers($succ_id)) {
281 $this->main_tpl->addOnLoadCode("$('.ilc_page_rnav_RightNavigation').addClass('ilNoDisplay');");
282 }
283 }
284 }
285 }
286 }
287
288 $tpl->setVariable("CLASS", ($top) ? "tnav_Top": "bnav_Bottom");
289
290 return $tpl->get();
291 }
292}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
static getAttribute($a_func_id)
Get accesskey HTML attribute.
static _getFrame($a_class, $a_type='')
Get content frame name.
Class ilGlobalPageTemplate.
__construct(ilLMPresentationService $service, ilLMPresentationGUI $parent_gui, ilLanguage $lng, ilObjUser $user, ilGlobalPageTemplate $main_tpl, int $requested_obj_id, string $requested_back_pg, string $requested_frame)
Constructor.
static _getPresentationTitle( $a_pg_id, $a_mode=self::CHAPTER_TITLE, $a_include_numbers=false, $a_time_scheduled_activation=false, $a_force_content=false, $a_lm_id=0, $a_lang="-", $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.
Main service init and factory.
language handling
special template class to simplify handling of ITX/PEAR
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$service
Definition: result.php:17