ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilDataCollectionGlobalTemplate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
29 protected string $tree_flat_link = "";
30 protected string $page_form_action = "";
31 protected array $permanent_link = [];
32 protected bool $standard_template_loaded = false;
34 protected array $on_load_code;
35 protected string $body_class;
36 protected string $icon_path;
37 protected ?bool $enable_fileupload = null;
38 protected string $left_content = "";
39 protected string $left_nav_content = "";
40 protected string $right_content = "";
41 protected string $main_content = "";
42 protected string $login_target_par = "";
43 protected string $tplIdentifier = "";
44 protected string $tree_flat_mode = "";
45 protected string $icon_desc = "";
48
49 public function __construct(
50 string $file,
51 bool $flag1,
52 bool $flag2,
53 string $in_module = "",
55 bool $plugin = false,
56 bool $a_use_cache = true
57 ) {
58 global $DIC;
59
60 $this->setBodyClass("std");
61 $this->lng = $DIC->language();
62 $this->http = $DIC->http();
63 $this->locator = $DIC["ilLocator"];
64 $this->tabs = $DIC->tabs();
65 $this->toolbar = $DIC->toolbar();
66 $this->settings = $DIC->settings();
67 $this->component_factory = $DIC["component.factory"];
68
69 $this->template = new ilTemplate($file, $flag1, $flag2, $in_module, $vars, $plugin, $a_use_cache);
70 }
71
72 public function printToString(): string
73 {
74 throw new ilException('not implemented');
75 }
76
77
78 //***********************************
79 //
80 // MAIN MENU
81 //
82 //***********************************
83
84 protected string $main_menu;
85 protected string $main_menu_spacer;
86
87 private function getMainMenu(): void
88 {
89 }
90
91 private function fillMainMenu(): void
92 {
93 }
94
95 private function initHelp(): void
96 {
97 }
98
99 public function hideFooter(): void
100 {
101 }
102
103
104 //***********************************
105 //
106 // MESSAGES
107 //
108 // setMessage is only used in ilUtil
109 //
110 //***********************************
111
115 protected static array $message_types
116 = [
121 ];
122 protected array $message = [];
123
124 public function setOnScreenMessage(string $type, string $a_txt, bool $a_keep = false): void
125 {
126 if (!in_array($type, self::$message_types) || $a_txt == "") {
127 return;
128 }
129 if (!$a_keep) {
130 $this->message[$type] = $a_txt;
131 } else {
132 ilSession::set($type, $a_txt);
133 }
134 }
135
139 private function fillMessage(): void
140 {
141 $out = "";
142
143 foreach (self::$message_types as $m) {
144 $txt = $this->getMessageTextForType($m);
145
146 if ($txt != "") {
148 }
149
150 $request = $this->http->request();
151 $accept_header = $request->getHeaderLine('Accept');
152 if (ilSession::has($m) && ilSession::get($m) && ($accept_header !== 'application/json')) {
154 }
155 }
156
157 if ($out != "") {
158 $this->setVariable("MESSAGE", $out);
159 }
160 }
161
162 private function getMessageTextForType(string $m): string
163 {
164 $txt = "";
165 if (ilSession::has($m) && ilSession::get($m) != "") {
166 $txt = ilSession::get($m);
167 } else {
168 if (isset($this->message[$m])) {
169 $txt = $this->message[$m];
170 }
171 }
172
173 return $txt;
174 }
175
176 //***********************************
177 //
178 // JAVASCRIPT files and code
179 //
180 //***********************************
181
186 protected array $js_files = [0 => "assets/js/Basic.js"];
191 protected array $js_files_vp = ["assets/js/Basic.js" => true];
196 protected array $js_files_batch = ["assets/js/Basic.js" => 1];
197
201 public function addJavaScript(string $a_js_file, bool $a_add_version_parameter = true, int $a_batch = 2): void
202 {
203 // three batches currently
204 if ($a_batch < 1 || $a_batch > 3) {
205 $a_batch = 2;
206 }
207
208 // ensure jquery files being loaded first
209 if (is_int(strpos($a_js_file, "components/ILIAS/jQuery"))
210 || is_int(strpos($a_js_file, "/jquery.js"))
211 || is_int(strpos($a_js_file, "/jquery-min.js"))
212 ) {
213 $a_batch = 0;
214 }
215
216 if (!in_array($a_js_file, $this->js_files)) {
217 $this->js_files[] = $a_js_file;
218 $this->js_files_vp[$a_js_file] = $a_add_version_parameter;
219 $this->js_files_batch[$a_js_file] = $a_batch;
220 }
221 }
222
226 public function addOnLoadCode(string $a_code, int $a_batch = 2): void
227 {
228 // three batches currently
229 if ($a_batch < 1 || $a_batch > 3) {
230 $a_batch = 2;
231 }
232 $this->on_load_code[$a_batch][] = $a_code;
233 }
234
239 public function getOnLoadCodeForAsynch(): string
240 {
241 $js = "";
242 for ($i = 1; $i <= 3; $i++) {
243 if (is_array($this->on_load_code[$i])) {
244 foreach ($this->on_load_code[$i] as $code) {
245 $js .= $code . "\n";
246 }
247 }
248 }
249 if ($js) {
250 return '<script type="text/javascript">' . "\n" .
251 $js .
252 '</script>' . "\n";
253 }
254
255 return '';
256 }
257
258 // REMOVAL CANDIDATE
259 // Usage locations:
260 // - latex.php
264 public function resetJavascript(): void
265 {
266 $this->js_files = [];
267 $this->js_files_vp = [];
268 $this->js_files_batch = [];
269 }
270
271 // PRIVATE CANDIDATE
272 // Usage locations:
273 // - ilPageObjectGUI
274 // - ilStartUpGUI
275 // - ilObjPortfolioGUI
276 // - latex.php
277 public function fillJavaScriptFiles(bool $a_force = false): void
278 {
279 $vers = "vers=" . str_replace([".", " "], "-", ILIAS_VERSION);
280
281 if (DEVMODE) {
282 $vers .= '-' . time();
283 }
284
285 if ($this->blockExists("js_file")) {
286 // three batches
287 for ($i = 0; $i <= 3; $i++) {
288 reset($this->js_files);
289 foreach ($this->js_files as $file) {
290 if ($this->js_files_batch[$file] == $i) {
291 if (is_file($file) || substr($file, 0, 4) == "http" || substr(
292 $file,
293 0,
294 2
295 ) == "//" || $a_force) {
296 $this->fillJavascriptFile($file, $vers);
297 } else {
298 if (substr($file, 0, 2) == './') { // #13962
299 $url_parts = parse_url($file);
300 if (is_file($url_parts['path'])) {
301 $this->fillJavascriptFile($file, $vers);
302 }
303 }
304 }
305 }
306 }
307 }
308 }
309 }
310
314 private function fillOnLoadCode(): void
315 {
316 for ($i = 1; $i <= 3; $i++) {
317 if (is_array($this->on_load_code[$i])) {
318 $this->setCurrentBlock("on_load_code");
319 foreach ($this->on_load_code[$i] as $code) {
320 $this->setCurrentBlock("on_load_code_inner");
321 $this->setVariable("OLCODE", $code);
322 $this->parseCurrentBlock();
323 }
324 $this->setCurrentBlock("on_load_code");
325 $this->parseCurrentBlock();
326 }
327 }
328 }
329
330 protected function fillJavascriptFile(string $file, string $vers): void
331 {
332 $this->setCurrentBlock("js_file");
333 if ($this->js_files_vp[$file]) {
334 $this->setVariable("JS_FILE", ilUtil::appendUrlParameterString($file, $vers));
335 } else {
336 $this->setVariable("JS_FILE", $file);
337 }
338 $this->parseCurrentBlock();
339 }
340
341
342 //***********************************
343 //
344 // CSS files and code
345 //
346 //***********************************
347
351 protected array $css_files = [];
355 protected array $inline_css = [];
356
360 public function addCss(string $a_css_file, string $media = "screen"): void
361 {
362 if (!array_key_exists($a_css_file . $media, $this->css_files)) {
363 $this->css_files[$a_css_file . $media] = ["file" => $a_css_file, "media" => $media];
364 }
365 }
366
367 // REMOVAL CANDIDATE
368 // Usage locations:
369 // - ilDclRecordEditGUI
370 // - ilObjStyleSheetGUI
374 public function addInlineCss(string $a_css, string $media = "screen"): void
375 {
376 $this->inline_css[] = ["css" => $a_css, "media" => $media];
377 }
378
379 // PRIVATE CANDIDATE
380 // Usage locations:
381 // - ilPageObjectGUI
382 // - ilDclDetailedViewGUI
383 // - ilStartUpGUI
388 public function fillCssFiles(bool $a_force = false): void
389 {
390 if (!$this->blockExists("css_file")) {
391 return;
392 }
393 foreach ($this->css_files as $css) {
394 $filename = $css["file"];
395 if (strpos($filename, "?") > 0) {
396 $filename = substr($filename, 0, strpos($filename, "?"));
397 }
398 if (is_file($filename) || $a_force) {
399 $this->setCurrentBlock("css_file");
400 $this->setVariable("CSS_FILE", $css["file"]);
401 $this->setVariable("CSS_MEDIA", $css["media"]);
402 $this->parseCurrentBlock();
403 }
404 }
405 }
406
407 // REMOVAL CANDIDATE:
408 // Usage locations:
409 // - ilObjMediaPoolGUI
410 // - ilAttendanceList
411 // - ilObjPortfolioGUI
412 // - ilSCORM2004ScoGUI
413 // - ilTestSubmissionReviewGUI
414 // - ilTestPlayerAbstractGUI
415 // - ilAssQuestionHintRequestGUI
416 // - ilWorkspaceFolderExplorer
417 public function setBodyClass(string $a_class = ""): void
418 {
419 $this->body_class = $a_class;
420 }
421
422 private function fillBodyClass(): void
423 {
424 if ($this->body_class != "" && $this->blockExists("body_class")) {
425 $this->setCurrentBlock("body_class");
426 $this->setVariable("BODY_CLASS", $this->body_class);
427 $this->parseCurrentBlock();
428 }
429 }
430
434 private function fillInlineCss(): void
435 {
436 if (!$this->blockExists("css_inline")) {
437 return;
438 }
439 foreach ($this->inline_css as $css) {
440 $this->setCurrentBlock("css_inline");
441 $this->setVariable("CSS_INLINE", $css["css"]);
442 $this->parseCurrentBlock();
443 }
444 }
445
449 private function fillNewContentStyle(): void
450 {
451 $this->setVariable(
452 "LOCATION_NEWCONTENT_STYLESHEET_TAG",
453 '<link rel="stylesheet" type="text/css" href="' .
455 . '" />'
456 );
457 }
458
459
460 //***********************************
461 //
462 // ILIAS STANDARD TEMPLATE
463 // which is responsible for the look
464 // i.e. a title, tabs, ...
465 //
466 //***********************************
467
468 public function loadStandardTemplate(): void
469 {
470 if ($this->standard_template_loaded) {
471 return;
472 }
473
474 // always load jQuery
476
477 $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
478 $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
479
480 $this->standard_template_loaded = true;
481 }
482
483
484 //***********************************
485 //
486 // HEADER in standard template
487 //
488 //***********************************
489
490 protected string $header_page_title = "";
491 protected string $title = "";
492 protected string $title_desc = "";
493 protected array $title_alerts = [];
494 protected string $header_action;
495
496 public function setTitle(string $a_title, bool $hidden = false): void
497 {
498 $this->title = $a_title;
499 $this->header_page_title = $a_title;
500 }
501
502 public function setDescription(string $a_descr): void
503 {
504 $this->title_desc = $a_descr;
505 }
506
507 public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
508 {
509 $this->icon_desc = $a_icon_desc;
510 $this->icon_path = $a_icon_path;
511 }
512
513 public function setAlertProperties(array $alerts): void
514 {
515 $this->title_alerts = $alerts;
516 }
517
521 public function clearHeader(): void
522 {
523 $this->setTitle("");
524 $this->setTitleIcon("");
525 $this->setDescription("");
526 $this->setAlertProperties([]);
527 }
528
529 // REMOVAL CANDIDATE
530 // Usage locations:
531 // - ilCalendarPresentationGUI
532 // - ilContainerGUI
533 // - ilObjDataCollectionGUI
534 // - ilDashboardGUI
535 // - ilObjPortfolioTemplateGUI
536 // - ilWikiPageGUI
537 // - ilObjWikiGUI
538 public function setHeaderActionMenu(string $a_header): void
539 {
540 $this->header_action = $a_header;
541 }
542
543 // REMOVAL CANDIDATE
544 // Usage locations:
545 // - ilObjLanguageExtGUI
546 // - ilTestServiceGUI
547 // - ilWikiPageGUI
548 public function setHeaderPageTitle(string $a_title): void
549 {
550 $this->header_page_title = $a_title;
551 }
552
556 private function fillHeader(): void
557 {
558 $header_tpl = new ilTemplate('tpl.il_header.html', true, true);
559
560 $header = false;
561
562 if ($this->icon_path != "") {
563 $header_tpl->setCurrentBlock("header_image");
564 if ($this->icon_desc != "") {
565 $header_tpl->setVariable("IMAGE_DESC", $this->lng->txt("icon") . " " . $this->icon_desc);
566 $header_tpl->setVariable("IMAGE_ALT", $this->lng->txt("icon") . " " . $this->icon_desc);
567 }
568
569 $header_tpl->setVariable("IMG_HEADER", $this->icon_path);
570 $header_tpl->parseCurrentBlock();
571 $header = true;
572 }
573
574 if ($this->title != "") {
575 $title = ilUtil::stripScriptHTML($this->title);
576 $header_tpl->setVariable("HEADER", $title);
577
578 $header = true;
579 }
580
581 if ($header) {
582 $header_tpl->setCurrentBlock("header_image");
583 $header_tpl->parseCurrentBlock();
584 }
585
586 if ($this->title_desc != "") {
587 $header_tpl->setCurrentBlock("header_desc");
588 $header_tpl->setVariable("H_DESCRIPTION", $this->title_desc);
589 $header_tpl->parseCurrentBlock();
590 }
591
592 $header = $this->getHeaderActionMenu();
593 if ($header) {
594 $header_tpl->setCurrentBlock("head_action_inner");
595 $header_tpl->setVariable("HEAD_ACTION", $header);
596 $header_tpl->parseCurrentBlock();
597 $header_tpl->touchBlock("head_action");
598 }
599
600 if (count($this->title_alerts)) {
601 foreach ($this->title_alerts as $alert) {
602 $header_tpl->setCurrentBlock('header_alert');
603 if (!($alert['propertyNameVisible'] === false)) {
604 $header_tpl->setVariable('H_PROP', $alert['property'] . ':');
605 }
606 $header_tpl->setVariable('H_VALUE', $alert['value']);
607 $header_tpl->parseCurrentBlock();
608 }
609 }
610
611 $this->template->setVariable("IL_HEADER", $header_tpl->get());
612 }
613
617 private function getHeaderActionMenu(): string
618 {
620 }
621
622
623 //***********************************
624 //
625 // LOCATOR in standard template
626 //
627 //***********************************
628
629 public function setLocator(): void
630 {
631 $html = "";
632
633 include_once("./components/ILIAS/UIComponent/classes/class.ilUIHookProcessor.php");
634 $html = $this->locator->getHTML();
635 $uip = new ilUIHookProcessor(
636 "components/ILIAS/Locator",
637 "main_locator",
638 ["locator_gui" => $this->locator, "html" => $html]
639 );
640 $html = $uip->getHTML($html);
641
642 $this->setVariable("LOCATOR", $html);
643 }
644
645 //***********************************
646 //
647 // TABS in standard template
648 //
649 //***********************************
650
651 protected string $tabs_html = "";
652 protected string $sub_tabs_html = "";
653
657 public function setTabs(string $a_tabs_html): void
658 {
659 if ($a_tabs_html != "" && $this->blockExists("tabs_outer_start")) {
660 $this->touchBlock("tabs_outer_start");
661 $this->touchBlock("tabs_outer_end");
662 $this->touchBlock("tabs_inner_start");
663 $this->touchBlock("tabs_inner_end");
664 $this->setVariable("TABS", $a_tabs_html);
665 }
666 }
667
671 public function setSubTabs(string $a_tabs_html): void
672 {
673 $this->setVariable("SUB_TABS", $a_tabs_html);
674 }
675
676 private function fillTabs(): void
677 {
678 if ($this->blockExists("tabs_outer_start")) {
679 $this->touchBlock("tabs_outer_start");
680 $this->touchBlock("tabs_outer_end");
681 $this->touchBlock("tabs_inner_start");
682 $this->touchBlock("tabs_inner_end");
683
684 if ($this->tabs_html != "") {
685 $this->setVariable("TABS", $this->tabs_html);
686 }
687 $this->setVariable("SUB_TABS", $this->sub_tabs_html);
688 }
689 }
690
691 private function getTabsHTML(): void
692 {
693 if ($this->blockExists("tabs_outer_start")) {
694 $this->sub_tabs_html = $this->tabs->getSubTabHTML();
695 $this->tabs_html = $this->tabs->getHTML(true);
696 }
697 }
698
699
700 //***********************************
701 //
702 // COLUMN LAYOUT in standard template
703 //
704 //***********************************
705
709 public function setContent(string $a_html): void
710 {
711 if ($a_html != "") {
712 $this->main_content = $a_html;
713 }
714 }
715
719 public function setLeftContent(string $a_html): void
720 {
721 $this->left_content = $a_html;
722 }
723
727 public function setLeftNavContent(string $a_content): void
728 {
729 $this->left_nav_content = $a_content;
730 }
731
735 private function fillLeftNav(): void
736 {
737 if (trim($this->left_nav_content) != "") {
738 $this->setCurrentBlock("left_nav");
739 $this->setVariable("LEFT_NAV_CONTENT", $this->left_nav_content);
740 $this->parseCurrentBlock();
741 $this->touchBlock("left_nav_space");
742 }
743 }
744
748 public function setRightContent(string $a_html): void
749 {
750 $this->right_content = $a_html;
751 }
752
753 private function setCenterColumnClass(): void
754 {
755 if (!$this->blockExists("center_col_width")) {
756 return;
757 }
758 $center_column_class = "";
759 if (trim($this->right_content) != "" && trim($this->left_content) != "") {
760 $center_column_class = "two_side_col";
761 } else {
762 if (trim($this->right_content) != "" || trim($this->left_content) != "") {
763 $center_column_class = "one_side_col";
764 }
765 }
766
767 switch ($center_column_class) {
768 case "one_side_col":
769 $center_column_class = "col-sm-9";
770 break;
771 case "two_side_col":
772 $center_column_class = "col-sm-6";
773 break;
774 default:
775 $center_column_class = "col-sm-12";
776 break;
777 }
778 if (trim($this->left_content) != "") {
779 $center_column_class .= " col-sm-push-3";
780 }
781
782 $this->setCurrentBlock("center_col_width");
783 $this->setVariable("CENTER_COL", $center_column_class);
784 $this->parseCurrentBlock();
785 }
786
787 private function fillMainContent(): void
788 {
789 if (trim($this->main_content) != "") {
790 $this->setVariable("ADM_CONTENT", $this->main_content);
791 }
792 }
793
794 private function fillLeftContent(): void
795 {
796 if (trim($this->left_content) != "") {
797 $this->setCurrentBlock("left_column");
798 $this->setVariable("LEFT_CONTENT", $this->left_content);
799 $left_col_class = (trim($this->right_content) == "")
800 ? "col-sm-3 col-sm-pull-9"
801 : "col-sm-3 col-sm-pull-6";
802 $this->setVariable("LEFT_COL_CLASS", $left_col_class);
803 $this->parseCurrentBlock();
804 }
805 }
806
807 private function fillRightContent(): void
808 {
809 if (trim($this->right_content) != "") {
810 $this->setCurrentBlock("right_column");
811 $this->setVariable("RIGHT_CONTENT", $this->right_content);
812 $this->parseCurrentBlock();
813 }
814 }
815
816
817 //***********************************
818 //
819 // TOOLBAR in standard template
820 //
821 //***********************************
822
823 private function fillToolbar(): void
824 {
825 $thtml = $this->toolbar->getHTML();
826 if ($thtml != "") {
827 $this->setCurrentBlock("toolbar_buttons");
828 $this->setVariable("BUTTONS", $thtml);
829 $this->parseCurrentBlock();
830 }
831 }
832
833 // SPECIAL REQUIREMENTS
834 //
835 // Stuff that is only used by a little other classes.
836
840 private function fillContentLanguage(): void
841 {
842 $this->setVariable('META_CONTENT_LANGUAGE', $this->lng->getContentLanguage());
843 $this->setVariable('LANGUAGE_DIRECTION', $this->lng->getTextDirection());
844 }
845
846 private function fillWindowTitle(): void
847 {
848 if ($this->header_page_title != "") {
849 $title = ilUtil::stripScriptHTML($this->header_page_title);
850 $this->setVariable("PAGETITLE", "- " . $title);
851 }
852
853 if ($this->settings->get('short_inst_name') != "") {
854 $this->setVariable(
855 "WINDOW_TITLE",
856 $this->settings->get('short_inst_name')
857 );
858 } else {
859 $this->setVariable(
860 "WINDOW_TITLE",
861 "ILIAS"
862 );
863 }
864 }
865
866 // REMOVAL CANDIDATE
867 // Usage locations:
868 // - ilLuceneAdvancedSearchGUI
869 // - ilLuceneSearchGUI
870 // - ilContainerGUI
871 public function setPageFormAction(string $a_action): void
872 {
873 $this->page_form_action = $a_action;
874 }
875
876 private function fillPageFormAction(): void
877 {
878 if ($this->page_form_action != "") {
879 $this->setCurrentBlock("page_form_start");
880 $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
881 $this->parseCurrentBlock();
882 $this->touchBlock("page_form_end");
883 }
884 }
885
886
887 // REMOVAL CANDIDATE
888 // Usage locations:
889 // - ilObjForumGUI
890 // - ilObjPortfolioBaseGUI
891 // - ilWikiPageGUI
896 public function setLoginTargetPar(string $a_val): void
897 {
898 $this->login_target_par = $a_val;
899 }
900
901
902 // REMOVAL CANDIDATE:
903 // Usage locations:
904 // - ilLPListOfObjectsGUI
905 // - ilExport
906 // - ilLMEditorGUI
907 // - ilObjPortfolioGUI
908 // - ilPortfolioHTMLExport
909 // - ilForumExportGUI
910 // - ilObjWikiGUI.php
911 // - ilWikiHTMLExport
912 // - ilScormSpecialPagesTableGUI
913 //
914 // Also this seems to be somehow similar to the stuff going on in printToStdout.
915 // Maybe we could unify them.
916 public function getSpecial(
917 string $part = self::DEFAULT_BLOCK,
918 bool $add_error_mess = false,
919 bool $handle_referer = false,
920 bool $add_ilias_footer = false,
921 bool $add_standard_elements = false,
922 bool $a_main_menu = true,
923 bool $a_tabs = true
924 ): string {
925 if ($add_error_mess) {
926 $this->fillMessage();
927 }
928
929 // set standard parts (tabs and title icon)
930 if ($add_standard_elements) {
931 if ($this->blockExists("content") && $a_tabs) {
932 // determine default screen id
933 $this->getTabsHTML();
934 }
935
936 // to get also the js files for the main menu
937 $this->getMainMenu();
938 $this->initHelp();
939
940 // these fill blocks in tpl.main.html
941 $this->fillCssFiles();
942 $this->fillInlineCss();
943 $this->fillBodyClass();
944
945 // these fill just plain placeholder variables in tpl.main.html
946 $this->setCurrentBlock();
947 $this->fillNewContentStyle();
948 $this->fillContentLanguage();
949 $this->fillWindowTitle();
950
951 // these fill blocks in tpl.adm_content.html
952 $this->fillHeader();
953 $this->fillSideIcons();
954 $this->fillLeftContent();
955 $this->fillLeftNav();
956 $this->fillRightContent();
957 $this->fillAdminPanel();
958 $this->fillToolbar();
959
960 $this->setCenterColumnClass();
961
962 // late loading of javascipr files, since operations above may add files
963 $this->fillJavaScriptFiles();
964 $this->fillOnLoadCode();
965
966 // these fill just plain placeholder variables in tpl.adm_content.html
967 if ($this->blockExists("content")) {
968 $this->setCurrentBlock("content");
969 if ($a_tabs) {
970 $this->fillTabs();
971 }
972 $this->fillMainContent();
973 if ($a_main_menu) {
974 $this->fillMainMenu();
975 }
976 $this->parseCurrentBlock();
977 }
978 }
979
980 if ($part == "DEFAULT") {
981 $html = $this->template->get();
982 } else {
983 $html = $this->template->get($part);
984 }
985
986 // save language usages as late as possible
988
989 return $html;
990 }
991
992 public function printToStdout(
993 string $part = self::DEFAULT_BLOCK,
994 bool $has_tabs = true,
995 bool $skip_main_menu = false
996 ): void {
997 switch ($this->http->request()->getHeaderLine('Accept')) {
998 case 'application/json':
999 $string = json_encode([
1000 self::MESSAGE_TYPE_SUCCESS => is_null($this->message[self::MESSAGE_TYPE_FAILURE]),
1001 'message' => '',
1002 ]);
1004 $this->http->saveResponse($this->http->response()->withBody($stream));
1005 $this->http->sendResponse();
1006 exit;
1007 default:
1008 header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
1009 header("Content-type: text/html; charset=UTF-8");
1010
1011 $this->fillMessage();
1012
1013 // set standard parts (tabs and title icon)
1014 $this->fillBodyClass();
1015 if ($has_tabs) {
1016 if ($this->blockExists("content")) {
1017 // determine default screen id
1018 $this->getTabsHTML();
1019 }
1020
1021 // to get also the js files for the main menu
1022 if (!$skip_main_menu) {
1023 $this->getMainMenu();
1024 $this->initHelp();
1025 }
1026
1027 // these fill blocks in tpl.main.html
1028 $this->fillCssFiles();
1029 $this->fillInlineCss();
1030 //$this->fillJavaScriptFiles();
1031
1032 // these fill just plain placeholder variables in tpl.main.html
1033 $this->setCurrentBlock();
1034 $this->fillNewContentStyle();
1035 $this->fillContentLanguage();
1036 $this->fillWindowTitle();
1037
1038 // these fill blocks in tpl.adm_content.html
1039 $this->fillHeader();
1040 $this->fillSideIcons();
1041 $this->fillLeftContent();
1042 $this->fillLeftNav();
1043 $this->fillRightContent();
1044 $this->fillAdminPanel();
1045 $this->fillToolbar();
1046
1047 $this->setCenterColumnClass();
1048
1049 // late loading of javascipr files, since operations above may add files
1050 $this->fillJavaScriptFiles();
1051 $this->fillOnLoadCode();
1052
1053 // these fill just plain placeholder variables in tpl.adm_content.html
1054 if ($this->blockExists("content")) {
1055 $this->setCurrentBlock("content");
1056 $this->fillTabs();
1057 $this->fillMainContent();
1058 $this->fillMainMenu();
1059 $this->parseCurrentBlock();
1060 }
1061 }
1062
1063 if ($part == "DEFAULT" or is_bool($part)) {
1064 $html = $this->template->getUnmodified();
1065 } else {
1066 $html = $this->template->getUnmodified($part);
1067 }
1068
1069 // Modification of html is done inline here and can't be done
1070 // by ilTemplate, because the "phase" is template_show in this
1071 // case here.
1072 foreach ($this->component_factory->getActivePluginsInSlot("uihk") as $plugin) {
1073 $gui_class = $plugin->getUIClassInstance();
1074
1075 $resp = $gui_class->getHTML(
1076 "",
1077 "template_show",
1078 ["tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html]
1079 );
1080
1081 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
1082 $html = $gui_class->modifyHTML($html, $resp);
1083 }
1084 }
1085
1086 // save language usages as late as possible
1088
1089 print $html;
1090
1091 break;
1092 }
1093 }
1094
1098 private function fillSideIcons(): void
1099 {
1100 // tree/flat icon
1101 if ($this->tree_flat_link != "") {
1102 if ($this->left_nav_content != "") {
1103 $this->touchBlock("tree_lns");
1104 }
1105
1106 $this->setCurrentBlock("tree_mode");
1107 $this->setVariable("LINK_MODE", $this->tree_flat_link);
1108 if ($this->settings->get("tree_frame") == "right") {
1109 $this->setVariable("IMG_TREE", ilUtil::getImagePath("standard/icon_sidebar_on.svg"));
1110 $this->setVariable("RIGHT", "Right");
1111 } else {
1112 $this->setVariable("IMG_TREE", ilUtil::getImagePath("standard/icon_sidebar_on.svg"));
1113 }
1114 $this->setVariable("ALT_TREE", $this->lng->txt($this->tree_flat_mode . "view"));
1115 $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
1116 $this->parseCurrentBlock();
1117 }
1118
1119 $this->setCurrentBlock("tree_icons");
1120 $this->parseCurrentBlock();
1121 }
1122
1123 public function setTreeFlatIcon(string $a_link, string $a_mode): void
1124 {
1125 $this->tree_flat_link = $a_link;
1126 $this->tree_flat_mode = $a_mode;
1127 }
1128
1129 // ADMIN PANEL
1130 //
1131 // Only used in ilContainerGUI
1132 //
1133 // An "Admin Panel" is that toolbar thingy that could be found on top and bottom
1134 // of a repository listing when editing objects in a container gui.
1135
1136 protected ?ilToolbarGUI $admin_panel_commands_toolbar = null;
1137 protected ?bool $admin_panel_arrow = null;
1138 protected ?bool $admin_panel_bottom = null;
1139
1140 public function addAdminPanelToolbar(
1141 ilToolbarGUI $toolbar,
1142 bool $is_bottom_panel = true,
1143 bool $has_arrow = false
1144 ): void {
1145 $this->admin_panel_commands_toolbar = $toolbar;
1146 $this->admin_panel_arrow = $has_arrow;
1147 $this->admin_panel_bottom = $is_bottom_panel;
1148 }
1149
1155 private function fillAdminPanel(): void
1156 {
1157 if ($this->admin_panel_commands_toolbar === null) {
1158 return;
1159 }
1160
1161 $toolb = $this->admin_panel_commands_toolbar;
1162
1163 // Add arrow if desired.
1164 if ($this->admin_panel_arrow) {
1165 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), $this->lng->txt("actions"));
1166 }
1167
1168 $this->fillPageFormAction();
1169
1170 // Add top admin bar.
1171 $this->setCurrentBlock("adm_view_components");
1172 $this->setVariable("ADM_PANEL1", $toolb->getHTML());
1173 $this->parseCurrentBlock();
1174
1175 // Add bottom admin bar if user wants one.
1176 if ($this->admin_panel_bottom) {
1177 $this->setCurrentBlock("adm_view_components2");
1178
1179 // Replace previously set arrow image.
1180 if ($this->admin_panel_arrow) {
1181 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), $this->lng->txt("actions"));
1182 }
1183
1184 $this->setVariable("ADM_PANEL2", $toolb->getHTML());
1185 $this->parseCurrentBlock();
1186 }
1187 }
1188
1189 public function setPermanentLink(
1190 string $a_type,
1191 ?int $a_id,
1192 string $a_append = "",
1193 string $a_target = "",
1194 string $a_title = ""
1195 ): void {
1196 $this->permanent_link = [
1197 "type" => $a_type,
1198 "id" => $a_id,
1199 "append" => $a_append,
1200 "target" => $a_target,
1201 "title" => $a_title,
1202 ];
1203 }
1204
1208 public function resetHeaderBlock(bool $a_reset_header_action = true): void
1209 {
1210 $this->setTitle("");
1211 $this->setTitleIcon("");
1212 $this->setDescription("");
1213 $this->setAlertProperties([]);
1214 $this->setFileUploadRefId(0);
1215
1216 // see setFullscreenHeader()
1217 if ($a_reset_header_action) {
1218 $this->setHeaderActionMenu("");
1219 }
1220 }
1221
1225 public function setFileUploadRefId(int $a_ref_id): void
1226 {
1227 $this->enable_fileupload = false;
1228 }
1229
1230
1231 // TEMPLATING AND GLOBAL RENDERING
1232 //
1233 // Forwards to ilTemplate-member.
1234
1239 public function get(string $part = "DEFAULT"): string
1240 {
1241 return $this->template->get($part);
1242 }
1243
1244 public function setVariable(string $variable, $value = ''): void
1245 {
1246 $this->template->setVariable($variable, $value);
1247 }
1248
1249 public function setCurrentBlock(string $part = "DEFAULT"): bool
1250 {
1251 return $this->template->setCurrentBlock($part);
1252 }
1253
1254 public function touchBlock(string $block): bool
1255 {
1256 return $this->template->touchBlock($block);
1257 }
1258
1259 public function parseCurrentBlock(string $block_name = "DEFAULT"): bool
1260 {
1261 return $this->template->parseCurrentBlock($block_name);
1262 }
1263
1264 public function addBlockFile(string $var, string $block, string $template_name, ?string $in_module = null): bool
1265 {
1266 return $this->template->addBlockFile($var, $block, $template_name, $in_module);
1267 }
1268
1269 public function blockExists(string $block_name): bool
1270 {
1271 return $this->template->blockExists($block_name);
1272 }
1273}
$filename
Definition: buildRTE.php:78
$out
Definition: buildRTE.php:24
Builds data types.
Definition: Factory.php:36
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
Class Services.
Definition: Services.php:38
setVariable(string $a_group_name, string $a_var_name, string $a_var_value)
sets a variable in a group
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
addInlineCss(string $a_css, string $media="screen")
Add a css file that should be included in the header.
setCurrentBlock(string $part="DEFAULT")
Sets the template to the given block.
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
array $css_files
Stores CSS-files to be included.
setSubTabs(string $a_tabs_html)
sets subtabs in standard template
setContent(string $a_html)
Sets content for standard template.
fillCssFiles(bool $a_force=false)
Fill in the css file tags.
getOnLoadCodeForAsynch()
Get js onload code for ajax calls.
__construct(string $file, bool $flag1, bool $flag2, string $in_module="", string $vars=ilGlobalTemplateInterface::DEFAULT_BLOCK, bool $plugin=false, bool $a_use_cache=true)
setPermanentLink(string $a_type, ?int $a_id, string $a_append="", string $a_target="", string $a_title="")
Generates and sets a permanent ilias link.
parseCurrentBlock(string $block_name="DEFAULT")
Parses the given block.
addAdminPanelToolbar(ilToolbarGUI $toolbar, bool $is_bottom_panel=true, bool $has_arrow=false)
setFileUploadRefId(int $a_ref_id)
Enables the file upload into this object by dropping a file.
setLeftNavContent(string $a_content)
Sets content of left navigation column.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setHeaderActionMenu(string $a_header)
Set header action menu.
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setHeaderPageTitle(string $a_title)
Sets the title of the page (for browser window).
array $inline_css
Stores CSS to be included directly.
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
getSpecial(string $part=self::DEFAULT_BLOCK, bool $add_error_mess=false, bool $handle_referer=false, bool $add_ilias_footer=false, bool $add_standard_elements=false, bool $a_main_menu=true, bool $a_tabs=true)
Renders the page with specific elements enabled.
setLeftContent(string $a_html)
Sets content of left column.
fillSideIcons()
Fill side icons (upper icon, tree icon, web folder icon)
hideFooter()
Make the template hide the footer.
printToString()
Use this method to get the finally rendered page as string.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setRightContent(string $a_html)
Sets content of right column.
fillJavaScriptFiles(bool $a_force=false)
Probably adds javascript files.
addBlockFile(string $var, string $block, string $template_name, ?string $in_module=null)
overwrites ITX::addBlockFile
fillContentLanguage()
Add current user language to meta tags.
touchBlock(string $block)
overwrites ITX::touchBlock.
setAlertProperties(array $alerts)
Set alert properties.
setTabs(string $a_tabs_html)
sets tabs in standard template
blockExists(string $block_name)
check if block exists in actual template
setDescription(string $a_descr)
Sets description below title in standard template.
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
setPageFormAction(string $a_action)
Sets the pages form action.
setTreeFlatIcon(string $a_link, string $a_mode)
Sets a tree or flat icon.
setBodyClass(string $a_class="")
Sets the body-tags class.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
Base class for ILIAS Exception handling.
static _getFrame(string $a_class)
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static has($a_var)
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getSystemMessageHTML(string $a_txt, string $a_type="info")
Get HTML for a system message.
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static getNewContentStyleSheetLocation(string $mode="output")
get full style sheet file name (path inclusive) of current user
static stripScriptHTML(string $a_str, string $a_allow="", bool $a_rm_js=true)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
exit
const ILIAS_VERSION
static http()
Fetches the global http state from ILIAS.
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26