constructor Template [line 223]
void Template(
[$root
$root = '.'], [$string
$unknowns = 'remove'])
|
|
**************************************************************************** Class constructor. May be called with two optional parameters.
The first parameter sets the template directory the second parameter sets the policy regarding handling of unknown variables.
usage: Template([string $root = "."], [string $unknowns = "remove"])
Tags:
Overridden in child classes as:
- MultiRootTemplate::Template()
Parameters:
method clear_var [line 455]
void clear_var(
$varname
$varname)
|
|
**************************************************************************** This functions clears the value of a variable.
It may be called with either a varname as a string or an array with the values being the varnames to be cleared.
The function sets the value of the variable in the $varvals hashes to "". It is not necessary for a variable to exist in these hashes before calling this function.
usage: clear_var(string $varname) or usage: clear_var(array $varname = (string $varname))
Tags:
Implementation of:
- ITemplate::clear_var()
Parameters:
method finish [line 799]
string finish(
$str
$str)
|
|
**************************************************************************** This function returns the finished version of $str. That is, the policy regarding unresolved variable names will be applied to $str.
Returns: a finished string derived from $str and $this->unknowns.
usage: finish(string $str)
Tags:
Implementation of:
- ITemplate::finish()
Parameters:
method get [line 852]
void get(
$varname
$varname)
|
|
**************************************************************************** This function returns the finished version of the value of the variable named by $varname. That is, the policy regarding unresolved variable names will be applied to the variable $varname and the result returned.
Returns: a finished string derived from the variable $varname.
usage: get(string $varname)
Tags:
Parameters:
method get_undefined [line 753]
array get_undefined(
$varname
$varname)
|
|
**************************************************************************** This function returns a hash of unresolved variable names in $varname, keyed by their names (that is, the hash has the form $a[$name] = $name).
Returns: a hash of varname/varname pairs or false on error.
usage: get_undefined(string $varname)
Tags:
Parameters:
method get_var [line 713]
string get_var(
$varname
$varname)
|
|
**************************************************************************** This function returns the value of the variable named by $varname.
If $varname references a file and that file has not been loaded yet, the variable will be reported as empty.
When called with an array of variable names this function will return a a hash of variable values keyed by their names.
Returns: a string or an array containing the value of $varname.
usage: get_var(string $varname) or usage: get_var(array $varname)
Tags:
Implementation of:
- ITemplate::get_var()
Parameters:
method get_vars [line 687]
**************************************************************************** This function returns an associative array of all defined variables with the name as the key and the value of the variable as the value.
This is mostly useful for debugging. Also note that $this->debug can be used to echo all variable assignments as they occur and to trace execution.
Returns: a hash of all defined variable values keyed by their names.
usage: get_vars()
Tags:
method haltmsg [line 990]
**************************************************************************** This function prints an error message.
It can be overridden by your subclass of Template. It will be called with an error message to display.
usage: haltmsg(string $msg)
Tags:
Parameters:
method p [line 832]
void p(
$varname
$varname)
|
|
**************************************************************************** This function prints the finished version of the value of the variable named by $varname. That is, the policy regarding unresolved variable names will be applied to the variable $varname then it will be printed.
usage: p(string $varname)
Tags:
Parameters:
method parse [line 613]
string parse(
$target
$target, $varname
$varname, [$append
$append = false])
|
|
**************************************************************************** The function substitutes the values of all defined variables in the variable named $varname and stores or appends the result in the variable named $target.
It may be called with either a target and a varname as two strings or a target as a string and an array of variable names in varname.
The function inserts the new value of the variable into the $varvals hashes. It is not necessary for a variable to exist in these hashes before calling this function.
An optional third parameter allows the value for each varname to be appended to the existing target variable instead of replacing it. The default is to replace.
If $target and $varname are both strings, the substituted value of the variable $varname is inserted into or appended to $target.
If $handle is an array of variable names the variables named by $handle are sequentially substituted and the result of each substitution step is inserted into or appended to in $target. The resulting substitution is available in the variable named by $target, as is each intermediate step for the next $varname in sequence. Note that while it is possible, it is only rarely desirable to call this function with an array of varnames and with $append = true. This append feature was introduced after the 7.2d release.
Returns: the last value assigned to $target.
usage: parse(string $target, string $varname, [boolean $append]) or usage: parse(string $target, array $varname = (string $varname), [boolean $append])
Tags:
Implementation of:
- ITemplate::parse()
Parameters:
method pparse [line 663]
false pparse(
$target
$target, $varname
$varname, [$append
$append = false])
|
|
**************************************************************************** This is shorthand for print $this->parse(...) and is functionally identical.
See parse for further details.
Returns: always returns false.
usage: pparse(string $target, string $varname, [boolean $append]) or usage: pparse(string $target, array $varname = (string $varname), [boolean $append])
Tags:
Parameters:
method psubst [line 563]
false psubst(
$varname
$varname)
|
|
**************************************************************************** This is shorthand for print $this->subst($varname). See subst for further details.
Returns: always returns false.
usage: psubst(string $varname)
Tags:
Parameters:
method set_block [line 356]
boolean set_block(
$parent
$parent, $varname
$varname, [$name
$name = ''])
|
|
**************************************************************************** A variable $parent may contain a variable block defined by: <!-- BEGIN $varname --> content <!-- END $varname -->. This function removes that block from $parent and replaces it with a variable reference named $name.
The block is inserted into the varvals hashes. If $name is omitted, it is assumed to be the same as $varname.
Blocks may be nested but care must be taken to extract the blocks in order from the innermost block to the outermost block.
Returns true on success, false on error.
usage: set_block(string $parent, string $varname, [string $name = ""])
Tags:
Implementation of:
- ITemplate::set_block()
Parameters:
method set_file [line 310]
boolean set_file(
$varname
$varname, [$filename
$filename = ''])
|
|
**************************************************************************** Defines a filename for the initial value of a variable.
It may be passed either a varname and a file name as two strings or a hash of strings with the key being the varname and the value being the file name.
The new mappings are stored in the array $this->file. The files are not loaded yet, but only when needed.
Returns true on success, false on error.
usage: set_file(array $filelist = (string $varname => string $filename)) or usage: set_file(string $varname, string $filename)
Tags:
Implementation of:
- ITemplate::set_file()
Parameters:
method set_root [line 246]
boolean set_root(
$root
$root)
|
|
**************************************************************************** Checks that $root is a valid directory and if so sets this directory as the base directory from which templates are loaded by storing the value in $this->root. Relative filenames are prepended with the path in $this->root.
Returns true on success, false on error.
usage: set_root(string $root)
Tags:
Overridden in child classes as:
- MultiRootTemplate::set_root()
Parameters:
method set_unknowns [line 281]
void set_unknowns(
[$unknowns
$unknowns = 'remove'])
|
|
**************************************************************************** Sets the policy for dealing with unresolved variable names.
unknowns defines what to do with undefined template variables "remove" = remove undefined variables "comment" = replace undefined variables with comments "keep" = keep undefined variables
Note: "comment" can cause unexpected results when the variable tag is embedded inside an HTML tag, for example a tag which is expected to be replaced with a URL.
usage: set_unknowns(string $unknowns)
Tags:
Parameters:
method set_var [line 407]
void set_var(
$varname
$varname, [$value
$value = ''], [$append
$append = false])
|
|
**************************************************************************** This functions sets the value of a variable.
It may be called with either a varname and a value as two strings or an an associative array with the key being the varname and the value being the new variable value.
The function inserts the new value of the variable into the $varvals hashes. It is not necessary for a variable to exist in these hashes before calling this function.
An optional third parameter allows the value for each varname to be appended to the existing variable instead of replacing it. The default is to replace. This feature was introduced after the 7.2d release.
usage: set_var(string $varname, [string $value = ""], [boolean $append = false]) or usage: set_var(array $varname = (string $varname => string $value), [mixed $dummy_var], [boolean $append = false])
Tags:
Implementation of:
- ITemplate::set_var()
Parameters:
method subst [line 531]
string subst(
$varname
$varname)
|
|
****************************************************************************
This function fills in all the variables contained within the variable named $varname. The resulting value is returned as the function result and the original value of the variable varname is not changed. The resulting string is not "finished", that is, the unresolved variable name policy has not been applied yet.
Returns: the value of the variable $varname with all variables substituted.
usage: subst(string $varname)
Tags:
Parameters:
method unset_var [line 495]
void unset_var(
$varname
$varname)
|
|
**************************************************************************** This functions unsets a variable completely.
It may be called with either a varname as a string or an array with the values being the varnames to be cleared.
The function removes the variable from the $varkeys and $varvals hashes. It is not necessary for a variable to exist in these hashes before calling this function.
usage: unset_var(string $varname) or usage: unset_var(array $varname = (string $varname))
Tags:
Implementation of:
- ITemplate::unset_var()
Parameters: