ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
PageContentGUI.php
Go to the documentation of this file.
2
3use ilTemplate;
4
11{
12
17
21 private $hiddenTitle = false;
22
26 public function __construct(string $file, bool $flag1, bool $flag2, bool $in_module = false, $vars = "DEFAULT", bool $plugin = false, bool $a_use_cache = true)
27 {
28 $this->template_file = new ilTemplate($file, $flag1, $flag2, $in_module, $vars, $plugin, $a_use_cache);
29 }
30
31
32 const MESSAGE_TYPE_FAILURE = 'failure';
33 const MESSAGE_TYPE_INFO = "info";
34 const MESSAGE_TYPE_SUCCESS = "success";
35 const MESSAGE_TYPE_QUESTION = "question";
39 protected static $message_types
40 = array(
41 self::MESSAGE_TYPE_FAILURE,
42 self::MESSAGE_TYPE_INFO,
43 self::MESSAGE_TYPE_SUCCESS,
44 self::MESSAGE_TYPE_QUESTION,
45 );
46 // Not used (derived from old ilGlobalTemplate)
49 private $show_footer;
50 private $main_menu;
52 private $js_files;
53 private $js_files_vp;
55 private $css_files;
56 private $inline_css;
58 private $body_class;
60 // needed for content-area
64 private $lightbox = [];
66 private $message;
68 private $title;
69 private $title_desc;
72 private $tabs_html;
79 private $icon_path;
80 private $icon_desc;
82 private $filter;
83 private $banner;
84 //
85 // Needed Methods for communication from the outside
86 //
87
96 public function addBlockFile($var, $block, $tplname, $in_module = false)
97 {
98 return $this->template_file->addBlockFile($var, $block, $tplname, $in_module);
99 }
100
101
107 public function blockExists($blockname)
108 {
109 return $this->template_file->blockExists($blockname);
110 }
111
112
116 public function removeBlockData($block)
117 {
118 $this->template_file->removeBlockData($block);
119 }
120
121
126 public function setVariable($variable, $value = '')
127 {
128 $this->template_file->setVariable($variable, $value);
129 }
130
131
135 public function setCurrentBlock($part = "DEFAULT")
136 {
137 $this->template_file->setCurrentBlock($part);
138 }
139
140
144 public function touchBlock($block)
145 {
146 $this->template_file->touchBlock($block);
147 }
148
149
153 public function parseCurrentBlock($part = "DEFAULT")
154 {
155 $this->template_file->parseCurrentBlock($part);
156 }
157
158
159
160
161
162
163
164
165
166 //
167 // BEGIN needed Setters
168 //
169
174 {
175 $this->page_form_action = $page_form_action;
176 }
177
178
183 {
184 $this->permanent_link = $permanent_link;
185 }
186
187
192 {
193 $this->main_content = $main_content;
194 }
195
196
201 public function addLightbox($a_html, $a_id)
202 {
203 $this->lightbox[$a_id] = $a_html;
204 }
205
206
211 {
212 $this->header_page_title = $header_page_title;
213 }
214
220 public function setBanner($a_val)
221 {
222 $this->banner = $a_val;
223 }
224
230 public function getBanner()
231 {
232 return $this->banner;
233 }
234
235
240 public function setTitle($title, bool $hidden = false)
241 {
242 $this->title = $title;
243 $this->hiddenTitle = $hidden;
244 }
245
246
250 public function setTitleDesc($title_desc)
251 {
252 $this->title_desc = $title_desc;
253 }
254
255
260 {
261 $this->title_alerts = $title_alerts;
262 }
263
264
269 {
270 $this->header_action = $header_action;
271 }
272
273
278 {
279 $this->admin_panel_commands_toolbar = $admin_panel_commands_toolbar;
280 }
281
282
287 {
288 $this->admin_panel_arrow = $admin_panel_arrow;
289 }
290
291
296 {
297 $this->admin_panel_bottom = $admin_panel_bottom;
298 }
299
300
304 public function setRightContent($a_html)
305 {
306 $this->right_content = $a_html;
307 }
308
309
314 {
315 $this->left_content = $left_content;
316 }
317
318
322 public function setFilter(string $filter)
323 {
324 $this->filter = $filter;
325 }
326
327
328 private function fillFilter()
329 {
330 if (trim($this->filter) != "") {
331 $this->template_file->setCurrentBlock("filter");
332 $this->template_file->setVariable("FILTER", $this->filter);
333 $this->template_file->parseCurrentBlock();
334 }
335 }
336
337
341 public function setIconPath($icon_path)
342 {
343 $this->icon_path = $icon_path;
344 }
345
346
350 public function setIconDesc($icon_desc)
351 {
352 $this->icon_desc = $icon_desc;
353 }
354
355
360 {
361 $this->enable_fileupload = $enable_fileupload;
362 }
363
364
376 public function setOnScreenMessage($a_type, $a_txt, $a_keep = false)
377 {
378 if (!in_array($a_type, self::$message_types) || $a_txt == "") {
379 return;
380 }
381 if (!$a_keep) {
382 $this->message[$a_type] = $a_txt;
383 } else {
384 $_SESSION[$a_type] = $a_txt;
385 }
386 }
387
388
389 //
390 // END needed Setters
391 //
392
393 public function renderPage($part, $a_fill_tabs, $a_skip_main_menu) : string
394 {
395 //
396 // Copied from old ilGlobalTemplate and modified
397 //
398 $this->fillMessage();
399
400 // display ILIAS footer
401 // if ($part !== false) {
402 // $this->fillFooter();
403 // }
404
405 // set standard parts (tabs and title icon)
406 // $this->fillBodyClass();
407
408 // see #22992
409 // $this->fillContentLanguage();
410
411 $this->fillPageFormAction();
412
413 if ($a_fill_tabs) {
414 if ($this->template_file->blockExists("content")) {
415 // determine default screen id
416 $this->getTabsHTML();
417 }
418
419 // to get also the js files for the main menu
420 if (!$a_skip_main_menu) {
421 // $this->getMainMenu();
422 //$this->initHelp();
423 }
424
425 //$this->initHelp();
426
427 // these fill blocks in tpl.main.html
428 // $this->fillCssFiles();
429 // $this->fillInlineCss();
430 //$this->fillJavaScriptFiles();
431
432 // these fill just plain placeholder variables in tpl.main.html
433 // $this->setCurrentBlock("DEFAULT");
434 // $this->fillNewContentStyle();
435 // $this->fillWindowTitle();
436
437 // these fill blocks in tpl.adm_content.html
438 $this->fillHeader();
439 // $this->fillSideIcons();
440 // $this->fillScreenReaderFocus(); // TODO
441 $this->fillLeftContent();
442 // $this->fillLeftNav();
443 $this->fillRightContent();
444 $this->fillAdminPanel();
445 $this->fillToolbar();
446 $this->fillFilter();
447 // $this->fillPermanentLink(); //TODO
448
449 $this->setCenterColumnClass();
450
451 // late loading of javascipr files, since operations above may add files
452 // $this->fillJavaScriptFiles();
453 // $this->fillOnLoadCode();
454
455 // these fill just plain placeholder variables in tpl.adm_content.html
456 if ($this->template_file->blockExists("content")) {
457 $this->template_file->setCurrentBlock("content");
458 $this->fillTabs();
459 $this->fillMainContent();
460 // $this->fillMainMenu();
461 $this->fillLightbox();
462 $this->template_file->parseCurrentBlock();
463 }
464 }
465
466 if ($part == "DEFAULT" or is_bool($part)) {
467 $html = $this->template_file->getUnmodified();
468 } else {
469 $html = $this->template_file->getUnmodified($part);
470 }
471
472 global $DIC;
473
474 // Modification of html is done inline here and can't be done
475 // by ilTemplate, because the "phase" is template_show in this
476 // case here.
477 $ilPluginAdmin = $DIC["ilPluginAdmin"];
478 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
479 foreach ($pl_names as $pl) {
480 $ui_plugin = \ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
481 $gui_class = $ui_plugin->getUIClassInstance();
482
483 $resp = $gui_class->getHTML(
484 "",
485 "template_show",
486 array("tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html)
487 );
488
489 if ($resp["mode"] != \ilUIHookPluginGUI::KEEP) {
490 $html = $gui_class->modifyHTML($html, $resp);
491 }
492 }
493
494 // save language usages as late as possible
496
497 return $html;
498 }
499
500
501 private function fillMessage()
502 {
503 global $DIC;
504
505 $out = "";
506
507 foreach (self::$message_types as $m) {
508 $txt = $this->getMessageTextForType($m);
509
510 if ($txt != "") {
512 }
513
514 $request = $DIC->http()->request();
515 $accept_header = $request->getHeaderLine('Accept');
516 if (isset($_SESSION[$m]) && $_SESSION[$m] && ($accept_header !== 'application/json')) {
517 unset($_SESSION[$m]);
518 }
519 }
520
521 if ($out != "") {
522 $this->template_file->setVariable("MESSAGE", $out);
523 }
524 }
525
526
532 private function getMessageTextForType($m)
533 {
534 $txt = "";
535 if (isset($_SESSION[$m]) && $_SESSION[$m] != "") {
536 $txt = $_SESSION[$m];
537 } else {
538 if (isset($this->message[$m])) {
539 $txt = $this->message[$m];
540 }
541 }
542
543 return $txt;
544 }
545
546
547 private function getTabsHTML()
548 {
549 global $DIC;
550
551 $ilTabs = $DIC["ilTabs"];
552
553 if ($this->template_file->blockExists("tabs_outer_start")) {
554 $this->sub_tabs_html = $ilTabs->getSubTabHTML();
555 $this->tabs_html = $ilTabs->getHTML(true);
556 }
557 }
558
559
563 private function initHelp()
564 {
565 include_once("./Services/Help/classes/class.ilHelpGUI.php");
566 //\ilHelpGUI::initHelp($this);
567 }
568
569
570 private function fillHeader()
571 {
572 global $DIC;
573
574 $lng = $DIC->language();
575
576
577 if ($this->banner != "" && $this->template_file->blockExists("banner_bl")) {
578 $this->template_file->setCurrentBlock("banner_bl");
579 $this->template_file->setVariable("BANNER_URL", $this->banner);
580 $header = true;
581 $this->template_file->parseCurrentBlock();
582 }
583
584
585 $icon = false;
586 if ($this->icon_path != "") {
587 $icon = true;
588 $this->template_file->setCurrentBlock("header_image");
589 if ($this->icon_desc != "") {
590 $this->template_file->setVariable("IMAGE_DESC", $lng->txt("icon") . " " . $this->icon_desc);
591 $this->template_file->setVariable("IMAGE_ALT", $lng->txt("icon") . " " . $this->icon_desc);
592 }
593
594 $this->template_file->setVariable("IMG_HEADER", $this->icon_path);
595 $this->template_file->parseCurrentBlock();
596 $header = true;
597 }
598
599 if ($this->title != "") {
600 $title = \ilUtil::stripScriptHTML($this->title);
601 $this->template_file->setVariable("HEADER", $title);
602 if ($this->hiddenTitle) {
603 $this->template_file->touchBlock("hidden_title");
604 }
605
606 $header = true;
607 }
608
609 if ($header && !$this->hiddenTitle) {
610 $this->template_file->setCurrentBlock("header_image");
611 $this->template_file->parseCurrentBlock();
612 }
613
614 if ($this->title_desc != "") {
615 $this->template_file->setCurrentBlock("header_desc");
616 $this->template_file->setVariable("H_DESCRIPTION", $this->title_desc);
617 $this->template_file->parseCurrentBlock();
618 }
619
620 $header = $this->header_action;
621 if ($header) {
622 $this->template_file->setCurrentBlock("head_action_inner");
623 $this->template_file->setVariable("HEAD_ACTION", $header);
624 $this->template_file->parseCurrentBlock();
625 $this->template_file->touchBlock("head_action");
626 }
627
628 if (count((array) $this->title_alerts)) {
629 foreach ($this->title_alerts as $alert) {
630 $this->template_file->setCurrentBlock('header_alert');
631 if (!($alert['propertyNameVisible'] === false)) {
632 $this->template_file->setVariable('H_PROP', $alert['property'] . ':');
633 }
634 $this->template_file->setVariable('H_VALUE', $alert['value']);
635 $this->template_file->parseCurrentBlock();
636 }
637 }
638
639 // add file upload drop zone in header
640 if ($this->enable_fileupload != null) {
641 $ref_id = $this->enable_fileupload;
642 $upload_id = "dropzone_" . $ref_id;
643
644 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
645 $upload = new \ilFileUploadGUI($upload_id, $ref_id, true);
646
647 $this->template_file->setVariable("FILEUPLOAD_DROPZONE_ID", " id=\"$upload_id\"");
648
649 $this->template_file->setCurrentBlock("header_fileupload");
650 $this->template_file->setVariable("HEADER_FILEUPLOAD_SCRIPT", $upload->getHTML());
651 $this->template_file->parseCurrentBlock();
652 }
653 }
654
655
656 private function setCenterColumnClass()
657 {
658 if (!$this->template_file->blockExists("center_col_width")) {
659 return;
660 }
661 $center_column_class = "";
662 if (trim($this->right_content) != "" && trim($this->left_content) != "") {
663 $center_column_class = "two_side_col";
664 } else {
665 if (trim($this->right_content) != "" || trim($this->left_content) != "") {
666 $center_column_class = "one_side_col";
667 }
668 }
669
670 switch ($center_column_class) {
671 case "one_side_col":
672 $center_column_class = "col-sm-9";
673 break;
674 case "two_side_col":
675 $center_column_class = "col-sm-6";
676 break;
677 default:
678 $center_column_class = "col-sm-12";
679 break;
680 }
681 if (trim($this->left_content) != "") {
682 $center_column_class .= " col-sm-push-3";
683 }
684
685 $this->template_file->setCurrentBlock("center_col_width");
686 $this->template_file->setVariable("CENTER_COL", $center_column_class);
687 $this->template_file->parseCurrentBlock();
688 }
689
690
691 private function fillMainContent()
692 {
693 if (trim($this->main_content) != "") {
694 $this->template_file->setVariable("ADM_CONTENT", $this->main_content);
695 }
696 }
697
698
699 private function fillLeftContent()
700 {
701 if (trim($this->left_content) != "") {
702 $this->template_file->setCurrentBlock("left_column");
703 $this->template_file->setVariable("LEFT_CONTENT", $this->left_content);
704 $left_col_class = (trim($this->right_content) == "")
705 ? "col-sm-3 col-sm-pull-9"
706 : "col-sm-3 col-sm-pull-6";
707 $this->template_file->setVariable("LEFT_COL_CLASS", $left_col_class);
708 $this->template_file->parseCurrentBlock();
709 }
710 }
711
712
713 private function fillRightContent()
714 {
715 if (trim($this->right_content) != "") {
716 $this->template_file->setCurrentBlock("right_column");
717 $this->template_file->setVariable("RIGHT_CONTENT", $this->right_content);
718 $this->template_file->parseCurrentBlock();
719 }
720 }
721
722
723 private function fillAdminPanel()
724 {
725 global $DIC;
726 $lng = $DIC->language();
727
728 if ($this->admin_panel_commands_toolbar === null) {
729 return;
730 }
731
733 assert($toolb instanceof \ilToolbarGUI);
734
735 // Add arrow if desired.
736 if ($this->admin_panel_arrow) {
737 $toolb->setLeadingImage(\ilUtil::getImagePath("arrow_upright.svg"), $lng->txt("actions"));
738 }
739
740 $this->fillPageFormAction();
741
742 // Add top admin bar.
743 $this->template_file->setCurrentBlock("adm_view_components");
744 $this->template_file->setVariable("ADM_PANEL1", $toolb->getHTML());
745 $this->template_file->parseCurrentBlock();
746
747 // Add bottom admin bar if user wants one.
748 if ($this->admin_panel_bottom) {
749 $this->template_file->setCurrentBlock("adm_view_components2");
750
751 // Replace previously set arrow image.
752 if ($this->admin_panel_arrow) {
753 $toolb->setLeadingImage(\ilUtil::getImagePath("arrow_downright.svg"), $lng->txt("actions"));
754 }
755
756 $this->template_file->setVariable("ADM_PANEL2", $toolb->getHTML());
757 $this->template_file->parseCurrentBlock();
758 }
759 }
760
761
762 private function fillPageFormAction()
763 {
764 if ($this->page_form_action != "") {
765 $this->template_file->setCurrentBlock("page_form_start");
766 $this->template_file->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
767 $this->template_file->parseCurrentBlock();
768 $this->template_file->touchBlock("page_form_end");
769 }
770 }
771
772
773 private function fillToolbar()
774 {
775 global $DIC;
776
777 $ilToolbar = $DIC["ilToolbar"];
778 ;
779
780 $thtml = $ilToolbar->getHTML();
781 if ($thtml != "") {
782 $this->template_file->setCurrentBlock("toolbar_buttons");
783 $this->template_file->setVariable("BUTTONS", $thtml);
784 $this->template_file->parseCurrentBlock();
785 }
786 }
787
788
789 private function fillTabs()
790 {
791 if ($this->template_file->blockExists("tabs_outer_start")) {
792 $this->template_file->touchBlock("tabs_outer_start");
793 $this->template_file->touchBlock("tabs_outer_end");
794 $this->template_file->touchBlock("tabs_inner_start");
795 $this->template_file->touchBlock("tabs_inner_end");
796
797 if ($this->tabs_html != "") {
798 $this->template_file->setVariable("TABS", $this->tabs_html);
799 }
800 $this->template_file->setVariable("SUB_TABS", $this->sub_tabs_html);
801 }
802 }
803
804
805 private function fillLightbox()
806 {
807 $this->template_file->setVariable('LIGHTBOX', implode('', $this->lightbox));
808 }
809}
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
addBlockFile($var, $block, $tplname, $in_module=false)
setOnScreenMessage($a_type, $a_txt, $a_keep=false)
Set a message to be displayed to the user.
setAdminPanelCommandsToolbar($admin_panel_commands_toolbar)
__construct(string $file, bool $flag1, bool $flag2, bool $in_module=false, $vars="DEFAULT", bool $plugin=false, bool $a_use_cache=true)
@inheritDoc
renderPage($part, $a_fill_tabs, $a_skip_main_menu)
const IL_COMP_SERVICE
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
special template class to simplify handling of ITX/PEAR
static stripScriptHTML($a_str, $a_allow="", $a_rm_js=true)
strip only html tags (4.0) from text $allowed contains tags to be allowed, in format tags a and b ar...
static getSystemMessageHTML($a_txt, $a_type="info")
Get HTML for a system message.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$txt
Definition: error.php:13
$lng
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46