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