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