ILIAS  release_8 Revision v8.24
ilIndependentTemplate.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21require_once("libs/composer/vendor/autoload.php");
22
23// Do the require-dance for ilTemplate.
24require_once("./Services/UICore/lib/html-it/IT.php");
25require_once("./Services/UICore/lib/html-it/ITX.php");
26require_once("./Services/UICore/classes/class.ilTemplate.php");
27
29{
30 public function __construct(
31 $file,
32 $flag1,
33 $flag2,
34 $in_module = '',
35 $vars = self::DEFAULT_BLOCK,
36 $plugin = false,
37 $a_use_cache = true
38 ) {
39 $this->setBodyClass("std");
40 $this->template = new ilIndependantTemplate($file, $flag1, $flag2, $in_module, $vars, $plugin, $a_use_cache);
41 }
42
43 // Small adjustment to fit \ILIAS\UI\Implementation\Template and call to
44 public function get(
45 string $part = null,
46 bool $add_error_mess = false,
47 bool $handle_referer = false,
48 bool $add_ilias_footer = false,
49 bool $add_standard_elements = false,
50 bool $a_main_menu = true,
51 bool $a_tabs = true
52 ): string {
53 return $this->template->get($part);
54 }
55}
56
58{
64 public function getFile(string $filename): string
65 {
66 if ($filename[0] === '/' && substr($this->fileRoot, -1) === '/') {
67 $filename = substr($filename, 1);
68 }
69
70 $filename = $this->fileRoot . $filename;
71
72 require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
73 $this->real_filename = $filename;
74
75 if (!($fh = @fopen($filename, 'rb'))) {
76 $this->err[] = (new PEAR())->raiseError(
77 $this->errorMessage(self::IT_TPL_NOT_FOUND) .
78 ': "' . $filename . '"',
79 self::IT_TPL_NOT_FOUND
80 );
81 return "";
82 }
83
84 $fsize = filesize($filename);
85 if ($fsize < 1) {
86 fclose($fh);
87 return '';
88 }
89
90 $content = fread($fh, $fsize);
91 fclose($fh);
92
93 return preg_replace_callback(
94 "#<!-- INCLUDE (.*) -->#im",
95 function ($hit) {
96 return $this->getFile($hit[1]);
97 },
98 $content
99 );
100 }
101
106 public function loadTemplatefile(
107 string $filename,
108 bool $removeUnknownVariables = true,
109 bool $removeEmptyBlocks = true
110 ): bool {
111 return HTML_Template_IT::loadTemplatefile($filename, $removeUnknownVariables, $removeEmptyBlocks);
112 }
113
114 // Small adjustment to fit \ILIAS\UI\Implementation\Template and call to
115 public function get(string $part = null): string
116 {
117 if ($part === null) {
118 $part = self::IT_DEFAULT_BLOCK;
119 }
120 if ($part === self::IT_DEFAULT_BLOCK && !$this->flagGlobalParsed) {
121 $this->parse(self::IT_DEFAULT_BLOCK);
122 }
123
124 if (!isset($this->blocklist[$part])) {
125 throw (new ilTemplateException($this->errorMessage(self::IT_BLOCK_NOT_FOUND) .
126 '"' . $part . "'"));
127 }
128
129 if (isset($this->blockdata[$part])) {
130 $ret = $this->blockdata[$part];
131 if ($this->clearCache) {
132 unset($this->blockdata[$part]);
133 }
134 if ($this->_options['preserve_data']) {
135 $ret = str_replace(
136 $this->openingDelimiter .
137 '%preserved%' . $this->closingDelimiter,
138 $this->openingDelimiter,
139 $ret
140 );
141 }
142 return $ret;
143 }
144
145 return '';
146 }
147}
$filename
Definition: buildRTE.php:78
Integrated Template - IT Well there's not much to say about it.
Definition: IT.php:98
return true
special template class to simplify handling of ITX/PEAR
setBodyClass(string $a_class="")
Sets the body-tags class.
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Reads a template file from the disk.
getFile(string $filename)
Reads a file from disk and returns its content.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $file, $flag1, $flag2, $in_module='', $vars=self::DEFAULT_BLOCK, $plugin=false, $a_use_cache=true)
special template class to simplify handling of ITX/PEAR
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
Interface to templating as it is used in the UI framework.
Definition: Template.php:29