ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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...
 
 getCurrentSkin ()
 
 getCurrentStyle ()
 
 fileExistsInSkin (string $path)
 
 getTemplatePath (string $a_tplname, string $a_in_module='')
 
 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 30 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 68 of file class.ilTemplate.php.

76 {
77 $this->activeBlock = HTML_Template_IT::IT_DEFAULT_BLOCK;
78 $this->il_use_cache = $a_use_cache;
79 $this->il_cur_key = $file . "/" . $in_module;
80
81 $fname = $this->getTemplatePath($file, $in_module);
82 if (!file_exists($fname)) {
83 throw new ilTemplateException("Template '$fname' was not found.\nfile: " . $file . "\nmodule: " . $in_module);
84 }
85
86 $this->tplName = basename($fname);
87 $this->tplPath = dirname($fname);
88 $this->vars["TPLPATH"] = $this->tplPath;
89 $this->tplIdentifier = $this->getTemplateIdentifier($file, $in_module);
90
92
93 $this->loadTemplatefile($fname, $flag1, $flag2);
94 $this->setOption('use_preg', false);
95 }
const IT_DEFAULT_BLOCK
Definition: IT.php:126
setOption(string $option, $value)
Sets the option for the template class.
Definition: IT.php:351
getTemplatePath(string $a_tplname, string $a_in_module='')
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 224 of file class.ilTemplate.php.

224 : bool
225 {
226 global $DIC;
227
228 $tplfile = $this->getTemplatePath($tplname, $in_module ?? '');
229 if (file_exists($tplfile) === false) {
230 echo "<br/>Template '" . $tplfile . "' doesn't exist! aborting...";
231 return false;
232 }
233
234 $id = $this->getTemplateIdentifier($tplname, $in_module);
235 $template = $this->getFile($tplfile);
236 $component_factory = $DIC["component.factory"];
237 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
238 $gui_class = $ui_plugin->getUIClassInstance();
239 $resp = $gui_class->getHTML(
240 "",
241 "template_add",
242 [
243 "tpl_id" => $id,
244 "tpl_obj" => $this,
245 "html" => $template,
246 ]
247 );
248
249 if ($resp["mode"] !== ilUIHookPluginGUI::KEEP) {
250 $template = $gui_class->modifyHTML($template, $resp);
251 }
252 }
253
254 return $this->addBlock($var, $block, $template);
255 }
$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:186
string $template
Content of the template.
Definition: IT.php:199
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:777
global $DIC
Definition: shib_login.php:26

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 135 of file class.ilTemplate.php.

135 : bool
136 {
137 // added second evaluation to the return statement because the first one
138 // only works for the content block (Helmut Schottmüller, 2007-09-14).
139 return
140 isset($this->blockvariables["content"][$a_blockname]) ||
141 isset($this->blockvariables[$a_blockname]);
142 }

◆ fileExistsInSkin()

ilTemplate::fileExistsInSkin ( string  $path)
protected

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

330 : bool
331 {
332 return file_exists($path);
333 }
$path
Definition: ltiservices.php:30

References $path.

◆ 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 261 of file class.ilTemplate.php.

