Constructor - Instantiate the object
XTemplate
XTemplate
(
string $file, [
string $tpldir =
''], [
array $files =
null], [
string $mainblock =
'main'], [
boolean $autosetup =
true])
-
string
$file: Template file to work on
-
string
$tpldir: Location of template files (useful for keeping files outside web server root)
-
array
$files: Filenames lookup
-
string
$mainblock: Name of main block in the template
-
boolean
$autosetup: If true, run setup() as part of constuctor
parses a block for every set of data in the values array
void
array_loop
(string $bname, string $var, array &$values)
-
string
$bname: Block name to loop
-
string
$var: Variable to assign values to
-
array
$values: Values to assign to $var
assign a variable
void
assign
(string $name, [string $val = ''])
-
string
$name: Variable to assign $val to
-
string
$val: / array $val Value to assign to $name
assign a file variable
void
assign_file
(string $name, [string $val = ''])
-
string
$name: Variable to assign $val to
-
string
$val: / array $val Values to assign to $name
sets AUTORESET to 0. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks)
void
clear_autoreset
()
gets error condition / string
boolean
get_error
()
inserts a loop ( call assign & parse )
void
insert_loop
(string $bname, string $var, [string $value = ''])
-
string
$bname: Block name to assign
-
string
$var: Variable to assign values to
-
string
$value: / array $value Value to assign to $var
prints the parsed text
void
out
(string $bname)
-
string
$bname: Block name to echo out
prints the parsed text to a specified file
void
out_file
(string $bname, string $fname)
-
string
$bname: Block name to write out
-
string
$fname: File name to write to
parse a block
void
parse
(string $bname)
-
string
$bname: Block name to parse
returns true if block was parsed, false if not
boolean
parsed
(string $bname)
-
string
$bname: Block name to test
resets the parsed text
void
reset
(string $bname)
-
string
$bname: Block to reset
Restart the class - allows one instantiation with several files processed by restarting
e.g. $xtpl = new XTemplate('file1.xtpl'); $xtpl->parse('main'); $xtpl->out('main'); $xtpl->restart('file2.xtpl'); $xtpl->parse('main'); $xtpl->out('main'); (Added in response to sf:641407 feature request)
void
restart
(string $file, [string $tpldir = ''], [array $files = null], [string $mainblock = 'main'], [boolean $autosetup = true], [string $tag_start = '{'], [string $tag_end = '}'])
-
string
$file: Template file to work on
-
string
$tpldir: Location of template files
-
array
$files: Filenames lookup
-
string
$mainblock: Name of main block in the template
-
boolean
$autosetup: If true, run setup() as part of restarting
-
string
$tag_start: {
-
string
$tag_end: }
returns the parsed text for a block, including all sub-blocks.
void
rparse
(string $bname)
-
string
$bname: Block name to parse
scans global variables and assigns to PHP array
void
scan_globals
()
sets the string to replace in case the block was not parsed
void
SetNullBlock
(string $str, [string $bname = ''])
-
string
$str: Display string for null block
-
string
$bname: Block name to apply $str to
sets the string to replace in case the var was not assigned
void
SetNullString
(string $str, [string $varname = ''])
-
string
$str: Display string for null block
-
string
$varname: Variable name to apply $str to
setup - the elements that were previously in the constructor
void
setup
([boolean $add_outer = false])
-
boolean
$add_outer: If true is passed when called, it adds an outer main block to the file
sets AUTORESET to 1. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks)
void
set_autoreset
()
returns the parsed text for a block
string
text
([string $bname = ''])
-
string
$bname: Block name to return
add an outer block delimiter set useful for rtfs etc - keeps them editable in word
void
_add_outer_block
()
Sub processing for assign_file method
void
_assign_file_sub
(string $name, string $val)
returns the contents of a file
string
_getfile
(string $file)
generates the array containing to-be-parsed stuff: $blocks["main"],$blocks["main.table"],$blocks["main.table.row"], etc. also builds the reverse parse order.
void
_maketree
(string $con, [string $parentblock = ''])
-
string
$con: content to be processed
-
string
$parentblock: name of the parent block in the block hierarchy
Debug function - var_dump wrapped in '
' tags
void
_pre_var_dump
(multiple 0)
-
multiple
0: Var_dumps all the supplied arguments
recursively gets the content of a file with {FILE "filename.tpl"} directives
string
_r_getfile
(string $file)
Set the error string
void
_set_error
(string $str)
store container block's name for file variables
array
_store_filevar_parents
(array $blocks)