ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Init.php
Go to the documentation of this file.
1<?php
2
20
24class Init
25{
26 protected \ILIAS\DI\UIServices $ui;
27 protected \ilCtrl $ctrl;
28 protected \ilLanguage $lng;
29
30 public function __construct()
31 {
32 global $DIC;
33
34 $this->ctrl = $DIC->ctrl();
35 $this->lng = $DIC->language();
36 $this->ui = $DIC->ui();
37 }
38
39 public function initUI(
41 ): void {
42 $ctrl = $this->ctrl;
44
46
47 $lang_vars = ["cont_last_update", "cont_error", "cont_sel_el_cut_use_paste", "cont_sel_el_copied_use_paste",
48 "cont_ed_new_col_before", "cont_ed_new_col_after", "cont_ed_col_left", "cont_ed_col_right", "cont_ed_delete_col",
49 "cont_ed_new_row_before", "cont_ed_new_row_after", "cont_ed_row_up", "cont_ed_row_down", "cont_ed_delete_row", "cont_saving",
50 "cont_ed_nr_cols", "cont_ed_nr_rows",
51 "cont_merge_cells", "cont_split_cell"
52 ];
53
54 foreach ($lang_vars as $l) {
55 $lng->toJS($l);
56 }
57
58 if (DEVMODE == 1) {
59 $main_tpl->addJavaScript("node_modules/tinymce/tinymce.js");
60 } else {
61 $main_tpl->addJavaScript("node_modules/tinymce/tinymce.min.js");
62 }
63
65 $main_tpl->addJavaScript("assets/js/ilExplorer.js");
66
67 // ensure that form.js is loaded which is needed for file input (js that shows file names)
68 $dummy = new \ilPropertyFormGUI();
69 $dummy->getHTML();
70 // ensure modal.js from ui framework is loaded
71 $this->ui->renderer()->render(
72 $this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy()->content(""))
73 );
74 }
75
76 protected function sanitizeAttribute(string $attr): string
77 {
78 return str_replace(["<", ">", "'", "\""], "", $attr);
79 }
80
81 public function getInitHtml(
82 string $openPlaceHolderPcId = "",
83 string $openFormPcId = "",
84 string $openFormCName = ""
85 ): string {
86 $ctrl = $this->ctrl;
87
88 $p1 = $this->sanitizeAttribute(
89 ILIAS_HTTP_PATH . "/" . $ctrl->getLinkTargetByClass(["ilPageEditorGUI", "ilPageEditorServerAdapterGUI"], "invokeServer")
90 );
91 $p2 = $this->sanitizeAttribute($ctrl->getFormActionByClass("ilPageEditorGUI"));
92 $p3 = $this->sanitizeAttribute($openPlaceHolderPcId);
93 $p4 = $this->sanitizeAttribute($openFormPcId);
94 $p5 = $this->sanitizeAttribute($openFormCName);
95
96 $init_span = <<<EOT
97<span id='il-copg-init'
98 data-endpoint='$p1'
99 data-formaction='$p2'
100 data-open-place-holder-pc-id='$p3'
101 data-open-form-pc-id='$p4'
102 data-open-form-cname='$p5'
103></span>
104EOT;
105
106 $debug = "";
107 //$debug = ".";
108 $module_tag = <<<EOT
109<script type="module" src="$debug./components/ILIAS/COPage/Editor/js/src/editor.js"></script>
110EOT;
111 return $init_span . $module_tag;
112 }
113
114}
getInitHtml(string $openPlaceHolderPcId="", string $openFormPcId="", string $openFormCName="")
Definition: Init.php:81
sanitizeAttribute(string $attr)
Definition: Init.php:76
ILIAS DI UIServices $ui
Definition: Init.php:26
initUI(\ilGlobalTemplateInterface $main_tpl)
Definition: Init.php:39
toJS($a_lang_key, ?ilGlobalTemplateInterface $a_tpl=null)
Transfer text to Javascript.
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Init.php:19
form( $class_path, string $cmd, string $submit_caption="")
global $DIC
Definition: shib_login.php:26