Class: I2CE TemplateMeister (Development)
This article describes the class I2CE_TemplateMeister .
- Extends the class: I2CE_Fuzzy.
- Child Classes:
- Location: Part of the module I2CE in the package I2CE 4.0-dev
- Source: Defined in the file lib/I2CE_TemplateMeister.php on line 33
The I2CE_Template class that all display pages use.
Variables
$doc
The top level DOM document that all methods work with.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 38
- Type: public DOMDocument $doc
$xpath
The XPath object used for search for DOM nodes in the document.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 43
- Type: protected DOMXPath $xpath
$user
The user who is accessing this template
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 49
- Type: protected I2CE_User $user
$working_dir
The working directory for the document. Used for validation and document creation.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 55
- Type: protected string $working_dir
$loadOptions
the load options used when loading XML templates
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 192
- Type: protected integer $loadOptions
$headers
@var protected array $header of string. The header strings.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 227
- Type: protected $headers
$verboseErrors
the verbosity of errors for validation
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 822
- Type: protected boolean $verboseErrors
Methods
__construct()
I2CE_Template constructor method. This constructor sets up the basic variables for all I2CE_Template objects.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 108
- Signature: public function __construct()
_loadFile()
Helper method. Load a file into the spectified document as XML
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 572
- Signature: protected function _loadFile($doc,$contentfile)
- Parameters:
- DOMDocument $doc
- string $contentfile
the file to load
- Returns: boolean
False on failure,
_loadText()
Helper method. Load text into the spectified document as XML @param string $contentfile the file to load
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 595
- Signature: protected function _loadText($doc,$text,$setEncoding)
- Parameters:
- DOMDocument $doc
- $text
- string $setEncoding
Defaults to true. If true, set the encoding to be that of the docuemnt. Only useful as false for loading root template files- Default Value: true
- Returns: boolean
False on failure,
addFile()
Load and add the template file to the document
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 672
- Signature: public function addFile($contentfile,$tag,$relative_node)
- Parameters:
- Returns: DOMNode
the node just created @see loadFile @see replaceNode
addHeader()
Add a header for this tempalte. If not set we user 'Content-type: text/xml; charset=utf-8'
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 207
- Signature: public function addHeader($header)
- Parameters:
- string $header
addText()
Add a string of text to the document and replace the node with the same id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 911
- Signature: public function addText($text,$tag,$relative_node)
- Parameters:
- Returns: DOMNode
the node created
addTextNode()
Add a string of text to the node with the given id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 771
- Signature: public function addTextNode($id,$text,$node)
- Parameters:
- Returns: DOMNode
the node just created
appendElementById()
Create and append an element to the given node by id. @param DOMNode $parent
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 745
- Signature: public function appendElementById($parent_id,$tag,$attr,$value,$node)
- Parameters:
- Returns: DOMNode
appendElementByNode()
Create and append an element to the given node by id.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 758
- Signature: public function appendElementByNode($parent,$tag,$attr,$value,$before)
- Parameters:
- Returns: DOMNode
appendFileById()
This will load the given template and append it to the node with the given id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 692
- Signature: public function appendFileById($contentfile,$tag,$parent_id,$before,$node)
- Parameters:
- string $contentfile
- string $tag
- string $parent_id
- boolean $before
If set the file will be appended as the first child instead of the last. @param $node if non null gets the element relative to that node. Defaults to null @see loadFile @see appendNodeById- Default Value: false
- $node
- Default Value: null
- Returns: DOMNode
appendFileByName()
This will load the given template and append it to the node with the given name attribute at the given occurrence.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 708
- Signature: public function appendFileByName($contentfile,$tag,$parent_name,$occurrence,$node)
- Parameters:
- Returns: DOMNode @see loadFile @see appendNodeByName
appendFileByNode()
This will load the given Template and append it to the given node.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 719
- Signature: public function appendFileByNode($contentfile,$tag,$parent)
- Parameters:
- Returns: DOMNode
if $tag is non-null, then it is the appended node, otherwise it is the parent node
appendNode()
Append a node to the given parent node if it exists.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 514
- Signature: public function appendNode($node,$parent,$before)
- Parameters:
appendNodeById()
Append a node to the node with the given id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 451
- Signature: public function appendNodeById($node,$id,$before,$relative_node)
- Parameters:
appendNodeByName()
Append a node to the give occurrence of the node with the given name attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 464
- Signature: public function appendNodeByName($node,$name,$occurrence,$relative_node)
- Parameters:
appendNodesByName()
Append a node to the give occurrence of the node with the given name attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 481
- Signature: public function appendNodesByName($nodes,$name,$occurrence,$before,$node)
- Parameters:
- mixed $nodes
array of DOMNode or a DOMNodeList - string $name
- integer $occurrence
which occurence of $name to use. If $occurrence is negative then it will return the occurence offset from the end. Example: -1 returns the last occurence. - boolean $before
If set then the node will be appended as the first child instead of the last. @param $node if non null gets the element relative to that node. Defaults to null- Default Value: false
- $node
- Default Value: null
- mixed $nodes
appendTextById()
Add a string of text to the document and append it to the node with the given id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 923
- Signature: public function appendTextById($text,$tag,$parent_id,$node)
- Parameters:
- Returns: DOMNode
the node just created
appendTextByName()
Add a string of text to the document and append it to the node with the given name attribute of the given occurrence.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 937
- Signature: public function appendTextByName($text,$tag,$parent_name,$occurrence,$node)
- Parameters:
- Returns: DOMNode
the node just created
changeAttributesOnNodes()
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 1044
- Signature: public function changeAttributesOnNodes($old,$new,$node)
- Parameters:
- $old
- $new
- $node
- Default Value: null
clearHeaders()
Clear all headers currently set for this template.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 213
- Signature: public function clearHeaders()
createElement()
Create an element to be added to this page. Create a new element in the document with the given attributes and return the node to be added where needed.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 367
- Signature: public function createElement($element_name,$attributes,$value)
- Parameters:
createTextNode()
Create a text node
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 952
- Signature: public function createTextNode($text)
- Parameters:
- string $text
the value of the text node
- string $text
evaluate()
evaluates an Xpath expression on the document
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 962
- Signature: public function evaluate($qry,$node)
- Parameters:
- Returns: mixed
findAndRemoveNodes()
Find and remove nodes. Search the document xpath for any matching nodes and remove them from the document.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 552
- Signature: public function findAndRemoveNodes($xpath,$node)
- Parameters:
- string $xpath @param $node if non null gets the element relative to that node. Defaults to null
- $node
- Default Value: null
findTemplate()
This method finds the location of a template file.If the file is not an absolute file path, it searches the class path 'XML' This method searches the template directory path from the global configuration array for the given template. If it exists it returns the full path to the file and if not it returns false. It seaches the path backwards so that later directories can override package versions of files.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 85
- Signature: public function findTemplate($template,$raise_error)
- Parameters:
- Returns: mixed
getDisplay()
Returns the displayed page as a (tidy!) string
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 242
- Signature: public function getDisplay()
- Returns: string
getDoc()
Get the DOM for the template
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 354
- Signature: public function getDoc()
- Returns: DOMDocument
getElementById()
Searches the DOM XPath for the given id. returns the first match found.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 268
- Signature: public function getElementById($id,$node)
- Parameters:
- string $id @param $node if non null gets the element relative to that node. Defaults to null
- $node
- Default Value: null
- Returns: DOMNode
getElementByName()
Searches the DOM XPath for the given name attribute. This searches the document for the given name attribute. It returns whatever occurrence is requested. If $occurrence is negative then it will return the occurence offset from the end. Example: -1 returns the last occurence. If $occurence is null it returns a DOMNodeList
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 295
- Signature: public function getElementByName($name,$occurrence,$node)
- Parameters:
- string $name
- integer $occurrence @param $node if non null gets the element relative to that node. Defaults to null
- $node
- Default Value: null
- Returns: DOMNode
getElementByTagName()
Searches the DOM XPath for the given tag name This searches the document for the given tagname . It returns whatever occurrence is requested. If $occurrence is negative then it will return the occurence offset from the end. Example: -1 returns the last occurence. If $occurence is null it returns a DOMNodeList
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 330
- Signature: public function getElementByTagName($tagname,$occurrence,$node)
- Parameters:
- string $tagname
- integer $occurrence @param $node if non null gets the element relative to that node. Defaults to null
- $node
- Default Value: null
- Returns: DOMNode
getHeaders()
Get the headers for this page.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 221
- Signature: public function getHeaders()
- Returns: array
of string
getUser()
Get the user for this template
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 68
- Signature: public function getUser()
- Returns: I2CE_User
$user or false if non has been set
importText()
Add a string of text to the document.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 786
- Signature: public function importText($text,$tag)
- Parameters:
- Returns: DOMNode
or array od DOMNodes null on failure
loadFile()
Load a template file into the current document. This will load the given template file into the current document. It will only load based on the surrounding tag name given. It doesn't place the given node into the document yet, just makes it available for use.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 642
- Signature: public function loadFile($contentfile,$tag)
- Parameters:
- Returns: mixed
DOMNode -- the node just created if $tag was non-nill. array if $tag was null consisting of the imported nodes.
loadRootFile()
Creates a new document and loads the root file used for this template.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 130
- Signature: public function loadRootFile($root_file)
- Parameters:
- string $root_file
- Returns: boolean
false on failure
loadRootText()
Creates a new document and loads the input text
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 164
- Signature: public function loadRootText($text)
- Parameters:
- string $text
- Returns: boolean.
false on failure
prepareDisplay()
Called to prepare the display.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 234
- Signature: public function prepareDisplay()
processArgs()
Process any arguments sent to the page
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 155
- Signature: public function processArgs($args)
- Parameters:
- $args
- Returns: boolean
true on sucess. false on failure
query()
Run an Xpath query on the document
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 978
- Signature: public function query($qry,$node)
- Parameters:
- Returns: DOMNodeList
raiseError()
A raise error method for template that behaves like I2CE::raiseError, except it also displays what is calling the I2CE_Template methods. Raises an error and redirect the user for any critical errors. The default redirect will go to the home page for the site. @param string/mixed $message The error message.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 1003
- Signature: protected function raiseError($message,$type,$redirect)
- Parameters:
- $message
- integer $type
The error type.- Default Value: E_USER_NOTICE
- string $redirect
The page to redirect to for critical errors. @global array- Default Value: ""
reIdNodes()
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 1039
- Signature: public function reIdNodes($old_name,$new_name,$node)
- Parameters:
- $old_name
- $new_name
- $node
- Default Value: null
removeNode()
Remove the given node from the document.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 538
- Signature: public function removeNode($node)
- Parameters:
- DOMNode $node
removeNodeById()
Remove a node with the given id attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 530
- Signature: public function removeNodeById($id,$node)
- Parameters:
- string $id @param $node if non null gets the element relative to that node. Defaults to null
- $node
- Default Value: null
renameNodes()
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 1035
- Signature: public function renameNodes($old_name,$new_name,$node)
- Parameters:
- $old_name
- $new_name
- $node
- Default Value: null
replaceNode()
Replace a node based on the id attribute. Finds a node with the same id attribute as the one in the node passed to this method and replaces it.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 435
- Signature: public function replaceNode($node,$relative_node)
- Parameters:
setAttribute()
Sets an attribute on the given node ID and xpath. Finds a given node by ID and then searches the given xpath and then adds or replaces the given attribute.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 396
- Signature: public function setAttribute($attr,$value,$id,$xpath,$node)
- Parameters:
- string $attr
- string $value
- string $id
If non-null we perform our xpath query relative to the node with this id - string $xpath
Defaults to null, in which case we set the attribute of the node by id. If non-null, we change the attribute of every node found by the xpath query which is searched relative to the the node with the given id. @param $node if non null gets the element by id relative to that node. Defaults to null- Default Value: null
- $node
- Default Value: null
setLoadOptions()
Set the load options used when loading XML templates. If not called, we use the load options = LIBXML_DTDVALID & & LIBXML_DTDATTR @param integer options.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 199
- Signature: public function setLoadOptions($options)
- Parameters:
- $options
setNodeAttribute()
Sets an attribute on the given node.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 419
- Signature: public function setNodeAttribute($attr,$value,$node)
- Parameters:
setUser()
Set the user for this template
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 60
- Signature: public function setUser($user)
- Parameters:
- I2CE_User $user
- Default Value: false
- I2CE_User $user
setVerboseErrors()
Set the verbosity of errors for validation
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 814
- Signature: public function setVerboseErrors($verbose)
- Parameters:
- boolean $verbose
setWorkingDir()
Set the working directory for the document. Used for validation and document creation.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 121
- Signature: public function setWorkingDir($working_dir)
- Parameters:
- string $working_dir
validate()
Validates the XML of this template.
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 827
- Signature: public function validate()
- Returns: boolean
true on sucess
xmlError()
Prints an XML error nicely. Based on http://us3.php.net/manual/en/function.libxml-get-errors.php
- Defined in i2ce/lib/I2CE_TemplateMeister.php on line 861
- Signature: public function xmlError($error,$ret_string)
- Parameters:
- LIBXmlError $error
or array or LIBXMLError - mixed $ret_string
Defaults to false in which it raises an error for the errors . If true, we return a string. if a string, it returns a string with the this value at the begining.- Default Value: false
- LIBXmlError $error
- Returns: string
Inherited Methods
_hasMethod()
This public method is inherited from I2CE_Fuzzy->_hasMethod()
Inherited Fuzzy Methods
userMessage()
This method is inherited from I2CE_Fuzzy->userMessage()