261 : int
262 {
263 $count = 0;
264 foreach ($this->vars as $key => $val) {
265 if (is_array($this->blockvariables[$this->activeBlock]) &&
266 array_key_exists($key, $this->blockvariables[$this->activeBlock])
267 ) {
268 $this->setVariable($key, $val);
269 $count++;
270 }
271 }
272
273 return $count;
274 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

References 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.

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

144 : string
145 {
146 global $DIC;
147
148 $html = $this->getUnmodified($part);
149 $component_factory = $DIC["component.factory"];
150 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
151 $gui_class = $ui_plugin->getUIClassInstance();
152 $resp = $gui_class->getHTML(
153 "",
154 "template_get",
155 [
156 "tpl_id" => $this->tplIdentifier,
157 "tpl_obj" => $this,
158 "html" => $html
159 ]
160 );
161
162 if (ilUIHookPluginGUI::KEEP !== $resp["mode"]) {
163 $html = $gui_class->modifyHTML($html, $resp);
164 }
165 }
166
167 return $html;
168 }
getUnmodified(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

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

Referenced by ilObjForumGUI\createThreadObject(), ilCalendarViewGUI\getContentByPlugins(), ilCalendarBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilRepositoryObjectSearchBlockGUI\getLegacyContent(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilTestPlayerAbstractGUI\getQuestionFeedbackModalHtml(), ilNewsForContextBlockGUI\showFeedUrl(), ilPDNewsBlockGUI\showFeedUrl(), and ilNewsForContextBlockGUI\showNews().

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

◆ getCurrentSkin()

ilTemplate::getCurrentSkin ( )
protected

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

319 : ?string
320 {
321 // use ilStyleDefinition instead of account to get the current skin
323 }
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...

References ilStyleDefinition\getCurrentSkin().

+ Here is the call graph for this function:

◆ getCurrentStyle()

ilTemplate::getCurrentStyle ( )
protected

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

325 : ?string
326 {
328 }
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...

References ilStyleDefinition\getCurrentStyle().

+ Here is the call 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 389 of file class.ilTemplate.php.

389 : string
390 {
391 if (strpos($a_tplname, "/") === false) {
392 if (null !== $a_in_module) {
393 $module_path = $a_in_module . "/";
394 } else {
395 $module_path = "";
396 }
397
398 return $module_path . basename($a_tplname);
399 }
400
401 return $a_tplname;
402 }

Referenced by __construct(), and addBlockFile().

+ Here is the caller graph for this function:

◆ getTemplatePath()

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

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

338 : string
339 {
340 $ilias_root = realpath(__DIR__ . '/../../../../') . '/';
341
342 if (str_starts_with($a_in_module, $ilias_root)) {
343 $a_in_module = str_replace($ilias_root, '', $a_in_module);
344 }
345
346 if (str_ends_with($a_in_module, '/')) {
347 $a_in_module = rtrim($a_in_module, '/');
348 }
349
350 $tpl_sub_path = '/templates/default/';
351 if (str_starts_with($a_tplname, 'components/ILIAS/UI/')) {
352 $a_in_module = 'components/ILIAS/UI/src';
353 $a_tplname = str_replace('components/ILIAS/UI/src/templates/default/', '', $a_tplname);
354 }
355
356 if (str_starts_with($a_tplname, $ilias_root)) {
357 $a_tplname = str_replace($ilias_root, '', $a_tplname);
358 }
359 if (strpos($a_tplname, 'public/Customizing/global/plugins')) {
360 $tpl_sub_path = '';
361 }
362
363 $base_path = $ilias_root;
364 $default = $base_path . $a_in_module . $tpl_sub_path . $a_tplname;
365
366 $skin = $this->getCurrentSkin();
367 if ($skin === 'default') {
368 return $default;
369 }
370
371 $style = $this->getCurrentStyle();
372 $base_path .= 'public/Customizing/skin/' . $skin . '/' . $style;
373
374 if ($a_in_module === 'components/ILIAS/UI/src') {
375 $a_in_module = 'UI';
376 }
377
378 $from_skin = $base_path . '/' . $a_in_module . '/' . $a_tplname;
379
380 return $this->fileExistsInSkin($from_skin) ? $from_skin : $default;
381 }
fileExistsInSkin(string $path)

Referenced by __construct(), and addBlockFile().

+ Here is the caller graph for this function:

◆ getUnmodified()

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

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

173 : string
174 {
175 // I can't believe how garbage this is.
178 }
179
180 return parent::get($part);
181 }
get(string $class_name)

References ILIAS\UICore\GlobalTemplate\DEFAULT_BLOCK, ILIAS\GlobalScreen\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 97 of file class.ilTemplate.php.

97 : void
98 {
99 $this->free();
100 $this->buildFunctionlist();
101
102 $cache_hit = false;
103 if ($this->il_use_cache &&
104 isset(self::$il_cache[$this->il_cur_key]) &&
105 is_array(self::$il_cache[$this->il_cur_key])
106 ) {
107 $cache_hit = true;
108 $this->err = self::$il_cache[$this->il_cur_key]["err"];
109 $this->flagBlocktrouble = self::$il_cache[$this->il_cur_key]["flagBlocktrouble"];
110 $this->blocklist = self::$il_cache[$this->il_cur_key]["blocklist"];
111 $this->blockdata = self::$il_cache[$this->il_cur_key]["blockdata"];
112 $this->blockinner = self::$il_cache[$this->il_cur_key]["blockinner"];
113 $this->blockparents = self::$il_cache[$this->il_cur_key]["blockparents"];
114 $this->blockvariables = self::$il_cache[$this->il_cur_key]["blockvariables"];
115 }
116
117 if (!$cache_hit) {
118 $this->findBlocks($this->template);
119 $this->buildBlockvariablelist();
120 if ($this->il_use_cache) {
121 self::$il_cache[$this->il_cur_key]["err"] = $this->err;
122 self::$il_cache[$this->il_cur_key]["flagBlocktrouble"] = $this->flagBlocktrouble;
123 self::$il_cache[$this->il_cur_key]["blocklist"] = $this->blocklist;
124 self::$il_cache[$this->il_cur_key]["blockdata"] = $this->blockdata;
125 self::$il_cache[$this->il_cur_key]["blockinner"] = $this->blockinner;
126 self::$il_cache[$this->il_cur_key]["blockparents"] = $this->blockparents;
127 self::$il_cache[$this->il_cur_key]["blockvariables"] = $this->blockvariables;
128 }
129 }
130
131 // we don't need it anymore
132 $this->template = '';
133 }
buildFunctionlist()
Builds a functionlist from the template.
Definition: ITX.php:285
free()
Clears all datafields of the object.
Definition: IT.php:623
buildBlockvariablelist()
Build a list of all variables within of a block.
Definition: IT.php:713
array $blockparents
Array of block parents.
Definition: IT.php:219
array $blockinner
Array of inner blocks of a block.
Definition: IT.php:224
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
Definition: IT.php:732
array $blockdata
Array with the parsed content of a block.
Definition: IT.php:209
array $blocklist
Array of all blocks and their content.
Definition: IT.php:204
array $err
Contains the error objects.
Definition: IT.php:134
array $blockvariables
Array of variables in a block.
Definition: IT.php:214
bool $flagBlocktrouble
Internal flag indicating that a blockname was used multiple times.
Definition: IT.php:272
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 276 of file class.ilTemplate.php.

280 : bool {
281 global $DIC;
282
283 $template = '';
284 if (!$this->flagCacheTemplatefile ||
285 $this->lastTemplatefile !== $filename
286 ) {
287 $template = $this->getFile($filename);
288 }
289 $this->lastTemplatefile = $filename;
290
291 $component_factory = $DIC["component.factory"];
292 foreach ($component_factory->getActivePluginsInSlot("uihk") as $ui_plugin) {
293 $gui_class = $ui_plugin->getUIClassInstance();
294 $resp = $gui_class->getHTML(
295 "",
296 "template_load",
297 [
298 "tpl_id" => $this->tplIdentifier,
299 "tpl_obj" => $this,
300 "html" => $template,
301 ]
302 );
303
304 if ($resp["mode"] !== ilUIHookPluginGUI::KEEP) {
305 $template = $gui_class->modifyHTML($template, $resp);
306 }
307 }
308
309 return
310 $template !== '' &&
311 $this->setTemplate(
312 $template,
315 );
316 }
$filename
Definition: buildRTE.php:78
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:184
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
Definition: IT.php:643
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:179

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 216 of file class.ilTemplate.php.

216 : bool
217 {
218 $this->fillVars();
219 $this->activeBlock = self::IT_DEFAULT_BLOCK;
220
221 return parent::parseCurrentBlock();
222 }
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 ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilObjForumGUI\createThreadObject(), ilTimingsCronReminder\fillObjectListForMailBody(), ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilSearchRootSelector\formatHeader(), ilPasteIntoMultipleItemsExplorer\formatHeader(), ilECSNodeMappingLocalExplorer\formatObject(), ilPasteIntoMultipleItemsExplorer\formatObject(), ilCalendarViewGUI\getContentByPlugins(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilOrgUnitGenericMultiInputGUI\insert(), ilScheduleInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDclGenericMultiInputGUI\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(), ilOrgUnitAuthorityInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilFontSizeInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilKprimChoiceWizardInputGUI\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(), ilExplorerSelectInputGUI\insert(), ilTagInputGUI\insert(), ilPCParagraphGUI\insertHelp(), ilNestedList\listItemStart(), ilNestedList\listStart(), ilFileInputGUI\outputSuffixes(), ilTestQuestionNavigationGUI\parseButtonsBlock(), ilTestQuestionNavigationGUI\parseNavigation(), ilAssQuestionPreviewGUI\populateCommentsPanel(), assMatchingQuestionGUI\populateDefinition(), ilAssQuestionPreviewGUI\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilPollAnswersRenderer\render(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderActionButton(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilExplorerBaseGUI\renderChilds(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilCalendarSelectionBlockGUI\renderItem(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderLinkList(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), 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 186 of file class.ilTemplate.php.

186 : bool
187 {
188 // I can't believe how garbage this is.
191 }
192
193 $this->activeBlock = $part;
194 return parent::setCurrentBlock($part);
195 }

References ILIAS\UICore\GlobalTemplate\DEFAULT_BLOCK, and HTML_Template_IT\IT_DEFAULT_BLOCK.

Referenced by ilContainerGUI\addHeaderRow(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilTimingsCronReminder\fillObjectListForMailBody(), ilPasteIntoMultipleItemsExplorer\formatHeader(), ilPasteIntoMultipleItemsExplorer\formatObject(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilWikiFunctionsBlockGUI\getLegacyContent(), assTextQuestionGUI\getPreview(), SurveyMultipleChoiceQuestionGUI\getWorkingForm(), ilOrgUnitGenericMultiInputGUI\insert(), ilScheduleInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDclGenericMultiInputGUI\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(), ilOrgUnitAuthorityInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilFontSizeInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilKprimChoiceWizardInputGUI\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(), ilExplorerSelectInputGUI\insert(), ilPCParagraphGUI\insertHelp(), ilPropertyFormGUI\insertItem(), ilNestedList\listItemStart(), ilNestedList\listStart(), ilFileInputGUI\outputSuffixes(), ilTestQuestionNavigationGUI\parseButtonsBlock(), ilTestQuestionNavigationGUI\parseNavigation(), ilAssQuestionPreviewGUI\populateCommentsPanel(), assMatchingQuestionGUI\populateDefinition(), ilAssQuestionPreviewGUI\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilPollAnswersRenderer\render(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderActionButton(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilCalendarSelectionBlockGUI\renderItem(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderLinkList(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), 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 200 of file class.ilTemplate.php.

200 : bool
201 {
202 $this->setCurrentBlock($block);
203 $count = $this->fillVars();
204 $this->parseCurrentBlock();
205
206 if (0 === $count) {
207 return parent::touchBlock($block);
208 }
209
210 return false;
211 }
parseCurrentBlock()
Parses the current block.
Definition: IT.php:529
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

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

Referenced by ilPasteIntoMultipleItemsExplorer\formatObject(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilExplorer\handleListEndTags(), ilExplorer\handleListStartTags(), ilNestedList\listEnd(), ilNestedList\listItemEnd(), ilNestedList\listItemStart(), and ilNestedList\listStart().

+ 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 404 of file class.ilTemplate.php.

404 : bool
405 {
406 return isset($this->blockvariables["content"][$a_variablename]);
407 }

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 42 of file class.ilTemplate.php.

◆ $il_cache

array ilTemplate::$il_cache = []
staticprotected

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

◆ $il_cur_key

string ilTemplate::$il_cur_key
protected

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

Referenced by init().

◆ $il_use_cache

bool ilTemplate::$il_use_cache
protected

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

◆ $tplIdentifier

string ilTemplate::$tplIdentifier
protected

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

◆ $tplName

string ilTemplate::$tplName
protected

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

◆ $tplPath

string ilTemplate::$tplPath
protected

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

Referenced by __construct().

◆ $vars

array ilTemplate::$vars = []

variablen die immer in jedem block ersetzt werden sollen

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


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