ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
477
478 $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
479 $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
480
481 $this->standard_template_loaded = true;
482 }
483
484
485 //***********************************
486 //
487 // HEADER in standard template
488 //
489 //***********************************
490
491 protected string $header_page_title = "";
492 protected string $title = "";
493 protected string $title_desc = "";
494 protected array $title_alerts = [];
495 protected string $header_action;
496
497 public function setTitle(string $a_title, bool $hidden = false): void
498 {
499 $this->title = $a_title;
500 $this->header_page_title = $a_title;
501 }
502
503 public function setDescription(string $a_descr): void
504 {
505 $this->title_desc = $a_descr;
506 }
507
508 public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
509 {
510 $this->icon_desc = $a_icon_desc;
511 $this->icon_path = $a_icon_path;
512 }
513
514 public function setAlertProperties(array $alerts): void
515 {
516 $this->title_alerts = $alerts;
517 }
518
522 public function clearHeader(): void
523 {
524 $this->setTitle("");
525 $this->setTitleIcon("");
526 $this->setDescription("");
527 $this->setAlertProperties([]);
528 }
529
530 // REMOVAL CANDIDATE
531 // Usage locations:
532 // - ilCalendarPresentationGUI
533 // - ilContainerGUI
534 // - ilObjDataCollectionGUI
535 // - ilDashboardGUI
536 // - ilObjPortfolioTemplateGUI
537 // - ilWikiPageGUI
538 // - ilObjWikiGUI
539 public function setHeaderActionMenu(string $a_header): void
540 {
541 $this->header_action = $a_header;
542 }
543
544 // REMOVAL CANDIDATE
545 // Usage locations:
546 // - ilObjLanguageExtGUI
547 // - ilTestServiceGUI
548 // - ilWikiPageGUI
549 public function setHeaderPageTitle(string $a_title): void
550 {
551 $this->header_page_title = $a_title;
552 }
553
557 private function fillHeader(): void
558 {
559 $header_tpl = new ilTemplate('tpl.il_header.html', true, true);
560
561 $header = false;
562
563 if ($this->icon_path != "") {
564 $header_tpl->setCurrentBlock("header_image");
565 if ($this->icon_desc != "") {
566 $header_tpl->setVariable("IMAGE_DESC", $this->lng->txt("icon") . " " . $this->icon_desc);
567 $header_tpl->setVariable("IMAGE_ALT", $this->lng->txt("icon") . " " . $this->icon_desc);
568 }
569
570 $header_tpl->setVariable("IMG_HEADER", $this->icon_path);
571 $header_tpl->parseCurrentBlock();
572 $header = true;
573 }
574
575 if ($this->title != "") {
576 $title = ilUtil::stripScriptHTML($this->title);
577 $header_tpl->setVariable("HEADER", $title);
578
579 $header = true;
580 }
581
582 if ($header) {
583 $header_tpl->setCurrentBlock("header_image");
584 $header_tpl->parseCurrentBlock();
585 }
586
587 if ($this->title_desc != "") {
588 $header_tpl->setCurrentBlock("header_desc");
589 $header_tpl->setVariable("H_DESCRIPTION", $this->title_desc);
590 $header_tpl->parseCurrentBlock();
591 }
592
593 $header = $this->getHeaderActionMenu();
594 if ($header) {
595 $header_tpl->setCurrentBlock("head_action_inner");
596 $header_tpl->setVariable("HEAD_ACTION", $header);
597 $header_tpl->parseCurrentBlock();
598 $header_tpl->touchBlock("head_action");
599 }
600
601 if (count($this->title_alerts)) {
602 foreach ($this->title_alerts as $alert) {
603 $header_tpl->setCurrentBlock('header_alert');
604 if (!($alert['propertyNameVisible'] === false)) {
605 $header_tpl->setVariable('H_PROP', $alert['property'] . ':');
606 }
607 $header_tpl->setVariable('H_VALUE', $alert['value']);
608 $header_tpl->parseCurrentBlock();
609 }
610 }
611
612 $this->template->setVariable("IL_HEADER", $header_tpl->get());
613 }
614
618 private function getHeaderActionMenu(): string
619 {
621 }
622
623
624 //***********************************
625 //
626 // LOCATOR in standard template
627 //
628 //***********************************
629
630 public function setLocator(): void
631 {
632 $html = "";
633
634 include_once("./components/ILIAS/UIComponent/classes/class.ilUIHookProcessor.php");
635 $html = $this->locator->getHTML();
636 $uip = new ilUIHookProcessor(
637 "components/ILIAS/Locator",
638 "main_locator",
639 ["locator_gui" => $this->locator, "html" => $html]
640 );
641 $html = $uip->getHTML($html);
642
643 $this->setVariable("LOCATOR", $html);
644 }
645
646 //***********************************
647 //
648 // TABS in standard template
649 //
650 //***********************************
651
652 protected string $tabs_html = "";
653 protected string $sub_tabs_html = "";
654
658 public function setTabs(string $a_tabs_html): void
659 {
660 if ($a_tabs_html != "" && $this->blockExists("tabs_outer_start")) {
661 $this->touchBlock("tabs_outer_start");
662 $this->touchBlock("tabs_outer_end");
663 $this->touchBlock("tabs_inner_start");
664 $this->touchBlock("tabs_inner_end");
665 $this->setVariable("TABS", $a_tabs_html);
666 }
667 }
668
672 public function setSubTabs(string $a_tabs_html): void
673 {
674 $this->setVariable("SUB_TABS", $a_tabs_html);
675 }
676
677 private function fillTabs(): void
678 {
679 if ($this->blockExists("tabs_outer_start")) {
680 $this->touchBlock("tabs_outer_start");
681 $this->touchBlock("tabs_outer_end");
682 $this->touchBlock("tabs_inner_start");
683 $this->touchBlock("tabs_inner_end");
684
685 if ($this->tabs_html != "") {
686 $this->setVariable("TABS", $this->tabs_html);
687 }
688 $this->setVariable("SUB_TABS", $this->sub_tabs_html);
689 }
690 }
691
692 private function getTabsHTML(): void
693 {
694 if ($this->blockExists("tabs_outer_start")) {
695 $this->sub_tabs_html = $this->tabs->getSubTabHTML();
696 $this->tabs_html = $this->tabs->getHTML(true);
697 }
698 }
699
700
701 //***********************************
702 //
703 // COLUMN LAYOUT in standard template
704 //
705 //***********************************
706
710 public function setContent(string $a_html): void
711 {
712 if ($a_html != "") {
713 $this->main_content = $a_html;
714 }
715 }
716
720 public function setLeftContent(string $a_html): void
721 {
722 $this->left_content = $a_html;
723 }
724
728 public function setLeftNavContent(string $a_content): void
729 {
730 $this->left_nav_content = $a_content;
731 }
732
736 private function fillLeftNav(): void
737 {
738 if (trim($this->left_nav_content) != "") {
739 $this->setCurrentBlock("left_nav");
740 $this->setVariable("LEFT_NAV_CONTENT", $this->left_nav_content);
741 $this->parseCurrentBlock();
742 $this->touchBlock("left_nav_space");
743 }
744 }
745
749 public function setRightContent(string $a_html): void
750 {
751 $this->right_content = $a_html;
752 }
753
754 private function setCenterColumnClass(): void
755 {
756 if (!$this->blockExists("center_col_width")) {
757 return;
758 }
759 $center_column_class = "";
760 if (trim($this->right_content) != "" && trim($this->left_content) != "") {
761 $center_column_class = "two_side_col";
762 } else {
763 if (trim($this->right_content) != "" || trim($this->left_content) != "") {
764 $center_column_class = "one_side_col";
765 }
766 }
767
768 switch ($center_column_class) {
769 case "one_side_col":
770 $center_column_class = "col-sm-9";
771 break;
772 case "two_side_col":
773 $center_column_class = "col-sm-6";
774 break;
775 default:
776 $center_column_class = "col-sm-12";
777 break;
778 }
779 if (trim($this->left_content) != "") {
780 $center_column_class .= " col-sm-push-3";
781 }
782
783 $this->setCurrentBlock("center_col_width");
784 $this->setVariable("CENTER_COL", $center_column_class);
785 $this->parseCurrentBlock();
786 }
787
788 private function fillMainContent(): void
789 {
790 if (trim($this->main_content) != "") {
791 $this->setVariable("ADM_CONTENT", $this->main_content);
792 }
793 }
794
795 private function fillLeftContent(): void
796 {
797 if (trim($this->left_content) != "") {
798 $this->setCurrentBlock("left_column");
799 $this->setVariable("LEFT_CONTENT", $this->left_content);
800 $left_col_class = (trim($this->right_content) == "")
801 ? "col-sm-3 col-sm-pull-9"
802 : "col-sm-3 col-sm-pull-6";
803 $this->setVariable("LEFT_COL_CLASS", $left_col_class);
804 $this->parseCurrentBlock();
805 }
806 }
807
808 private function fillRightContent(): void
809 {
810 if (trim($this->right_content) != "") {
811 $this->setCurrentBlock("right_column");
812 $this->setVariable("RIGHT_CONTENT", $this->right_content);
813 $this->parseCurrentBlock();
814 }
815 }
816
817
818 //***********************************
819 //
820 // TOOLBAR in standard template
821 //
822 //***********************************
823
824 private function fillToolbar(): void
825 {
826 $thtml = $this->toolbar->getHTML();
827 if ($thtml != "") {
828 $this->setCurrentBlock("toolbar_buttons");
829 $this->setVariable("BUTTONS", $thtml);
830 $this->parseCurrentBlock();
831 }
832 }
833
834 // SPECIAL REQUIREMENTS
835 //
836 // Stuff that is only used by a little other classes.
837
841 private function fillContentLanguage(): void
842 {
843 $this->setVariable('META_CONTENT_LANGUAGE', $this->lng->getContentLanguage());
844 $this->setVariable('LANGUAGE_DIRECTION', $this->lng->getTextDirection());
845 }
846
847 private function fillWindowTitle(): void
848 {
849 if ($this->header_page_title != "") {
850 $title = ilUtil::stripScriptHTML($this->header_page_title);
851 $this->setVariable("PAGETITLE", "- " . $title);
852 }
853
854 if ($this->settings->get('short_inst_name') != "") {
855 $this->setVariable(
856 "WINDOW_TITLE",
857 $this->settings->get('short_inst_name')
858 );
859 } else {
860 $this->setVariable(
861 "WINDOW_TITLE",
862 "ILIAS"
863 );
864 }
865 }
866
867 // REMOVAL CANDIDATE
868 // Usage locations:
869 // - ilLuceneAdvancedSearchGUI
870 // - ilLuceneSearchGUI
871 // - ilContainerGUI
872 public function setPageFormAction(string $a_action): void
873 {
874 $this->page_form_action = $a_action;
875 }
876
877 private function fillPageFormAction(): void
878 {
879 if ($this->page_form_action != "") {
880 $this->setCurrentBlock("page_form_start");
881 $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
882 $this->parseCurrentBlock();
883 $this->touchBlock("page_form_end");
884 }
885 }
886
887
888 // REMOVAL CANDIDATE
889 // Usage locations:
890 // - ilObjForumGUI
891 // - ilObjPortfolioBaseGUI
892 // - ilWikiPageGUI
897 public function setLoginTargetPar(string $a_val): void
898 {
899 $this->login_target_par = $a_val;
900 }
901
902
903 // REMOVAL CANDIDATE:
904 // Usage locations:
905 // - ilLPListOfObjectsGUI
906 // - ilExport
907 // - ilLMEditorGUI
908 // - ilObjPortfolioGUI
909 // - ilPortfolioHTMLExport
910 // - ilForumExportGUI
911 // - ilObjWikiGUI.php
912 // - ilWikiHTMLExport
913 // - ilScormSpecialPagesTableGUI
914 //
915 // Also this seems to be somehow similar to the stuff going on in printToStdout.
916 // Maybe we could unify them.
917 public function getSpecial(
918 string $part = self::DEFAULT_BLOCK,
919 bool $add_error_mess = false,
920 bool $handle_referer = false,
921 bool $add_ilias_footer = false,
922 bool $add_standard_elements = false,
923 bool $a_main_menu = true,
924 bool $a_tabs = true
925 ): string {
926 if ($add_error_mess) {
927 $this->fillMessage();
928 }
929
930 // set standard parts (tabs and title icon)
931 if ($add_standard_elements) {
932 if ($this->blockExists("content") && $a_tabs) {
933 // determine default screen id
934 $this->getTabsHTML();
935 }
936
937 // to get also the js files for the main menu
938 $this->getMainMenu();
939 $this->initHelp();
940
941 // these fill blocks in tpl.main.html
942 $this->fillCssFiles();
943 $this->fillInlineCss();
944 $this->fillBodyClass();
945
946 // these fill just plain placeholder variables in tpl.main.html
947 $this->setCurrentBlock();
948 $this->fillNewContentStyle();
949 $this->fillContentLanguage();
950 $this->fillWindowTitle();
951
952 // these fill blocks in tpl.adm_content.html
953 $this->fillHeader();
954 $this->fillSideIcons();
955 $this->fillLeftContent();
956 $this->fillLeftNav();
957 $this->fillRightContent();
958 $this->fillAdminPanel();
959 $this->fillToolbar();
960
961 $this->setCenterColumnClass();
962
963 // late loading of javascipr files, since operations above may add files
964 $this->fillJavaScriptFiles();
965 $this->fillOnLoadCode();
966
967 // these fill just plain placeholder variables in tpl.adm_content.html
968 if ($this->blockExists("content")) {
969 $this->setCurrentBlock("content");
970 if ($a_tabs) {
971 $this->fillTabs();
972 }
973 $this->fillMainContent();
974 if ($a_main_menu) {
975 $this->fillMainMenu();
976 }
977 $this->parseCurrentBlock();
978 }
979 }
980
981 if ($part == "DEFAULT") {
982 $html = $this->template->get();
983 } else {
984 $html = $this->template->get($part);
985 }
986
987 // save language usages as late as possible
989
990 return $html;
991 }
992
993 public function printToStdout(
994 string $part = self::DEFAULT_BLOCK,
995 bool $has_tabs = true,
996 bool $skip_main_menu = false
997 ): void {
998 switch ($this->http->request()->getHeaderLine('Accept')) {
999 case 'application/json':
1000 $string = json_encode([
1001 self::MESSAGE_TYPE_SUCCESS => is_null($this->message[self::MESSAGE_TYPE_FAILURE]),
1002 'message' => '',
1003 ]);
1005 $this->http->saveResponse($this->http->response()->withBody($stream));
1006 $this->http->sendResponse();
1007 exit;
1008 default:
1009 // include yahoo dom per default
1011
1012 header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
1013 header("Content-type: text/html; charset=UTF-8");
1014
1015 $this->fillMessage();
1016
1017 // set standard parts (tabs and title icon)
1018 $this->fillBodyClass();
1019 if ($has_tabs) {
1020 if ($this->blockExists("content")) {
1021 // determine default screen id
1022 $this->getTabsHTML();
1023 }
1024
1025 // to get also the js files for the main menu
1026 if (!$skip_main_menu) {
1027 $this->getMainMenu();
1028 $this->initHelp();
1029 }
1030
1031 // these fill blocks in tpl.main.html
1032 $this->fillCssFiles();
1033 $this->fillInlineCss();
1034 //$this->fillJavaScriptFiles();
1035
1036 // these fill just plain placeholder variables in tpl.main.html
1037 $this->setCurrentBlock();
1038 $this->fillNewContentStyle();
1039 $this->fillContentLanguage();
1040 $this->fillWindowTitle();
1041
1042 // these fill blocks in tpl.adm_content.html
1043 $this->fillHeader();
1044 $this->fillSideIcons();
1045 $this->fillLeftContent();
1046 $this->fillLeftNav();
1047 $this->fillRightContent();
1048 $this->fillAdminPanel();
1049 $this->fillToolbar();
1050
1051 $this->setCenterColumnClass();
1052
1053 // late loading of javascipr files, since operations above may add files
1054 $this->fillJavaScriptFiles();
1055 $this->fillOnLoadCode();
1056
1057 // these fill just plain placeholder variables in tpl.adm_content.html
1058 if ($this->blockExists("content")) {
1059 $this->setCurrentBlock("content");
1060 $this->fillTabs();
1061 $this->fillMainContent();
1062 $this->fillMainMenu();
1063 $this->parseCurrentBlock();
1064 }
1065 }
1066
1067 if ($part == "DEFAULT" or is_bool($part)) {
1068 $html = $this->template->getUnmodified();
1069 } else {
1070 $html = $this->template->getUnmodified($part);
1071 }
1072
1073 // Modification of html is done inline here and can't be done
1074 // by ilTemplate, because the "phase" is template_show in this
1075 // case here.
1076 foreach ($this->component_factory->getActivePluginsInSlot("uihk") as $plugin) {
1077 $gui_class = $plugin->getUIClassInstance();
1078
1079 $resp = $gui_class->getHTML(
1080 "",
1081 "template_show",
1082 ["tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html]
1083 );
1084
1085 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
1086 $html = $gui_class->modifyHTML($html, $resp);
1087 }
1088 }
1089
1090 // save language usages as late as possible
1092
1093 print $html;
1094
1095 break;
1096 }
1097 }
1098
1102 private function fillSideIcons(): void
1103 {
1104 // tree/flat icon
1105 if ($this->tree_flat_link != "") {
1106 if ($this->left_nav_content != "") {
1107 $this->touchBlock("tree_lns");
1108 }
1109
1110 $this->setCurrentBlock("tree_mode");
1111 $this->setVariable("LINK_MODE", $this->tree_flat_link);
1112 if ($this->settings->get("tree_frame") == "right") {
1113 $this->setVariable("IMG_TREE", ilUtil::getImagePath("standard/icon_sidebar_on.svg"));
1114 $this->setVariable("RIGHT", "Right");
1115 } else {
1116 $this->setVariable("IMG_TREE", ilUtil::getImagePath("standard/icon_sidebar_on.svg"));
1117 }
1118 $this->setVariable("ALT_TREE", $this->lng->txt($this->tree_flat_mode . "view"));
1119 $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
1120 $this->parseCurrentBlock();
1121 }
1122
1123 $this->setCurrentBlock("tree_icons");
1124 $this->parseCurrentBlock();
1125 }
1126
1127 public function setTreeFlatIcon(string $a_link, string $a_mode): void
1128 {
1129 $this->tree_flat_link = $a_link;
1130 $this->tree_flat_mode = $a_mode;
1131 }
1132
1133 // ADMIN PANEL
1134 //
1135 // Only used in ilContainerGUI
1136 //
1137 // An "Admin Panel" is that toolbar thingy that could be found on top and bottom
1138 // of a repository listing when editing objects in a container gui.
1139
1140 protected ?ilToolbarGUI $admin_panel_commands_toolbar = null;
1141 protected ?bool $admin_panel_arrow = null;
1142 protected ?bool $admin_panel_bottom = null;
1143
1144 public function addAdminPanelToolbar(
1145 ilToolbarGUI $toolbar,
1146 bool $is_bottom_panel = true,
1147 bool $has_arrow = false
1148 ): void {
1149 $this->admin_panel_commands_toolbar = $toolbar;
1150 $this->admin_panel_arrow = $has_arrow;
1151 $this->admin_panel_bottom = $is_bottom_panel;
1152 }
1153
1159 private function fillAdminPanel(): void
1160 {
1161 if ($this->admin_panel_commands_toolbar === null) {
1162 return;
1163 }
1164
1165 $toolb = $this->admin_panel_commands_toolbar;
1166
1167 // Add arrow if desired.
1168 if ($this->admin_panel_arrow) {
1169 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), $this->lng->txt("actions"));
1170 }
1171
1172 $this->fillPageFormAction();
1173
1174 // Add top admin bar.
1175 $this->setCurrentBlock("adm_view_components");
1176 $this->setVariable("ADM_PANEL1", $toolb->getHTML());
1177 $this->parseCurrentBlock();
1178
1179 // Add bottom admin bar if user wants one.
1180 if ($this->admin_panel_bottom) {
1181 $this->setCurrentBlock("adm_view_components2");
1182
1183 // Replace previously set arrow image.
1184 if ($this->admin_panel_arrow) {
1185 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), $this->lng->txt("actions"));
1186 }
1187
1188 $this->setVariable("ADM_PANEL2", $toolb->getHTML());
1189 $this->parseCurrentBlock();
1190 }
1191 }
1192
1193 public function setPermanentLink(
1194 string $a_type,
1195 ?int $a_id,
1196 string $a_append = "",
1197 string $a_target = "",
1198 string $a_title = ""
1199 ): void {
1200 $this->permanent_link = [
1201 "type" => $a_type,
1202 "id" => $a_id,
1203 "append" => $a_append,
1204 "target" => $a_target,
1205 "title" => $a_title,
1206 ];
1207 }
1208
1212 public function resetHeaderBlock(bool $a_reset_header_action = true): void
1213 {
1214 $this->setTitle("");
1215 $this->setTitleIcon("");
1216 $this->setDescription("");
1217 $this->setAlertProperties([]);
1218 $this->setFileUploadRefId(0);
1219
1220 // see setFullscreenHeader()
1221 if ($a_reset_header_action) {
1222 $this->setHeaderActionMenu("");
1223 }
1224 }
1225
1229 public function setFileUploadRefId(int $a_ref_id): void
1230 {
1231 $this->enable_fileupload = false;
1232 }
1233
1234
1235 // TEMPLATING AND GLOBAL RENDERING
1236 //
1237 // Forwards to ilTemplate-member.
1238
1243 public function get(string $part = "DEFAULT"): string
1244 {
1245 return $this->template->get($part);
1246 }
1247
1248 public function setVariable(string $variable, $value = ''): void
1249 {
1250 $this->template->setVariable($variable, $value);
1251 }
1252
1253 public function setCurrentBlock(string $part = "DEFAULT"): bool
1254 {
1255 return $this->template->setCurrentBlock($part);
1256 }
1257
1258 public function touchBlock(string $block): bool
1259 {
1260 return $this->template->touchBlock($block);
1261 }
1262
1263 public function parseCurrentBlock(string $block_name = "DEFAULT"): bool
1264 {
1265 return $this->template->parseCurrentBlock($block_name);
1266 }
1267
1268 public function addBlockFile(string $var, string $block, string $template_name, ?string $in_module = null): bool
1269 {
1270 return $this->template->addBlockFile($var, $block, $template_name, $in_module);
1271 }
1272
1273 public function blockExists(string $block_name): bool
1274 {
1275 return $this->template->blockExists($block_name);
1276 }
1277}
$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 initDom(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Dom.
static initjQueryUI(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
exit
$txt
Definition: error.php:31
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