Class XTemplate

Description

Located in /xtemplate.class.php (line 39)


	
			
Variable Summary
Method Summary
XTemplate XTemplate (string $file, [string $tpldir = ''], [array $files = null], [string $mainblock = 'main'], [boolean $autosetup = true])
void array_loop (string $bname, string $var, array &$values)
void assign (string $name, [string $val = ''])
void assign_file (string $name, [string $val = ''])
void clear_autoreset ()
boolean get_error ()
void insert_loop (string $bname, string $var, [string $value = ''])
void out (string $bname)
void out_file (string $bname, string $fname)
void parse (string $bname)
boolean parsed (string $bname)
void reset (string $bname)
void restart (string $file, [string $tpldir = ''], [array $files = null], [string $mainblock = 'main'], [boolean $autosetup = true], [string $tag_start = '{'], [string $tag_end = '}'])
void rparse (string $bname)
void scan_globals ()
void SetNullBlock (string $str, [string $bname = ''])
void SetNullString (string $str, [string $varname = ''])
void setup ([boolean $add_outer = false])
void set_autoreset ()
string text ([string $bname = ''])
void _assign_file_sub (string $name, string $val)
string _getfile (string $file)
void _maketree (string $con, [string $parentblock = ''])
void _pre_var_dump (multiple 0)
string _r_getfile (string $file)
void _set_error (string $str)
array _store_filevar_parents (array $blocks)
Variables
mixed $blocks = array() (line 44)
mixed $block_end_delim = '-->' (line 63)
mixed $block_end_word = 'END:' (line 65)
mixed $block_parse_order = array() (line 47)
mixed $block_start_delim = '<!-- ' (line 62)
mixed $block_start_word = 'BEGIN:' (line 64)
mixed $filecache = array() (line 52)
mixed $filecontents = '' (line 43)

*[ variables ]**********************************************************

mixed $filename = '' (line 56)
mixed $files = null (line 55)
mixed $filevars = array() (line 50)
mixed $filevar_delim = '' (line 60)
mixed $filevar_delim_nl = '' (line 61)
mixed $filevar_parent = array() (line 51)
mixed $file_delim = '' (line 59)
mixed $mainblock = 'main' (line 73)
mixed $output_type = 'HTML' (line 75)
mixed $parsed_blocks = array() (line 45)
mixed $preparsed_blocks = array() (line 46)
mixed $sub_blocks = array() (line 48)
mixed $tag_end_delim = '}' (line 70)
mixed $tag_start_delim = '{' (line 69)
mixed $tpldir = '' (line 54)
mixed $vars = array() (line 49)
mixed $_autoreset = true (line 80)
mixed $_error = '' (line 79)
mixed $_file_name_full_path = '' (line 86)
mixed $_ignore_missing_blocks = true (line 82)
mixed $_null_block = array('' => '') (line 78)
mixed $_null_string = array('' => '') (line 77)
Methods
Constructor XTemplate (line 98)

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
array_loop (line 465)

parses a block for every set of data in the values array

  • access: public
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 (line 222)

assign a variable

  • access: public
void assign (string $name, [string $val = ''])
  • string $name: Variable to assign $val to
  • string $val: / array $val Value to assign to $name
assign_file (line 243)

assign a file variable

  • access: public
void assign_file (string $name, [string $val = ''])
  • string $name: Variable to assign $val to
  • string $val: / array $val Values to assign to $name
clear_autoreset (line 608)

sets AUTORESET to 0. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks)

  • access: public
void clear_autoreset ()
get_error (line 635)

gets error condition / string

  • return: / string
  • access: public
boolean get_error ()
insert_loop (line 451)

inserts a loop ( call assign & parse )

  • access: public
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
out (line 507)

prints the parsed text

  • access: public
void out (string $bname)
  • string $bname: Block name to echo out
out_file (line 532)

prints the parsed text to a specified file

  • access: public
void out_file (string $bname, string $fname)
  • string $bname: Block name to write out
  • string $fname: File name to write to
parse (line 263)

parse a block

  • access: public
void parse (string $bname)
  • string $bname: Block name to parse
parsed (line 560)

returns true if block was parsed, false if not

  • access: public
boolean parsed (string $bname)
  • string $bname: Block name to test
reset (line 548)

resets the parsed text

  • access: public
void reset (string $bname)
  • string $bname: Block to reset
restart (line 142)

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: }
rparse (line 426)

returns the parsed text for a block, including all sub-blocks.

  • access: public
void rparse (string $bname)
  • string $bname: Block name to parse
scan_globals (line 618)

scans global variables and assigns to PHP array

  • access: public
void scan_globals ()
SetNullBlock (line 584)

sets the string to replace in case the block was not parsed

  • access: public
void SetNullBlock (string $str, [string $bname = ''])
  • string $str: Display string for null block
  • string $bname: Block name to apply $str to
SetNullString (line 572)

sets the string to replace in case the var was not assigned

  • access: public
void SetNullString (string $str, [string $varname = ''])
  • string $str: Display string for null block
  • string $varname: Variable name to apply $str to
setup (line 184)

setup - the elements that were previously in the constructor

  • access: public
void setup ([boolean $add_outer = false])
  • boolean $add_outer: If true is passed when called, it adds an outer main block to the file
set_autoreset (line 596)

sets AUTORESET to 1. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks)

  • access: public
void set_autoreset ()
text (line 484)

returns the parsed text for a block

  • access: public
string text ([string $bname = ''])
  • string $bname: Block name to return
_add_outer_block (line 926)

add an outer block delimiter set useful for rtfs etc - keeps them editable in word

  • access: private
void _add_outer_block ()
_assign_file_sub (line 759)

Sub processing for assign_file method

void _assign_file_sub (string $name, string $val)
  • string $name
  • string $val
_getfile (line 844)

returns the contents of a file

  • access: private
string _getfile (string $file)
  • string $file
_maketree (line 668)

generates the array containing to-be-parsed stuff: $blocks["main"],$blocks["main.table"],$blocks["main.table.row"], etc. also builds the reverse parse order.

  • access: private
void _maketree (string $con, [string $parentblock = ''])
  • string $con: content to be processed
  • string $parentblock: name of the parent block in the block hierarchy
_pre_var_dump (line 940)

Debug function - var_dump wrapped in '

' tags

  • access: private
void _pre_var_dump (multiple 0)
  • multiple 0: Var_dumps all the supplied arguments
_r_getfile (line 905)

recursively gets the content of a file with {FILE "filename.tpl"} directives

  • access: private
string _r_getfile (string $file)
  • string $file
_set_error (line 828)

Set the error string

void _set_error (string $str)
  • string $str
_store_filevar_parents (line 805)

store container block's name for file variables

  • access: private
array _store_filevar_parents (array $blocks)
  • array $blocks

Documentation generated on Mon, 11 Apr 2005 10:59:12 +0100 by phpDocumentor 1.3.0RC3