ILIAS  release_8 Revision v8.24
ilTemplate Class Reference

special template class to simplify handling of ITX/PEAR More...

+ Inheritance diagram for ilTemplate:
+ Collaboration diagram for ilTemplate:

Public Member Functions

 __construct (string $file, bool $flag1, bool $flag2, string $in_module="", string $vars=ilGlobalTemplateInterface::DEFAULT_BLOCK, bool $plugin=false, bool $a_use_cache=true)
 constructor ilTemplate constructor. More...
 
 blockExists (string $a_blockname)
 Checks wheter a block exists. More...
 
 get (string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 Returns a block with all replacements done. More...
 
 getUnmodified (string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
 setCurrentBlock (string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
 touchBlock (string $block)
 
 parseCurrentBlock (string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
 addBlockFile (string $var, string $block, string $tplname, string $in_module=null)
 
 loadTemplatefile (string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
 Reads a template file from the disk. More...
 
 getTemplateIdentifier (string $a_tplname, string $a_in_module=null)
 get a unique template identifier The identifier is common for default or customized skins but distincts templates of different services with the same name. More...
 
 variableExists (string $a_variablename)
 
- Public Member Functions inherited from HTML_Template_ITX
 __construct (string $root='')
 Builds some complex regexps and calls the constructor of the parent class. More...
 
 replaceBlock (string $block, string $template, bool $keep_content=false)
 Replaces an existing block with new content. More...
 
 addBlock (string $placeholder, string $blockname, string $template)
 Adds a block to the template changing a variable placeholder to a block placeholder. More...
 
 addBlockfile (string $placeholder, string $blockname, string $filename)
 Adds a block taken from a file to the template changing a variable placeholder to a block placeholder. More...
 
 removeBlockData (string $block)
 Recursively removes all data assiciated with a block, including all inner blocks. More...
 
 blockExists (string $blockname)
 Checks wheter a block exists. More...
 
 buildFunctionlist ()
 Builds a functionlist from the template. More...
 
 getValue (string $code, $delimiter)
 Truncates the given code from the first occurence of $delimiter but ignores $delimiter enclosed by " or '. More...
 
 deleteFromBlockvariablelist (string $block, $variables)
 Deletes one or many variables from the block variable list. More...
 
 updateBlockvariablelist (string $block)
 Updates the variable list of a block. More...
 
 findPlaceholderBlocks (string $variable)
 Returns an array of blocknames where the given variable placeholder is used. More...
 
 warning (string $message, string $file='', int $line=0)
 Handles warnings, saves them to $warn and prints them or calls die() depending on the flags. More...
 
- Public Member Functions inherited from HTML_Template_IT
 __construct (string $root='', array $options=null)
 Builds some complex regular expressions and optinally sets the file root directory. More...
 
 setOption (string $option, $value)
 Sets the option for the template class. More...
 
 setOptions (array $options)
 Sets the options for the template class. More...
 
 show (string $block=self::IT_DEFAULT_BLOCK)
 Print a certain block with all replacements done. More...
 
 get (string $block=self::IT_DEFAULT_BLOCK)
 Returns a block with all replacements done. More...
 
 parse (string $block=self::IT_DEFAULT_BLOCK, bool $flag_recursion=false)
 Parses the given block. More...
 
 parseCurrentBlock ()
 Parses the current block. More...
 
 setVariable ($variable, $value='')
 Sets a variable value. More...
 
 setCurrentBlock (string $block=self::IT_DEFAULT_BLOCK)
 Sets the name of the current block that is the block where variables are added. More...
 
 touchBlock (string $block)
 Preserves an empty block even if removeEmptyBlocks is true. More...
 
 free ()
 Clears all datafields of the object. More...
 
 setTemplate (string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
 Sets the template. More...
 
 loadTemplatefile (string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
 Reads a template file from the disk. More...
 
 setRoot (string $root)
 Sets the file root. More...
 
 buildBlockvariablelist ()
 Build a list of all variables within of a block. More...
 
 findBlocks (string $string)
 Recusively builds a list of all blocks within the template. More...
 
 getFile (string $filename)
 Reads a file from disk and returns its content. More...
 
 _addPregDelimiters (string $str)
 Adds delimiters to a string, so it can be used as a pattern in preg_* functions. More...
 
 _preserveOpeningDelimiter (string $str)
 Replaces an opening delimiter by a special string. More...
 
 errorMessage (int $value, string $blockname='')
 Return a textual error message for a IT error code. More...
 

Data Fields

array $vars = []
 variablen die immer in jedem block ersetzt werden sollen More...
 
string $activeBlock = ''
 Aktueller Block Der wird gemerkt bei der berladenen Funktion setCurrentBlock, damit beim ParseBlock vorher ein replace auf alle Variablen gemacht werden kann, die mit dem BLockname anfangen. More...
 
- Data Fields inherited from HTML_Template_ITX
array $warn = []
 Array with all warnings. More...
 
bool $printWarning = false
 Print warnings? More...
 
bool $haltOnWarning = false
 Call die() on warning? More...
 
string $checkblocknameRegExp = ''
 RegExp used to test for a valid blockname. More...
 
string $functionPrefix = 'func_'
 Functionnameprefix used when searching function calls in the template. More...
 
string $functionnameRegExp = '[_a-zA-Z]+[A-Za-z_0-9]*'
 Functionname RegExp. More...
 
string $functionRegExp = ''
 RegExp used to grep function calls in the template. More...
 
array $functions = []
 List of functions found in the template. More...
 
array $callback = []
 List of callback functions specified by the user. More...
 
- Data Fields inherited from HTML_Template_IT
const IT_OK = 1
 
const IT_ERROR = -1
 
const IT_TPL_NOT_FOUND = -2
 
const IT_BLOCK_NOT_FOUND = -3
 
const IT_BLOCK_DUPLICATE = -4
 
const IT_UNKNOWN_OPTION = -6
 
const IT_DEFAULT_BLOCK = '__global__'
 
array $err = []
 Contains the error objects. More...
 
bool $clearCache = false
 Clear cache on get()? More...
 
string $openingDelimiter = '{'
 First character of a variable placeholder ( _{_VARIABLE} ). More...
 
string $closingDelimiter = '}'
 Last character of a variable placeholder ( {VARIABLE_}_ ). More...
 
string $blocknameRegExp = '[\.0-9A-Za-z_-]+'
 RegExp matching a block in the template. More...
 
string $variablenameRegExp = '[\.0-9A-Za-z_-]+'
 RegExp matching a variable placeholder in the template. More...
 
string $variablesRegExp = ''
 RegExp used to find variable placeholder, filled by the constructor. More...
 
string $removeVariablesRegExp = ''
 RegExp used to strip unused variable placeholder. More...
 
bool $removeUnknownVariables = true
 Controls the handling of unknown variables, default is remove. More...
 
bool $removeEmptyBlocks = true
 Controls the handling of empty blocks, default is remove. More...
 
string $blockRegExp = ''
 RegExp used to find blocks an their content, filled by the constructor. More...
 
string $currentBlock = self::IT_DEFAULT_BLOCK
 Name of the current block. More...
 
string $template = ''
 Content of the template. More...
 
array $blocklist = []
 Array of all blocks and their content. More...
 
array $blockdata = []
 Array with the parsed content of a block. More...
 
array $blockvariables = []
 Array of variables in a block. More...
 
array $blockparents = []
 Array of block parents. More...
 
array $blockinner = []
 Array of inner blocks of a block. More...
 
array $touchedBlocks = []
 List of blocks to preverse even if they are "empty". More...
 
array $variableCache = []
 Variable cache. More...
 
bool $clearCacheOnParse = false
 Clear the variable cache on parse? If you're not an expert just leave the default false. More...
 
string $fileRoot = ''
 Root directory for all file operations. More...
 
bool $flagBlocktrouble = false
 Internal flag indicating that a blockname was used multiple times. More...
 
bool $flagGlobalParsed = false
 Flag indicating that the global block was parsed. More...
 
bool $flagCacheTemplatefile = true
 EXPERIMENTAL! FIXME! Flag indication that a template gets cached. More...
 
string $lastTemplatefile = ''
 EXPERIMENTAL! FIXME! More...
 
array $_options
 $_options['preserve_data'] Whether to substitute variables and remove empty placeholders in data passed through setVariable (see also bugs #20199, #21951). More...
 

Protected Member Functions

 init ()
 Clears all datafields of the object and rebuild the internal blocklist LoadTemplatefile() and setTemplate() automatically call this function when a new template is given. More...
 
 getTemplatePath (string $a_tplname, string $a_in_module=null)
 
 init ()
 Clears all datafields of the object and rebuild the internal blocklist LoadTemplatefile() and setTemplate() automatically call this function when a new template is given. More...
 
 init ()
 Clears all datafields of the object and rebuild the internal blocklist LoadTemplatefile() and setTemplate() automatically call this function when a new template is given. More...
 

Protected Attributes

bool $il_use_cache
 
string $il_cur_key
 
string $tplName
 
string $tplPath
 
string $tplIdentifier
 
- Protected Attributes inherited from HTML_Template_IT
string $real_filename = ''
 Holds the real template file name. More...
 

Static Protected Attributes

static array $il_cache = []
 

Private Member Functions

 fillVars ()
 all template vars defined in $vars will be replaced automatically without setting and parsing them with setVariable & parseCurrentBlock More...
 

Detailed Description

special template class to simplify handling of ITX/PEAR

Author
Stefan Kesseler skess.nosp@m.eler.nosp@m.@data.nosp@m.bay..nosp@m.de
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns

Definition at line 16 of file class.ilTemplate.php.

Constructor & Destructor Documentation

◆ __construct()

ilTemplate::__construct ( string  $file,
bool  $flag1,
bool  $flag2,
string  $in_module = "",
string  $vars = ilGlobalTemplateInterface::DEFAULT_BLOCK,
bool  $plugin = false,
bool  $a_use_cache = true 
)

constructor ilTemplate constructor.

Parameters
string$filetemplate file
bool$flag1remove unknown variables
bool$flag2remove empty blocks
string$in_modulemodule/service subdirectory
string$varsvariables to replace
bool$pluginplugin template
bool$a_use_cacheus cache
Exceptions
ilTemplateException|ilSystemStyleException

Definition at line 54 of file class.ilTemplate.php.

62 {
63 $this->activeBlock = HTML_Template_IT::IT_DEFAULT_BLOCK;
64 $this->il_use_cache = $a_use_cache;
65 $this->il_cur_key = $file . "/" . $in_module;
66
67 $fname = $this->getTemplatePath($file, $in_module);
68 if (!file_exists($fname)) {
69 throw new ilTemplateException("Template '$fname' was not found.");
70 }
71
72 $this->tplName = basename($fname);
73 $this->tplPath = dirname($fname);
74 $this->vars["TPLPATH"] = $this->tplPath;
75 $this->tplIdentifier = $this->getTemplateIdentifier($file, $in_module);
76
78
79 $this->loadTemplatefile($fname, $flag1, $flag2);
80 $this->setOption('use_preg', false);
81 }
const IT_DEFAULT_BLOCK
Definition: IT.php:105
setOption(string $option, $value)
Sets the option for the template class.
Definition: IT.php:321
getTemplatePath(string $a_tplname, string $a_in_module=null)
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Reads a template file from the disk.
getTemplateIdentifier(string $a_tplname, string $a_in_module=null)
get a unique template identifier The identifier is common for default or customized skins but distinc...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $tplPath, ILIAS\GlobalScreen\Provider\__construct(), getTemplateIdentifier(), getTemplatePath(), HTML_Template_IT\IT_DEFAULT_BLOCK, loadTemplatefile(), and HTML_Template_IT\setOption().

+ Here is the call graph for this function:

Member Function Documentation

◆ addBlockFile()

ilTemplate::addBlockFile ( string  $var,
string  $block,
string  $tplname,
string  $in_module = null 
)

Definition at line 210 of file class.ilTemplate.php.

210 : bool
211 {
212 global $DIC;
213
214 if (DEBUG) {
215 echo "<br/>Template '" . $this->tplPath . "/" . $tplname . "'";
216 }
217
218 $tplfile = $this->getTemplatePath($tplname, $in_module);
219 if (file_exists($tplfile) === false) {
220 echo "<br/>Template '" . $tplfile . "' doesn't exist! aborting...";
221 return false;
222 }
223
224 $id = $this->getTemplateIdentifier($tplname, $in_module);
225 $template = $this->getFile($tplfile);
226 $component_factory = $DIC["component.factory"];
227 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
228 $gui_class = $ui_plugin->getUIClassInstance();
229 $resp = $gui_class->getHTML(
230 "",
231 "template_add",
232 [
233 "tpl_id" => $id,
234 "tpl_obj" => $this,
235 "html" => $template,
236 ]
237 );
238
239 if ($resp["mode"] !== ilUIHookPluginGUI::KEEP) {
240 $template = $gui_class->modifyHTML($template, $resp);
241 }
242 }
243
244 return $this->addBlock($var, $block, $template);
245 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
addBlock(string $placeholder, string $blockname, string $template)
Adds a block to the template changing a variable placeholder to a block placeholder.
Definition: ITX.php:173
string $template
Content of the template.
Definition: IT.php:175
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:750
global $DIC
Definition: feed.php:28

References $DIC, $id, XapiProxy\$resp, HTML_Template_IT\$template, HTML_Template_ITX\addBlock(), HTML_Template_IT\getFile(), getTemplateIdentifier(), getTemplatePath(), and ilUIHookPluginGUI\KEEP.

+ Here is the call graph for this function:

◆ blockExists()

ilTemplate::blockExists ( string  $blockname)

Checks wheter a block exists.

Reimplemented from HTML_Template_ITX.

Definition at line 121 of file class.ilTemplate.php.

121 : bool
122 {
123 // added second evaluation to the return statement because the first one
124 // only works for the content block (Helmut Schottmüller, 2007-09-14).
125 return
126 isset($this->blockvariables["content"][$a_blockname]) ||
127 isset($this->blockvariables[$a_blockname]);
128 }

◆ fillVars()

ilTemplate::fillVars ( )
private

all template vars defined in $vars will be replaced automatically without setting and parsing them with setVariable & parseCurrentBlock

Definition at line 251 of file class.ilTemplate.php.

251 : int
252 {
253 $count = 0;
254 foreach ($this->vars as $key => $val) {
255 if (is_array($this->blockvariables[$this->activeBlock]) &&
256 array_key_exists($key, $this->blockvariables[$this->activeBlock])
257 ) {
258 $this->setVariable($key, $val);
259 $count++;
260 }
261 }
262
263 return $count;
264 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, and HTML_Template_IT\setVariable().

Referenced by parseCurrentBlock(), and touchBlock().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

ilTemplate::get ( string  $block = ilGlobalTemplateInterface::DEFAULT_BLOCK)

Returns a block with all replacements done.

Exceptions
ilTemplateException

Reimplemented from HTML_Template_IT.

Reimplemented in ilIndependantTemplate.

Definition at line 130 of file class.ilTemplate.php.

130 : string
131 {
132 global $DIC;
133
134 $html = $this->getUnmodified($part);
135 $component_factory = $DIC["component.factory"];
136 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
137 $gui_class = $ui_plugin->getUIClassInstance();
138 $resp = $gui_class->getHTML(
139 "",
140 "template_get",
141 [
142 "tpl_id" => $this->tplIdentifier,
143 "tpl_obj" => $this,
144 "html" => $html
145 ]
146 );
147
148 if (ilUIHookPluginGUI::KEEP !== $resp["mode"]) {
149 $html = $gui_class->modifyHTML($html, $resp);
150 }
151 }
152
153 return $html;
154 }
getUnmodified(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References $DIC, XapiProxy\$resp, getUnmodified(), and ilUIHookPluginGUI\KEEP.

Referenced by ilCalendarBlockGUI\fillDataSection(), ilCalendarViewGUI\getContentByPlugins(), ilAsyncPropertyFormGUI\getErrorMessageTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilRepositoryObjectSearchBlockGUI\getLegacyContent(), ilNewsForContextBlockGUI\showFeedUrl(), ilPDNewsBlockGUI\showFeedUrl(), and ilNewsForContextBlockGUI\showNews().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTemplateIdentifier()

ilTemplate::getTemplateIdentifier ( string  $a_tplname,
string  $a_in_module = null 
)

get a unique template identifier The identifier is common for default or customized skins but distincts templates of different services with the same name.

This is used by the UI plugin hook for template input/output

Definition at line 367 of file class.ilTemplate.php.

367 : string
368 {
369 if (strpos($a_tplname, "/") === false) {
370 if (null !== $a_in_module) {
371 $module_path = $a_in_module . "/";
372 } else {
373 $module_path = "";
374 }
375
376 return $module_path . basename($a_tplname);
377 }
378
379 return $a_tplname;
380 }

Referenced by __construct(), and addBlockFile().

+ Here is the caller graph for this function:

◆ getTemplatePath()

ilTemplate::getTemplatePath ( string  $a_tplname,
string  $a_in_module = null 
)
protected
Exceptions
ilSystemStyleException

Definition at line 311 of file class.ilTemplate.php.

311 : string
312 {
313 $fname = "";
314 if (strpos($a_tplname, "/") === false) {
315 $module_path = "";
316
317 if ($a_in_module !== "") {
318 $module_path = $a_in_module . "/";
319 }
320
321 // use ilStyleDefinition instead of account to get the current skin
322 if (ilStyleDefinition::getCurrentSkin() !== "default") {
324
325 $fname = "./Customizing/global/skin/" .
326 ilStyleDefinition::getCurrentSkin() . "/" . $style . "/" . $module_path
327 . basename($a_tplname);
328
329 if ($fname === "" || !file_exists($fname)) {
330 $fname = "./Customizing/global/skin/" .
331 ilStyleDefinition::getCurrentSkin() . "/" . $module_path . basename($a_tplname);
332 }
333 }
334
335 if ($fname === "" || !file_exists($fname)) {
336 $fname = "./" . $module_path . "templates/default/" . basename($a_tplname);
337 }
338 } elseif (strpos($a_tplname, "src/UI") === 0) {
339 if (class_exists("ilStyleDefinition") // for testing
340 && ilStyleDefinition::getCurrentSkin() != "default") {
343 $base_path = "./Customizing/global/skin/";
344 $ui_path = "/" . str_replace("src/UI/templates/default", "UI", $a_tplname);
345 $fname = $base_path . ilStyleDefinition::getCurrentSkin() . "/" . $style . "/" . $ui_path;
346
347 if (!file_exists($fname)) {
348 $fname = $base_path . $skin . "/" . $ui_path;
349 }
350 }
351
352 if ($fname == "" || !file_exists($fname)) {
353 $fname = $a_tplname;
354 }
355 } else {
356 $fname = $a_tplname;
357 }
358 return $fname;
359 }
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...

References ilStyleDefinition\getCurrentSkin(), and ilStyleDefinition\getCurrentStyle().

Referenced by __construct(), and addBlockFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUnmodified()

ilTemplate::getUnmodified ( string  $part = ilGlobalTemplateInterface::DEFAULT_BLOCK)
Exceptions
ilTemplateException

Definition at line 159 of file class.ilTemplate.php.

159 : string
160 {
161 // I can't believe how garbage this is.
164 }
165
166 return parent::get($part);
167 }
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.

References ilGlobalTemplateInterface\DEFAULT_BLOCK, ILIAS\Repository\get(), and HTML_Template_IT\IT_DEFAULT_BLOCK.

Referenced by get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilTemplate::init ( )
protected

Clears all datafields of the object and rebuild the internal blocklist LoadTemplatefile() and setTemplate() automatically call this function when a new template is given.

Don't use this function unless you know what you're doing.

Exceptions
ilTemplateException

Reimplemented from HTML_Template_ITX.

Definition at line 83 of file class.ilTemplate.php.

83 : void
84 {
85 $this->free();
86 $this->buildFunctionlist();
87
88 $cache_hit = false;
89 if ($this->il_use_cache &&
90 isset(self::$il_cache[$this->il_cur_key]) &&
91 is_array(self::$il_cache[$this->il_cur_key])
92 ) {
93 $cache_hit = true;
94 $this->err = self::$il_cache[$this->il_cur_key]["err"];
95 $this->flagBlocktrouble = self::$il_cache[$this->il_cur_key]["flagBlocktrouble"];
96 $this->blocklist = self::$il_cache[$this->il_cur_key]["blocklist"];
97 $this->blockdata = self::$il_cache[$this->il_cur_key]["blockdata"];
98 $this->blockinner = self::$il_cache[$this->il_cur_key]["blockinner"];
99 $this->blockparents = self::$il_cache[$this->il_cur_key]["blockparents"];
100 $this->blockvariables = self::$il_cache[$this->il_cur_key]["blockvariables"];
101 }
102
103 if (!$cache_hit) {
104 $this->findBlocks($this->template);
105 $this->buildBlockvariablelist();
106 if ($this->il_use_cache) {
107 self::$il_cache[$this->il_cur_key]["err"] = $this->err;
108 self::$il_cache[$this->il_cur_key]["flagBlocktrouble"] = $this->flagBlocktrouble;
109 self::$il_cache[$this->il_cur_key]["blocklist"] = $this->blocklist;
110 self::$il_cache[$this->il_cur_key]["blockdata"] = $this->blockdata;
111 self::$il_cache[$this->il_cur_key]["blockinner"] = $this->blockinner;
112 self::$il_cache[$this->il_cur_key]["blockparents"] = $this->blockparents;
113 self::$il_cache[$this->il_cur_key]["blockvariables"] = $this->blockvariables;
114 }
115 }
116
117 // we don't need it anymore
118 $this->template = '';
119 }
buildFunctionlist()
Builds a functionlist from the template.
Definition: ITX.php:272
free()
Clears all datafields of the object.
Definition: IT.php:596
buildBlockvariablelist()
Build a list of all variables within of a block.
Definition: IT.php:686
array $blockparents
Array of block parents.
Definition: IT.php:195
array $blockinner
Array of inner blocks of a block.
Definition: IT.php:200
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
Definition: IT.php:705
array $blockdata
Array with the parsed content of a block.
Definition: IT.php:185
array $blocklist
Array of all blocks and their content.
Definition: IT.php:180
array $err
Contains the error objects.
Definition: IT.php:110
array $blockvariables
Array of variables in a block.
Definition: IT.php:190
bool $flagBlocktrouble
Internal flag indicating that a blockname was used multiple times.
Definition: IT.php:248
string $il_cur_key

References HTML_Template_IT\$blockdata, HTML_Template_IT\$blockinner, HTML_Template_IT\$blocklist, HTML_Template_IT\$blockparents, HTML_Template_IT\$blockvariables, HTML_Template_IT\$err, HTML_Template_IT\$flagBlocktrouble, $il_cur_key, HTML_Template_IT\buildBlockvariablelist(), HTML_Template_ITX\buildFunctionlist(), HTML_Template_IT\findBlocks(), and HTML_Template_IT\free().

+ Here is the call graph for this function:

◆ loadTemplatefile()

ilTemplate::loadTemplatefile ( string  $filename,
bool  $removeUnknownVariables = true,
bool  $removeEmptyBlocks = true 
)

Reads a template file from the disk.

Exceptions
ilTemplateException

Reimplemented from HTML_Template_IT.

Reimplemented in ilIndependantTemplate.

Definition at line 266 of file class.ilTemplate.php.

270 : bool {
271 global $DIC;
272
273 $template = '';
274 if (!$this->flagCacheTemplatefile ||
275 $this->lastTemplatefile !== $filename
276 ) {
277 $template = $this->getFile($filename);
278 }
279 $this->lastTemplatefile = $filename;
280
281 $component_factory = $DIC["component.factory"];
282 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
283 $gui_class = $ui_plugin->getUIClassInstance();
284 $resp = $gui_class->getHTML(
285 "",
286 "template_load",
287 [
288 "tpl_id" => $this->tplIdentifier,
289 "tpl_obj" => $this,
290 "html" => $template,
291 ]
292 );
293
294 if ($resp["mode"] !== ilUIHookPluginGUI::KEEP) {
295 $template = $gui_class->modifyHTML($template, $resp);
296 }
297 }
298
299 return
300 $template !== '' &&
301 $this->setTemplate(
302 $template,
305 );
306 }
$filename
Definition: buildRTE.php:78
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:160
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
Definition: IT.php:616
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:155

References HTML_Template_IT\$template, and HTML_Template_IT\getFile().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseCurrentBlock()

ilTemplate::parseCurrentBlock ( string  $part = ilGlobalTemplateInterface::DEFAULT_BLOCK)
Exceptions
ilTemplateException

Definition at line 202 of file class.ilTemplate.php.

202 : bool
203 {
204 $this->fillVars();
205 $this->activeBlock = self::IT_DEFAULT_BLOCK;
206
207 return parent::parseCurrentBlock();
208 }
fillVars()
all template vars defined in $vars will be replaced automatically without setting and parsing them wi...

References fillVars(), and HTML_Template_IT\IT_DEFAULT_BLOCK.

Referenced by ilMDEditorGUI\__fillSubelements(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilSearchRootSelector\formatHeader(), ilECSNodeMappingLocalExplorer\formatObject(), ilCalendarViewGUI\getContentByPlugins(), ilAsyncPropertyFormGUI\getErrorMessageTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilOrgUnitGenericMultiInputGUI\insert(), ilScheduleInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilOrgUnitMultiLineInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilImageWizardInputGUI\insert(), ilKVPWizardInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilCheckboxInputGUI\insert(), ilColorPickerInputGUI\insert(), ilCombinationInputGUI\insert(), ilCSSRectInputGUI\insert(), ilCustomInputGUI\insert(), ilDateDurationInputGUI\insert(), ilDateTimeInputGUI\insert(), ilDurationInputGUI\insert(), ilEMailInputGUI\insert(), ilFileInputGUI\insert(), ilFileWizardInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilHiddenInputGUI\insert(), ilImageFileInputGUI\insert(), ilLinkInputGUI\insert(), ilLocationInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilNestedListInputGUI\insert(), ilNonEditableValueGUI\insert(), ilNumberInputGUI\insert(), ilPasswordInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilSelectInputGUI\insert(), ilTextAreaInputGUI\insert(), ilTextInputGUI\insert(), ilTextWizardInputGUI\insert(), ilUserLoginInputGUI\insert(), ilMailFormAttachmentPropertyGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilTypicalLearningTimeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilFontSizeInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilClozeGapInputBuilderGUI\insert(), ilPCParagraphGUI\insertHelp(), ilFileInputGUI\outputSuffixes(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilHierarchyFormGUI\renderChild(), ilExplorerBaseGUI\renderChilds(), ilPreviewGUI\renderCommand(), ilContainerRenderer\renderDetails(), ilContainerRenderer\renderHelperGeneric(), ilCalendarSelectionBlockGUI\renderItem(), ilSurveyPageEditGUI\renderPageNode(), ilContainerRenderer\renderSelectAllBlock(), ilInfoScreenGUI\showLearningProgress(), and ilNewsForContextBlockGUI\showNews().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCurrentBlock()

ilTemplate::setCurrentBlock ( string  $part = ilGlobalTemplateInterface::DEFAULT_BLOCK)
Exceptions
ilTemplateException

Reimplemented from HTML_Template_IT.

Definition at line 172 of file class.ilTemplate.php.

172 : bool
173 {
174 // I can't believe how garbage this is.
177 }
178
179 $this->activeBlock = $part;
180 return parent::setCurrentBlock($part);
181 }

References ilGlobalTemplateInterface\DEFAULT_BLOCK, and HTML_Template_IT\IT_DEFAULT_BLOCK.

Referenced by ilContainerGUI\addHeaderRow(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilAsyncPropertyFormGUI\getErrorMessageTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilOrgUnitGenericMultiInputGUI\insert(), ilScheduleInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilOrgUnitMultiLineInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilImageWizardInputGUI\insert(), ilKVPWizardInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilCheckboxInputGUI\insert(), ilColorPickerInputGUI\insert(), ilCombinationInputGUI\insert(), ilCSSRectInputGUI\insert(), ilCustomInputGUI\insert(), ilDateDurationInputGUI\insert(), ilDateTimeInputGUI\insert(), ilDurationInputGUI\insert(), ilEMailInputGUI\insert(), ilFileInputGUI\insert(), ilFileWizardInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilHiddenInputGUI\insert(), ilImageFileInputGUI\insert(), ilLinkInputGUI\insert(), ilLocationInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilNestedListInputGUI\insert(), ilNonEditableValueGUI\insert(), ilNumberInputGUI\insert(), ilPasswordInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilSelectInputGUI\insert(), ilTextAreaInputGUI\insert(), ilTextInputGUI\insert(), ilTextWizardInputGUI\insert(), ilUserLoginInputGUI\insert(), ilMailFormAttachmentPropertyGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilTypicalLearningTimeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilFontSizeInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilClozeGapInputBuilderGUI\insert(), ilPCParagraphGUI\insertHelp(), ilFileInputGUI\outputSuffixes(), ilHierarchyFormGUI\renderChild(), ilPreviewGUI\renderCommand(), ilContainerRenderer\renderDetails(), ilContainerRenderer\renderHelperGeneric(), ilCalendarSelectionBlockGUI\renderItem(), ilSurveyPageEditGUI\renderPageNode(), ilContainerRenderer\renderSelectAllBlock(), ilNewsForContextBlockGUI\showNews(), and touchBlock().

+ Here is the caller graph for this function:

◆ touchBlock()

ilTemplate::touchBlock ( string  $block)
Exceptions
ilTemplateException

Reimplemented from HTML_Template_IT.

Definition at line 186 of file class.ilTemplate.php.

186 : bool
187 {
188 $this->setCurrentBlock($block);
189 $count = $this->fillVars();
190 $this->parseCurrentBlock();
191
192 if (0 === $count) {
193 return parent::touchBlock($block);
194 }
195
196 return false;
197 }
parseCurrentBlock()
Parses the current block.
Definition: IT.php:499
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References fillVars(), HTML_Template_IT\parseCurrentBlock(), and setCurrentBlock().

Referenced by ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilExplorer\handleListEndTags(), and ilExplorer\handleListStartTags().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ variableExists()

ilTemplate::variableExists ( string  $a_variablename)

Definition at line 382 of file class.ilTemplate.php.

382 : bool
383 {
384 return isset($this->blockvariables["content"][$a_variablename]);
385 }

Field Documentation

◆ $activeBlock

string ilTemplate::$activeBlock = ''

Aktueller Block Der wird gemerkt bei der berladenen Funktion setCurrentBlock, damit beim ParseBlock vorher ein replace auf alle Variablen gemacht werden kann, die mit dem BLockname anfangen.

Definition at line 28 of file class.ilTemplate.php.

◆ $il_cache

array ilTemplate::$il_cache = []
staticprotected

Definition at line 30 of file class.ilTemplate.php.

◆ $il_cur_key

string ilTemplate::$il_cur_key
protected

Definition at line 34 of file class.ilTemplate.php.

Referenced by init().

◆ $il_use_cache

bool ilTemplate::$il_use_cache
protected

Definition at line 32 of file class.ilTemplate.php.

◆ $tplIdentifier

string ilTemplate::$tplIdentifier
protected

Definition at line 40 of file class.ilTemplate.php.

◆ $tplName

string ilTemplate::$tplName
protected

Definition at line 36 of file class.ilTemplate.php.

◆ $tplPath

string ilTemplate::$tplPath
protected

Definition at line 38 of file class.ilTemplate.php.

Referenced by __construct().

◆ $vars

array ilTemplate::$vars = []

variablen die immer in jedem block ersetzt werden sollen

Definition at line 21 of file class.ilTemplate.php.


The documentation for this class was generated from the following file: