ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilRTEGlobalTemplate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected string $tree_flat_link = '';
29 protected string $page_form_action = '';
30 protected bool $permanent_link = false;
31 protected bool $standard_template_loaded = false;
33 protected string $body_class = '';
38 protected array $js_files = [0 => 'assets/js/Basic.js'];
39
44 protected array $js_files_vp = ['assets/js/Basic.js' => true];
45
50 protected array $js_files_batch = ['assets/js/Basic.js' => 1];
51
52 public function __construct(
53 string $file,
54 bool $flag1,
55 bool $flag2,
56 string $in_module = '',
57 string $vars = 'DEFAULT',
58 bool $plugin = false,
59 bool $a_use_cache = true
60 ) {
61 $this->setBodyClass('std');
62 $this->template = new ilTemplate($file, $flag1, $flag2, $in_module, $vars, $plugin, $a_use_cache);
63 }
64
65 public function printToString(): string
66 {
67 throw new ilException('not implemented');
68 }
69
70 public function hideFooter(): void
71 {
72 }
73
74 public function setOnScreenMessage(string $type, string $a_txt, bool $a_keep = false): void
75 {
76 }
77
78 public function addJavaScript(string $a_js_file, bool $a_add_version_parameter = true, int $a_batch = 2): void
79 {
80 // three batches currently
81 if ($a_batch < 1 || $a_batch > 3) {
82 $a_batch = 2;
83 }
84
85 // ensure jquery files being loaded first
86 if (
87 is_int(strpos($a_js_file, 'components/ILIAS/jQuery')) ||
88 is_int(strpos($a_js_file, '/jquery.js')) ||
89 is_int(strpos($a_js_file, '/jquery-min.js'))
90 ) {
91 $a_batch = 0;
92 }
93
94 if (!in_array($a_js_file, $this->js_files, true)) {
95 $this->js_files[] = $a_js_file;
96 $this->js_files_vp[$a_js_file] = $a_add_version_parameter;
97 $this->js_files_batch[$a_js_file] = $a_batch;
98 }
99 }
100
101 public function addOnLoadCode(string $a_code, int $a_batch = 2): void
102 {
103 }
104
105
106 public function getOnLoadCodeForAsynch(): string
107 {
108 return '';
109 }
110
111 public function resetJavascript(): void
112 {
113 $this->js_files = [];
114 $this->js_files_vp = [];
115 $this->js_files_batch = [];
116 }
117
118 public function fillJavaScriptFiles(bool $a_force = false): void
119 {
120 global $DIC;
121
122 $ilSetting = $DIC->settings();
123
124 $vers = '';
125 if (is_object($ilSetting)) {
126 $vers = 'vers=' . str_replace(['.', ' '], '-', ILIAS_VERSION);
127
128 if (defined('DEVMODE') && DEVMODE) {
129 $vers .= '-' . time();
130 }
131 }
132
133 if ($this->blockExists('js_file')) {
134 for ($i = 0; $i <= 3; $i++) {
135 reset($this->js_files);
136 foreach ($this->js_files as $file) {
137 if ($this->js_files_batch[$file] === $i) {
138 if ($a_force || is_file($file) || strpos($file, 'http') === 0 || strpos($file, '//') === 0) {
139 $this->fillJavascriptFile($file, $vers);
140 } elseif (strpos($file, './') === 0) { // #13962
141 $url_parts = parse_url($file);
142 if (is_file($url_parts['path'])) {
143 $this->fillJavascriptFile($file, $vers);
144 }
145 }
146 }
147 }
148 }
149 }
150 }
151
152 protected function fillJavascriptFile(string $file, string $vers): void
153 {
154 $this->setCurrentBlock('js_file');
155 if ($this->js_files_vp[$file]) {
156 $this->setVariable('JS_FILE', ilUtil::appendUrlParameterString($file, $vers));
157 } else {
158 $this->setVariable('JS_FILE', $file);
159 }
160 $this->parseCurrentBlock();
161 }
162
163 public function addCss(string $a_css_file, string $media = "screen"): void
164 {
165 }
166
167 public function addInlineCss(string $a_css, string $media = "screen"): void
168 {
169 }
170
171 public function setBodyClass(string $a_class = ''): void
172 {
173 $this->body_class = $a_class;
174 }
175
176 private function fillBodyClass(): void
177 {
178 if ($this->body_class !== '' && $this->blockExists('body_class')) {
179 $this->setCurrentBlock('body_class');
180 $this->setVariable('BODY_CLASS', $this->body_class);
181 $this->parseCurrentBlock();
182 }
183 }
184
185 public function loadStandardTemplate(): void
186 {
187 if ($this->standard_template_loaded) {
188 return;
189 }
190
192
193 $this->addBlockFile('CONTENT', 'content', 'tpl.adm_content.html');
194 $this->addBlockFile('STATUSLINE', 'statusline', 'tpl.statusline.html');
195
196 $this->standard_template_loaded = true;
197 }
198
199 public function setTitle(string $a_title, bool $hidden = false): void
200 {
201 }
202
203 public function setDescription(string $a_descr): void
204 {
205 }
206
207 public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
208 {
209 }
210
211 public function setAlertProperties(array $alerts): void
212 {
213 }
214
215 public function clearHeader(): void
216 {
217 }
218
219 public function setHeaderActionMenu(string $a_header): void
220 {
221 }
222
223 public function setHeaderPageTitle(string $a_title): void
224 {
225 }
226
227 public function setLocator(): void
228 {
229 }
230
231 public function setTabs(string $a_tabs_html): void
232 {
233 }
234
235
236 public function setSubTabs(string $a_tabs_html): void
237 {
238 }
239
240 public function setContent(string $a_html): void
241 {
242 }
243
244 public function setLeftContent(string $a_html): void
245 {
246 }
247
248 public function setLeftNavContent(string $a_content): void
249 {
250 }
251
252 public function setRightContent(string $a_html): void
253 {
254 }
255
256 public function setPageFormAction(string $a_action): void
257 {
258 }
259
260 public function setLoginTargetPar(string $a_val): void
261 {
262 }
263
264 public function getSpecial(
265 string $part = self::DEFAULT_BLOCK,
266 bool $add_error_mess = false,
267 bool $handle_referer = false,
268 bool $add_ilias_footer = false,
269 bool $add_standard_elements = false,
270 bool $a_main_menu = true,
271 bool $a_tabs = true
272 ): string {
273 return '';
274 }
275
276 public function printToStdout(
277 string $part = self::DEFAULT_BLOCK,
278 bool $has_tabs = true,
279 bool $skip_main_menu = false
280 ): void {
281 global $DIC;
282
283 $http = $DIC->http();
284 switch ($http->request()->getHeaderLine('Accept')) {
285 default:
286 header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
287 header('Content-type: text/html; charset=UTF-8');
288
289 $this->fillBodyClass();
290 if ($has_tabs) {
291 $this->setCurrentBlock(self::DEFAULT_BLOCK);
292 $this->fillJavaScriptFiles();
293 }
294
295 if ($part === self::DEFAULT_BLOCK) {
296 $html = $this->template->getUnmodified();
297 } else {
298 $html = $this->template->getUnmodified($part);
299 }
300
301 print $html;
302
303 break;
304 }
305 }
306
307 public function setTreeFlatIcon(string $a_link, string $a_mode): void
308 {
309 }
310
311 public function addAdminPanelToolbar(
312 ilToolbarGUI $toolbar,
313 bool $is_bottom_panel = true,
314 bool $has_arrow = false
315 ): void {
316 }
317
318 public function setPermanentLink(
319 string $a_type,
320 ?int $a_id,
321 string $a_append = "",
322 string $a_target = "",
323 string $a_title = ""
324 ): void {
325 }
326
327 public function resetHeaderBlock(bool $a_reset_header_action = true): void
328 {
329 }
330
331 public function setFileUploadRefId(int $a_ref_id): void
332 {
333 }
334
335 public function get(string $part = self::DEFAULT_BLOCK): string
336 {
337 return $this->template->get($part);
338 }
339
340 public function setVariable(string $variable, $value = ''): void
341 {
342 $this->template->setVariable($variable, $value);
343 }
344
345 public function setCurrentBlock(string $part = self::DEFAULT_BLOCK): bool
346 {
347 return $this->template->setCurrentBlock($part);
348 }
349
350 public function touchBlock(string $block): bool
351 {
352 return $this->template->touchBlock($block);
353 }
354
355 public function parseCurrentBlock(string $block_name = self::DEFAULT_BLOCK): bool
356 {
357 return $this->template->parseCurrentBlock($block_name);
358 }
359
360 public function addBlockFile(string $var, string $block, string $template_name, ?string $in_module = null): bool
361 {
362 return $this->template->addBlockFile($var, $block, $template_name, $in_module);
363 }
364
365 public function blockExists(string $block_name): bool
366 {
367 return $this->template->blockExists($block_name);
368 }
369}
return true
Base class for ILIAS Exception handling.
Special template class to simplify handling of ITX/PEAR.
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
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.
addAdminPanelToolbar(ilToolbarGUI $toolbar, bool $is_bottom_panel=true, bool $has_arrow=false)
fillJavaScriptFiles(bool $a_force=false)
Probably adds javascript files.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
setAlertProperties(array $alerts)
Set alert properties.
setFileUploadRefId(int $a_ref_id)
Enables the file upload into this object by dropping a file.
setBodyClass(string $a_class='')
Sets the body-tags class.
blockExists(string $block_name)
check if block exists in actual template
printToString()
Use this method to get the finally rendered page as string.
setLeftNavContent(string $a_content)
Sets content of left navigation column.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
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.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
addInlineCss(string $a_css, string $media="screen")
Add a css file that should be included in the header.
addBlockFile(string $var, string $block, string $template_name, ?string $in_module=null)
overwrites ITX::addBlockFile
setRightContent(string $a_html)
Sets content of right column.
setContent(string $a_html)
Sets content for standard template.
setTreeFlatIcon(string $a_link, string $a_mode)
Sets a tree or flat icon.
touchBlock(string $block)
overwrites ITX::touchBlock.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setTabs(string $a_tabs_html)
sets tabs in standard template
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
setHeaderPageTitle(string $a_title)
Sets the title of the page (for browser window).
__construct(string $file, bool $flag1, bool $flag2, string $in_module='', string $vars='DEFAULT', bool $plugin=false, bool $a_use_cache=true)
loadStandardTemplate()
This loads the standard template "tpl.adm_content.html" and "tpl.statusline.html" the CONTENT and STA...
addOnLoadCode(string $a_code, int $a_batch=2)
Add on load code.
setPageFormAction(string $a_action)
Sets the pages form action.
setLeftContent(string $a_html)
Sets content of left column.
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
fillJavascriptFile(string $file, string $vers)
resetJavascript()
Reset javascript files.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setHeaderActionMenu(string $a_header)
Set header action menu.
setSubTabs(string $a_tabs_html)
sets subtabs in standard template
hideFooter()
Make the template hide the footer.
printToStdout(string $part=self::DEFAULT_BLOCK, bool $has_tabs=true, bool $skip_main_menu=false)
getOnLoadCodeForAsynch()
Get js onload code for ajax calls.
setDescription(string $a_descr)
Sets description below title in standard template.
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$http
Definition: deliver.php:30
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ILIAS_VERSION
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26