ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilGlobalTemplate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30{
33
38 protected array $js_files = [
39 "assets/js/Basic.js",
40 ];
41
46 protected array $js_files_vp = [
47 "assets/js/Basic.js" => true,
48 ];
49
54 protected array $js_files_batch = [
55 "assets/js/Basic.js" => 1,
56 ];
57
62 protected array $css_files = [];
63
68 protected array $inline_css = [];
69
70 protected string $in_module;
71 protected string $template_name;
72 protected string $body_class = '';
73 protected string $tree_flat_link = "";
74 protected string $page_form_action = "";
75 protected array $permanent_link = [];
76 protected string $main_content = "";
77 protected array $lightbox = [];
78 protected bool $standard_template_loaded = false;
79 protected string $main_menu = '';
80 protected string $main_menu_spacer = '';
81 protected array $messages = [];
82 protected bool $show_footer = true;
83 protected array $on_load_code = [];
84 protected string $left_nav_content = '';
85 protected string $tree_flat_mode = '';
86 protected bool $admin_panel_arrow = false;
87 protected bool $admin_panel_bottom = false;
88 protected ?int $enable_fileupload = null;
89 protected string $header_page_title = "";
90 protected string $title = "";
91 protected string $title_desc = "";
92 protected array $title_alerts = [];
93 protected string $header_action = '';
94 protected string $icon_desc = '';
95 protected string $icon_path = '';
96 protected string $tabs_html = "";
97 protected string $sub_tabs_html = "";
98 protected string $left_content = '';
99 protected string $right_content = '';
100 protected string $login_target_par = '';
101
105 public function __construct(
106 string $file,
107 bool $flag1,
108 bool $flag2,
109 string $in_module = '',
110 string $vars = self::DEFAULT_BLOCK,
111 bool $plugin = false,
112 bool $a_use_cache = true
113 ) {
114 $this->setBodyClass("std");
115 $this->template_name = $file;
116 $this->in_module = $in_module;
117 $this->template = new ilTemplate(
118 $file,
119 $flag1,
120 $flag2,
122 $vars,
123 $plugin,
124 $a_use_cache
125 );
126 }
127
128 public function printToString(string $part = self::DEFAULT_BLOCK): string
129 {
130 global $DIC;
131 return $this->renderPage($part, true, false, $DIC);
132 }
133
134 public function hideFooter(): void
135 {
136 $this->show_footer = false;
137 }
138
139 protected function getMainMenu(): void
140 {
141 }
142
143 protected function fillMainMenu(): void
144 {
145 }
146
147 protected function initHelp(): void
148 {
149 //ilHelpGUI::initHelp($this);
150 }
151
152 public function setOnScreenMessage(string $a_type, string $a_txt, bool $a_keep = false): void
153 {
154 if ($a_txt === "" ||
155 !in_array($a_type, self::MESSAGE_TYPES, true)
156 ) {
157 return;
158 }
159
160 if (!$a_keep) {
161 $this->messages[$a_type] = $a_txt;
162 } else {
163 ilSession::set($a_type, $a_txt);
164 }
165 }
166
167 protected function fillMessage(): void
168 {
169 $out = "";
170 foreach (self::MESSAGE_TYPES as $type) {
171 $txt = $this->getMessageTextForType($type);
172 if (null !== $txt) {
173 $out .= ilUtil::getSystemMessageHTML($txt, $type);
174 }
175
176 ilSession::clear($type);
177 }
178
179 if ($out !== "") {
180 $this->setVariable("MESSAGE", $out);
181 }
182 }
183
184 protected function getMessageTextForType(string $type): ?string
185 {
186 if (ilSession::has($type)) {
187 return (string) ilSession::get($type);
188 }
189
190 return $this->messages[$type] ?? null;
191 }
192
193 public function addJavaScript(string $a_js_file, bool $a_add_version_parameter = true, int $a_batch = 2): void
194 {
195 // three batches currently
196 if ($a_batch < 1 || $a_batch > 3) {
197 $a_batch = 2;
198 }
199
200 // ensure jquery files being loaded first
201 if (is_int(strpos($a_js_file, "components/ILIAS/jQuery")) ||
202 is_int(strpos($a_js_file, "/jquery.js")) ||
203 is_int(strpos($a_js_file, "/jquery/")) ||
204 is_int(strpos($a_js_file, "/jquery-ui/")) ||
205 is_int(strpos($a_js_file, "/jquery-min.js"))
206 ) {
207 $a_batch = 0;
208 }
209
210 if (!in_array($a_js_file, $this->js_files, true)) {
211 $this->js_files[] = $a_js_file;
212 $this->js_files_vp[$a_js_file] = $a_add_version_parameter;
213 $this->js_files_batch[$a_js_file] = $a_batch;
214 }
215 }
216
217 public function addOnLoadCode(string $a_code, int $a_batch = 2): void
218 {
219 // three batches currently
220 if ($a_batch < 1 || $a_batch > 3) {
221 $a_batch = 2;
222 }
223
224 $this->on_load_code[$a_batch][] = $a_code;
225 }
226
227 public function getOnLoadCodeForAsynch(): string
228 {
229 $js = "";
230 for ($i = 1; $i <= 3; $i++) {
231 if (isset($this->on_load_code[$i])) {
232 foreach ($this->on_load_code[$i] as $code) {
233 $js .= $code . "\n";
234 }
235 }
236 }
237 if ($js) {
238 return '<script type="text/javascript">' . "\n" .
239 $js .
240 '</script>' . "\n";
241 }
242
243 return '';
244 }
245
246 public function resetJavascript(): void
247 {
248 $this->js_files = [];
249 $this->js_files_vp = [];
250 $this->js_files_batch = [];
251 }
252
253 public function fillJavaScriptFiles(bool $a_force = false): void
254 {
255 global $DIC;
256
257 $ilSetting = $DIC->settings();
258
259 $vers = '';
260 if (is_object($ilSetting)) { // maybe this one can be removed
261 $vers = "vers=" . str_replace([".", " "], "-", ILIAS_VERSION);
262
263 if (DEVMODE) {
264 $vers .= '-' . time();
265 }
266 }
267 if ($this->blockExists("js_file")) {
268 // three batches
269 for ($i = 0; $i <= 3; $i++) {
270 reset($this->js_files);
271 foreach ($this->js_files as $file) {
272 if ($this->js_files_batch[$file] === $i) {
273 if ($a_force ||
274 is_file($file) ||
275 strpos($file, "http") === 0 ||
276 strpos($file, "//") === 0
277 ) {
278 $this->fillJavascriptFile($file, $vers);
279 } elseif (strpos($file, './') === 0) { // #13962
280 $url_parts = parse_url($file);
281 if (is_file($url_parts['path'])) {
282 $this->fillJavascriptFile($file, $vers);
283 }
284 }
285 }
286 }
287 }
288 }
289 }
290
291 public function fillOnLoadCode(): void
292 {
293 for ($i = 1; $i <= 3; $i++) {
294 if (isset($this->on_load_code[$i])) {
295 $this->setCurrentBlock("on_load_code");
296 foreach ($this->on_load_code[$i] as $code) {
297 $this->setCurrentBlock("on_load_code_inner");
298 $this->setVariable("OLCODE", $code);
299 $this->parseCurrentBlock();
300 }
301 $this->setCurrentBlock("on_load_code");
302 $this->parseCurrentBlock();
303 }
304 }
305 }
306
307 protected function fillJavascriptFile(string $file, string $vers): void
308 {
309 $this->setCurrentBlock("js_file");
310 if ($this->js_files_vp[$file]) {
311 $this->setVariable("JS_FILE", ilUtil::appendUrlParameterString($file, $vers));
312 } else {
313 $this->setVariable("JS_FILE", $file);
314 }
315 $this->parseCurrentBlock();
316 }
317
318 public function addCss(string $a_css_file, string $media = "screen"): void
319 {
320 if (!array_key_exists($a_css_file . $media, $this->css_files)) {
321 $this->css_files[$a_css_file . $media] = [
322 "file" => $a_css_file,
323 "media" => $media,
324 ];
325 }
326 }
327
328 public function addInlineCss(string $a_css, string $media = "screen"): void
329 {
330 $this->inline_css[] = [
331 "css" => $a_css,
332 "media" => $media,
333 ];
334 }
335
339 public function fillCssFiles(bool $a_force = false): void
340 {
341 if (!$this->blockExists("css_file")) {
342 return;
343 }
344 foreach ($this->css_files as $css) {
345 $filename = $css["file"];
346 if (strpos($filename, "?") > 0) {
347 $filename = substr($filename, 0, strpos($filename, "?"));
348 }
349 if ($a_force || is_file($filename)) {
350 $this->setCurrentBlock("css_file");
351 $this->setVariable("CSS_FILE", $css["file"]);
352 $this->setVariable("CSS_MEDIA", $css["media"]);
353 $this->parseCurrentBlock();
354 }
355 }
356 }
357
358 public function setBodyClass(string $a_class = ""): void
359 {
360 $this->body_class = $a_class;
361 }
362
366 public function fillBodyClass(): void
367 {
368 if ($this->body_class !== "" && $this->blockExists("body_class")) {
369 $this->setCurrentBlock("body_class");
370 $this->setVariable("BODY_CLASS", $this->body_class);
371 $this->parseCurrentBlock();
372 }
373 }
374
379 public function renderPage(
380 string $part,
381 bool $a_fill_tabs,
382 bool $a_skip_main_menu,
384 ): string {
385 $this->fillMessage();
386
387 // set standard parts (tabs and title icon)
388 $this->fillBodyClass();
389
390 // see #22992
391 $this->fillContentLanguage();
392
393 if ($a_fill_tabs) {
394 if ($this->blockExists("content")) {
395 // determine default screen id
396 $this->getTabsHTML();
397 }
398 // to get also the js files for the main menu
399 if (!$a_skip_main_menu) {
400 $this->getMainMenu();
401 $this->initHelp();
402 }
403
404 // these fill blocks in tpl.main.html
405 $this->fillCssFiles();
406 $this->fillInlineCss();
407 //$this->fillJavaScriptFiles();
408
409 // these fill just plain placeholder variables in tpl.main.html
410 $this->setCurrentBlock();
411 $this->fillNewContentStyle();
412 $this->fillWindowTitle();
413
414 // these fill blocks in tpl.adm_content.html
415 $this->fillHeader();
416 $this->fillSideIcons();
417 $this->fillScreenReaderFocus();
418 $this->fillLeftContent();
419 $this->fillLeftNav();
420 $this->fillRightContent();
421 $this->fillAdminPanel();
422 $this->fillToolbar();
423 $this->fillPermanentLink();
424
425 $this->setCenterColumnClass();
426
427 // late loading of javascipr files, since operations above may add files
428 $this->fillJavaScriptFiles();
429 $this->fillOnLoadCode();
430
431 // these fill just plain placeholder variables in tpl.adm_content.html
432 if ($this->blockExists("content")) {
433 $this->setCurrentBlock("content");
434 $this->fillTabs();
435 $this->fillMainContent();
436 $this->fillMainMenu();
437 $this->parseCurrentBlock();
438 }
439 }
440
441 if ($part === self::DEFAULT_BLOCK) {
442 $html = $this->template->getUnmodified();
443 } else {
444 $html = $this->template->getUnmodified($part);
445 }
446
447 // Modification of html is done inline here and can't be done
448 // by ilTemplate, because the "phase" is template_show in this
449 // case here.
450 $component_factory = $DIC["component.factory"];
451
452 // not quite sure if that's good.
453 $id = $this->template->getTemplateIdentifier(
454 $this->template_name,
455 $this->in_module
456 );
457
458 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
459 $gui_class = $ui_plugin->getUIClassInstance();
460 $resp = $gui_class->getHTML(
461 "",
462 "template_show",
463 [
464 "tpl_id" => $id,
465 "tpl_obj" => $this,
466 "html" => $html
467 ]
468 );
469
470 if ($resp["mode"] !== ilUIHookPluginGUI::KEEP) {
471 $html = $gui_class->modifyHTML($html, $resp);
472 }
473 }
474
475 // save language usages as late as possible
477
478 return $html;
479 }
480
481 protected function resetCss(): void
482 {
483 $this->css_files = [];
484 }
485
489 protected function fillInlineCss(): void
490 {
491 if (!$this->blockExists("css_inline")) {
492 return;
493 }
494 foreach ($this->inline_css as $css) {
495 $this->setCurrentBlock("css_inline");
496 $this->setVariable("CSS_INLINE", $css["css"]);
497 $this->parseCurrentBlock();
498 }
499 }
500
501 protected function fillNewContentStyle(): void
502 {
503 $this->setVariable(
504 "LOCATION_NEWCONTENT_STYLESHEET_TAG",
505 '<link rel="stylesheet" type="text/css" href="' .
507 . '" />'
508 );
509 }
510
517 public function loadStandardTemplate(): void
518 {
519 if ($this->standard_template_loaded) {
520 return;
521 }
522
523 // always load jQuery
525
526 $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
527 $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
528
529 $this->standard_template_loaded = true;
530 }
531
536 public function setTitle(string $a_title, bool $hidden = false): void
537 {
538 $this->title = $a_title;
539 $this->header_page_title = $a_title;
540 }
541
545 public function setDescription(string $a_descr): void
546 {
547 $this->title_desc = $a_descr;
548 }
549
553 public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
554 {
555 $this->icon_desc = $a_icon_desc;
556 $this->icon_path = $a_icon_path;
557 }
558
559 public function setAlertProperties(array $a_props): void
560 {
561 $this->title_alerts = $a_props;
562 }
563
564 public function clearHeader(): void
565 {
566 $this->setTitle("");
567 $this->setTitleIcon("");
568 $this->setDescription("");
569 $this->setAlertProperties([]);
570 }
571
572 public function setHeaderActionMenu(string $a_header): void
573 {
574 $this->header_action = $a_header;
575 }
576
577 public function setHeaderPageTitle(string $a_title): void
578 {
579 $this->header_page_title = $a_title;
580 }
581
585 protected function fillHeader(): void
586 {
587 global $DIC;
588
589 $lng = $DIC->language();
590 $header = $this->getHeaderActionMenu();
591
592 $header_tpl = new ilTemplate('tpl.il_header.html', true, true);
593
594 if ($this->icon_path !== "") {
595 $header_tpl->setCurrentBlock("header_image");
596 $header_tpl->setVariable("IMG_HEADER", $this->icon_path);
597 $header_tpl->parseCurrentBlock();
598 $header = true;
599 }
600
601 if ($this->title !== "") {
602 $title = ilUtil::stripScriptHTML($this->title);
603 $header_tpl->setVariable("HEADER", $title);
604
605 $header = true;
606 }
607
608 if ($header !== '') {
609 $header_tpl->setCurrentBlock("header_image");
610 $header_tpl->parseCurrentBlock();
611 }
612
613 if ($this->title_desc !== "") {
614 $header_tpl->setCurrentBlock("header_desc");
615 $header_tpl->setVariable("H_DESCRIPTION", $this->title_desc);
616 $header_tpl->parseCurrentBlock();
617 }
618
619 if ($header !== '') {
620 $header_tpl->setCurrentBlock("head_action_inner");
621 $header_tpl->setVariable("HEAD_ACTION", $header);
622 $header_tpl->parseCurrentBlock();
623 }
624
625 foreach ($this->title_alerts as $alert) {
626 $header_tpl->setCurrentBlock('header_alert');
627 if (!($alert['propertyNameVisible'] === false)) {
628 $header_tpl->setVariable('H_PROP', $alert['property'] . ':');
629 }
630 $header_tpl->setVariable('H_VALUE', $alert['value']);
631 $header_tpl->parseCurrentBlock();
632 }
633
634 // add file upload drop zone in header
635 if ($this->enable_fileupload !== null) {
636 $file_upload = new ilObjFileUploadDropzone(
637 $this->enable_fileupload,
638 $header_tpl->get()
639 );
640
641 $this->setVariable(
642 "IL_DROPZONE_HEADER",
643 $file_upload->getDropzoneHtml()
644 );
645 } else {
646 $this->setVariable("IL_HEADER", $header_tpl->get());
647 }
648 }
649
650 protected function getHeaderActionMenu(): string
651 {
652 return $this->header_action;
653 }
654
655 public function setLocator(): void
656 {
657 global $DIC;
658
659 $ilLocator = $DIC["ilLocator"];
660 $html = "";
661
662 $uip = new ilUIHookProcessor(
663 "components/ILIAS/Locator",
664 "main_locator",
665 ["locator_gui" => $ilLocator]
666 );
667 if (!$uip->replaced()) {
668 $html = $ilLocator->getHTML();
669 }
670 $html = $uip->getHTML($html);
671
672 $this->setVariable("LOCATOR", $html);
673 }
674
678 public function setTabs(string $a_tabs_html): void
679 {
680 if ($a_tabs_html !== "" && $this->blockExists("tabs_outer_start")) {
681 $this->touchBlock("tabs_outer_start");
682 $this->touchBlock("tabs_outer_end");
683 $this->touchBlock("tabs_inner_start");
684 $this->touchBlock("tabs_inner_end");
685 $this->setVariable("TABS", $a_tabs_html);
686 }
687 }
688
689 public function setSubTabs(string $a_tabs_html): void
690 {
691 $this->setVariable("SUB_TABS", $a_tabs_html);
692 }
693
697 public function fillTabs(): void
698 {
699 if ($this->blockExists("tabs_outer_start")) {
700 $this->touchBlock("tabs_outer_start");
701 $this->touchBlock("tabs_outer_end");
702 $this->touchBlock("tabs_inner_start");
703 $this->touchBlock("tabs_inner_end");
704
705 if ($this->tabs_html !== "") {
706 $this->setVariable("TABS", $this->tabs_html);
707 }
708 $this->setVariable("SUB_TABS", $this->sub_tabs_html);
709 }
710 }
711
712 protected function getTabsHTML(): void
713 {
714 global $DIC;
715
716 $ilTabs = $DIC["ilTabs"];
717
718 if ($this->blockExists("tabs_outer_start")) {
719 $this->sub_tabs_html = $ilTabs->getSubTabHTML();
720 $this->tabs_html = $ilTabs->getHTML(true);
721 }
722 }
723
724 public function setContent(string $a_html): void
725 {
726 if ($a_html !== "") {
727 $this->main_content = $a_html;
728 }
729 }
730
731 public function setLeftContent(string $a_html): void
732 {
733 if ($a_html !== "") {
734 $this->left_content = $a_html;
735 }
736 }
737
738 public function setLeftNavContent(string $a_content): void
739 {
740 if ($a_content !== "") {
741 $this->left_nav_content = $a_content;
742 }
743 }
744
748 protected function fillLeftNav(): void
749 {
750 if (trim($this->left_nav_content) !== "") {
751 $this->setCurrentBlock("left_nav");
752 $this->setVariable("LEFT_NAV_CONTENT", trim($this->left_nav_content));
753 $this->parseCurrentBlock();
754 $this->touchBlock("left_nav_space");
755 }
756 }
757
758 public function setRightContent(string $a_html): void
759 {
760 if ($a_html !== '') {
761 $this->right_content = $a_html;
762 }
763 }
764
768 protected function setCenterColumnClass(): void
769 {
770 if (!$this->blockExists("center_col_width")) {
771 return;
772 }
773
774 $left = trim($this->left_content);
775 $right = trim($this->right_content);
776
777 switch (true) {
778 case ('' !== $left && '' !== $right):
779 $center_column_class = 'col-sm-6';
780 break;
781
782 case ('' !== $left || '' !== $right):
783 $center_column_class = 'col-sm-9';
784 break;
785
786 default:
787 $center_column_class = "col-sm-12";
788 break;
789 }
790
791 if ('' !== $left) {
792 $center_column_class .= " col-sm-push-3";
793 }
794
795 $this->setCurrentBlock("center_col_width");
796 $this->setVariable("CENTER_COL", $center_column_class);
797 $this->parseCurrentBlock();
798 }
799
800 protected function fillMainContent(): void
801 {
802 if (trim($this->main_content) !== "") {
803 $this->setVariable("ADM_CONTENT", trim($this->main_content));
804 }
805 }
806
810 protected function fillLeftContent(): void
811 {
812 if (trim($this->left_content) !== "") {
813 $this->setCurrentBlock("left_column");
814 $this->setVariable("LEFT_CONTENT", trim($this->left_content));
815 $left_col_class = (trim($this->right_content) === "")
816 ? "col-sm-3 col-sm-pull-9"
817 : "col-sm-3 col-sm-pull-6";
818 $this->setVariable("LEFT_COL_CLASS", $left_col_class);
819 $this->parseCurrentBlock();
820 }
821 }
822
826 protected function fillRightContent(): void
827 {
828 if (trim($this->right_content) !== "") {
829 $this->setCurrentBlock("right_column");
830 $this->setVariable("RIGHT_CONTENT", trim($this->right_content));
831 $this->parseCurrentBlock();
832 }
833 }
834
838 protected function fillToolbar(): void
839 {
840 global $DIC;
841
842 $ilToolbar = $DIC["ilToolbar"];
843 $thtml = $ilToolbar->getHTML();
844
845 if ($thtml !== "") {
846 $this->setCurrentBlock("toolbar_buttons");
847 $this->setVariable("BUTTONS", $thtml);
848 $this->parseCurrentBlock();
849 }
850 }
851
852 public function fillContentLanguage(): void
853 {
854 global $DIC;
855 $lng = $DIC->language();
856
857 if (is_object($lng)) {
858 $this->setVariable('META_CONTENT_LANGUAGE', $lng->getContentLanguage());
859 $this->setVariable('LANGUAGE_DIRECTION', $lng->getTextDirection());
860 }
861 }
862
863 public function fillWindowTitle(): void
864 {
865 global $DIC;
866
867 $ilSetting = $DIC->settings();
868
869 if ($this->header_page_title !== "") {
870 $title = ilUtil::stripScriptHTML($this->header_page_title);
871 $this->setVariable("PAGETITLE", "- " . $title);
872 }
873
874 if ($ilSetting->get('short_inst_name') !== "") {
875 $this->setVariable(
876 "WINDOW_TITLE",
877 $ilSetting->get('short_inst_name')
878 );
879 } else {
880 $this->setVariable(
881 "WINDOW_TITLE",
882 "ILIAS"
883 );
884 }
885 }
886
887 public function setPageFormAction(string $a_action): void
888 {
889 $this->page_form_action = $a_action;
890 }
891
895 protected function fillPageFormAction(): void
896 {
897 if ($this->page_form_action !== "") {
898 $this->setCurrentBlock("page_form_start");
899 $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
900 $this->parseCurrentBlock();
901 $this->touchBlock("page_form_end");
902 }
903 }
904
909 public function setLoginTargetPar(string $a_val): void
910 {
911 $this->login_target_par = $a_val;
912 }
913
914 protected function getLoginTargetPar(): string
915 {
916 return $this->login_target_par;
917 }
918
923 public function getSpecial(
924 string $part = self::DEFAULT_BLOCK,
925 bool $add_error_mess = false,
926 bool $handle_referer = false,
927 bool $add_ilias_footer = false,
928 bool $add_standard_elements = false,
929 bool $a_main_menu = true,
930 bool $a_tabs = true
931 ): string {
932 if ($add_error_mess) {
933 $this->fillMessage();
934 }
935
936 // set standard parts (tabs and title icon)
937 if ($add_standard_elements) {
938 if ($a_tabs && $this->blockExists("content")) {
939 // determine default screen id
940 $this->getTabsHTML();
941 }
942
943 // to get also the js files for the main menu
944 $this->getMainMenu();
945 $this->initHelp();
946
947 // these fill blocks in tpl.main.html
948 $this->fillCssFiles();
949 $this->fillInlineCss();
950 $this->fillBodyClass();
951
952 // these fill just plain placeholder variables in tpl.main.html
953 $this->setCurrentBlock();
954 $this->fillNewContentStyle();
955 $this->fillContentLanguage();
956 $this->fillWindowTitle();
957
958 // these fill blocks in tpl.adm_content.html
959 $this->fillHeader();
960 $this->fillSideIcons();
961 $this->fillScreenReaderFocus();
962 $this->fillLeftContent();
963 $this->fillLeftNav();
964 $this->fillRightContent();
965 $this->fillAdminPanel();
966 $this->fillToolbar();
967 $this->fillPermanentLink();
968
969 $this->setCenterColumnClass();
970
971 // late loading of javascipr files, since operations above may add files
972 $this->fillJavaScriptFiles();
973 $this->fillOnLoadCode();
974
975 // these fill just plain placeholder variables in tpl.adm_content.html
976 if ($this->blockExists("content")) {
977 $this->setCurrentBlock("content");
978 if ($a_tabs) {
979 $this->fillTabs();
980 }
981 $this->fillMainContent();
982 if ($a_main_menu) {
983 $this->fillMainMenu();
984 }
985 $this->parseCurrentBlock();
986 }
987 }
988
989 if ($part === self::DEFAULT_BLOCK) {
990 $html = $this->template->get();
991 } else {
992 $html = $this->template->get($part);
993 }
994
995 // save language usages as late as possible
997
998 return $html;
999 }
1000
1001 public function printToStdout(
1002 string $part = self::DEFAULT_BLOCK,
1003 bool $a_fill_tabs = true,
1004 bool $a_skip_main_menu = false
1005 ): void {
1006 global $DIC;
1007
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 print $this->renderPage(
1012 $part,
1013 $a_fill_tabs,
1014 $a_skip_main_menu,
1015 $DIC
1016 );
1017 }
1018
1019 public function fillScreenReaderFocus(): void
1020 {
1021 // abandoned
1022 }
1023
1027 protected function fillSideIcons(): void
1028 {
1029 global $DIC;
1030
1031 $ilSetting = $DIC->settings();
1032 $lng = $DIC->language();
1033
1034 if ($this->tree_flat_link !== "") {
1035 if ($this->left_nav_content !== "") {
1036 $this->touchBlock("tree_lns");
1037 }
1038
1039 $this->setCurrentBlock("tree_mode");
1040 $this->setVariable("LINK_MODE", $this->tree_flat_link);
1041 $this->setVariable("IMG_TREE", ilUtil::getImagePath("standard/icon_sidebar_on.svg"));
1042 if ($ilSetting->get("tree_frame") === "right") {
1043 $this->setVariable("RIGHT", "Right");
1044 }
1045 $this->setVariable("ALT_TREE", $lng->txt($this->tree_flat_mode . "view"));
1046 $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
1047 $this->parseCurrentBlock();
1048 }
1049
1050 $this->setCurrentBlock("tree_icons");
1051 $this->parseCurrentBlock();
1052 }
1053
1054 public function setTreeFlatIcon(string $a_link, string $a_mode): void
1055 {
1056 $this->tree_flat_link = $a_link;
1057 $this->tree_flat_mode = $a_mode;
1058 }
1059
1060 public function addAdminPanelToolbar(ilToolbarGUI $toolb, bool $a_bottom_panel = true, bool $a_arrow = false): void
1061 {
1062 $this->admin_panel_commands_toolbar = $toolb;
1063 $this->admin_panel_arrow = $a_arrow;
1064 $this->admin_panel_bottom = $a_bottom_panel;
1065 }
1066
1070 protected function fillAdminPanel(): void
1071 {
1072 global $DIC;
1073 $lng = $DIC->language();
1074
1075 if ($this->admin_panel_commands_toolbar === null) {
1076 return;
1077 }
1078
1079 $toolb = $this->admin_panel_commands_toolbar;
1080
1081 // Add arrow if desired.
1082 if ($this->admin_panel_arrow) {
1083 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_upright.svg"), $lng->txt("actions"));
1084 }
1085
1086 $this->fillPageFormAction();
1087
1088 // Add top admin bar.
1089 $this->setCurrentBlock("adm_view_components");
1090 $this->setVariable("ADM_PANEL1", $toolb->getHTML());
1091 $this->parseCurrentBlock();
1092
1093 // Add bottom admin bar if user wants one.
1094 if ($this->admin_panel_bottom) {
1095 $this->setCurrentBlock("adm_view_components2");
1096
1097 // Replace previously set arrow image.
1098 if ($this->admin_panel_arrow) {
1099 $toolb->setLeadingImage(ilUtil::getImagePath("nav/arrow_downright.svg"), $lng->txt("actions"));
1100 }
1101
1102 $this->setVariable("ADM_PANEL2", $toolb->getHTML());
1103 $this->parseCurrentBlock();
1104 }
1105 }
1106
1107 public function setPermanentLink(
1108 string $a_type,
1109 ?int $a_id,
1110 string $a_append = "",
1111 string $a_target = "",
1112 string $a_title = ""
1113 ): void {
1114 $this->permanent_link = [
1115 "type" => $a_type,
1116 "id" => $a_id,
1117 "append" => $a_append,
1118 "target" => $a_target,
1119 "title" => $a_title
1120 ];
1121 }
1122
1123 protected function fillPermanentLink(): void
1124 {
1125 if (!empty($this->permanent_link)) {
1126 $plinkgui = new ilPermanentLinkGUI(
1127 $this->permanent_link["type"],
1128 $this->permanent_link["id"],
1129 $this->permanent_link["append"],
1130 $this->permanent_link["target"]
1131 );
1132 if ($this->permanent_link["title"] !== "") {
1133 $plinkgui->setTitle($this->permanent_link["title"]);
1134 }
1135 $this->setVariable("PRMLINK", $plinkgui->getHTML());
1136 }
1137 }
1138
1139 public function resetHeaderBlock(bool $a_reset_header_action = true): void
1140 {
1141 $this->setTitle('');
1142 $this->setTitleIcon('');
1143 $this->setDescription('');
1144 $this->setAlertProperties([]);
1145 $this->enable_fileupload = null;
1146
1147 // see setFullscreenHeader()
1148 if ($a_reset_header_action) {
1149 $this->setHeaderActionMenu('');
1150 }
1151 }
1152
1153 public function setFileUploadRefId(int $a_ref_id): void
1154 {
1155 $this->enable_fileupload = $a_ref_id;
1156 }
1157
1161 public function get(string $part = self::DEFAULT_BLOCK): string
1162 {
1163 return $this->template->get($part);
1164 }
1165
1166 public function setVariable(string $variable, $value = ''): void
1167 {
1168 $this->template->setVariable($variable, $value);
1169 }
1170
1171 protected function variableExists(string $a_variablename): bool
1172 {
1173 return $this->template->variableExists($a_variablename);
1174 }
1175
1179 public function setCurrentBlock(string $part = self::DEFAULT_BLOCK): bool
1180 {
1181 return $this->template->setCurrentBlock($part);
1182 }
1183
1187 public function touchBlock(string $block): bool
1188 {
1189 return $this->template->touchBlock($block);
1190 }
1191
1195 public function parseCurrentBlock(string $part = self::DEFAULT_BLOCK): bool
1196 {
1197 return $this->template->parseCurrentBlock($part);
1198 }
1199
1203 public function addBlockFile(string $var, string $block, string $template_name, ?string $in_module = null): bool
1204 {
1205 return $this->template->addBlockFile($var, $block, $template_name, $in_module);
1206 }
1207
1208 public function blockExists(string $a_blockname): bool
1209 {
1210 return $this->template->blockExists($a_blockname);
1211 }
1212
1213 public function getJSFiles(): array
1214 {
1215 return $this->js_files_batch;
1216 }
1217
1218 public function getCSSFiles(): array
1219 {
1220 return $this->css_files;
1221 }
1222}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$filename
Definition: buildRTE.php:78
$out
Definition: buildRTE.php:24
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
setVariable(string $a_group_name, string $a_var_name, string $a_var_value)
sets a variable in a group
static _getFrame(string $a_class)
special template class to simplify handling of ITX/PEAR
printToStdout(string $part=self::DEFAULT_BLOCK, bool $a_fill_tabs=true, bool $a_skip_main_menu=false)
setHeaderActionMenu(string $a_header)
Set header action menu.
setBodyClass(string $a_class="")
Sets the body-tags class.
addInlineCss(string $a_css, string $media="screen")
Add a css file that should be included in the header.
setTabs(string $a_tabs_html)
setPageFormAction(string $a_action)
Sets the pages form action.
setOnScreenMessage(string $a_type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setPermanentLink(string $a_type, ?int $a_id, string $a_append="", string $a_target="", string $a_title="")
Generates and sets a permanent ilias link.
setDescription(string $a_descr)
Sets descripton below title in standard template.
getMessageTextForType(string $type)
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
fillJavaScriptFiles(bool $a_force=false)
Probably adds javascript files.
setLocator()
Insert locator.
addAdminPanelToolbar(ilToolbarGUI $toolb, bool $a_bottom_panel=true, bool $a_arrow=false)
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
getOnLoadCodeForAsynch()
Get js onload code for ajax calls.
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.
resetHeaderBlock(bool $a_reset_header_action=true)
Reset all header properties: title, icon, description, alerts, action menu.
ilToolbarGUI $admin_panel_commands_toolbar
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
hideFooter()
Make the template hide the footer.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
printToString(string $part=self::DEFAULT_BLOCK)
setLeftContent(string $a_html)
Sets content of left column.
setTreeFlatIcon(string $a_link, string $a_mode)
Sets a tree or flat icon.
setLeftNavContent(string $a_content)
Sets content of left navigation column.
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
setContent(string $a_html)
Sets content for standard template.
fillJavascriptFile(string $file, string $vers)
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setFileUploadRefId(int $a_ref_id)
Enables the file upload into this object by dropping a file.
setSubTabs(string $a_tabs_html)
sets subtabs in standard template
setHeaderPageTitle(string $a_title)
Sets the title of the page (for browser window).
renderPage(string $part, bool $a_fill_tabs, bool $a_skip_main_menu, Container $DIC)
blockExists(string $a_blockname)
check if block exists in actual template
addBlockFile(string $var, string $block, string $template_name, ?string $in_module=null)
__construct(string $file, bool $flag1, bool $flag2, string $in_module='', string $vars=self::DEFAULT_BLOCK, bool $plugin=false, bool $a_use_cache=true)
parseCurrentBlock(string $part=self::DEFAULT_BLOCK)
fillCssFiles(bool $a_force=false)
setAlertProperties(array $a_props)
Set alert properties.
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)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setRightContent(string $a_html)
Sets content of right column.
resetJavascript()
Reset javascript files.
variableExists(string $a_variablename)
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)
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
const ILIAS_VERSION
global $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26