Geeklog
[ class tree: Geeklog ] [ index: Geeklog ] [ all elements ]

Class: Template

Source Location: /system/classes/template.class.php

Class Overview




Implements interfaces:

Variables

Methods


Child classes:


Class Details

[line 68]


[ Top ]


Class Variables

$classname =  'Template'

[line 76]

Serialization helper, the name of this class.



Tags:

access:  public

Type:   string


[ Top ]

$debug =  false

[line 92]

Determines how much debugging output Template will produce.

This is a bitwise mask of available debug levels:

  1. = no debugging
  2. = debug variable assignments
  3. = debug calls to get variable
4 = debug internals (outputs all function calls with parameters).

Note: setting $this->debug = true will enable debugging of variable assignments only which is the same behaviour as versions up to release 7.2d.




Tags:

access:  public

Type:   int


[ Top ]

$halt_on_error =  'yes'

[line 144]

Determines how Template handles error conditions.

"yes" = the error is reported, then execution is halted "report" = the error is reported, then execution continues by returning "false" "no" = errors are silently ignored, and execution resumes reporting "false"




Tags:

see:  halt
access:  public

Type:   string


[ Top ]

$last_error =  ''

[line 153]

The last error message is retained in this variable.



Tags:

see:  halt
access:  public

Type:   string


[ Top ]

$postprocess_fn =  ''

[line 171]

The name of a function is retained in this variable and is used to do any post processing work.



Tags:

see:  _postprocess
access:  public

Type:   string


[ Top ]

$preprocess_fn =  ''

[line 162]

The name of a function is retained in this variable and is used to do any pre processing work.



Tags:

see:  _preprocess
access:  public

Type:   string


[ Top ]



Class Methods


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:

see:  Template::set_root()
see:  Template::set_unknowns()
access:  public


Overridden in child classes as:

MultiRootTemplate::Template()

Parameters:

$root   $root   path to template directory
$string   $unknowns   what to do with undefined variables

[ Top ]

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:

access:  public



Implementation of:
ITemplate::clear_var()

Parameters:

$varname   $varname   either a string containing a varname or an array of varnames.

[ Top ]

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:

see:  Template::set_unknowns()
access:  public



Implementation of:
ITemplate::finish()

Parameters:

$str   $str   a string to which to apply the unresolved variable policy

[ Top ]

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:

see:  Template::finish()
see:  Template::set_unknowns()
access:  public


Parameters:

$varname   $varname   a string containing the name of the variable to finish

[ Top ]

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:

access:  public


Parameters:

$varname   $varname   a string containing the name the name of the variable to scan for unresolved variables

[ Top ]

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:

return:  or array
access:  public



Implementation of:
ITemplate::get_var()

Parameters:

$varname   $varname   if a string, the name the name of the variable to get the value of, or if an array a list of variables to return the value of

[ Top ]

method get_vars [line 687]

array get_vars( )

**************************************************************************** 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:

see:  Template::$debug
access:  public


[ Top ]

method haltmsg [line 990]

void haltmsg( $msg $msg)

**************************************************************************** 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:

see:  halt
access:  public


Parameters:

$msg   $msg   a string containing the error message to display

[ Top ]

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:

see:  Template::finish()
see:  Template::set_unknowns()
access:  public


Parameters:

$varname   $varname   a string containing the name of the variable to finish and print

[ Top ]

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:

see:  Template::subst()
access:  public



Implementation of:
ITemplate::parse()

Parameters:

$target   $target   a string containing the name of the variable into which substituted $varnames are to be stored
$varname   $varname   if a string, the name the name of the variable to substitute or if an array a list of variables to be substituted
$append   $append   if true, the substituted variables are appended to $target otherwise the existing value of $target is replaced

[ Top ]

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:

see:  Template::parse()
access:  public


Parameters:

$target   $target   a string containing the name of the variable into which substituted $varnames are to be stored
$varname   $varname   if a string, the name the name of the variable to substitute or if an array a list of variables to be substituted
$append   $append   if true, the substituted variables are appended to $target otherwise the existing value of $target is replaced

[ Top ]

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:

see:  Template::subst()
access:  public


Parameters:

$varname   $varname   the name of the variable within which variables are to be substituted

[ Top ]

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:

access:  public



Implementation of:
ITemplate::set_block()

Parameters:

$parent   $parent   a string containing the name of the parent variable
$varname   $varname   a string containing the name of the block to be extracted
$name   $name   the name of the variable in which to store the block

[ Top ]

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:

access:  public



Implementation of:
ITemplate::set_file()

Parameters:

$varname   $varname   either a string containing a varname or a hash of varname/file name pairs.
$filename   $filename   if varname is a string this is the filename otherwise filename is not required

[ Top ]

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:

see:  root
access:  public


Overridden in child classes as:

MultiRootTemplate::set_root()

Parameters:

$root   $root   string containing new template directory

[ Top ]

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:

see:  unknowns
access:  public


Parameters:

$unknowns   $unknowns   new value for unknowns

[ Top ]

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:

access:  public



Implementation of:
ITemplate::set_var()

Parameters:

$varname   $varname   either a string containing a varname or a hash of varname/value pairs.
$value   $value   if $varname is a string this contains the new value for the variable otherwise this parameter is ignored
$append   $append   if true, the value is appended to the variable's existing value

[ Top ]

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:

access:  public


Parameters:

$varname   $varname   the name of the variable within which variables are to be substituted

[ Top ]

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:

access:  public



Implementation of:
ITemplate::unset_var()

Parameters:

$varname   $varname   either a string containing a varname or an array of varnames.

[ Top ]


Documentation generated on Thu, 24 May 2012 02:09:19 -0400 by phpDocumentor 1.4.3