ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTemplate Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 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)
 
 get (string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
 
 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)
 
 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 ()
 
 getTemplatePath (string $a_tplname, string $a_in_module=null)
 
- Protected Member Functions inherited from HTML_Template_ITX
 init ()
 
- Protected Member Functions inherited from HTML_Template_IT
 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
array 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

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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.

References $tplPath, ILIAS\MetaData\Repository\Validation\Data\__construct(), getTemplateIdentifier(), getTemplatePath(), HTML_Template_IT\IT_DEFAULT_BLOCK, loadTemplatefile(), and HTML_Template_IT\setOption().

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.");
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:128
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
getTemplatePath(string $a_tplname, string $a_in_module=null)
setOption(string $option, $value)
Sets the option for the template class.
Definition: IT.php:353
__construct(VocabulariesInterface $vocabularies)
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...
+ 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.

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

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  }
string $template
Content of the template.
Definition: IT.php:201
getTemplatePath(string $a_tplname, string $a_in_module=null)
global $DIC
Definition: feed.php:28
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:779
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...
$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
+ Here is the call graph for this function:

◆ blockExists()

ilTemplate::blockExists ( string  $a_blockname)

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

Referenced by ilTinyMCE\handleImgContextMenuItem().

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  }
+ Here is the caller graph for this function:

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

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

Referenced by parseCurrentBlock(), and touchBlock().

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:546
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

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

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

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

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

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)
global $DIC
Definition: feed.php:28
+ 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 377 of file class.ilTemplate.php.

Referenced by __construct(), and addBlockFile().

377  : string
378  {
379  if (strpos($a_tplname, "/") === false) {
380  if (null !== $a_in_module) {
381  $module_path = $a_in_module . "/";
382  } else {
383  $module_path = "";
384  }
385 
386  return $module_path . basename($a_tplname);
387  }
388 
389  return $a_tplname;
390  }
+ 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 321 of file class.ilTemplate.php.

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

Referenced by __construct(), and addBlockFile().

321  : string
322  {
323  $fname = "";
324  if (strpos($a_tplname, "/") === false) {
325  $module_path = "";
326 
327  if ($a_in_module !== "") {
328  $module_path = $a_in_module . "/";
329  }
330 
331  // use ilStyleDefinition instead of account to get the current skin
332  if (ilStyleDefinition::getCurrentSkin() !== "default") {
334 
335  $fname = "./Customizing/global/skin/" .
336  ilStyleDefinition::getCurrentSkin() . "/" . $style . "/" . $module_path
337  . basename($a_tplname);
338 
339  if ($fname === "" || !file_exists($fname)) {
340  $fname = "./Customizing/global/skin/" .
341  ilStyleDefinition::getCurrentSkin() . "/" . $module_path . basename($a_tplname);
342  }
343  }
344 
345  if ($fname === "" || !file_exists($fname)) {
346  $fname = "./" . $module_path . "templates/default/" . basename($a_tplname);
347  }
348  } elseif (strpos($a_tplname, "src/UI") === 0) {
349  if (class_exists("ilStyleDefinition") // for testing
350  && ilStyleDefinition::getCurrentSkin() != "default") {
353  $base_path = "./Customizing/global/skin/";
354  $ui_path = "/" . str_replace("src/UI/templates/default", "UI", $a_tplname);
355  $fname = $base_path . ilStyleDefinition::getCurrentSkin() . "/" . $style . "/" . $ui_path;
356 
357  if (!file_exists($fname)) {
358  $fname = $base_path . $skin . "/" . $ui_path;
359  }
360  }
361 
362  if ($fname == "" || !file_exists($fname)) {
363  $fname = $a_tplname;
364  }
365  } else {
366  $fname = $a_tplname;
367  }
368  return $fname;
369  }
static getCurrentSkin()
get the current skin use always this function instead of getting the account&#39;s skin the current skin ...
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account&#39;s style th...
+ 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 173 of file class.ilTemplate.php.

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

Referenced by get().

173  : string
174  {
175  // I can't believe how garbage this is.
177  $part = self::IT_DEFAULT_BLOCK;
178  }
179 
180  return parent::get($part);
181  }
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilTemplate::init ( )
protected

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

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().

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  }
array $blockparents
Array of block parents.
Definition: IT.php:221
array $blockvariables
Array of variables in a block.
Definition: IT.php:216
bool $flagBlocktrouble
Internal flag indicating that a blockname was used multiple times.
Definition: IT.php:274
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
Definition: IT.php:734
free()
Clears all datafields of the object.
Definition: IT.php:625
string $il_cur_key
buildBlockvariablelist()
Build a list of all variables within of a block.
Definition: IT.php:715
array $blockinner
Array of inner blocks of a block.
Definition: IT.php:226
array $err
Contains the error objects.
Definition: IT.php:136
array $blockdata
Array with the parsed content of a block.
Definition: IT.php:211
array $blocklist
Array of all blocks and their content.
Definition: IT.php:206
buildFunctionlist()
Builds a functionlist from the template.
Definition: ITX.php:272
+ Here is the call graph for this function:

