ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilRTEGlobalTemplate.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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;
32  protected ilTemplate $template;
33  protected string $body_class = '';
38  protected array $js_files = [0 => './Services/JavaScript/js/Basic.js'];
39 
44  protected array $js_files_vp = ['./Services/JavaScript/js/Basic.js' => true];
45 
50  protected array $js_files_batch = ['./Services/JavaScript/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, 'Services/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 
193 
195 
196  $this->addBlockFile('CONTENT', 'content', 'tpl.adm_content.html');
197  $this->addBlockFile('STATUSLINE', 'statusline', 'tpl.statusline.html');
198 
199  $this->standard_template_loaded = true;
200  }
201 
202  public function setTitle(string $a_title, bool $hidden = false): void
203  {
204  }
205 
206  public function setDescription(string $a_descr): void
207  {
208  }
209 
210  public function setTitleIcon(string $a_icon_path, string $a_icon_desc = ""): void
211  {
212  }
213 
214  public function setAlertProperties(array $alerts): void
215  {
216  }
217 
218  public function clearHeader(): void
219  {
220  }
221 
222  public function setHeaderActionMenu(string $a_header): void
223  {
224  }
225 
226  public function setHeaderPageTitle(string $a_title): void
227  {
228  }
229 
230  public function setLocator(): void
231  {
232  }
233 
234  public function setTabs(string $a_tabs_html): void
235  {
236  }
237 
238 
239  public function setSubTabs(string $a_tabs_html): void
240  {
241  }
242 
243  public function setContent(string $a_html): void
244  {
245  }
246 
247  public function setLeftContent(string $a_html): void
248  {
249  }
250 
251  public function setLeftNavContent(string $a_content): void
252  {
253  }
254 
255  public function setRightContent(string $a_html): void
256  {
257  }
258 
259  public function setPageFormAction(string $a_action): void
260  {
261  }
262 
263  public function setLoginTargetPar(string $a_val): void
264  {
265  }
266 
267  public function getSpecial(
268  string $part = self::DEFAULT_BLOCK,
269  bool $add_error_mess = false,
270  bool $handle_referer = false,
271  bool $add_ilias_footer = false,
272  bool $add_standard_elements = false,
273  bool $a_main_menu = true,
274  bool $a_tabs = true
275  ): string {
276  return '';
277  }
278 
279  public function printToStdout(
280  string $part = self::DEFAULT_BLOCK,
281  bool $has_tabs = true,
282  bool $skip_main_menu = false
283  ): void {
284  global $DIC;
285 
286  $http = $DIC->http();
287  switch ($http->request()->getHeaderLine('Accept')) {
288  default:
290 
291  header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
292  header('Content-type: text/html; charset=UTF-8');
293 
294  $this->fillBodyClass();
295  if ($has_tabs) {
296  $this->setCurrentBlock(self::DEFAULT_BLOCK);
297  $this->fillJavaScriptFiles();
298  }
299 
300  if ($part === self::DEFAULT_BLOCK) {
301  $html = $this->template->getUnmodified();
302  } else {
303  $html = $this->template->getUnmodified($part);
304  }
305 
306  print $html;
307 
308  break;
309  }
310  }
311 
312  public function setTreeFlatIcon(string $a_link, string $a_mode): void
313  {
314  }
315 
316  public function addAdminPanelToolbar(
317  ilToolbarGUI $toolbar,
318  bool $is_bottom_panel = true,
319  bool $has_arrow = false
320  ): void {
321  }
322 
323  public function setPermanentLink(
324  string $a_type,
325  ?int $a_id,
326  string $a_append = "",
327  string $a_target = "",
328  string $a_title = ""
329  ): void {
330  }
331 
332  public function resetHeaderBlock(bool $a_reset_header_action = true): void
333  {
334  }
335 
336  public function setFileUploadRefId(int $a_ref_id): void
337  {
338  }
339 
340  public function get(string $part = self::DEFAULT_BLOCK): string
341  {
342  return $this->template->get($part);
343  }
344 
345  public function setVariable(string $variable, $value = ''): void
346  {
347  $this->template->setVariable($variable, $value);
348  }
349 
350  public function setCurrentBlock(string $part = self::DEFAULT_BLOCK): bool
351  {
352  return $this->template->setCurrentBlock($part);
353  }
354 
355  public function touchBlock(string $block): bool
356  {
357  return $this->template->touchBlock($block);
358  }
359 
360  public function parseCurrentBlock(string $block_name = self::DEFAULT_BLOCK): bool
361  {
362  return $this->template->parseCurrentBlock($block_name);
363  }
364 
365  public function addBlockFile(string $var, string $block, string $template_name, string $in_module = null): bool
366  {
367  return $this->template->addBlockFile($var, $block, $template_name, $in_module);
368  }
369 
370  public function blockExists(string $block_name): bool
371  {
372  return $this->template->blockExists($block_name);
373  }
374 }
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.
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
setLoginTargetPar(string $a_val)
Set target parameter for login (public sector).
Special template class to simplify handling of ITX/PEAR.
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.
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:18
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.