ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilGlobalPageTemplate.php
Go to the documentation of this file.
1<?php
2
9
16{
17
21 private static $ignored_blocks = ['ContentStyle', "DEFAULT", "SyntaxStyle", ""];
22 //
23 // SERVICES
24 //
28 private $http;
32 private $gs;
36 private $ui;
44 private $lng;
45
46
51 {
52 global $DIC;
53 $this->lng = $DIC->language();
54 $this->ui = $ui;
55 $this->gs = $gs;
56 $this->http = $http;
57 $this->legacy_content_template = new PageContentGUI("tpl.page_content.html", true, true);
58 $this->il_settings = $DIC->settings();
59 }
60
61
62 private function prepareOutputHeaders()
63 {
64 $this->http->saveResponse($this->http->response()->withAddedHeader('P3P', 'CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"'));
65 $this->http->saveResponse($this->http->response()->withAddedHeader('Content-type', 'text/html; charset=UTF-8'));
66
67 if (defined("ILIAS_HTTP_PATH")) {
68 $this->gs->layout()->meta()->setBaseURL((substr(ILIAS_HTTP_PATH, -1) == '/' ? ILIAS_HTTP_PATH : ILIAS_HTTP_PATH . '/'));
69 }
70 }
71
72
73 private function prepareBasicJS()
74 {
77 $this->gs->layout()->meta()->addJs("./Services/JavaScript/js/Basic.js", true, 1);
82
83 $sessionReminder = new ilSessionReminderGUI(
85 $this,
86 $this->lng
87 );
88 $sessionReminder->populatePage();
89
90 $onScreenNotifier = new ilNotificationOSDGUI($this, $this->lng);
91 $onScreenNotifier->populatePage();
92 }
93
94
95 private function prepareBasicCSS()
96 {
97 $this->gs->layout()->meta()->addCss(\ilUtil::getStyleSheetLocation());
98 $this->gs->layout()->meta()->addCss(\ilUtil::getNewContentStyleSheetLocation());
99 }
100
101
105 public function printToStdout($part = "DEFAULT", $a_fill_tabs = true, $a_skip_main_menu = false)
106 {
107 $this->prepareOutputHeaders();
108 $this->prepareBasicJS();
109 $this->prepareBasicCSS();
110
111 PageContentProvider::setContent($this->legacy_content_template->renderPage("DEFAULT", true, false));
112 print $this->ui->renderer()->render($this->gs->collector()->layout()->getFinalPage());
113
114 // save language usages as late as possible
116
117 // see #26968
118 $this->handleReferer();
119 }
120
121
125 public function printToString() : string
126 {
127 $this->prepareOutputHeaders();
128 $this->prepareBasicJS();
129 $this->prepareBasicCSS();
130
131 PageContentProvider::setContent($this->legacy_content_template->renderPage("DEFAULT", true, false));
132
133 return $this->ui->renderer()->render($this->gs->collector()->layout()->getFinalPage());
134 }
135
136
137 //
138 // NEEDED METHODS, but wrapped and will triage to the internal template or to the
139 //
140
141 // CSS & JS
145 public function addJavaScript($a_js_file, $a_add_version_parameter = true, $a_batch = 2)
146 {
147 $this->gs->layout()->meta()->addJs($a_js_file, $a_add_version_parameter, $a_batch);
148 }
149
150
154 public function addCss($a_css_file, $media = "screen")
155 {
156 $this->gs->layout()->meta()->addCss($a_css_file, $media);
157 }
158
159
163 public function addOnLoadCode($a_code, $a_batch = 2)
164 {
165 $this->gs->layout()->meta()->addOnloadCode($a_code, $a_batch);
166 }
167
168
172 public function addInlineCss($a_css, $media = "screen")
173 {
174 $this->gs->layout()->meta()->addInlineCss($a_css, $media);
175 }
176
177
178 // CONTENT
179
180
184 public function setContent($a_html)
185 {
186 $this->legacy_content_template->setMainContent($a_html);
187 }
188
189
193 public function setLeftContent($a_html)
194 {
195 $this->legacy_content_template->setLeftContent($a_html);
196 }
197
198
202 public function setRightContent($a_html)
203 {
204 $this->legacy_content_template->setRightContent($a_html);
205 }
206
207 // Filter section
208
209
213 public function setFilter(string $filter)
214 {
215 $this->legacy_content_template->setFilter($filter);
216 }
217
218
219 // MAIN INFOS
220
221
225 public function setTitle($a_title, $hidden = false)
226 {
227 $this->legacy_content_template->setTitle((string) $a_title, $hidden);
228
229 $short_title = (string) $this->il_settings->get('short_inst_name');
230 if (trim($short_title) === "") {
231 $short_title = 'ILIAS';
232 }
233
234 PageContentProvider::setShortTitle($short_title);
235 PageContentProvider::setViewTitle((string) $a_title);
236 $header_title = ilObjSystemFolder::_getHeaderTitle();
237 PageContentProvider::setTitle($header_title);
238 }
239
240
244 public function setDescription($a_descr)
245 {
246 $this->legacy_content_template->setTitleDesc($a_descr);
247 }
248
249
253 public function setTitleIcon($a_icon_path, $a_icon_desc = "")
254 {
255 $this->legacy_content_template->setIconPath($a_icon_path);
256 $this->legacy_content_template->setIconDesc($a_icon_desc);
257 }
258
259
260 public function setBanner(string $img_src)
261 {
262 $this->legacy_content_template->setBanner($img_src);
263 }
264
265 // ALERTS & OS-MESSAGES
266
267
271 public function setAlertProperties(array $a_props)
272 {
273 $this->legacy_content_template->setTitleAlerts($a_props);
274 }
275
276
280 public function setOnScreenMessage($a_type, $a_txt, $a_keep = false)
281 {
282 $this->legacy_content_template->setOnScreenMessage($a_type, $a_txt, $a_keep);
283 }
284
285 // SPECIAL FEATURES
286
287
291 public function enableDragDropFileUpload($a_ref_id)
292 {
293 $this->legacy_content_template->setEnableFileupload((int) $a_ref_id);
294 }
295
296
300 public function setHeaderActionMenu($a_header)
301 {
302 $this->legacy_content_template->setHeaderAction($a_header);
303 }
304
305
309 public function setHeaderPageTitle($a_title)
310 {
311 $this->legacy_content_template->setHeaderPageTitle($a_title);
312 }
313
314
318 public function addLightbox($a_html, $a_id)
319 { //
320 $this->legacy_content_template->addLightbox($a_html, $a_id);
321 }
322
323
327 public function setPageFormAction($a_action)
328 {
329 $this->legacy_content_template->setPageFormAction($a_action);
330 }
331
332
336 public function addAdminPanelToolbar(ilToolbarGUI $toolb, $a_bottom_panel = true, $a_arrow = false)
337 {
338 $this->legacy_content_template->setAdminPanelCommandsToolbar($toolb);
339 $this->legacy_content_template->setAdminPanelArrow($a_arrow);
340 $this->legacy_content_template->setAdminPanelBottom($a_bottom_panel);
341 }
342
343
344
345 //
346 // Currently needed but should vanish soon
347 //
348
353 public function setVariable($variable, $value = '')
354 {
355 if ($variable === "LOCATION_CONTENT_STYLESHEET" || $variable === "LOCATION_SYNTAX_STYLESHEET") {
356 $this->addCss($value);
357
358 return;
359 }
360 $this->legacy_content_template->setVariable($variable, $value);
361 }
362
363
367 public function resetJavascript()
368 {
369 $this->gs->layout()->meta()->getJs()->clear();
370 }
371
372
376 public function get($part = "DEFAULT")
377 {
378 return $this->legacy_content_template->get($part);
379 }
380
381
385 public function setCurrentBlock($blockname = "DEFAULT")
386 {
387 if (in_array($blockname, self::$ignored_blocks)) {
388 return; // TODO why is this needed?
389 }
390
391 if ($this->blockExists($blockname)) {
392 $this->legacy_content_template->setCurrentBlock($blockname);
393 } else {
394 throw new ilTemplateException("block " . var_export($blockname, true) . " not found");
395 }
396 }
397
398
402 public function touchBlock($blockname)
403 {
404 if (in_array($blockname, self::$ignored_blocks)) {
405 return; // TODO why is this needed?
406 }
407 if ($this->blockExists($blockname)) {
408 $this->legacy_content_template->touchBlock($blockname);
409 } else {
410 throw new ilTemplateException("block " . var_export($blockname, true) . " not found");
411 }
412 }
413
414
418 public function parseCurrentBlock($blockname = "DEFAULT")
419 {
420 if (in_array($blockname, self::$ignored_blocks)) {
421 return; // TODO why is this needed?
422 }
423 if ($this->blockExists($blockname)) {
424 return $this->legacy_content_template->parseCurrentBlock($blockname);
425 } else {
426 throw new ilTemplateException("block " . var_export($blockname, true) . " not found");
427 }
428 }
429
430
434 public function addBlockFile($var, $block, $tplname, $in_module = false)
435 {
436 if ($this->blockExists($block)) {
437 $this->legacy_content_template->removeBlockData($block);
438 }
439
440 return $this->legacy_content_template->addBlockFile($var, $block, $tplname, $in_module);
441 }
442
443
447 public function blockExists($blockname)
448 {
449 if (in_array($blockname, self::$ignored_blocks)) {
450 return false; // TODO why is this needed?
451 }
452
453 return $this->legacy_content_template->blockExists($blockname);
454 }
455
456
457
458
459 //
460 // Currently part of the interface but no applicable in ilGlobalPageTemplate
461 //
462
466 public function loadStandardTemplate()
467 {
468 // Nothing to do
469 }
470
471
475 public function setLocator()
476 {
477 // Nothing to do
478 }
479
480
484 public function setPermanentLink($a_type, $a_id, $a_append = "", $a_target = "", $a_title = "")
485 {
486 $href = ilLink::_getStaticLink($a_id, $a_type, true, $a_append);
487 PageContentProvider::setPermaLink($href);
488 }
489
490
494 public function setTreeFlatIcon($a_link, $a_mode)
495 {
496 // Nothing to do
497 }
498
499
503 public function hideFooter()
504 {
505 // Nothing to do
506 }
507
508
513 {
514 // Nothing to do, this should be handled in Slates later
515 }
516
517
521 public function resetHeaderBlock($a_reset_header_action = true)
522 {
523 // Nothing to do
524 }
525
526
530 public function setLoginTargetPar($a_val)
531 {
532 // Nothing to do
533 }
534
535 //
536 // NO LONGER AVAILABLE
537 //
538
542 public function getOnLoadCodeForAsynch()
543 {
544 // see e.g. bug #26413
545 $js = "";
546 foreach ($this->gs->layout()->meta()->getOnLoadCode()->getItemsInOrderOfDelivery() as $code) {
547 $js .= $code->getContent() . "\n";
548 }
549 if ($js) {
550 return '<script type="text/javascript">' . "\n" .
551 $js .
552 '</script>' . "\n";
553 }
554 return "";
555 }
556
557
561 public function fillJavaScriptFiles($a_force = false)
562 {
563 throw new NotImplementedException("This Method is no longer available in GlobalTemplate");
564 }
565
566
570 public function setBodyClass($a_class = "")
571 {
572 throw new NotImplementedException("This Method is no longer available in GlobalTemplate");
573 }
574
575
579 public function clearHeader()
580 {
581 throw new NotImplementedException("This Method is no longer available in GlobalTemplate");
582 }
583
584
588 public function setTabs($a_tabs_html)
589 {
590 throw new NotImplementedException("This Method is no longer available in GlobalTemplate");
591 }
592
593
597 public function setSubTabs($a_tabs_html)
598 {
599 throw new NotImplementedException("This Method is no longer available in GlobalTemplate");
600 }
601
602
606 public function getSpecial($part = "DEFAULT", $add_error_mess = false, $handle_referer = false, $add_ilias_footer = false, $add_standard_elements = false, $a_main_menu = true, $a_tabs = true)
607 { //
608 throw new NotImplementedException();
609 }
610
615 private function handleReferer()
616 {
617 if (((substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "error.php")
618 && (substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "adm_menu.php")
619 && (substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "chat.php"))) {
620 $_SESSION["post_vars"] = $_POST;
621
622 // referer is modified if query string contains cmd=gateway and $_POST is not empty.
623 // this is a workaround to display formular again in case of error and if the referer points to another page
624 $url_parts = @parse_url($_SERVER["REQUEST_URI"]);
625 if (!$url_parts) {
626 $protocol = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://';
627 $host = $_SERVER['HTTP_HOST'];
628 $path = $_SERVER['REQUEST_URI'];
629 $url_parts = @parse_url($protocol . $host . $path);
630 }
631
632 if (isset($url_parts["query"]) && preg_match("/cmd=gateway/", $url_parts["query"]) && (isset($_POST["cmd"]["create"]))) {
633 foreach ($_POST as $key => $val) {
634 if (is_array($val)) {
635 $val = key($val);
636 }
637
638 $str .= "&" . $key . "=" . $val;
639 }
640
641 $_SESSION["referer"] = preg_replace("/cmd=gateway/", substr($str, 1), $_SERVER["REQUEST_URI"]);
642 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
643 } elseif (isset($url_parts["query"]) && preg_match("/cmd=post/", $url_parts["query"]) && (isset($_POST["cmd"]["create"]))) {
644 foreach ($_POST as $key => $val) {
645 if (is_array($val)) {
646 $val = key($val);
647 }
648
649 $str .= "&" . $key . "=" . $val;
650 }
651
652 $_SESSION["referer"] = preg_replace("/cmd=post/", substr($str, 1), $_SERVER["REQUEST_URI"]);
653 if (isset($_GET['ref_id'])) {
654 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
655 } else {
656 $_SESSION['referer_ref_id'] = 0;
657 }
658 } else {
659 $_SESSION["referer"] = $_SERVER["REQUEST_URI"];
660 if (isset($_GET['ref_id'])) {
661 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
662 } else {
663 $_SESSION['referer_ref_id'] = 0;
664 }
665 }
666
667 unset($_SESSION["error_post_vars"]);
668 }
669 }
670}
if(! $in) print
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static initPage(\ilGlobalTemplateInterface $page)
Provides an interface to the ILIAS HTTP services.
Provides fluid interface to RBAC services.
Definition: UIServices.php:10
Class ilPageContentProvider.
This exception indicates that an UI component was accepted by the JF but is not backed by a real impl...
static initializeFrontend(ilGlobalTemplateInterface $page)
Class ilGlobalPageTemplate.
enableDragDropFileUpload($a_ref_id)
@inheritDoc
addInlineCss($a_css, $media="screen")
@inheritDoc
addJavaScript($a_js_file, $a_add_version_parameter=true, $a_batch=2)
@inheritDoc
blockExists($blockname)
@inheritDoc
setHeaderActionMenu($a_header)
@inheritDoc
setTitleIcon($a_icon_path, $a_icon_desc="")
@inheritDoc
setAlertProperties(array $a_props)
@inheritDoc
__construct(Services $gs, UIServices $ui, HTTPServices $http)
@inheritDoc
addAdminPanelToolbar(ilToolbarGUI $toolb, $a_bottom_panel=true, $a_arrow=false)
@inheritDoc
handleReferer()
Old method from global template fixing #26968.
addCss($a_css_file, $media="screen")
@inheritDoc
addOnLoadCode($a_code, $a_batch=2)
@inheritDoc
setDescription($a_descr)
@inheritDoc
setSubTabs($a_tabs_html)
@inheritDoc
setTreeFlatIcon($a_link, $a_mode)
@inheritDoc
setRightContent($a_html)
@inheritDoc
touchBlock($blockname)
@inheritDoc
setPermanentLink($a_type, $a_id, $a_append="", $a_target="", $a_title="")
@inheritDoc
addLightbox($a_html, $a_id)
@inheritDoc
setBodyClass($a_class="")
@inheritDoc
setTabs($a_tabs_html)
@inheritDoc
setLoginTargetPar($a_val)
@inheritDoc
setVariable($variable, $value='')
setLeftContent($a_html)
@inheritDoc
addBlockFile($var, $block, $tplname, $in_module=false)
@inheritDoc
setCurrentBlock($blockname="DEFAULT")
@inheritDoc
getSpecial($part="DEFAULT", $add_error_mess=false, $handle_referer=false, $add_ilias_footer=false, $add_standard_elements=false, $a_main_menu=true, $a_tabs=true)
@inheritDoc
resetHeaderBlock($a_reset_header_action=true)
@inheritDoc
setLeftNavContent($a_content)
@inheritDoc
printToStdout($part="DEFAULT", $a_fill_tabs=true, $a_skip_main_menu=false)
@inheritDoc
setOnScreenMessage($a_type, $a_txt, $a_keep=false)
@inheritDoc
parseCurrentBlock($blockname="DEFAULT")
@inheritDoc
setHeaderPageTitle($a_title)
@inheritDoc
setTitle($a_title, $hidden=false)
@inheritDoc
Class ilNotificationOSDGUI.
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static initializeFrontend(ilGlobalTemplateInterface $page)
Initialize frontend and delivers required javascript files and configuration to the global template.
static createInstanceWithCurrentUserSession()
static init(ilGlobalTemplateInterface $a_tpl=null)
Init.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getNewContentStyleSheetLocation($mode="output")
get full style sheet file name (path inclusive) of current user
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static http()
Fetches the global http state from ILIAS.
Class ilAsqQuestionAuthoringFactory.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
ui()
Definition: ui.php:5
$a_content
Definition: workflow.php:93
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46