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