ILIAS  release_8 Revision v8.24
class.ilDataCollectionGlobalTemplate.php
Go to the documentation of this file.
1<?php
2
19include_once("./Services/UICore/lib/html-it/IT.php");
20include_once("./Services/UICore/lib/html-it/ITX.php");
21
23{
24 protected $tree_flat_link = "";
25 protected $page_form_action = "";
26 protected $permanent_link = false;
27 protected $lightbox = array();
28 protected $standard_template_loaded = false;
30 protected array $on_load_code;
31 protected string $body_class;
32 protected string $icon_path;
33 protected ?bool $enable_fileupload = null;
34 protected string $left_content = "";
35 protected string $left_nav_content = "";
36 protected string $right_content = "";
37 protected string $main_content = "";
38 protected string $login_target_par = "";
39 protected string $tplIdentifier = "";
40 protected string $tree_flat_mode = "";
41 protected string $icon_desc = "";
44
56 public function __construct(
57 string $file,
58 bool $flag1,
59 bool $flag2,
60 string $in_module = "",
62 bool $plugin = false,
63 bool $a_use_cache = true
64 ) {
65 $this->setBodyClass("std");
66
67 $this->template = new ilTemplate($file, $flag1, $flag2, $in_module, $vars, $plugin, $a_use_cache);
68 }
69
70 public function printToString(): string
71 {
72 throw new ilException('not implemented');
73 }
74
75
76 //***********************************
77 //
78 // FOOTER
79 //
80 // Used in:
81 // * ilStartUPGUI
82 // * ilTestSubmissionReviewGUI
83 // * ilTestPlayerAbstractGUI
84 // * ilAssQuestionHintRequestGUI
85 //
86 //***********************************
87
88 private bool $show_footer = true;
89
93 public function hideFooter(): void
94 {
95 $this->show_footer = false;
96 }
97
101 private function fillFooter(): void
102 {
103 global $DIC;
104
105 $ilSetting = $DIC->settings();
106
107 $lng = $DIC->language();
108
109 $ilCtrl = $DIC->ctrl();
110 $ilDB = $DIC->database();
111
112 if (!$this->show_footer) {
113 return;
114 }
115
116 $ftpl = new ilTemplate("tpl.footer.html", true, true, "Services/UICore");
117
118 $php = "";
119 if (DEVMODE) {
120 $php = ", PHP " . phpversion();
121 }
122 $ftpl->setVariable("ILIAS_VERSION", ILIAS_VERSION . $php);
123
124 $link_items = array();
125
126 $this->http = $DIC->http();
127 $this->refinery = $DIC->refinery();
128
129 // imprint
130 if ($this->http->wrapper()->query()->has('record_id')) {
131 $baseClass = $this->http->wrapper()->query()->retrieve('baseClass', $this->refinery->kindlyTo()->string());
132 }
133 if ($this->http->wrapper()->post()->has('record_id')) {
134 $baseClass = $this->http->wrapper()->post()->retrieve('baseClass', $this->refinery->kindlyTo()->string());
135 }
136 if ($baseClass != "ilImprintGUI" && ilImprint::isActive()) {
137 $link_items[ilLink::_getStaticLink(0, "impr")] = array($lng->txt("imprint"), true);
138 }
139
140 // system support contacts
142 $link_items[$l] = array(ilSystemSupportContactsGUI::getFooterText(), false);
143 }
144
145 if (DEVMODE) {
146 if (function_exists("tidy_parse_string")) {
148 $_SERVER["REQUEST_URI"],
149 "do_dev_validate=xhtml"
150 )] = array("Validate", true);
152 $_SERVER["REQUEST_URI"],
153 "do_dev_validate=accessibility"
154 )] = array("Accessibility", true);
155 }
156 }
157
158 // output translation link
160 $link_items[ilObjLanguageAccess::_getTranslationLink()] = array($lng->txt('translation'), true);
161 }
162
163 $cnt = 0;
164 foreach ($link_items as $url => $caption) {
165 $cnt++;
166 if ($caption[1]) {
167 $ftpl->touchBlock("blank");
168 }
169 if ($cnt < sizeof($link_items)) {
170 $ftpl->touchBlock("item_separator");
171 }
172
173 $ftpl->setCurrentBlock("items");
174 $ftpl->setVariable("URL_ITEM", ilUtil::secureUrl($url));
175 $ftpl->setVariable("TXT_ITEM", $caption[0]);
176 $ftpl->parseCurrentBlock();
177 }
178
179 $this->setVariable("FOOTER", $ftpl->get());
180 }
181
182
183 //***********************************
184 //
185 // MAIN MENU
186 //
187 //***********************************
188
189 protected string $main_menu;
190 protected string $main_menu_spacer;
191
192 private function getMainMenu(): void
193 {
194 }
195
196 private function fillMainMenu(): void
197 {
198 }
199
200 private function initHelp(): void
201 {
202 }
203
204
205 //***********************************
206 //
207 // MESSAGES
208 //
209 // setMessage is only used in ilUtil
210 //
211 //***********************************
212
216 protected static $message_types
217 = array(
218 self::MESSAGE_TYPE_FAILURE,
219 self::MESSAGE_TYPE_INFO,
220 self::MESSAGE_TYPE_SUCCESS,
221 self::MESSAGE_TYPE_QUESTION,
222 );
223 protected array $message = array();
224
225 public function setOnScreenMessage(string $type, string $a_txt, bool $a_keep = false): void
226 {
227 if (!in_array($type, self::$message_types) || $a_txt == "") {
228 return;
229 }
230 if (!$a_keep) {
231 $this->message[$type] = $a_txt;
232 } else {
233 ilSession::set($type, $a_txt);
234 }
235 }
236
240 private function fillMessage(): void
241 {
242 global $DIC;
243
244 $out = "";
245
246 foreach (self::$message_types as $m) {
247 $txt = $this->getMessageTextForType($m);
248
249 if ($txt != "") {
251 }
252
253 $request = $DIC->http()->request();
254 $accept_header = $request->getHeaderLine('Accept');
255 if (ilSession::has($m) && ilSession::get($m) && ($accept_header !== 'application/json')) {
257 }
258 }
259
260 if ($out != "") {
261 $this->setVariable("MESSAGE", $out);
262 }
263 }
264
265 private function getMessageTextForType(string $m): string
266 {
267 $txt = "";
268 if (ilSession::has($m) && ilSession::get($m) != "") {
269 $txt = ilSession::get($m);
270 } else {
271 if (isset($this->message[$m])) {
272 $txt = $this->message[$m];
273 }
274 }
275
276 return $txt;
277 }
278
279 //***********************************
280 //
281 // JAVASCRIPT files and code
282 //
283 //***********************************
284
289 protected $js_files = array(0 => "./Services/JavaScript/js/Basic.js");
294 protected $js_files_vp = array("./Services/JavaScript/js/Basic.js" => true);
299 protected $js_files_batch = array("./Services/JavaScript/js/Basic.js" => 1);
300
304 public function addJavaScript(string $a_js_file, bool $a_add_version_parameter = true, int $a_batch = 2): void
305 {
306 // three batches currently
307 if ($a_batch < 1 || $a_batch > 3) {
308 $a_batch = 2;
309 }
310
311 // ensure jquery files being loaded first
312 if (is_int(strpos($a_js_file, "Services/jQuery"))
313 || is_int(strpos($a_js_file, "/jquery.js"))
314 || is_int(strpos($a_js_file, "/jquery-min.js"))
315 ) {
316 $a_batch = 0;
317 }
318
319 if (!in_array($a_js_file, $this->js_files)) {
320 $this->js_files[] = $a_js_file;
321 $this->js_files_vp[$a_js_file] = $a_add_version_parameter;
322 $this->js_files_batch[$a_js_file] = $a_batch;
323 }
324 }
325
329 public function addOnLoadCode(string $a_code, int $a_batch = 2): void
330 {
331 // three batches currently
332 if ($a_batch < 1 || $a_batch > 3) {
333 $a_batch = 2;
334 }
335 $this->on_load_code[$a_batch][] = $a_code;
336 }
337
342 public function getOnLoadCodeForAsynch(): string
343 {
344 $js = "";
345 for ($i = 1; $i <= 3; $i++) {
346 if (is_array($this->on_load_code[$i])) {
347 foreach ($this->on_load_code[$i] as $code) {
348 $js .= $code . "\n";
349 }
350 }
351 }
352 if ($js) {
353 return '<script type="text/javascript">' . "\n" .
354 $js .
355 '</script>' . "\n";
356 }
357
358 return '';
359 }
360
361 // REMOVAL CANDIDATE
362 // Usage locations:
363 // - latex.php
367 public function resetJavascript(): void
368 {
369 $this->js_files = array();
370 $this->js_files_vp = array();
371 $this->js_files_batch = array();
372 }
373
374 // PRIVATE CANDIDATE
375 // Usage locations:
376 // - ilPageObjectGUI
377 // - ilStartUpGUI
378 // - ilObjPortfolioGUI
379 // - latex.php
380 public function fillJavaScriptFiles(bool $a_force = false): void
381 {
382 global $DIC;
383
384 $ilSetting = $DIC->settings();
385
386 if (is_object($ilSetting)) { // maybe this one can be removed
387 $vers = "vers=" . str_replace(array(".", " "), "-", ILIAS_VERSION);
388
389 if (DEVMODE) {
390 $vers .= '-' . time();
391 }
392 }
393 if ($this->blockExists("js_file")) {
394 // three batches
395 for ($i = 0; $i <= 3; $i++) {
396 reset($this->js_files);
397 foreach ($this->js_files as $file) {
398 if ($this->js_files_batch[$file] == $i) {
399 if (is_file($file) || substr($file, 0, 4) == "http" || substr(
400 $file,
401 0,
402 2
403 ) == "//" || $a_force) {
404 $this->fillJavascriptFile($file, $vers);
405 } else {
406 if (substr($file, 0, 2) == './') { // #13962
407 $url_parts = parse_url($file);
408 if (is_file($url_parts['path'])) {
409 $this->fillJavascriptFile($file, $vers);
410 }
411 }
412 }
413 }
414 }
415 }
416 }
417 }
418
422 private function fillOnLoadCode(): void
423 {
424 for ($i = 1; $i <= 3; $i++) {
425 if (is_array($this->on_load_code[$i])) {
426 $this->setCurrentBlock("on_load_code");
427 foreach ($this->on_load_code[$i] as $code) {
428 $this->setCurrentBlock("on_load_code_inner");
429 $this->setVariable("OLCODE", $code);
430 $this->parseCurrentBlock();
431 }
432 $this->setCurrentBlock("on_load_code");
433 $this->parseCurrentBlock();
434 }
435 }
436 }
437
438 protected function fillJavascriptFile(string $file, string $vers): void
439 {
440 $this->setCurrentBlock("js_file");
441 if ($this->js_files_vp[$file]) {
442 $this->setVariable("JS_FILE", ilUtil::appendUrlParameterString($file, $vers));
443 } else {
444 $this->setVariable("JS_FILE", $file);
445 }
446 $this->parseCurrentBlock();
447 }
448
449
450 //***********************************
451 //
452 // CSS files and code
453 //
454 //***********************************
455
460 protected $css_files = array();
465 protected $inline_css = array();
466
470 public function addCss(string $a_css_file, string $media = "screen"): void
471 {
472 if (!array_key_exists($a_css_file . $media, $this->css_files)) {
473 $this->css_files[$a_css_file . $media] = array("file" => $a_css_file, "media" => $media);
474 }
475 }
476
477 // REMOVAL CANDIDATE
478 // Usage locations:
479 // - ilDclRecordEditGUI
480 // - ilObjStyleSheetGUI
484 public function addInlineCss(string $a_css, string $media = "screen"): void
485 {
486 $this->inline_css[] = array("css" => $a_css, "media" => $media);
487 }
488
489 // PRIVATE CANDIDATE
490 // Usage locations:
491 // - ilPageObjectGUI
492 // - ilDclDetailedViewGUI
493 // - ilStartUpGUI
498 public function fillCssFiles(bool $a_force = false): void
499 {
500 if (!$this->blockExists("css_file")) {
501 return;
502 }
503 foreach ($this->css_files as $css) {
504 $filename = $css["file"];
505 if (strpos($filename, "?") > 0) {
506 $filename = substr($filename, 0, strpos($filename, "?"));
507 }
508 if (is_file($filename) || $a_force) {
509 $this->setCurrentBlock("css_file");
510 $this->setVariable("CSS_FILE", $css["file"]);
511 $this->setVariable("CSS_MEDIA", $css["media"]);
512 $this->parseCurrentBlock();
513 }
514 }
515 }
516
517 // REMOVAL CANDIDATE:
518 // Usage locations:
519 // - ilObjMediaPoolGUI
520 // - ilAttendanceList
521 // - ilObjPortfolioGUI
522 // - ilSCORM2004ScoGUI
523 // - ilTestSubmissionReviewGUI
524 // - ilTestPlayerAbstractGUI
525 // - ilAssQuestionHintRequestGUI
526 // - ilWorkspaceFolderExplorer
527 public function setBodyClass(string $a_class = ""): void
528 {
529 $this->body_class = $a_class;
530 }
531
532 private function fillBodyClass(): void
533 {
534 if ($this->body_class != "" && $this->blockExists("body_class")) {
535 $this->setCurrentBlock("body_class");
536 $this->setVariable("BODY_CLASS", $this->body_class);
537 $this->parseCurrentBlock();
538 }
539 }
540
544 private function resetCss(): void
545 {
546 $this->css_files = array();
547 }
548
552 private function fillInlineCss(): void
553 {
554 if (!$this->blockExists("css_inline")) {
555 return;
556 }
557 foreach ($this->inline_css as $css) {
558 $this->setCurrentBlock("css_inline");
559 $this->setVariable("CSS_INLINE", $css["css"]);
560 $this->parseCurrentBlock();
561 }
562 }
563
567 private function fillNewContentStyle(): void
568 {
569 $this->setVariable(
570 "LOCATION_NEWCONTENT_STYLESHEET_TAG",
571 '<link rel="stylesheet" type="text/css" href="' .
573 . '" />'
574 );
575 }
576
577
578 //***********************************
579 //
580 // ILIAS STANDARD TEMPLATE
581 // which is responsible for the look
582 // i.e. a title, tabs, ...
583 //
584 //***********************************
585
586 public function loadStandardTemplate(): void
587 {
588 if ($this->standard_template_loaded) {
589 return;
590 }
591
592 // always load jQuery
595
596 // always load ui framework
598
599 $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
600 $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
601
602 $this->standard_template_loaded = true;
603 }
604
605
606 //***********************************
607 //
608 // HEADER in standard template
609 //
610 //***********************************
611
612 protected string $header_page_title = "";
613 protected string $title = "";
614 protected string $title_desc = "";
615 protected array $title_alerts = array();
616 protected string $header_action;
617
618 public function setTitle(string $a_title, bool $hidden = false): void
619 {
620 $this->title = $a_title;
621 $this->header_page_title = $a_title;
622 }
623
624 public function setDescription(string $a_descr): void
625 {
626 $this->title_desc = $a_descr;
627 }
628
629 public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
630 {
631 $this->icon_desc = $a_icon_desc;
632 $this->icon_path = $a_icon_path;
633 }
634
635 public function setAlertProperties(array $alerts): void
636 {
637 $this->title_alerts = $alerts;
638 }
639
643 public function clearHeader(): void
644 {
645 $this->setTitle("");
646 $this->setTitleIcon("");
647 $this->setDescription("");
648 $this->setAlertProperties(array());
649 }
650
651 // REMOVAL CANDIDATE
652 // Usage locations:
653 // - ilCalendarPresentationGUI
654 // - ilContainerGUI
655 // - ilObjDataCollectionGUI
656 // - ilDashboardGUI
657 // - ilObjPortfolioTemplateGUI
658 // - ilWikiPageGUI
659 // - ilObjWikiGUI
660 public function setHeaderActionMenu(string $a_header): void
661 {
662 $this->header_action = $a_header;
663 }
664
665 // REMOVAL CANDIDATE
666 // Usage locations:
667 // - ilObjLanguageExtGUI
668 // - ilTestServiceGUI
669 // - ilWikiPageGUI
670 public function setHeaderPageTitle(string $a_title): void
671 {
672 $this->header_page_title = $a_title;
673 }
674
678 private function fillHeader(): void
679 {
680 global $DIC;
681
682 $lng = $DIC->language();
683
684 $header_tpl = new ilTemplate('tpl.il_header.html', true, true);
685
686 $icon = false;
687 if ($this->icon_path != "") {
688 $icon = true;
689 $header_tpl->setCurrentBlock("header_image");
690 if ($this->icon_desc != "") {
691 $header_tpl->setVariable("IMAGE_DESC", $lng->txt("icon") . " " . $this->icon_desc);
692 $header_tpl->setVariable("IMAGE_ALT", $lng->txt("icon") . " " . $this->icon_desc);
693 }
694
695 $header_tpl->setVariable("IMG_HEADER", $this->icon_path);
696 $header_tpl->parseCurrentBlock();
697 $header = true;
698 }
699
700 if ($this->title != "") {
701 $title = ilUtil::stripScriptHTML($this->title);
702 $header_tpl->setVariable("HEADER", $title);
703
704 $header = true;
705 }
706
707 if ($header) {
708 $header_tpl->setCurrentBlock("header_image");
709 $header_tpl->parseCurrentBlock();
710 }
711
712 if ($this->title_desc != "") {
713 $header_tpl->setCurrentBlock("header_desc");
714 $header_tpl->setVariable("H_DESCRIPTION", $this->title_desc);
715 $header_tpl->parseCurrentBlock();
716 }
717
718 $header = $this->getHeaderActionMenu();
719 if ($header) {
720 $header_tpl->setCurrentBlock("head_action_inner");
721 $header_tpl->setVariable("HEAD_ACTION", $header);
722 $header_tpl->parseCurrentBlock();
723 $header_tpl->touchBlock("head_action");
724 }
725
726 if (count($this->title_alerts)) {
727 foreach ($this->title_alerts as $alert) {
728 $header_tpl->setCurrentBlock('header_alert');
729 if (!($alert['propertyNameVisible'] === false)) {
730 $header_tpl->setVariable('H_PROP', $alert['property'] . ':');
731 }
732 $header_tpl->setVariable('H_VALUE', $alert['value']);
733 $header_tpl->parseCurrentBlock();
734 }
735 }
736
737 // add file upload drop zone in header
738 if ($this->enable_fileupload !== null) {
739 $file_upload = new ilObjFileUploadDropzone(
740 $this->enable_fileupload,
741 $header_tpl->get()
742 );
743
744 $this->template->setVariable(
745 "IL_DROPZONE_HEADER",
746 $file_upload->getDropzoneHtml()
747 );
748 } else {
749 $this->template->setVariable("IL_HEADER", $header_tpl->get());
750 }
751 }
752
756 private function getHeaderActionMenu(): string
757 {
759 }
760
761
762 //***********************************
763 //
764 // LOCATOR in standard template
765 //
766 //***********************************
767
768 public function setLocator(): void
769 {
770 global $DIC;
771
772 $ilLocator = $DIC["ilLocator"];
773 $ilPluginAdmin = $DIC["ilPluginAdmin"];
774
775 $html = "";
776
777 if (is_object($ilPluginAdmin)) {
778 include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php");
779 $html = $ilLocator->getHTML();
780 $uip = new ilUIHookProcessor(
781 "Services/Locator",
782 "main_locator",
783 ["locator_gui" => $ilLocator, "html" => $html]
784 );
785 $html = $uip->getHTML($html);
786 } else {
787 $html = $ilLocator->getHTML();
788 }
789 $this->setVariable("LOCATOR", $html);
790 }
791
792 //***********************************
793 //
794 // TABS in standard template
795 //
796 //***********************************
797
798 protected string $tabs_html = "";
799 protected string $sub_tabs_html = "";
800
804 public function setTabs(string $a_tabs_html): void
805 {
806 if ($a_tabs_html != "" && $this->blockExists("tabs_outer_start")) {
807 $this->touchBlock("tabs_outer_start");
808 $this->touchBlock("tabs_outer_end");
809 $this->touchBlock("tabs_inner_start");
810 $this->touchBlock("tabs_inner_end");
811 $this->setVariable("TABS", $a_tabs_html);
812 }
813 }
814
818 public function setSubTabs(string $a_tabs_html): void
819 {
820 $this->setVariable("SUB_TABS", $a_tabs_html);
821 }
822
823 private function fillTabs(): void
824 {
825 if ($this->blockExists("tabs_outer_start")) {
826 $this->touchBlock("tabs_outer_start");
827 $this->touchBlock("tabs_outer_end");
828 $this->touchBlock("tabs_inner_start");
829 $this->touchBlock("tabs_inner_end");
830
831 if ($this->tabs_html != "") {
832 $this->setVariable("TABS", $this->tabs_html);
833 }
834 $this->setVariable("SUB_TABS", $this->sub_tabs_html);
835 }
836 }
837
838 private function getTabsHTML(): void
839 {
840 global $DIC;
841
842 $ilTabs = $DIC["ilTabs"];
843
844 if ($this->blockExists("tabs_outer_start")) {
845 $this->sub_tabs_html = $ilTabs->getSubTabHTML();
846 $this->tabs_html = $ilTabs->getHTML(true);
847 }
848 }
849
850
851 //***********************************
852 //
853 // COLUMN LAYOUT in standard template
854 //
855 //***********************************
856
860 public function setContent(string $a_html): void
861 {
862 if ($a_html != "") {
863 $this->main_content = $a_html;
864 }
865 }
866
870 public function setLeftContent(string $a_html): void
871 {
872 $this->left_content = $a_html;
873 }
874
878 public function setLeftNavContent(string $a_content): void
879 {
880 $this->left_nav_content = $a_content;
881 }
882
886 private function fillLeftNav(): void
887 {
888 if (trim($this->left_nav_content) != "") {
889 $this->setCurrentBlock("left_nav");
890 $this->setVariable("LEFT_NAV_CONTENT", $this->left_nav_content);
891 $this->parseCurrentBlock();
892 $this->touchBlock("left_nav_space");
893 }
894 }
895
899 public function setRightContent(string $a_html): void
900 {
901 $this->right_content = $a_html;
902 }
903
904 private function setCenterColumnClass(): void
905 {
906 if (!$this->blockExists("center_col_width")) {
907 return;
908 }
909 $center_column_class = "";
910 if (trim($this->right_content) != "" && trim($this->left_content) != "") {
911 $center_column_class = "two_side_col";
912 } else {
913 if (trim($this->right_content) != "" || trim($this->left_content) != "") {
914 $center_column_class = "one_side_col";
915 }
916 }
917
918 switch ($center_column_class) {
919 case "one_side_col":
920 $center_column_class = "col-sm-9";
921 break;
922 case "two_side_col":
923 $center_column_class = "col-sm-6";
924 break;
925 default:
926 $center_column_class = "col-sm-12";
927 break;
928 }
929 if (trim($this->left_content) != "") {
930 $center_column_class .= " col-sm-push-3";
931 }
932
933 $this->setCurrentBlock("center_col_width");
934 $this->setVariable("CENTER_COL", $center_column_class);
935 $this->parseCurrentBlock();
936 }
937
938 private function fillMainContent(): void
939 {
940 if (trim($this->main_content) != "") {
941 $this->setVariable("ADM_CONTENT", $this->main_content);
942 }
943 }
944
945 private function fillLeftContent(): void
946 {
947 if (trim($this->left_content) != "") {
948 $this->setCurrentBlock("left_column");
949 $this->setVariable("LEFT_CONTENT", $this->left_content);
950 $left_col_class = (trim($this->right_content) == "")
951 ? "col-sm-3 col-sm-pull-9"
952 : "col-sm-3 col-sm-pull-6";
953 $this->setVariable("LEFT_COL_CLASS", $left_col_class);
954 $this->parseCurrentBlock();
955 }
956 }
957
958 private function fillRightContent(): void
959 {
960 if (trim($this->right_content) != "") {
961 $this->setCurrentBlock("right_column");
962 $this->setVariable("RIGHT_CONTENT", $this->right_content);
963 $this->parseCurrentBlock();
964 }
965 }
966
967
968 //***********************************
969 //
970 // TOOLBAR in standard template
971 //
972 //***********************************
973
974 private function fillToolbar(): void
975 {
976 global $DIC;
977
978 $ilToolbar = $DIC["ilToolbar"];
979
980 $thtml = $ilToolbar->getHTML();
981 if ($thtml != "") {
982 $this->setCurrentBlock("toolbar_buttons");
983 $this->setVariable("BUTTONS", $thtml);
984 $this->parseCurrentBlock();
985 }
986 }
987
988 // SPECIAL REQUIREMENTS
989 //
990 // Stuff that is only used by a little other classes.
991
995 private function fillContentLanguage(): void
996 {
997 global $DIC;
998 $lng = $DIC->language();
999
1000 if (is_object($lng)) {
1001 $this->setVariable('META_CONTENT_LANGUAGE', $lng->getContentLanguage());
1002 $this->setVariable('LANGUAGE_DIRECTION', $lng->getTextDirection());
1003 }
1004 }
1005
1006 private function fillWindowTitle(): void
1007 {
1008 global $DIC;
1009
1010 $ilSetting = $DIC->settings();
1011
1012 if ($this->header_page_title != "") {
1013 $title = ilUtil::stripScriptHTML($this->header_page_title);
1014 $this->setVariable("PAGETITLE", "- " . $title);
1015 }
1016
1017 if ($ilSetting->get('short_inst_name') != "") {
1018 $this->setVariable(
1019 "WINDOW_TITLE",
1020 $ilSetting->get('short_inst_name')
1021 );
1022 } else {
1023 $this->setVariable(
1024 "WINDOW_TITLE",
1025 "ILIAS"
1026 );
1027 }
1028 }
1029
1030 // REMOVAL CANDIDATE
1031 // Usage locations:
1032 // - ilLuceneAdvancedSearchGUI
1033 // - ilLuceneSearchGUI
1034 // - ilContainerGUI
1035 public function setPageFormAction(string $a_action): void
1036 {
1037 $this->page_form_action = $a_action;
1038 }
1039
1040 private function fillPageFormAction(): void
1041 {
1042 if ($this->page_form_action != "") {
1043 $this->setCurrentBlock("page_form_start");
1044 $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
1045 $this->parseCurrentBlock();
1046 $this->touchBlock("page_form_end");
1047 }
1048 }
1049
1050
1051 // REMOVAL CANDIDATE
1052 // Usage locations:
1053 // - ilObjForumGUI
1054 // - ilObjPortfolioBaseGUI
1055 // - ilWikiPageGUI
1060 public function setLoginTargetPar(string $a_val): void
1061 {
1062 $this->login_target_par = $a_val;
1063 }
1064
1068 private function getLoginTargetPar(): string
1069 {
1071 }
1072
1073
1074 // REMOVAL CANDIDATE:
1075 // Usage locations:
1076 // - ilLPListOfObjectsGUI
1077 // - ilExport
1078 // - ilLMEditorGUI
1079 // - ilObjPortfolioGUI
1080 // - ilPortfolioHTMLExport
1081 // - ilForumExportGUI
1082 // - ilObjWikiGUI.php
1083 // - ilWikiHTMLExport
1084 // - ilScormSpecialPagesTableGUI
1085 //
1086 // Also this seems to be somehow similar to the stuff going on in printToStdout.
1087 // Maybe we could unify them.
1088 public function getSpecial(
1089 string $part = self::DEFAULT_BLOCK,
1090 bool $add_error_mess = false,
1091 bool $handle_referer = false,
1092 bool $add_ilias_footer = false,
1093 bool $add_standard_elements = false,
1094 bool $a_main_menu = true,
1095 bool $a_tabs = true
1096 ): string {
1097 if ($add_error_mess) {
1098 $this->fillMessage();
1099 }
1100
1101 if ($add_ilias_footer) {
1102 $this->fillFooter();
1103 }
1104
1105 // set standard parts (tabs and title icon)
1106 if ($add_standard_elements) {
1107 if ($this->blockExists("content") && $a_tabs) {
1108 // determine default screen id
1109 $this->getTabsHTML();
1110 }
1111
1112 // to get also the js files for the main menu
1113 $this->getMainMenu();
1114 $this->initHelp();
1115
1116 // these fill blocks in tpl.main.html
1117 $this->fillCssFiles();
1118 $this->fillInlineCss();
1119 $this->fillBodyClass();
1120
1121 // these fill just plain placeholder variables in tpl.main.html
1122 $this->setCurrentBlock("DEFAULT");
1123 $this->fillNewContentStyle();
1124 $this->fillContentLanguage();
1125 $this->fillWindowTitle();
1126
1127 // these fill blocks in tpl.adm_content.html
1128 $this->fillHeader();
1129 $this->fillSideIcons();
1130 $this->fillLeftContent();
1131 $this->fillLeftNav();
1132 $this->fillRightContent();
1133 $this->fillAdminPanel();
1134 $this->fillToolbar();
1135 $this->fillPermanentLink();
1136
1137 $this->setCenterColumnClass();
1138
1139 // late loading of javascipr files, since operations above may add files
1140 $this->fillJavaScriptFiles();
1141 $this->fillOnLoadCode();
1142
1143 // these fill just plain placeholder variables in tpl.adm_content.html
1144 if ($this->blockExists("content")) {
1145 $this->setCurrentBlock("content");
1146 if ($a_tabs) {
1147 $this->fillTabs();
1148 }
1149 $this->fillMainContent();
1150 if ($a_main_menu) {
1151 $this->fillMainMenu();
1152 }
1153 $this->fillLightbox();
1154 $this->parseCurrentBlock();
1155 }
1156 }
1157
1158 if ($part == "DEFAULT") {
1159 $html = $this->template->get();
1160 } else {
1161 $html = $this->template->get($part);
1162 }
1163
1164 // save language usages as late as possible
1166
1167 return $html;
1168 }
1169
1170 public function printToStdout(
1171 string $part = self::DEFAULT_BLOCK,
1172 bool $has_tabs = true,
1173 bool $skip_main_menu = false
1174 ): void {
1175 global $DIC;
1176
1177 $http = $DIC->http();
1178 switch ($http->request()->getHeaderLine('Accept')) {
1179 case 'application/json':
1180 $string = json_encode([
1181 self::MESSAGE_TYPE_SUCCESS => is_null($this->message[self::MESSAGE_TYPE_FAILURE]),
1182 'message' => '',
1183 ]);
1185 $http->saveResponse($http->response()->withBody($stream));
1186 $http->sendResponse();
1187 exit;
1188 default:
1189 // include yahoo dom per default
1191
1192 header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
1193 header("Content-type: text/html; charset=UTF-8");
1194
1195 $this->fillMessage();
1196
1197 // display ILIAS footer
1198 if ($part !== false) {
1199 $this->fillFooter();
1200 }
1201
1202 // set standard parts (tabs and title icon)
1203 $this->fillBodyClass();
1204 if ($has_tabs) {
1205 if ($this->blockExists("content")) {
1206 // determine default screen id
1207 $this->getTabsHTML();
1208 }
1209
1210 // to get also the js files for the main menu
1211 if (!$skip_main_menu) {
1212 $this->getMainMenu();
1213 $this->initHelp();
1214 }
1215
1216 // these fill blocks in tpl.main.html
1217 $this->fillCssFiles();
1218 $this->fillInlineCss();
1219 //$this->fillJavaScriptFiles();
1220
1221 // these fill just plain placeholder variables in tpl.main.html
1222 $this->setCurrentBlock("DEFAULT");
1223 $this->fillNewContentStyle();
1224 $this->fillContentLanguage();
1225 $this->fillWindowTitle();
1226
1227 // these fill blocks in tpl.adm_content.html
1228 $this->fillHeader();
1229 $this->fillSideIcons();
1230 $this->fillLeftContent();
1231 $this->fillLeftNav();
1232 $this->fillRightContent();
1233 $this->fillAdminPanel();
1234 $this->fillToolbar();
1235 $this->fillPermanentLink();
1236
1237 $this->setCenterColumnClass();
1238
1239 // late loading of javascipr files, since operations above may add files
1240 $this->fillJavaScriptFiles();
1241 $this->fillOnLoadCode();
1242
1243 // these fill just plain placeholder variables in tpl.adm_content.html
1244 if ($this->blockExists("content")) {
1245 $this->setCurrentBlock("content");
1246 $this->fillTabs();
1247 $this->fillMainContent();
1248 $this->fillMainMenu();
1249 $this->fillLightbox();
1250 $this->parseCurrentBlock();
1251 }
1252 }
1253
1254 if ($part == "DEFAULT" or is_bool($part)) {
1255 $html = $this->template->getUnmodified();
1256 } else {
1257 $html = $this->template->getUnmodified($part);
1258 }
1259
1260 // Modification of html is done inline here and can't be done
1261 // by ilTemplate, because the "phase" is template_show in this
1262 // case here.
1263 $component_factory = $DIC["component.factory"];
1264 foreach ($component_factory->getActivePluginsInSlot("uihk") as $plugin) {
1265 $gui_class = $plugin->getUIClassInstance();
1266
1267 $resp = $gui_class->getHTML(
1268 "",
1269 "template_show",
1270 array("tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html)
1271 );
1272
1273 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
1274 $html = $gui_class->modifyHTML($html, $resp);
1275 }
1276 }
1277
1278 // save language usages as late as possible
1280
1281 print $html;
1282
1283 break;
1284 }
1285 }
1286
1290 private function fillSideIcons(): void
1291 {
1292 global $DIC;
1293
1294 $ilSetting = $DIC->settings();
1295
1296 $lng = $DIC->language();
1297
1298 // tree/flat icon
1299 if ($this->tree_flat_link != "") {
1300 if ($this->left_nav_content != "") {
1301 $this->touchBlock("tree_lns");
1302 }
1303
1304 $this->setCurrentBlock("tree_mode");
1305 $this->setVariable("LINK_MODE", $this->tree_flat_link);
1306 if ($ilSetting->get("tree_frame") == "right") {
1307 if ($this->tree_flat_mode === "tree") {
1308 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
1309 $this->setVariable("RIGHT", "Right");
1310 } else {
1311 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
1312 $this->setVariable("RIGHT", "Right");
1313 }
1314 } else {
1315 if ($this->tree_flat_mode == "tree") {
1316 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
1317 } else {
1318 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
1319 }
1320 }
1321 $this->setVariable("ALT_TREE", $lng->txt($this->tree_flat_mode . "view"));
1322 $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
1323 $this->parseCurrentBlock();
1324 }
1325
1326 $this->setCurrentBlock("tree_icons");
1327 $this->parseCurrentBlock();
1328 }
1329
1330 public function setTreeFlatIcon(string $a_link, string $a_mode): void
1331 {
1332 $this->tree_flat_link = $a_link;
1333 $this->tree_flat_mode = $a_mode;
1334 }
1335
1336 public function addLightbox(string $a_html, string $a_id): void
1337 {
1338 $this->lightbox[$a_id] = $a_html;
1339 }
1340
1346 private function fillLightbox(): void
1347 {
1348 $html = implode('', $this->lightbox);
1349 $this->setVariable("LIGHTBOX", $html);
1350 }
1351
1352 // ADMIN PANEL
1353 //
1354 // Only used in ilContainerGUI
1355 //
1356 // An "Admin Panel" is that toolbar thingy that could be found on top and bottom
1357 // of a repository listing when editing objects in a container gui.
1358
1359 protected ?ilToolbarGUI $admin_panel_commands_toolbar = null;
1360 protected ?bool $admin_panel_arrow = null;
1361 protected ?bool $admin_panel_bottom = null;
1362
1363 public function addAdminPanelToolbar(
1364 ilToolbarGUI $toolbar,
1365 bool $is_bottom_panel = true,
1366 bool $has_arrow = false
1367 ): void {
1368 $this->admin_panel_commands_toolbar = $toolbar;
1369 $this->admin_panel_arrow = $has_arrow;
1370 $this->admin_panel_bottom = $is_bottom_panel;
1371 }
1372
1378 private function fillAdminPanel(): void
1379 {
1380 global $DIC;
1381 $lng = $DIC->language();
1382
1383 if ($this->admin_panel_commands_toolbar === null) {
1384 return;
1385 }
1386
1387 $toolb = $this->admin_panel_commands_toolbar;
1388
1389 // Add arrow if desired.
1390 if ($this->admin_panel_arrow) {
1391 $toolb->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), $lng->txt("actions"));
1392 }
1393
1394 $this->fillPageFormAction();
1395
1396 // Add top admin bar.
1397 $this->setCurrentBlock("adm_view_components");
1398 $this->setVariable("ADM_PANEL1", $toolb->getHTML());
1399 $this->parseCurrentBlock();
1400
1401 // Add bottom admin bar if user wants one.
1402 if ($this->admin_panel_bottom) {
1403 $this->setCurrentBlock("adm_view_components2");
1404
1405 // Replace previously set arrow image.
1406 if ($this->admin_panel_arrow) {
1407 $toolb->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), $lng->txt("actions"));
1408 }
1409
1410 $this->setVariable("ADM_PANEL2", $toolb->getHTML());
1411 $this->parseCurrentBlock();
1412 }
1413 }
1414
1415 public function setPermanentLink(
1416 string $a_type,
1417 ?int $a_id,
1418 string $a_append = "",
1419 string $a_target = "",
1420 string $a_title = ""
1421 ): void {
1422 $this->permanent_link = array(
1423 "type" => $a_type,
1424 "id" => $a_id,
1425 "append" => $a_append,
1426 "target" => $a_target,
1427 "title" => $a_title,
1428 );
1429 }
1430
1434 private function fillPermanentLink(): void
1435 {
1436 if (is_array($this->permanent_link)) {
1437 $plinkgui = new ilPermanentLinkGUI(
1438 $this->permanent_link["type"],
1439 $this->permanent_link["id"],
1440 $this->permanent_link["append"],
1441 $this->permanent_link["target"]
1442 );
1443 if ($this->permanent_link["title"] != "") {
1444 $plinkgui->setTitle($this->permanent_link["title"]);
1445 }
1446 $this->setVariable("PRMLINK", $plinkgui->getHTML());
1447 }
1448 }
1449
1453 public function resetHeaderBlock(bool $a_reset_header_action = true): void
1454 {
1455 $this->setTitle(null);
1456 $this->setTitleIcon(null);
1457 $this->setDescription(null);
1458 $this->setAlertProperties(array());
1459 $this->setFileUploadRefId(null);
1460
1461 // see setFullscreenHeader()
1462 if ($a_reset_header_action) {
1463 $this->setHeaderActionMenu(null);
1464 }
1465 }
1466
1470 public function setFileUploadRefId(int $a_ref_id): void
1471 {
1472 $this->enable_fileupload = $a_ref_id;
1473 }
1474
1475
1476 // TEMPLATING AND GLOBAL RENDERING
1477 //
1478 // Forwards to ilTemplate-member.
1479
1484 public function get(string $part = "DEFAULT"): string
1485 {
1486 return $this->template->get($part);
1487 }
1488
1489 public function setVariable(string $variable, $value = ''): void
1490 {
1491 $this->template->setVariable($variable, $value);
1492 }
1493
1494 private function variableExists(string $a_variablename)
1495 {
1496 return $this->template->variableExists($a_variablename);
1497 }
1498
1499 public function setCurrentBlock(string $part = "DEFAULT"): bool
1500 {
1501 return $this->template->setCurrentBlock($part);
1502 }
1503
1504 public function touchBlock(string $block): bool
1505 {
1506 return $this->template->touchBlock($block);
1507 }
1508
1509 public function parseCurrentBlock(string $block_name = "DEFAULT"): bool
1510 {
1511 return $this->template->parseCurrentBlock($block_name);
1512 }
1513
1514 public function addBlockFile(string $var, string $block, string $template_name, string $in_module = null): bool
1515 {
1516 return $this->template->addBlockFile($var, $block, $template_name, $in_module);
1517 }
1518
1519 public function blockExists(string $block_name): bool
1520 {
1521 return $this->template->blockExists($block_name);
1522 }
1523}
$filename
Definition: buildRTE.php:78
$out
Definition: buildRTE.php:24
Builds data types.
Definition: Factory.php:21
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$inline_css
Stores CSS to be included directly.
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.
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.
addBlockFile(string $var, string $block, string $template_name, string $in_module=null)
overwrites ITX::addBlockFile
__construct(string $file, bool $flag1, bool $flag2, string $in_module="", string $vars=ilGlobalTemplateInterface::DEFAULT_BLOCK, bool $plugin=false, bool $a_use_cache=true)
constructor
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)
Add admin panel commands as toolbar.
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).
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.
getLoginTargetPar()
Get target parameter for login.
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.
fillContentLanguage()
Add current user language to meta tags.
touchBlock(string $block)
overwrites ITX::touchBlock.
addLightbox(string $a_html, string $a_id)
Add a lightbox html to the template.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getFrame(string $a_class)
static isActive()
static _saveUsages()
Store the collected language variable usages in the user session This should be called as late as pos...
static _checkTranslate()
Permission check for translations.
static _isPageTranslation()
Check if the current request is a page translation.
static _getTranslationLink()
Get the link to translate the current page.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
static init(ilGlobalTemplateInterface $template=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, 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 secureUrl(string $url)
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
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
global $ilPluginAdmin
Definition: goto.php:23
const ILIAS_VERSION
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
Definition: login.php:28
$i
Definition: metadata.php:41
static http()
Fetches the global http state from ILIAS.
global $ilSetting
Definition: privfeed.php:17
$type
$url
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$http
Definition: raiseError.php:7
$lng