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