ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 ()
 
 getCurrentSkin ()
 
 getCurrentStyle ()
 
 fileExistsInSkin (string $path)
 
 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 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\GlobalScreen\Provider\__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  }
getTemplatePath(string $a_tplname, ?string $a_in_module=null)
const IT_DEFAULT_BLOCK
Definition: IT.php:126
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
setOption(string $option, $value)
Sets the option for the template class.
Definition: IT.php:351
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 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:199
getTemplatePath(string $a_tplname, ?string $a_in_module=null)
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:777
global $DIC
Definition: shib_login.php:22
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:186
+ Here is the call graph for this function:

◆ blockExists()

ilTemplate::blockExists ( string  $a_blockname)

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.

Referenced by getTemplatePath().

330  : bool
331  {
332  return file_exists($path);
333  }
$path
Definition: ltiservices.php:29
+ 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 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:544
+ 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(), ilRepositoryObjectSearchBlockGUI\getLegacyContent(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilCalendarBlockGUI\getLegacyContent(), ilTestPlayerAbstractGUI\getQuestionFeedbackModalHtml(), 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: shib_login.php:22
+ 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.

References ilStyleDefinition\getCurrentSkin().

Referenced by getTemplatePath().

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&#39;s skin the current skin ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentStyle()

ilTemplate::getCurrentStyle ( )
protected

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

References ilStyleDefinition\getCurrentStyle().

Referenced by getTemplatePath().

325  : ?string
326  {
328  }
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:

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

References null.

Referenced by __construct(), and addBlockFile().

381  : string
382  {
383  if (strpos($a_tplname, "/") === false) {
384  if (null !== $a_in_module) {
385  $module_path = $a_in_module . "/";
386  } else {
387  $module_path = "";
388  }
389 
390  return $module_path . basename($a_tplname);
391  }
392 
393  return $a_tplname;
394  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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 338 of file class.ilTemplate.php.

References fileExistsInSkin(), getCurrentSkin(), and getCurrentStyle().

Referenced by __construct(), and addBlockFile().

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  if (str_starts_with($a_tplname, 'components/ILIAS/UI/')) {
351  $a_in_module = 'components/ILIAS/UI/src';
352  $a_tplname = str_replace('components/ILIAS/UI/src/templates/default/', '', $a_tplname);
353  }
354 
355  $base_path = $ilias_root;
356  $default = $base_path . $a_in_module . '/templates/default/' . $a_tplname;
357 
358  $skin = $this->getCurrentSkin();
359  if ($skin === 'default') {
360  return $default;
361  }
362 
363  $style = $this->getCurrentStyle();
364  $base_path .= 'public/Customizing/skin/' . $skin . '/' . $style;
365 
366  if ($a_in_module === 'components/ILIAS/UI/src') {
367  $a_in_module = 'UI';
368  }
369 
370  $from_skin = $base_path . '/' . $a_in_module . '/' . $a_tplname;
371 
372  return $this->fileExistsInSkin($from_skin) ? $from_skin : $default;
373  }
fileExistsInSkin(string $path)
+ 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 ILIAS\UICore\GlobalTemplate\DEFAULT_BLOCK, and ILIAS\GlobalScreen\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 $class_name)
+ 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:219
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
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
Definition: IT.php:732
free()
Clears all datafields of the object.
Definition: IT.php:623
string $il_cur_key
buildBlockvariablelist()
Build a list of all variables within of a block.
Definition: IT.php:713
array $blockinner
Array of inner blocks of a block.
Definition: IT.php:224
array $err
Contains the error objects.
Definition: IT.php:134
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
buildFunctionlist()
Builds a functionlist from the template.
Definition: ITX.php:285
+ 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:643
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:184
string $template
Content of the template.
Definition: IT.php:199
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:179
getFile(string $filename)
Reads a file from disk and returns its content.
Definition: IT.php:777
global $DIC
Definition: shib_login.php:22
$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(), ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate(), ILIAS\Test\Questions\Presentation\Printer\addResultUserInfoToTemplate(), ilExerciseGSToolProvider\addSection(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilKprimChoiceCorrectionsInputGUI\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(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilSCORMExplorer\getOutputIcons(), ilMailFormAttachmentPropertyGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilCustomInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilUserLoginInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilKprimChoiceWizardInputGUI\insert(), ilNonEditableValueGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilCheckboxInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDurationInputGUI\insert(), ilFileWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTagInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilCombinationInputGUI\insert(), ilSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilDateTimeInputGUI\insert(), ilNumberInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilOrgUnitGenericMultiInputGUI\insert(), ilFileInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilTextInputGUI\insert(), ilDateDurationInputGUI\insert(), ilLinkInputGUI\insert(), ilPCParagraphGUI\insertCharacteristicTable(), ilPCParagraphGUI\insertHelp(), ilSCORMExplorer\insertObject(), ilNestedList\listItemStart(), ilExplorerBaseGUI\listItemStart(), ilNestedList\listStart(), ilSurveyExecutionGUI\outNavigationButtons(), SurveyMetricQuestion\outPreconditionSelectValue(), 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\renderActionsIcon(), ilPollAnswersRenderer\renderAnswer(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilExplorerBaseGUI\renderChilds(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), 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 ILIAS\UICore\GlobalTemplate\DEFAULT_BLOCK.

Referenced by ilContainerRenderer\addHeaderRow(), ilContainerGUI\addHeaderRow(), ilContainerGUI\addMessageRow(), ilMiniCalendarGUI\addMiniMonth(), ilCalendarBlockGUI\addMiniMonth(), ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate(), ILIAS\Test\Questions\Presentation\Printer\addResultUserInfoToTemplate(), ilExerciseGSToolProvider\addSection(), ilContainerRenderer\addSeparatorRow(), ilContainerRenderer\addStandardRow(), ilCalendarBlockGUI\addSubscriptionButton(), ilRecurrenceInputGUI\buildWeekDaySelection(), ilKprimChoiceCorrectionsInputGUI\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(), ilWikiFunctionsBlockGUI\getLegacyContent(), ilCalendarSelectionBlockGUI\getLegacyContent(), ilSCORMExplorer\getOutputIcons(), ilMailFormAttachmentPropertyGUI\insert(), ilAssLongmenuCorrectionsInputGUI\insert(), ilAssClozeTestCombinationVariantsInputGUI\insert(), ilAssSingleChoiceCorrectionsInputGUI\insert(), ilOrgUnitAuthorityInputGUI\insert(), ilAssErrorTextCorrectionsInputGUI\insert(), ilCustomInputGUI\insert(), ilAssAnswerCorrectionsInputGUI\insert(), ilHiddenInputGUI\insert(), ilAssMultipleChoiceCorrectionsInputGUI\insert(), ilAssMatchingPairCorrectionsInputGUI\insert(), ilImagemapCorrectionsInputGUI\insert(), ilEssayKeywordWizardInputGUI\insert(), ilFontSizeInputGUI\insert(), ilBackgroundImageInputGUI\insert(), ilNumericStyleValueInputGUI\insert(), ilManualPlaceholderInputGUI\insert(), ilRadioGroupInputGUI\insert(), ilFormSectionHeaderGUI\insert(), ilTextWizardInputGUI\insert(), ilWidthHeightInputGUI\insert(), ilSelectBuilderInputGUI\insert(), ilEMailInputGUI\insert(), ilImageFileInputGUI\insert(), ilUserLoginInputGUI\insert(), ilLocationInputGUI\insert(), ilNestedListInputGUI\insert(), ilCheckboxGroupInputGUI\insert(), ilAdvSelectInputGUI\insert(), ilBackgroundPositionInputGUI\insert(), ilTRBLBorderStyleInputGUI\insert(), ilKprimChoiceWizardInputGUI\insert(), ilNonEditableValueGUI\insert(), ilMatrixRowWizardInputGUI\insert(), ilCheckboxInputGUI\insert(), ilTRBLBorderWidthInputGUI\insert(), ilTRBLNumericStyleValueInputGUI\insert(), ilChatroomAuthInputGUI\insert(), ilDurationInputGUI\insert(), ilFileWizardInputGUI\insert(), ilTRBLColorPickerInputGUI\insert(), ilTagInputGUI\insert(), ilMatchingPairWizardInputGUI\insert(), ilColorPickerInputGUI\insert(), ilMultipleChoiceWizardInputGUI\insert(), ilCSSRectInputGUI\insert(), ilMultiSelectInputGUI\insert(), ilCombinationInputGUI\insert(), ilSelectInputGUI\insert(), ilScheduleInputGUI\insert(), ilRepositorySelectorInputGUI\insert(), ilExplorerSelectInputGUI\insert(), ilErrorTextWizardInputGUI\insert(), ilDateTimeInputGUI\insert(), ilNumberInputGUI\insert(), ilAnswerWizardInputGUI\insert(), ilRecurrenceInputGUI\insert(), ilMatchingWizardInputGUI\insert(), ilCategoryWizardInputGUI\insert(), ilImagemapFileInputGUI\insert(), ilPasswordInputGUI\insert(), ilTextAreaInputGUI\insert(), ilDclGenericMultiInputGUI\insert(), ilOrgUnitGenericMultiInputGUI\insert(), ilFileInputGUI\insert(), ilSingleChoiceWizardInputGUI\insert(), ilTextInputGUI\insert(), ilDateDurationInputGUI\insert(), ilLinkInputGUI\insert(), ilPCParagraphGUI\insertCharacteristicTable(), ilPCParagraphGUI\insertHelp(), ilPropertyFormGUI\insertItem(), ilSCORMExplorer\insertObject(), ilNestedList\listItemStart(), ilExplorerBaseGUI\listItemStart(), ilNestedList\listStart(), ilSurveyExecutionGUI\outNavigationButtons(), SurveyMetricQuestion\outPreconditionSelectValue(), 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\renderActionsIcon(), ilTestQuestionNavigationGUI\renderButtonInstance(), ilExplorerBaseGUI\renderChilds(), ilAssLacLegendGUI\renderCommonLegendPart(), ilContainerRenderer\renderDetails(), ilObjForumGUI\renderDraftContent(), ilAssLacLegendGUI\renderExample(), ilContainerRenderer\renderHelperGeneric(), 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(), ilExplorer\handleListEndTags(), ilExplorer\handleListStartTags(), ilPCParagraphGUI\insertCharacteristicTable(), ilNestedList\listEnd(), ilExplorerBaseGUI\listEnd(), ilNestedList\listItemEnd(), ilExplorerBaseGUI\listItemEnd(), ilNestedList\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:529
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 396 of file class.ilTemplate.php.

396  : bool
397  {
398  return isset($this->blockvariables["content"][$a_variablename]);
399  }

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: