Member Function Documentation
_addPregDelimiters |
( |
|
$str | ) |
|
Adds delimiters to a string, so it can be used as a pattern in preg_* functions
- Parameters
-
- Returns
- string
_preserveOpeningDelimiter |
( |
|
$str | ) |
|
Replaces an opening delimiter by a special string
- Parameters
-
- Returns
- string
buildBlockvariablelist |
( |
| ) |
|
Build a list of all variables within of a block
errorMessage |
( |
|
$value, |
|
|
|
$blockname = '' |
|
) |
| |
Return a textual error message for a IT error code
- Parameters
-
- Returns
- string error message, or false if the error code was not recognized
Recusively builds a list of all blocks within the template.
- Parameters
-
string | string that gets scanned |
- See Also
- $blocklist
Clears all datafields of the object.
Don't use this function unless you know what you're doing.
public
- See Also
- init()
get |
( |
|
$block = '__global__' | ) |
|
Returns a block with all replacements done.
- Parameters
-
- Returns
- string
- Exceptions
-
- See Also
- show()
Reads a file from disk and returns its content.
- Parameters
-
- Returns
- string Filecontent
Returns a list of all global variables
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.
- Parameters
-
string | File root directory, prefix for all filenames given to the object. |
- See Also
- setRoot()
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
- See Also
- free()
Reimplemented in HTML_Template_ITX.
loadTemplatefile |
( |
|
$filename, |
|
|
|
$removeUnknownVariables = true , |
|
|
|
$removeEmptyBlocks = true |
|
) |
| |
parse |
( |
|
$block = '__global__' , |
|
|
|
$flag_recursion = false |
|
) |
| |
Parses the given block.
- Parameters
-
string | name of the block to be parsed public |
- See Also
- parseCurrentBlock()
- Exceptions
-
setCurrentBlock |
( |
|
$block = '__global__' | ) |
|
Sets the name of the current block that is the block where variables are added.
- Parameters
-
- Returns
- boolean false on failure, otherwise true
- Exceptions
-
setOption |
( |
|
$option, |
|
|
|
$value |
|
) |
| |
Sets the option for the template class
public
- Parameters
-
string | option name |
mixed | option value |
- Returns
- mixed IT_OK on success, error object on failure
Sets the options for the template class
public
- Parameters
-
string | options array of options default value: 'preserve_data' => false, 'use_preg' => true |
mixed | option value |
- Returns
- mixed IT_OK on success, error object on failure
- See Also
- $options
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.
- Parameters
-
- See Also
- HTML_Template_IT() public
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.
- Parameters
-
string | template content |
boolean | remove unknown/unused variables? |
boolean | remove empty blocks? |
- See Also
- LoadTemplatefile(), $template public
- Returns
- boolean
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().
- Parameters
-
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 |
show |
( |
|
$block = '__global__' | ) |
|
Print a certain block with all replacements done. get()
Preserves an empty block even if removeEmptyBlocks is true.
- Parameters
-
- Returns
- boolean false on false, otherwise true
- Exceptions
-
- See Also
- $removeEmptyBlocks
Field Documentation
array $_hiddenBlocks = array() |
List of blocks which should not be shown even if not "empty"
- See Also
- hideBlock(), $removeEmptyBlocks
Initial value: array(
'preserve_data' => false,
'use_preg' => true
)
$_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)
$blocknameRegExp = '[0-9A-Za-z_-]+' |
$blockvariables = array() |
$clearCacheOnParse = false |
$closingDelimiter = '###' |
$currentBlock = '__global__' |
$flagBlocktrouble = false |
$flagCacheTemplatefile = true |
$flagGlobalParsed = false |
$openingDelimiter = '###' |
$removeEmptyBlocks = true |
$removeUnknownVariables = true |
$removeVariablesRegExp = '' |
RegExp used to strip unused variable placeholder. $variablesRegExp
array $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.
- See Also
- touchBlock(), $removeEmptyBlocks
$variablenameRegExp = '[\.0-9A-Za-z_-]+' |
The documentation for this class was generated from the following file:
- lib/extern/lib/HTML_Template_IT/IT.php