◆ loadTemplatefile()

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

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

References $DIC, $filename, HTML_Template_IT\$removeEmptyBlocks, HTML_Template_IT\$removeUnknownVariables, XapiProxy\$resp, HTML_Template_IT\$template, HTML_Template_IT\getFile(), ilUIHookPluginGUI\KEEP, and HTML_Template_IT\setTemplate().

Referenced by __construct().

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  }
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
Definition: IT.php:645
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:186
string $template
Content of the template.
Definition: IT.php:201
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:181
global $DIC
Definition: feed.php:28
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:779
$filename
Definition: buildRTE.php:78
+ 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.

References fillVars().

Referenced by ilContainerRenderer\addHeaderRow(), ilContainerGUI\addHeaderRow(), ilContainerGUI\addMessageRow(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilExerciseGSToolProvider\addSection(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilKprimChoiceCorrectionsInputGUI\checkInput(), ilKprimChoiceWizardInputGUI\checkInput(), ilTimingsCronReminder\fillObjectListForMailBody(), ilStudyProgrammeProgressListGUI\fillTemplate(), ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilSCORMExplorer\formatHeader(), ilContainerSelectionExplorer\formatHeader(), ilSearchRootSelector\formatHeader(), ilECSNodeMappingLocalExplorer\formatHeader(), ilECSNodeMappingCmsExplorer\formatHeader(), ilPasteIntoMultipleItemsExplorer\formatHeader(), ilRepositoryExplorer\formatHeader(), ilECSNodeMappingLocalExplorer\formatObject(), ilPasteIntoMultipleItemsExplorer\formatObject(), ilExplorer\formatObject(), ilCalendarViewGUI\getContentByPlugins(), ilAsyncPropertyFormGUI\getErrorMessageTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilSCORMExplorer\getOutputIcons(), ilMailFormAttachmentPropertyGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilCustomInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilUserLoginInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilNonEditableValueGUI\insert(), ilCheckboxInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDurationInputGUI\insert(), ilFileWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilColorPickerInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilCombinationInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilNumberInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilDateTimeInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilOrgUnitGenericMultiInputGUI\insert(), ilOrgUnitMultiLineInputGUI\insert(), ilFileInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilTextInputGUI\insert(), ilDateDurationInputGUI\insert(), ilLinkInputGUI\insert(), ilPCParagraphGUI\insertCharacteristicTable(), ilPCParagraphGUI\insertHelp(), ilSCORMExplorer\insertObject(), ilNestedList\listItemStart(), ilObjStudyProgrammeTreeExplorerGUI\listItemStart(), ilExplorerBaseGUI\listItemStart(), ilNestedList\listStart(), ilSurveyExecutionGUI\outNavigationButtons(), SurveyMetricQuestion\outPreconditionSelectValue(), ilFileInputGUI\outputSuffixes(), ilTestQuestionNavigationGUI\parseButtonsBlock(), ilObjStudyProgrammeTreeExplorerGUI\parseLeafNodeButtons(), ilTestQuestionNavigationGUI\parseNavigation(), ilObjStudyProgrammeTreeExplorerGUI\parseStudyProgrammeNodeButtons(), ilAssQuestionPreviewGUI\populateCommentsPanel(), ilAssQuestionPreviewGUI\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilPollAnswersRenderer\render(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderActionButton(), ilTestQuestionNavigationGUI\renderActionsIcon(), ilPollAnswersRenderer\renderAnswer(), ilPollResultsRenderer\renderBarChart(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilHierarchyFormGUI\renderChild(), ilExplorerBaseGUI\renderChilds(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilTestQuestionNavigationGUI\renderIcon(), ilCalendarSelectionBlockGUI\renderItem(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderLinkList(), ilNestedList\renderNode(), ilExplorerBaseGUI\renderNode(), ilObjForumGUI\renderPostContent(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), ilContainerRenderer\renderSelectAllBlock(), ilClozeGapInputBuilderGUI\setValueByArray(), ilInfoScreenGUI\showLearningProgress(), and ilNewsForContextBlockGUI\showNews().

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

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

References ilGlobalTemplateInterface\DEFAULT_BLOCK.

Referenced by ilContainerRenderer\addHeaderRow(), ilContainerGUI\addHeaderRow(), ilContainerGUI\addMessageRow(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ilExerciseGSToolProvider\addSection(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilKprimChoiceCorrectionsInputGUI\checkInput(), ilKprimChoiceWizardInputGUI\checkInput(), ilTimingsCronReminder\fillObjectListForMailBody(), ilStudyProgrammeProgressListGUI\fillTemplate(), ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilSCORMExplorer\formatHeader(), ilContainerSelectionExplorer\formatHeader(), ilSearchRootSelector\formatHeader(), ilECSNodeMappingLocalExplorer\formatHeader(), ilECSNodeMappingCmsExplorer\formatHeader(), ilPasteIntoMultipleItemsExplorer\formatHeader(), ilRepositoryExplorer\formatHeader(), ilECSNodeMappingLocalExplorer\formatObject(), ilPasteIntoMultipleItemsExplorer\formatObject(), ilExplorer\formatObject(), ilAsyncPropertyFormGUI\getErrorMessageTemplate(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilSCORMExplorer\getOutputIcons(), ilMailFormAttachmentPropertyGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilCustomInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilUserLoginInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilNonEditableValueGUI\insert(), ilCheckboxInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDurationInputGUI\insert(), ilFileWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilColorPickerInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilCombinationInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilNumberInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilDateTimeInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilOrgUnitGenericMultiInputGUI\insert(), ilOrgUnitMultiLineInputGUI\insert(), ilFileInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilTextInputGUI\insert(), ilDateDurationInputGUI\insert(), ilLinkInputGUI\insert(), ilPCParagraphGUI\insertCharacteristicTable(), ilPCParagraphGUI\insertHelp(), ilPropertyFormGUI\insertItem(), ilSCORMExplorer\insertObject(), ilNestedList\listItemStart(), ilObjStudyProgrammeTreeExplorerGUI\listItemStart(), ilExplorerBaseGUI\listItemStart(), ilNestedList\listStart(), ilSurveyExecutionGUI\outNavigationButtons(), SurveyMetricQuestion\outPreconditionSelectValue(), ilFileInputGUI\outputSuffixes(), ilTestQuestionNavigationGUI\parseButtonsBlock(), ilObjStudyProgrammeTreeExplorerGUI\parseLeafNodeButtons(), ilTestQuestionNavigationGUI\parseNavigation(), ilObjStudyProgrammeTreeExplorerGUI\parseStudyProgrammeNodeButtons(), ilAssQuestionPreviewGUI\populateCommentsPanel(), ilAssQuestionPreviewGUI\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilPollAnswersRenderer\render(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderActionButton(), ilTestQuestionNavigationGUI\renderActionsIcon(), ilPollResultsRenderer\renderBarChart(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilHierarchyFormGUI\renderChild(), ilExplorerBaseGUI\renderChilds(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilTestQuestionNavigationGUI\renderIcon(), ilCalendarSelectionBlockGUI\renderItem(), ILIAS\Exercise\Assignment\PanelBuilderUI\renderLinkList(), ilNestedList\renderNode(), ilExplorerBaseGUI\renderNode(), ilObjForumGUI\renderPostContent(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), ilContainerRenderer\renderSelectAllBlock(), ilObjForumGUI\renderSplitButton(), ilClozeGapInputBuilderGUI\setValueByArray(), ilNewsForContextBlockGUI\showNews(), and touchBlock().

186  : bool
187  {
188  // I can't believe how garbage this is.
190  $part = self::IT_DEFAULT_BLOCK;
191  }
192 
193  $this->activeBlock = $part;
194  return parent::setCurrentBlock($part);
195  }
+ Here is the caller graph for this function:

◆ touchBlock()

ilTemplate::touchBlock ( string  $block)
Exceptions
ilTemplateException

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

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

Referenced by ilContainerRenderer\addHeaderRow(), ilContainerGUI\addHeaderRow(), ilContainerGUI\addMessageRow(), ilContainerRenderer\addStandardRow(), ilStudyProgrammeExpandableProgressListGUI\fillTemplate(), ilECSNodeMappingLocalExplorer\formatObject(), ilPasteIntoMultipleItemsExplorer\formatObject(), ilExplorer\formatObject(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilTinyMCE\handleImgContextMenuItem(), ilExplorer\handleListEndTags(), ilExplorer\handleListStartTags(), ilPCParagraphGUI\insertCharacteristicTable(), ilNestedList\listEnd(), ilExplorerBaseGUI\listEnd(), ilNestedList\listItemEnd(), ilExplorerBaseGUI\listItemEnd(), ilNestedList\listItemStart(), ilObjStudyProgrammeTreeExplorerGUI\listItemStart(), ilExplorerBaseGUI\listItemStart(), ilNestedList\listStart(), ilExplorerBaseGUI\listStart(), ilExplorerBaseGUI\renderChilds(), ilNestedList\renderNode(), and ilExplorerBaseGUI\renderNode().

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:531
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
fillVars()
all template vars defined in $vars will be replaced automatically without setting and parsing them wi...
+ 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 392 of file class.ilTemplate.php.

392  : bool
393  {
394  return isset($this->blockvariables["content"][$a_variablename]);
395  }

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: