Class Template

Description

Template class.

The interface was originally inspired by PHPLib templates, and the template file formats are quite similar.

  • version: 1.1
  • author: Nathan Codding of the phpBB group

Located in /Core/Template.php (line 12)


	
			
Direct descendents
Class Description
TestTemplate Template class.
Method Summary
Template Template ([String $root = "."])
Boolean assignBlockVars (String $blockname,  $vararray)
Boolean assignVar (String $varName, String $varValue)
Boolean assignVars ( $varArray)
String compile (String $code, [Boolean $doNotEcho = false], [String $retvar = ''])
void destroy ()
void execute ( $code, [ $varname = ''])
String generateBlockDataRef (String $blockname, Boolean $includeLastIterator)
String generateBlockVarRef (String $namespace, String $varname)
String getCompiledCode (String $handle)
String getUncompiledCode (String $handle)
Boolean loadFile (String $handle)
String makeFilename (String $filename)
boolean setFilenames ( $filenameArray)
boolean setRootdir (String $dir)
Methods
Constructor Template (line 39)

Constructor. Simply sets the root dir.

  • access: public
Template Template ([String $root = "."])
  • String $root: Root directory to be set
assignBlockVars (line 159)

Block-level variable assignment. Adds a new block iteration with the given variable assignments. Note that this should only be called once per block iteration.

  • return: Always returns true
  • access: public
Boolean assignBlockVars (String $blockname,  $vararray)
  • String $blockname: Name of the block
  • Array $vararray: Array of the key-values pairs
assignVar (line 132)

Root-level variable assignment. Adds to current assignments, overriding any existing variable assignment with the same name.

  • return: Always returns true
  • access: public
Boolean assignVar (String $varName, String $varValue)
  • String $varName: Name of the variable
  • String $varValue: Value of the variable
assignVars (line 143)

Root-level variable assignment. Adds to current assignments, overriding any existing variable assignment with the same name.

  • return: Always returns true
  • access: public
Boolean assignVars ( $varArray)
  • Array $varArray: Array of key-values pairs
compile (line 257)

Compiles the given string of code, and returns the result in a string.

If "doNotEcho" is true, the returned code will not be directly executable, but can be used as part of a variable assignment for use in assignCodeFromHandle().

  • return: Compiled code
  • access: public
String compile (String $code, [Boolean $doNotEcho = false], [String $retvar = ''])
  • String $code: Code to be compiled
  • Boolean $doNotEcho: Set this to true for not echoing
  • String $retvar: Name of the variable to be set
destroy (line 47)

Destroys this template object. Should be called when you're done with it, in order to clear out the template data so you can load/parse a new template set.

  • access: public
void destroy ()
execute (line 400)
  • access: public
void execute ( $code, [ $varname = ''])
  • $code
  • $varname
generateBlockDataRef (line 199)

Generates a reference to the array of data values for the given (possibly nested) block namespace. This is a string of the form: $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']

NOTE: does not expect a trailing "." on the blockname.

  • return: String of the described form
  • access: protected
String generateBlockDataRef (String $blockname, Boolean $includeLastIterator)
  • String $blockname: name of the block to work with
  • Boolean $includeLastIterator: If $includeLastIterator is true, then [$_childN_i] will be appended to the form shown above.

Redefined in descendants as:
generateBlockVarRef (line 229)

Generates a reference to the given variable inside the given (possibly nested) block namespace. This is a string of the form: ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . ' It's ready to be inserted into an "echo" line in one of the templates.

NOTE: expects a trailing "." on the namespace.

  • return: String of the described form
  • access: protected
String generateBlockVarRef (String $namespace, String $varname)
  • String $namespace: Name space of the variable
  • String $varname: Name of the variable

Redefined in descendants as:
getCompiledCode (line 391)

Returns compiled code for the given handle.

  • return: Compiled code
  • access: public
String getCompiledCode (String $handle)
  • String $handle: Name of the handle
getUncompiledCode (line 377)

Returns uncompiled code for the given handle.

  • return: Uncompiled code
  • access: public
String getUncompiledCode (String $handle)
  • String $handle: Name of the handle
loadFile (line 103)

If not already done, load the file for the given handle and populate the uncompiled_code[] hash with its code. Do not compile.

  • return: True if file contents is loaded (also if already loaded)
  • access: protected
Boolean loadFile (String $handle)
  • String $handle: Handle for this file

Redefined in descendants as:
makeFilename (line 84)

Generates a full path+filename for the given filename, which can either be an absolute name, or a name relative to the rootdir for this Template object.

  • return: Checked and parsed filename
  • access: protected
String makeFilename (String $filename)
  • String $filename: Filename to be checked

Redefined in descendants as:
setFilenames (line 69)

Sets the template filenames for handles. $filenameArray should be a hash of handle => filename pairs.

  • return: Always returns true
  • access: public
boolean setFilenames ( $filenameArray)
  • Array $filenameArray: Array of handle-filename pairs
setRootdir (line 56)

Sets the template root directory for this Template object.

  • return: False is returned if parameter does not point to directory
  • access: public
boolean setRootdir (String $dir)
  • String $dir: Directory name to be set

Documentation generated on Mon, 11 Dec 2006 22:42:38 +0300 by phpDocumentor 1.3.0