Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

tv2-engine
Class ctlTpl

Direct Known Subclasses:
ctlViewService

class ctlTpl

ctlTpl template engine.

Authors:
Emilis Dambauskas (emilis@gildija.lt)
Version:
$Id: ctlTpl.class.php,v 1.7 2004/01/06 07:09:30 lunaticlt Exp $
Copyright:
2002–2003 Emilis Dambauskas under Artistic license

Change logs
2003-07-07 Full code comments
2003-07-21 Added method loadLibrary()
2003-07-24 Added checking if templates exist by Linas Gricius linas@gricius.net
2003-08-04 Added method checkVars
2003-08-04 Fixed bug with quieting down fatal errors in methods process() and template().
2003-08-04 Fixed constructor comments


Field Summary
private boolean$cie
Variable used to enable/disable checking if template exists or not.
private integer$e
Stores PHP error reporting level while parsing
private string$file
Template filename
private mixed$k
Temporary variable used while parsing (stores var values).
private string$tpl_dir
Stores default temlpate directory name
private string$v
Temporary variable used while parsing (stores var names).
private array$vars
Template variable storage

Constructor Summary
void ctlTpl([string $td], [boolean $cie])
Constructor.

Method Summary
private void checkTpl(string $filename)
Checks if template exists or not.
boolean checkVars(mixed $var_names)
Checks if template var[s] exist
void clearVars()
Clears all stored template vars
void loadLibrary(string $filename)
Loads a function library
string process(string $file, [boolean $clr_vars])
Parses the given template file and clears vars if needed.
void regVar(string $name, mixed& $var)
Registers a reference to an external variable as a tpl var:
void setVar(string $name, mixed $value)
Creates/changes template var value
void setVars(array $array)
Creates/changes multiple template variables
string template(string $file, [string $myname], [boolean $clr_vars])
Includes the result from the template script that is being parsed now into template specified by $name.
void unsetAllVars()
Alias of ctlTpl::clearVars.
void unsetVar(string $name)
Clears a variable


Field Detail

cie

private boolean $cie

Variable used to enable/disable checking if template exists or not.


e

private integer $e

Stores PHP error reporting level while parsing


file

private string $file

Template filename


k

private mixed $k

Temporary variable used while parsing (stores var values).


tpl_dir

private string $tpl_dir

Stores default temlpate directory name


v

private string $v

Temporary variable used while parsing (stores var names).


vars

private array $vars

Template variable storage


Constructor Detail

ctlTpl()

void ctlTpl([string $td], [boolean $cie])

Constructor. Sets default template directory and clears vars array.

Parameters:
td - default template directory (default value './' -- current directory)
cie - enable checking if template exists or not

Method Detail

checkTpl()

private void checkTpl(string $filename)

Checks if template exists or not.

Parameters:
filename - function library name

checkVars()

boolean checkVars(mixed $var_names)

Checks if template var[s] exist

Parameters:
var_names - variable name array or variable name string
Returns:
TRUE if all vars exist, FALSE otherwise

clearVars()

void clearVars()

Clears all stored template vars


loadLibrary()

void loadLibrary(string $filename)

Loads a function library

Parameters:
filename - function library name
Since:
2003-07-21

process()

string process(string $file, [boolean $clr_vars])

Parses the given template file and clears vars if needed.

Parameters:
file - template file name (relative to default template dir or absolute).
clr_vars - should the variables be cleared after parsing? Default: FALSE.
Returns:
output from template

regVar()

void regVar(string $name, mixed& $var)

Registers a reference to an external variable as a tpl var:

Parameters:
name - variable name
var - variable reference

setVar()

void setVar(string $name, mixed $value)

Creates/changes template var value

Parameters:
name - variable name
value - variable value

setVars()

void setVars(array $array)

Creates/changes multiple template variables

Parameters:
array - variable array. Format should be: array('varname1'=>'value1', 'varname2'=>'value2', ...).

template()

string template(string $file, [string $myname], [boolean $clr_vars])

Includes the result from the template script that is being parsed now into template specified by $name. The result is stored in a variable specified by $myname. NOTICE: this method should be called AT THE END of any template script.

Parameters:
file - template file name (relative to default template dir or absolute).
myname - variable name for included text.
clr_vars - should the variables be cleared after parsing? Default: FALSE.
Returns:
output from template

unsetAllVars()

void unsetAllVars()

Alias of ctlTpl::clearVars.


unsetVar()

void unsetVar(string $name)

Clears a variable

Parameters:
name - variable name

 Overview   Package   Tree   Index 
Tv2 documentation
PREV  NEXT FRAMES  NO FRAME 
SUMMARY:  FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug

This document was generated by phpdocgen 0.17-rc3.
Copyright © 2002-03 Stéphane GALLAND (under the GNU General Public License)