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