ILIAS
Release_4_2_x_branch Revision 61807
|
Public Member Functions | |
HTML_Template_IT ($root= '', $options=null) | |
Builds some complex regular expressions and optinally sets the file root directory. | |
setOption ($option, $value) | |
Sets the option for the template class. | |
setOptions ($options) | |
Sets the options for the template class. | |
show ($block= '__global__') | |
Print a certain block with all replacements done. | |
get ($block= '__global__') | |
Returns a block with all replacements done. | |
parse ($block= '__global__', $flag_recursion=false) | |
Parses the given block. | |
parseCurrentBlock () | |
Parses the current block. | |
setVariable ($variable, $value= '') | |
Sets a variable value. | |
setCurrentBlock ($block= '__global__') | |
Sets the name of the current block that is the block where variables are added. | |
touchBlock ($block) | |
Preserves an empty block even if removeEmptyBlocks is true. | |
init () | |
Clears all datafields of the object and rebuild the internal blocklist. | |
free () | |
Clears all datafields of the object. | |
setTemplate ($template, $removeUnknownVariables=true, $removeEmptyBlocks=true) | |
Sets the template. | |
loadTemplatefile ($filename, $removeUnknownVariables=true, $removeEmptyBlocks=true) | |
Reads a template file from the disk. | |
setRoot ($root) | |
Sets the file root. | |
buildBlockvariablelist () | |
Build a list of all variables within of a block. | |
getGlobalvariables () | |
Returns a list of all global variables. | |
findBlocks ($string) | |
Recusively builds a list of all blocks within the template. | |
getFile ($filename) | |
Reads a file from disk and returns its content. | |
_addPregDelimiters ($str) | |
Adds delimiters to a string, so it can be used as a pattern in preg_* functions. | |
_preserveOpeningDelimiter ($str) | |
Replaces an opening delimiter by a special string. | |
errorMessage ($value, $blockname= '') | |
Return a textual error message for a IT error code. |
Data Fields | |
$err = array() | |
$clearCache = false | |
$openingDelimiter = '{' | |
$closingDelimiter = '}' | |
$blocknameRegExp = '[\.0-9A-Za-z_-]+' | |
$variablenameRegExp = '[\.0-9A-Za-z_-]+' | |
$variablesRegExp = '' | |
$removeVariablesRegExp = '' | |
RegExp used to strip unused variable placeholder. | |
$removeUnknownVariables = true | |
$removeEmptyBlocks = true | |
$blockRegExp = '' | |
$currentBlock = '__global__' | |
$template = '' | |
$blocklist = array() | |
$blockdata = array() | |
$blockvariables = array() | |
$blockinner = array() | |
$touchedBlocks = array() | |
List of blocks to preverse even if they are "empty". | |
$_hiddenBlocks = array() | |
List of blocks which should not be shown even if not "empty". | |
$variableCache = array() | |
$clearCacheOnParse = false | |
$fileRoot = '' | |
$flagBlocktrouble = false | |
$flagGlobalParsed = false | |
$flagCacheTemplatefile = true | |
$lastTemplatefile = '' | |
EXPERIMENTAL! FIXME! | |
$_options | |
$_options['preserve_data'] Whether to substitute variables and remove empty placeholders in data passed through setVariable (see also bugs #20199, #21951). |
HTML_Template_IT::_addPregDelimiters | ( | $str | ) |
HTML_Template_IT::_preserveOpeningDelimiter | ( | $str | ) |
Replaces an opening delimiter by a special string.
string |
Definition at line 955 of file IT.php.
HTML_Template_IT::buildBlockvariablelist | ( | ) |
Build a list of all variables within of a block.
Definition at line 813 of file IT.php.
Referenced by ilTemplate\init(), HTML_Template_ITX\init(), init(), and HTML_Template_ITX\replaceBlock().
HTML_Template_IT::errorMessage | ( | $value, | |
$blockname = '' |
|||
) |
Return a textual error message for a IT error code.
integer | $value | error code |
Definition at line 975 of file IT.php.
References PEAR\isError(), IT_BLOCK_DUPLICATE, IT_BLOCK_NOT_FOUND, IT_ERROR, IT_OK, IT_TPL_NOT_FOUND, and IT_UNKNOWN_OPTION.
Referenced by findBlocks(), get(), getFile(), parse(), setCurrentBlock(), setOption(), and touchBlock().
HTML_Template_IT::findBlocks | ( | $string | ) |
Recusively builds a list of all blocks within the template.
string | string that gets scanned |
Definition at line 854 of file IT.php.
References $blocklist, errorMessage(), IT_BLOCK_DUPLICATE, and PEAR\raiseError().
Referenced by HTML_Template_ITX\addBlock(), ilTemplate\init(), HTML_Template_ITX\init(), init(), and HTML_Template_ITX\replaceBlock().
HTML_Template_IT::free | ( | ) |
Clears all datafields of the object.
Don't use this function unless you know what you're doing.
public
Definition at line 710 of file IT.php.
Referenced by ilTemplate\init(), HTML_Template_ITX\init(), and init().
HTML_Template_IT::get | ( | $block = '__global__' | ) |
Returns a block with all replacements done.
string | name of the block |
PEAR_Error | public |
Reimplemented in ilTemplate.
Definition at line 454 of file IT.php.
References $ret, errorMessage(), IT_BLOCK_NOT_FOUND, parse(), and PEAR\raiseError().
HTML_Template_IT::getFile | ( | $filename | ) |
Reads a file from disk and returns its content.
string | Filename |
Definition at line 906 of file IT.php.
References $filename, errorMessage(), IT_TPL_NOT_FOUND, and PEAR\raiseError().
Referenced by HTML_Template_ITX\addBlockfile(), ilTemplate\addBlockFile(), loadTemplatefile(), ilTemplate\loadTemplatefile(), and HTML_Template_ITX\replaceBlockfile().
HTML_Template_IT::getGlobalvariables | ( | ) |
Returns a list of all global variables.
Definition at line 831 of file IT.php.
HTML_Template_IT::HTML_Template_IT | ( | $root = '' , |
|
$options = null |
|||
) |
Builds some complex regular expressions and optinally sets the file root directory.
Make sure that you call this constructor if you derive your template class from this one.
string | File root directory, prefix for all filenames given to the object. |
Definition at line 370 of file IT.php.
References setOptions(), and setRoot().
Referenced by HTML_Template_ITX\HTML_Template_ITX().
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. Don't use this function unless you know what you're doing.
public
Reimplemented in HTML_Template_ITX, and ilTemplate.
Definition at line 693 of file IT.php.
References buildBlockvariablelist(), findBlocks(), and free().
Referenced by setTemplate().
HTML_Template_IT::loadTemplatefile | ( | $filename, | |
$removeUnknownVariables = true , |
|||
$removeEmptyBlocks = true |
|||
) |
Reads a template file from the disk.
string | name of the template file |
bool | how to handle unknown variables. |
bool | how to handle empty blocks. public |
Reimplemented in ilTemplate.
Definition at line 772 of file IT.php.
References $filename, $removeEmptyBlocks, $removeUnknownVariables, $template, getFile(), and setTemplate().
HTML_Template_IT::parse | ( | $block = '__global__' , |
|
$flag_recursion = false |
|||
) |
Parses the given block.
string | name of the block to be parsed public |
PEAR_Error |
Definition at line 496 of file IT.php.
References $closingDelimiter, errorMessage(), IT_BLOCK_NOT_FOUND, and PEAR\raiseError().
Referenced by get(), and parseCurrentBlock().
HTML_Template_IT::parseCurrentBlock | ( | ) |
Parses the current block.
Definition at line 607 of file IT.php.
References parse().
Referenced by ilTemplate\fillAdminPanel(), ilTemplate\fillBodyClass(), ilTemplate\fillContentStyle(), ilTemplate\fillCssFiles(), ilTemplate\fillHeader(), ilTemplate\fillInlineCss(), ilTemplate\fillJavaScriptFiles(), ilTemplate\fillLeftContent(), ilTemplate\fillOnLoadCode(), ilTemplate\fillPageFormAction(), ilTemplate\fillRightContent(), ilTemplate\fillSideIcons(), ilTemplate\get(), ilTemplate\parseCurrentBlock(), ilTemplate\replaceFromDatabase(), ilTemplate\setFullscreenHeader(), ilTemplate\setTopBar(), ilTemplate\show(), and ilTemplate\touchBlock().
HTML_Template_IT::setCurrentBlock | ( | $block = '__global__' | ) |
Sets the name of the current block that is the block where variables are added.
string | name of the block |
PEAR_Error | public |
Reimplemented in ilTemplate, and ilTemplate.
Definition at line 646 of file IT.php.
References errorMessage(), IT_BLOCK_NOT_FOUND, and PEAR\raiseError().
HTML_Template_IT::setOption | ( | $option, | |
$value | |||
) |
Sets the option for the template class.
public
string | option name |
mixed | option value |
Definition at line 397 of file IT.php.
References errorMessage(), IT_OK, IT_UNKNOWN_OPTION, and PEAR\raiseError().
Referenced by ilTemplate\ilTemplate(), and setOptions().
HTML_Template_IT::setOptions | ( | $options | ) |
Sets the options for the template class.
public
string | options array of options default value: 'preserve_data' => false, 'use_preg' => true |
mixed | option value |
Definition at line 422 of file IT.php.
References PEAR\isError(), IT_OK, and setOption().
Referenced by HTML_Template_IT().
HTML_Template_IT::setRoot | ( | $root | ) |
Sets the file root.
The file root gets prefixed to all filenames passed to the object.
Make sure that you override this function when using the class on windows.
string |
Definition at line 801 of file IT.php.
Referenced by HTML_Template_IT().
HTML_Template_IT::setTemplate | ( | $template, | |
$removeUnknownVariables = true , |
|||
$removeEmptyBlocks = true |
|||
) |
Sets the template.
You can eighter load a template file from disk with LoadTemplatefile() or set the template manually using this function.
string | template content |
boolean | remove unknown/unused variables? |
boolean | remove empty blocks? |
Definition at line 737 of file IT.php.
References $removeEmptyBlocks, $removeUnknownVariables, $template, and init().
Referenced by loadTemplatefile(), and ilTemplate\loadTemplatefile().
HTML_Template_IT::setVariable | ( | $variable, | |
$value = '' |
|||
) |
Sets a variable value.
The function can be used eighter like setVariable( "varname", "value") or with one array $variables["varname"] = "value" given setVariable($variables) quite like phplib templates set_var().
mixed | string with the variable name or an array variables["varname"] = "value" |
string | value of the variable or empty if $variable is an array. |
string | prefix for variable names public |
Definition at line 626 of file IT.php.
Referenced by ilTemplate\addILIASFooter(), ilTemplate\fillAdminPanel(), ilTemplate\fillBodyClass(), ilTemplate\fillContentLanguage(), ilTemplate\fillContentStyle(), ilTemplate\fillCssFiles(), ilTemplate\fillHeader(), ilTemplate\fillInlineCss(), ilTemplate\fillJavaScriptFiles(), ilTemplate\fillLeftContent(), ilTemplate\fillMainContent(), ilTemplate\fillMessage(), ilTemplate\fillNewContentStyle(), ilTemplate\fillOnLoadCode(), ilTemplate\fillPageFormAction(), ilTemplate\fillPermanentLink(), ilTemplate\fillRightContent(), ilTemplate\fillSideIcons(), ilTemplate\fillTabs(), ilTemplate\fillToolbar(), ilTemplate\fillVars(), ilTemplate\fillWindowTitle(), ilSurveyPageGUI\renderPageNode(), ilTemplate\replace(), ilTemplate\setFullscreenHeader(), ilTemplate\setLocator(), ilTemplate\setNewContentStyleSheetLocation(), ilTemplate\setStyleSheetLocation(), ilTemplate\setSubTabs(), ilTemplate\setTabs(), ilTemplate\setTopBar(), and ilTemplate\show().
HTML_Template_IT::show | ( | $block = '__global__' | ) |
Print a certain block with all replacements done.
Reimplemented in ilTemplate.
Definition at line 440 of file IT.php.
HTML_Template_IT::touchBlock | ( | $block | ) |
Preserves an empty block even if removeEmptyBlocks is true.
string | name of the block |
PEAR_Error | public |
Reimplemented in ilTemplate, and ilTemplate.
Definition at line 670 of file IT.php.
References errorMessage(), IT_BLOCK_NOT_FOUND, and PEAR\raiseError().
array HTML_Template_IT::$_hiddenBlocks = array() |
List of blocks which should not be shown even if not "empty".
HTML_Template_IT::$_options |
$_options['preserve_data'] Whether to substitute variables and remove empty placeholders in data passed through setVariable (see also bugs #20199, #21951).
$_options['use_preg'] Whether to use preg_replace instead of str_replace in parse() (this is a backwards compatibility feature, see also bugs #21951, #20392)
HTML_Template_IT::$blockdata = array() |
Definition at line 236 of file IT.php.
Referenced by ilTemplate\init(), and HTML_Template_ITX\replaceBlock().
HTML_Template_IT::$blockinner = array() |
Definition at line 248 of file IT.php.
Referenced by ilTemplate\init().
HTML_Template_IT::$blocklist = array() |
Definition at line 229 of file IT.php.
Referenced by findBlocks(), HTML_Template_ITX\getBlocklist(), and ilTemplate\init().
HTML_Template_IT::$blockvariables = array() |
Definition at line 242 of file IT.php.
Referenced by ilTemplate\init().
HTML_Template_IT::$closingDelimiter = '}' |
Definition at line 154 of file IT.php.
Referenced by HTML_Template_ITX\buildFunctionlist(), and parse().
HTML_Template_IT::$err = array() |
Definition at line 132 of file IT.php.
Referenced by ilTemplate\init().
HTML_Template_IT::$flagBlocktrouble = false |
Definition at line 319 of file IT.php.
Referenced by ilTemplate\init().
HTML_Template_IT::$lastTemplatefile = '' |
HTML_Template_IT::$removeEmptyBlocks = true |
Definition at line 202 of file IT.php.
Referenced by loadTemplatefile(), ilTemplate\loadTemplatefile(), and setTemplate().
HTML_Template_IT::$removeUnknownVariables = true |
Definition at line 195 of file IT.php.
Referenced by loadTemplatefile(), ilTemplate\loadTemplatefile(), and setTemplate().
HTML_Template_IT::$removeVariablesRegExp = '' |
HTML_Template_IT::$template = '' |
Definition at line 221 of file IT.php.
Referenced by HTML_Template_ITX\addBlock(), ilTemplate\addBlockFile(), HTML_Template_ITX\buildFunctionlist(), loadTemplatefile(), ilTemplate\loadTemplatefile(), HTML_Template_ITX\replaceBlock(), and setTemplate().
array HTML_Template_IT::$touchedBlocks = array() |
List of blocks to preverse even if they are "empty".
This is something special. Sometimes you have blocks that should be preserved although they are empty (no placeholder replaced). Think of a shopping basket. If it's empty you have to drop a message to the user. If it's filled you have to show the contents of the shopping baseket. Now where do you place the message that the basket is empty? It's no good idea to place it in you applications as customers tend to like unecessary minor text changes. Having another template file for an empty basket means that it's very likely that one fine day the filled and empty basket templates have different layout. I decided to introduce blocks that to not contain any placeholder but only text such as the message "Your shopping basked is empty".
Now if there is no replacement done in such a block the block will be recognized as "empty" and by default ($removeEmptyBlocks = true) be stripped off. To avoid thisyou can now call touchBlock() to avoid this.
The array $touchedBlocks stores a list of touched block which must not be removed even if they are empty.