ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilIndependantTemplate Class Reference
+ Inheritance diagram for ilIndependantTemplate:
+ Collaboration diagram for ilIndependantTemplate:

Public Member Functions

 getFile (string $filename)
 Reads a file from disk and returns its content. More...
 
 loadTemplatefile (string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
 Reads a template file from the disk. More...
 
 get (?string $part=null)
 
- Public Member Functions inherited from 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. 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...
 

Additional Inherited Members

- Data Fields inherited from ilTemplate
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 inherited from ilTemplate
 init ()
 
 getCurrentSkin ()
 
 getCurrentStyle ()
 
 fileExistsInSkin (string $path)
 
 getTemplatePath (string $a_tplname, string $a_in_module='')
 
- 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 inherited from ilTemplate
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 inherited from ilTemplate
static array $il_cache = []
 

Detailed Description

Definition at line 57 of file ilIndependentTemplate.php.

Member Function Documentation

◆ get()

ilIndependantTemplate::get ( ?string  $part = null)

Definition at line 114 of file ilIndependentTemplate.php.

References null.

114  : string
115  {
116  if ($part === null) {
117  $part = self::IT_DEFAULT_BLOCK;
118  }
119  if ($part === self::IT_DEFAULT_BLOCK && !$this->flagGlobalParsed) {
120  $this->parse(self::IT_DEFAULT_BLOCK);
121  }
122 
123  if (!isset($this->blocklist[$part])) {
124  throw (new ilTemplateException($this->errorMessage(self::IT_BLOCK_NOT_FOUND) .
125  '"' . $part . "'"));
126  }
127 
128  if (isset($this->blockdata[$part])) {
129  $ret = $this->blockdata[$part];
130  if ($this->clearCache) {
131  unset($this->blockdata[$part]);
132  }
133  if ($this->_options['preserve_data']) {
134  $ret = str_replace(
135  $this->openingDelimiter .
136  '%preserved%' . $this->closingDelimiter,
137  $this->openingDelimiter,
138  $ret
139  );
140  }
141  return $ret;
142  }
143 
144  return '';
145  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
errorMessage(int $value, string $blockname='')
Return a textual error message for a IT error code.
Definition: IT.php:833
parse(string $block=self::IT_DEFAULT_BLOCK, bool $flag_recursion=false)
Parses the given block.
Definition: IT.php:424

◆ getFile()

ilIndependantTemplate::getFile ( string  $filename)

Reads a file from disk and returns its content.

Copy from Service/PEAR/lib/HTML/Template/IT.php with GlobalCache-stuff removed.

Definition at line 64 of file ilIndependentTemplate.php.

References $filename.

64  : string
65  {
66  if ($filename[0] === '/' && substr($this->fileRoot, -1) === '/') {
67  $filename = substr($filename, 1);
68  }
69 
70  $filename = $this->fileRoot . $filename;
71 
72  $this->real_filename = $filename;
73 
74  if (!($fh = @fopen($filename, 'rb'))) {
75  $this->err[] = (new PEAR())->raiseError(
76  $this->errorMessage(self::IT_TPL_NOT_FOUND) .
77  ': "' . $filename . '"',
78  self::IT_TPL_NOT_FOUND
79  );
80  return "";
81  }
82 
83  $fsize = filesize($filename);
84  if ($fsize < 1) {
85  fclose($fh);
86  return '';
87  }
88 
89  $content = fread($fh, $fsize);
90  fclose($fh);
91 
92  return preg_replace_callback(
93  "#<!-- INCLUDE (.*) -->#im",
94  function ($hit) {
95  return $this->getFile($hit[1]);
96  },
97  $content
98  );
99  }
getFile(string $filename)
Reads a file from disk and returns its content.
errorMessage(int $value, string $blockname='')
Return a textual error message for a IT error code.
Definition: IT.php:833
$filename
Definition: buildRTE.php:78

◆ loadTemplatefile()

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

Reads a template file from the disk.

unoverwrites IT:loadTemplateFile to deinclude the template input hook

Definition at line 105 of file ilIndependentTemplate.php.

References HTML_Template_IT\loadTemplatefile().

109  : bool {
111  }
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
Definition: IT.php:184
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
Definition: IT.php:179
$filename
Definition: buildRTE.php:78
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Reads a template file from the disk.
Definition: IT.php:675
+ Here is the call graph for this function:

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