ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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

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.

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

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
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:321
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)
+ 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.

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

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  }
string $template
Content of the template.
Definition: IT.php:175
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:750
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 121 of file class.ilTemplate.php.

Referenced by ilTinyMCE\handleImgContextMenuItem().

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

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

Referenced by parseCurrentBlock(), and touchBlock().

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

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

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

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

Referenced by __construct(), and addBlockFile().

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

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

Referenced by __construct(), and addBlockFile().

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&#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 159 of file class.ilTemplate.php.

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

Referenced by get().

159  : string
160  {
161  // I can't believe how garbage this is.
163  $part = self::IT_DEFAULT_BLOCK;
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilTemplate::init ( )
protected

Definition at line 83 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().

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  }
array $blockparents
Array of block parents.
Definition: IT.php:195
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
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
Definition: IT.php:705
free()
Clears all datafields of the object.
Definition: IT.php:596
string $il_cur_key
buildBlockvariablelist()
Build a list of all variables within of a block.
Definition: IT.php:686
array $blockinner
Array of inner blocks of a block.
Definition: IT.php:200
array $err
Contains the error objects.
Definition: IT.php:110
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
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 266 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().

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  }
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
Definition: IT.php:616
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:160
string $template
Content of the template.
Definition: IT.php:175
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:155
global $DIC
Definition: feed.php:28
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:750
$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 202 of file class.ilTemplate.php.

References fillVars().

Referenced by ilMDEditorGUI\__fillSubelements(), ilContainerSessionsContentGUI\addFooterRow(), 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(), ilAssLongmenuCorrectionsInputGUI\insert(), ilMailFormAttachmentPropertyGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilCustomInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilUserLoginInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTypicalLearningTimeInputGUI\insert(), ilNonEditableValueGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilCheckboxInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDurationInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilFileWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilSelectInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilCombinationInputGUI\insert(), ilImageWizardInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilClozeGapInputBuilderGUI\insert(), ilAnswerWizardInputGUI\insert(), ilNumberInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilKVPWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilDateTimeInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilDclGenericMultiInputGUI\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\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateNotesPanel(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilTestQuestionNavigationGUI\renderActionsIcon(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilHierarchyFormGUI\renderChild(), ilExplorerBaseGUI\renderChilds(), ilPreviewGUI\renderCommand(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilTestQuestionNavigationGUI\renderIcon(), ilCalendarSelectionBlockGUI\renderItem(), ilNestedList\renderNode(), ilExplorerBaseGUI\renderNode(), ilSurveyPageEditGUI\renderPageNode(), ilObjForumGUI\renderPostContent(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), ilContainerRenderer\renderSelectAllBlock(), ilInfoScreenGUI\showLearningProgress(), and ilNewsForContextBlockGUI\showNews().

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

References ilGlobalTemplateInterface\DEFAULT_BLOCK.

Referenced by ilMDEditorGUI\__fillSubelements(), ilContainerSessionsContentGUI\addFooterRow(), 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(), ilAssLongmenuCorrectionsInputGUI\insert(), ilMailFormAttachmentPropertyGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilCustomInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilGloAdvColSortInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilUserLoginInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTypicalLearningTimeInputGUI\insert(), ilNonEditableValueGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilCheckboxInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilDurationInputGUI\insert(), ilFileWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilSelectInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilCombinationInputGUI\insert(), ilImageWizardInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilClozeGapInputBuilderGUI\insert(), ilNumberInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilKVPWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilDateTimeInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilDclGenericMultiInputGUI\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\populateGenericQuestionFeedback(), ilAssQuestionPreviewGUI\populateInstantResponseHeader(), ilAssQuestionPreviewGUI\populateInstantResponseMessage(), ilAssQuestionPreviewGUI\populateNotesPanel(), ilAssQuestionPreviewGUI\populateReachedPointsOutput(), ilAssQuestionPreviewGUI\populateSolutionOutput(), ilAssQuestionPreviewGUI\populateSpecificQuestionFeedback(), ilTestQuestionNavigationGUI\renderActionsIcon(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilHierarchyFormGUI\renderChild(), ilExplorerBaseGUI\renderChilds(), ilPreviewGUI\renderCommand(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), ilTestQuestionNavigationGUI\renderIcon(), ilCalendarSelectionBlockGUI\renderItem(), ilNestedList\renderNode(), ilExplorerBaseGUI\renderNode(), ilSurveyPageEditGUI\renderPageNode(), ilObjForumGUI\renderPostContent(), ilAssLacLegendGUI\renderQuestSpecificLegendPart(), ilContainerRenderer\renderSelectAllBlock(), ilObjForumGUI\renderSplitButton(), ilNewsForContextBlockGUI\showNews(), and touchBlock().

172  : bool
173  {
174  // I can't believe how garbage this is.
176  $part = self::IT_DEFAULT_BLOCK;
177  }
178 
179  $this->activeBlock = $part;
180  return parent::setCurrentBlock($part);
181  }
+ Here is the caller graph for this function:

◆ touchBlock()

ilTemplate::touchBlock ( string  $block)
Exceptions
ilTemplateException

Definition at line 186 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(), ilExplorerBaseGUI\renderNode(), and ilSurveyPageEditGUI\renderPageNode().

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)
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 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: