Class: I2CE TemplateMeister: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 35: Line 35:
==Methods==
==Methods==
===__construct()===
===__construct()===
I2CE_Template constructor method.
I2CE_Template constructor method. This constructor sets up the basic variables for all I2CE_Template objects.
 
This constructor sets up the basic variables for all I2CE_Template objects.
*Signature: public function __construct()
*Signature: public function __construct()
===_loadFile()===
===_loadFile()===
Helper method.  Load a file into the spectified document as XML
Helper method.  Load a file into the spectified document as XML
*Signature: protected function _loadFile($doc,$contentfile)
*Signature: protected function _loadFile($doc,$contentfile)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] False on failure,
*Parameters:
Parameters:
** [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
* [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile <br/>the file to load
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile<br/>the file to load
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>False on failure,
===_loadText()===
===_loadText()===
Helper method.  Load text into the spectified document as XML
Helper method.  Load text into the spectified document as XML @param string $contentfile the file to load
@param string $contentfile the file to load
*Signature: protected function _loadText($doc,$text,$setEncoding)
*Signature: protected function _loadText($doc,$text,$setEncoding)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]  False on failure,
*Parameters:
Parameters:
** [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
* [http://www.php.net/manual/en/class.domdocument.php DOMDocument ] $doc
*$text  
*$text  
* [http://www.php.net/manual/en/language.types.string.php string ] $setEncoding<br/>Defaults to true.  If true, set the encoding to be that of the docuemnt.  Only useful as false for loading root template files
** [http://www.php.net/manual/en/language.types.string.php string ] $setEncoding <br/>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
***Default Value: true
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>False on failure,
===addFile()===
===addFile()===
Load and add the  template file to the document
Load and add the  template file to the document
*Signature: public function addFile($contentfile,$tag,$relative_node)
*Signature: public function addFile($contentfile,$tag,$relative_node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node just created
*Parameters:
@see loadFile
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
@see replaceNode
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
Parameters:
***Default Value: "div"
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node <br/>if non null gets the element relative to that node.  Defaults to null
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
***Default Value: null  
**Default Value: "div"
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>the node just created @see loadFile @see replaceNode
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node<br/>if non null gets the element relative to that node.  Defaults to null
**Default Value: null  
===addHeader()===
===addHeader()===
Add a header for this tempalte.  If not set we user 'Content-type: text/xml; charset=utf-8'
Add a header for this tempalte.  If not set we user 'Content-type: text/xml; charset=utf-8'
*Signature: public function addHeader($header)
*Signature: public function addHeader($header)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $header
** [http://www.php.net/manual/en/language.types.string.php string ] $header
===addText()===
===addText()===
Add a string of text to the document and replace the node with the same id attribute.
Add a string of text to the document and replace the node with the same id attribute.
*Signature: public function addText($text,$tag,$relative_node)
*Signature: public function addText($text,$tag,$relative_node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node created
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $text
* [http://www.php.net/manual/en/language.types.string.php string ] $text
** [http://www.php.net/manual/en/language.types.string.php string ] $tag <br/>Defaults to "div."
* [http://www.php.net/manual/en/language.types.string.php string ] $tag<br/>Defaults to "div."
***Default Value: "div"  
**Default Value: "div"  
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node <br/>if non null gets the element relative to that node.  Defaults to null
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node<br/>if non null gets the element relative to that node.  Defaults to null
***Default Value: null
**Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>the node created
===addTextNode()===
===addTextNode()===
Add a string of text to the node with the given id attribute.
Add a string of text to the node with the given id attribute.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function addTextNode($id,$text,$node)
*Signature: public function addTextNode($id,$text,$node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node just created
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $id <br/>string an id, or a DOMNode
* [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $id<br/>string an id, or a DOMNode
** [http://www.php.net/manual/en/language.types.string.php string ] $text @param $node if non null gets the element relative to that node.  Defaults to null
* [http://www.php.net/manual/en/language.types.string.php string ] $text
*$node  
*$node  
**Default Value: null  
***Default Value: null  
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>the node just created
===appendElementById()===
===appendElementById()===
Create and append an element to the given node by id.
Create and append an element to the given node by id. @param DOMNode $parent
@param DOMNode $parent
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendElementById($parent_id,$tag,$attr,$value,$node)
*Signature: public function appendElementById($parent_id,$tag,$attr,$value,$node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Parameters:
Parameters:
*$parent_id  
*$parent_id  
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
* [http://www.php.net/manual/en/language.types.array.php array ] $attr
** [http://www.php.net/manual/en/language.types.array.php array ] $attr
**Default Value: array()
***Default Value: array()
* [http://www.php.net/manual/en/language.types.string.php string ] $value
** [http://www.php.net/manual/en/language.types.string.php string ] $value @param $node if non null gets the element relative to that node.  Defaults to null
**Default Value: ""  
***Default Value: ""  
*$node  
*$node  
**Default Value: null
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
===appendElementByNode()===
===appendElementByNode()===
Create and append an element to the given node by id.
Create and append an element to the given node by id.
*Signature: public function appendElementByNode($parent,$tag,$attr,$value,$before)
*Signature: public function appendElementByNode($parent,$tag,$attr,$value,$before)
*Parameters:
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
** [http://www.php.net/manual/en/language.types.array.php array ] $attr
***Default Value: array()
** [http://www.php.net/manual/en/language.types.string.php string ] $value
***Default Value: ""
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before <br/>defaults to false
***Default Value: false
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
* [http://www.php.net/manual/en/language.types.array.php array ] $attr
**Default Value: array()
* [http://www.php.net/manual/en/language.types.string.php string ] $value
**Default Value: ""
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before<br/>defaults to false
**Default Value: false
===appendFileById()===
===appendFileById()===
This will load the given template and append it to the node with the given id attribute.
This will load the given template and append it to the node with the given id attribute.
@param $node if non null gets the element relative to that node.  Defaults to null
@see loadFile
@see appendNodeById
*Signature: public function appendFileById($contentfile,$tag,$parent_id,$before,$node)
*Signature: public function appendFileById($contentfile,$tag,$parent_id,$before,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
** [http://www.php.net/manual/en/language.types.string.php string ] $parent_id
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before <br/>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: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
* [http://www.php.net/manual/en/language.types.string.php string ] $parent_id
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before<br/>If set the file will be appended as the first child instead of the last.
**Default Value: false
*$node
**Default Value: null
===appendFileByName()===
===appendFileByName()===
This will load the given  template and append it to the node with the given name attribute
This will load the given  template and append it to the node with the given name attribute at the given occurrence.
at the given occurrence.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendFileByName($contentfile,$tag,$parent_name,$occurrence,$node)
*Signature: public function appendFileByName($contentfile,$tag,$parent_name,$occurrence,$node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Parameters:
@see loadFile
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
@see appendNodeByName
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $parent_name
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
** integer $occurrence @param $node if non null gets the element relative to that node.  Defaults to null
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
***Default Value: 0
* [http://www.php.net/manual/en/language.types.string.php string ] $parent_name
* integer $occurrence
**Default Value: 0
*$node  
*$node  
**Default Value: null  
***Default Value: null  
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]@see loadFile @see appendNodeByName
===appendFileByNode()===
===appendFileByNode()===
This will load the given  Template and append it to the given node.
This will load the given  Template and append it to the given node.
*Signature: public function appendFileByNode($contentfile,$tag,$parent)
*Signature: public function appendFileByNode($contentfile,$tag,$parent)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] if $tag is non-null, then it is the appended node, otherwise it is the parent node
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
** [http://www.php.net/manual/en/language.types.string.php string ] $tag <br/>The tagname we of the top-level imported node we wish to append.  if null, we import all nodes
* [http://www.php.net/manual/en/language.types.string.php string ] $tag<br/>The tagname we of the top-level imported node we wish to append.  if null, we import all nodes
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>if $tag is non-null, then it is the appended node, otherwise it is the parent node
===appendNode()===
===appendNode()===
Append a node to the given parent node if it exists.
Append a node to the given parent node if it exists.
*Signature: public function appendNode($node,$parent,$before)
*Signature: public function appendNode($node,$parent,$before)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $parent
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before<br/>If set then the node will be appended as the first child instead of the last.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before <br/>If set then the node will be appended as the first child instead of the last.
**Default Value: false  
***Default Value: false  
===appendNodeById()===
===appendNodeById()===
Append a node to the node with the given id attribute.
Append a node to the node with the given id attribute.
*Signature: public function appendNodeById($node,$id,$before,$relative_node)
*Signature: public function appendNodeById($node,$id,$before,$relative_node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/language.types.string.php string ] $id
** [http://www.php.net/manual/en/language.types.string.php string ] $id
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before<br/>If set then the node will be appended as the first child instead of the last.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before <br/>If set then the node will be appended as the first child instead of the last.
**Default Value: false
***Default Value: false
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node<br/>if non null gets the element relative to that node.  Defaults to null
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node <br/>if non null gets the element relative to that node.  Defaults to null
**Default Value: null  
***Default Value: null  
===appendNodeByName()===
===appendNodeByName()===
Append a node to the give occurrence of the node with the given name attribute.
Append a node to the give occurrence of the node with the given name attribute.
@param $relative_node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendNodeByName($node,$name,$occurrence,$relative_node)
*Signature: public function appendNodeByName($node,$name,$occurrence,$relative_node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/language.types.string.php string ] $name
** [http://www.php.net/manual/en/language.types.string.php string ] $name
* integer $occurrence
** integer $occurrence @param $relative_node if non null gets the element relative to that node.  Defaults to null
*$relative_node  
*$relative_node  
**Default Value: null  
***Default Value: null  
===appendNodesByName()===
===appendNodesByName()===
Append a node to the give occurrence of the node with the given name attribute.
Append a node to the give occurrence of the node with the given name attribute.
If $occurrence is negative then it will return the occurence offset from the end.
Example: -1 returns the last occurence.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendNodesByName($nodes,$name,$occurrence,$before,$node)
*Signature: public function appendNodesByName($nodes,$name,$occurrence,$before,$node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $nodes<br/>array of DOMNode or a DOMNodeList
** [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $nodes <br/>array of DOMNode or a DOMNodeList
* [http://www.php.net/manual/en/language.types.string.php string ] $name
** [http://www.php.net/manual/en/language.types.string.php string ] $name
* integer $occurrence<br/>which occurence of $name to use.
** integer $occurrence <br/>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.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before<br/>If set then the node will be appended as the first child instead of the last.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $before <br/>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
***Default Value: false
*$node  
*$node  
**Default Value: null  
***Default Value: null  
===appendTextById()===
===appendTextById()===
Add a string of  text to the document and append it to the node with the given id attribute.
Add a string of  text to the document and append it to the node with the given id attribute.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendTextById($text,$tag,$parent_id,$node)
*Signature: public function appendTextById($text,$tag,$parent_id,$node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node just created
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $text
* [http://www.php.net/manual/en/language.types.string.php string ] $text
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
** [http://www.php.net/manual/en/language.types.string.php string ] $parent_id @param $node if non null gets the element relative to that node.  Defaults to null
* [http://www.php.net/manual/en/language.types.string.php string ] $parent_id
*$node  
*$node  
**Default Value: null
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>the node just created
===appendTextByName()===
===appendTextByName()===
Add a string of  text to the document and append it to the node with the given name attribute
Add a string of  text to the document and append it to the node with the given name attribute of the given occurrence.
of the given occurrence.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function appendTextByName($text,$tag,$parent_name,$occurrence,$node)
*Signature: public function appendTextByName($text,$tag,$parent_name,$occurrence,$node)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] -- the node just created
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $text
* [http://www.php.net/manual/en/language.types.string.php string ] $text
** [http://www.php.net/manual/en/language.types.string.php string ] $tag
* [http://www.php.net/manual/en/language.types.string.php string ] $tag
** [http://www.php.net/manual/en/language.types.string.php string ] $parent_name
* [http://www.php.net/manual/en/language.types.string.php string ] $parent_name
** integer $occurrence @param $node if non null gets the element relative to that node.  Defaults to null
* integer $occurrence
*$node  
*$node  
**Default Value: null  
***Default Value: null  
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>the node just created
===changeAttributesOnNodes()===
===changeAttributesOnNodes()===
*Signature: public function changeAttributesOnNodes($old,$new,$node)
*Signature: public function changeAttributesOnNodes($old,$new,$node)
Parameters:
*Parameters:
*$old  
*$old  
*$new  
*$new  
*$node  
*$node  
**Default Value: null
***Default Value: null
===clearHeaders()===
===clearHeaders()===
Clear all headers currently set for this template.
Clear all headers currently set for this template.
*Signature: public function clearHeaders()
*Signature: public function clearHeaders()
===createElement()===
===createElement()===
Create an element to be added to this page.
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.
 
Create a new element in the document with the given attributes and return the node to be
added where needed.
*Signature: public function createElement($element_name,$attributes,$value)
*Signature: public function createElement($element_name,$attributes,$value)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $element_name
** [http://www.php.net/manual/en/language.types.string.php string ] $element_name
* [http://www.php.net/manual/en/language.types.array.php array ] $attributes
** [http://www.php.net/manual/en/language.types.array.php array ] $attributes
**Default Value: array()
***Default Value: array()
*$value  
*$value  
**Default Value: ""  
***Default Value: ""  
===createTextNode()===
===createTextNode()===
Create a text node
Create a text node
*Signature: public function createTextNode($text)
*Signature: public function createTextNode($text)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $text<br/>the value of the text node
** [http://www.php.net/manual/en/language.types.string.php string ] $text <br/>the value of the text node
===evaluate()===
===evaluate()===
evaluates an Xpath expression on the document
evaluates an Xpath expression on the document
*Signature: public function evaluate($qry,$node)
*Signature: public function evaluate($qry,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $qry <br/>an xpath query
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node <br/>If non null, the node at wich we we start the query
***Default Value: null
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $qry<br/>an xpath query
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>If non null, the node at wich we we start the query
**Default Value: null
===findAndRemoveNodes()===
===findAndRemoveNodes()===
Find and remove nodes.
Find and remove nodes. Search the document xpath for any matching nodes and remove them from the document.
 
Search the document xpath for any matching nodes and remove them from the document.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function findAndRemoveNodes($xpath,$node)
*Signature: public function findAndRemoveNodes($xpath,$node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $xpath
** [http://www.php.net/manual/en/language.types.string.php string ] $xpath @param $node if non null gets the element relative to that node.  Defaults to null
*$node  
*$node  
**Default Value: null  
***Default Value: null  
===findTemplate()===
===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 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.
 
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.
*Signature: public function findTemplate($template,$raise_error)
*Signature: public function findTemplate($template,$raise_error)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $template <br/>The name of the template file.
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $raise_error <br/>Defaults to true.  Raise error if template is not found
***Default Value: true
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $template<br/>The name of the template file.
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $raise_error<br/>Defaults to true.  Raise error if template is not found
**Default Value: true
===getDisplay()===
===getDisplay()===
Returns the displayed page as a (tidy!) string
Returns the displayed page as a (tidy!) string
Line 293: Line 260:
*Returns: [http://www.php.net/manual/en/class.domdocument.php DOMDocument ]
*Returns: [http://www.php.net/manual/en/class.domdocument.php DOMDocument ]
===getElementById()===
===getElementById()===
Searches the DOM XPath for the given id.
Searches the DOM XPath for the given id. returns the first match found.
 
returns the first match found.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function getElementById($id,$node)
*Signature: public function getElementById($id,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $id @param $node if non null gets the element relative to that node.  Defaults to null
*$node
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $id
*$node
**Default Value: null
===getElementByName()===
===getElementByName()===
Searches the DOM XPath for the given name attribute.
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
 
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
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function getElementByName($name,$occurrence,$node)
*Signature: public function getElementByName($name,$occurrence,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $name
** integer $occurrence @param $node if non null gets the element relative to that node.  Defaults to null
*$node
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $name
* integer $occurrence
*$node
**Default Value: null
===getElementByTagName()===
===getElementByTagName()===
Searches the DOM XPath for the given tag name
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
 
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
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function getElementByTagName($tagname,$occurrence,$node)
*Signature: public function getElementByTagName($tagname,$occurrence,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $tagname
** integer $occurrence @param $node if non null gets the element relative to that node.  Defaults to null
*$node
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $tagname
* integer $occurrence
*$node
**Default Value: null
===getHeaders()===
===getHeaders()===
Get the headers for this page.
Get the headers for this page.
*Signature: public function getHeaders()
*Signature: public function getHeaders()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string
===getUser()===
===getUser()===
Get the user for this template
Get the user for this template
*Signature: public function getUser()
*Signature: public function getUser()
*Returns: [[Class: I2CE_User | I2CE_User]] $user or false if non has been set
*Returns: [[Class: I2CE_User | I2CE_User]]<br/>$user or false if non has been set
===importText()===
===importText()===
Add a string of text to the document.
Add a string of text to the document.
*Signature: public function importText($text,$tag)
*Signature: public function importText($text,$tag)
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ] or array od DOMNodes null on failure
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $text
* [http://www.php.net/manual/en/language.types.string.php string ] $text
** [http://www.php.net/manual/en/language.types.string.php string ] $tag <br/>Defaults to "div."  If null, all top-level nodes are returned in an array
* [http://www.php.net/manual/en/language.types.string.php string ] $tag<br/>Defaults to "div."  If null, all top-level nodes are returned in an array
***Default Value: "div"
**Default Value: "div"
*Returns: [http://www.php.net/manual/en/class.domnode.php DOMNode ]<br/>or array od DOMNodes null on failure
===loadFile()===
===loadFile()===
Load a template file into the current document.
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.
 
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.
*Signature: public function loadFile($contentfile,$tag)
*Signature: public function loadFile($contentfile,$tag)
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ] DOMNode -- the node just created if $tag was non-nill.  array if $tag was null consisting of the imported nodes.
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
* [http://www.php.net/manual/en/language.types.string.php string ] $contentfile
** [http://www.php.net/manual/en/language.types.string.php string ] $tag <br/>If non-null it is the tagname of a toplevel node we wish to import. if null, we import all nodes.
* [http://www.php.net/manual/en/language.types.string.php string ] $tag<br/>If non-null it is the tagname of a toplevel node we wish to import. if null, we import all nodes.
***Default Value: "div"  
**Default Value: "div"  
*Returns: [http://www.php.net/manual/en/language.pseudo-types.php mixed ]<br/>DOMNode -- the node just created if $tag was non-nill.  array if $tag was null consisting of the imported nodes.
===loadRootFile()===
===loadRootFile()===
Creates a new document and loads the root file used for this template.
Creates a new document and loads the root file used for this template.
*Signature: public function loadRootFile($root_file)
*Signature: public function loadRootFile($root_file)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] false on failure
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $root_file
* [http://www.php.net/manual/en/language.types.string.php string ] $root_file
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>false on failure
===loadRootText()===
===loadRootText()===
Creates a new document and loads the input text
Creates a new document and loads the input text
*Signature: public function loadRootText($text)
*Signature: public function loadRootText($text)
*Returns: boolean. false on failure
*Parameters:
Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $text <br/>;
* [http://www.php.net/manual/en/language.types.string.php string ] $text<br/>;
*Returns: boolean.<br/>false on failure
===prepareDisplay()===
===prepareDisplay()===
Called to prepare the display.
Called to prepare the display.
Line 378: Line 327:
Process any arguments sent to the page
Process any arguments sent to the page
*Signature: public function processArgs($args)
*Signature: public function processArgs($args)
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] true on sucess. false on failure
*Parameters:
Parameters:
*$args  
*$args  
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>true on sucess. false on failure
===query()===
===query()===
Run an Xpath query on the document
Run an Xpath query on the document
*Signature: public function query($qry,$node)
*Signature: public function query($qry,$node)
*Parameters:
** [http://www.php.net/manual/en/language.types.string.php string ] $qry <br/>an xpath query
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node <br/>If non null, the node at wich we we start the query
***Default Value: null
*Returns: [http://www.php.net/manual/en/class.domnodelist.php DOMNodeList ]
*Returns: [http://www.php.net/manual/en/class.domnodelist.php DOMNodeList ]
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $qry<br/>an xpath query
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node<br/>If non null, the node at wich we we start the query
**Default Value: null
===raiseError()===
===raiseError()===
A raise error method for template that behaves like I2CE::raiseError, except it also displays what
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.
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.
@global array
*Signature: protected function raiseError($message,$type,$redirect)
*Signature: protected function raiseError($message,$type,$redirect)
Parameters:
*Parameters:
*$message  
*$message  
* integer $type<br/>The error type.
** integer $type <br/>The error type.
**Default Value: E_USER_NOTICE
***Default Value: E_USER_NOTICE
* [http://www.php.net/manual/en/language.types.string.php string ] $redirect<br/>The page to redirect to for critical errors.
** [http://www.php.net/manual/en/language.types.string.php string ] $redirect <br/>The page to redirect to for critical errors. @global array
**Default Value: ""  
***Default Value: ""  
===reIdNodes()===
===reIdNodes()===
*Signature: public function reIdNodes($old_name,$new_name,$node)
*Signature: public function reIdNodes($old_name,$new_name,$node)
Parameters:
*Parameters:
*$old_name  
*$old_name  
*$new_name  
*$new_name  
*$node  
*$node  
**Default Value: null
***Default Value: null
===removeNode()===
===removeNode()===
Remove the given node from the document.
Remove the given node from the document.
*Signature: public function removeNode($node)
*Signature: public function removeNode($node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
===removeNodeById()===
===removeNodeById()===
Remove a node with the given id attribute.
Remove a node with the given id attribute.
@param $node if non null gets the element relative to that node.  Defaults to null
*Signature: public function removeNodeById($id,$node)
*Signature: public function removeNodeById($id,$node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $id
** [http://www.php.net/manual/en/language.types.string.php string ] $id @param $node if non null gets the element relative to that node.  Defaults to null
*$node  
*$node  
**Default Value: null  
***Default Value: null  
===renameNodes()===
===renameNodes()===
*Signature: public function renameNodes($old_name,$new_name,$node)
*Signature: public function renameNodes($old_name,$new_name,$node)
Parameters:
*Parameters:
*$old_name  
*$old_name  
*$new_name  
*$new_name  
*$node  
*$node  
**Default Value: null
***Default Value: null
===replaceNode()===
===replaceNode()===
Replace a node based on the id attribute.
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.
 
Finds a node with the same id attribute as the one in the
node passed to this method and replaces it.
*Signature: public function replaceNode($node,$relative_node)
*Signature: public function replaceNode($node,$relative_node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node<br/>if non null gets the element relative to that node.  Defaults to null
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $relative_node <br/>if non null gets the element relative to that node.  Defaults to null
**Default Value: null  
***Default Value: null  
===setAttribute()===
===setAttribute()===
Sets an attribute on the given node ID and xpath.
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.
 
Finds a given node by ID and then searches the given xpath and then
adds or replaces the given attribute.
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
*Signature: public function setAttribute($attr,$value,$id,$xpath,$node)
*Signature: public function setAttribute($attr,$value,$id,$xpath,$node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $attr
** [http://www.php.net/manual/en/language.types.string.php string ] $attr
* [http://www.php.net/manual/en/language.types.string.php string ] $value
** [http://www.php.net/manual/en/language.types.string.php string ] $value
* [http://www.php.net/manual/en/language.types.string.php string ] $id<br/>If non-null we perform our xpath query relative to the node with this id
** [http://www.php.net/manual/en/language.types.string.php string ] $id <br/>If non-null we perform our xpath query relative to the node with this id
* [http://www.php.net/manual/en/language.types.string.php string ] $xpath<br/>Defaults to null, in which case we set the attribute of the node by id.
** [http://www.php.net/manual/en/language.types.string.php string ] $xpath <br/>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
***Default Value: null
*$node  
*$node  
**Default Value: null  
***Default Value: null  
===setLoadOptions()===
===setLoadOptions()===
Set the load options used when loading XML templates.  If not called, we use the
Set the load options used when loading XML templates.  If not called, we use the load options = LIBXML_DTDVALID &  & LIBXML_DTDATTR @param integer options.
load options = LIBXML_DTDVALID &  & LIBXML_DTDATTR
@param integer options.
*Signature: public function setLoadOptions($options)
*Signature: public function setLoadOptions($options)
Parameters:
*Parameters:
*$options  
*$options  
===setNodeAttribute()===
===setNodeAttribute()===
Sets an attribute on the given node.
Sets an attribute on the given node.
*Signature: public function setNodeAttribute($attr,$value,$node)
*Signature: public function setNodeAttribute($attr,$value,$node)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $attr
** [http://www.php.net/manual/en/language.types.string.php string ] $attr
* [http://www.php.net/manual/en/language.types.string.php string ] $value
** [http://www.php.net/manual/en/language.types.string.php string ] $value
* [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
** [http://www.php.net/manual/en/class.domnode.php DOMNode ] $node
===setUser()===
===setUser()===
Set the user for this template
Set the user for this template
*Signature: public function setUser($user)
*Signature: public function setUser($user)
Parameters:
*Parameters:
* [[Class: I2CE_User | I2CE_User]] $user
** [[Class: I2CE_User | I2CE_User]] $user
**Default Value: false
***Default Value: false
===setVerboseErrors()===
===setVerboseErrors()===
Set the verbosity of errors for validation
Set the verbosity of errors for validation
*Signature: public function setVerboseErrors($verbose)
*Signature: public function setVerboseErrors($verbose)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $verbose
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $verbose
===setWorkingDir()===
===setWorkingDir()===
Set the working directory for the document.  Used for validation and document creation.
Set the working directory for the document.  Used for validation and document creation.
*Signature: public function setWorkingDir($working_dir)
*Signature: public function setWorkingDir($working_dir)
Parameters:
*Parameters:
* [http://www.php.net/manual/en/language.types.string.php string ] $working_dir
** [http://www.php.net/manual/en/language.types.string.php string ] $working_dir
===validate()===
===validate()===
Validates the XML of this template.
Validates the XML of this template.
*Signature: public function validate()
*Signature: public function validate()
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] true on sucess
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>true on sucess
===xmlError()===
===xmlError()===
Prints an XML error nicely.  Based on http://us3.php.net/manual/en/function.libxml-get-errors.php
Prints an XML error nicely.  Based on http://us3.php.net/manual/en/function.libxml-get-errors.php
if a string, it returns a string with the this value at the begining.
*Signature: public function xmlError($error,$ret_string)
*Signature: public function xmlError($error,$ret_string)
*Parameters:
** LIBXmlError $error <br/>or array or LIBXMLError
** [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $ret_string <br/>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
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]
Parameters:
* LIBXmlError $error<br/>or array or LIBXMLError
* [http://www.php.net/manual/en/language.pseudo-types.php mixed ] $ret_string<br/>Defaults to false in which it raises an error for the errors .  If true, we return a string.
**Default Value: false
==Inherited Fuzzy Methods==
==Inherited Fuzzy Methods==
===userMessage()===
===userMessage()===

Revision as of 23:40, 16 October 2009

This article desrcibes the class I2CE_TemplateMeister.

The I2CE_Template class that all display pages use.

Variables

$doc

The top level DOM document that all methods work with.

$xpath

The XPath object used for search for DOM nodes in the document.

$user

The user who is accessing this template

$working_dir

The working directory for the document. Used for validation and document creation.

  • Type: protected ng $working_dir

$loadOptions

the load options used when loading XML templates

  • Type: protected nteger $loadOptions

$headers

@var protected array $header of string. The header strings.

  • Type: protected $headers

$verboseErrors

the verbosity of errors for validation

  • Type: protected n $verboseErrors

Methods

__construct()

I2CE_Template constructor method. This constructor sets up the basic variables for all I2CE_Template objects.

  • Signature: public function __construct()

_loadFile()

Helper method. Load a file into the spectified document as XML

  • Signature: protected function _loadFile($doc,$contentfile)
  • Parameters:
  • Returns: boolean
    False on failure,

_loadText()

Helper method. Load text into the spectified document as XML @param string $contentfile the file to load

  • Signature: protected function _loadText($doc,$text,$setEncoding)
  • Parameters:
  • $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

  • Signature: public function addFile($contentfile,$tag,$relative_node)
  • Parameters:
    • string $contentfile
    • string $tag
      • Default Value: "div"
    • DOMNode $relative_node
      if non null gets the element relative to that node. Defaults to null
      • Default Value: null
  • 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'

  • Signature: public function addHeader($header)
  • Parameters:

addText()

Add a string of text to the document and replace the node with the same id attribute.

  • Signature: public function addText($text,$tag,$relative_node)
  • Parameters:
    • string $text
    • string $tag
      Defaults to "div."
      • Default Value: "div"
    • DOMNode $relative_node
      if non null gets the element relative to that node. Defaults to null
      • Default Value: null
  • Returns: DOMNode
    the node created

addTextNode()

Add a string of text to the node with the given id attribute.

  • Signature: public function addTextNode($id,$text,$node)
  • Parameters:
    • mixed $id
      string an id, or a DOMNode
    • string $text @param $node if non null gets the element relative to that node. Defaults to null
  • $node
      • Default Value: null
  • Returns: DOMNode
    the node just created

appendElementById()

Create and append an element to the given node by id. @param DOMNode $parent

  • Signature: public function appendElementById($parent_id,$tag,$attr,$value,$node)
  • Parameters:
  • $parent_id
    • string $tag
    • array $attr
      • Default Value: array()
    • string $value @param $node if non null gets the element relative to that node. Defaults to null
      • Default Value: ""
  • $node
      • Default Value: null
  • Returns: DOMNode

appendElementByNode()

Create and append an element to the given node by id.

  • 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.

  • 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.

  • Signature: public function appendFileByName($contentfile,$tag,$parent_name,$occurrence,$node)
  • Parameters:
    • string $contentfile
    • string $tag
    • string $parent_name
    • integer $occurrence @param $node if non null gets the element relative to that node. Defaults to null
      • Default Value: 0
  • $node
      • Default Value: null
  • Returns: DOMNode @see loadFile @see appendNodeByName

appendFileByNode()

This will load the given Template and append it to the given node.

  • Signature: public function appendFileByNode($contentfile,$tag,$parent)
  • Parameters:
    • string $contentfile
    • string $tag
      The tagname we of the top-level imported node we wish to append. if null, we import all nodes
    • DOMNode $parent
  • 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.

  • Signature: public function appendNode($node,$parent,$before)
  • Parameters:
    • DOMNode $node
    • DOMNode $parent
    • boolean $before
      If set then the node will be appended as the first child instead of the last.
      • Default Value: false

appendNodeById()

Append a node to the node with the given id attribute.

  • Signature: public function appendNodeById($node,$id,$before,$relative_node)
  • Parameters:
    • DOMNode $node
    • string $id
    • boolean $before
      If set then the node will be appended as the first child instead of the last.
      • Default Value: false
    • DOMNode $relative_node
      if non null gets the element relative to that node. Defaults to null
      • Default Value: null

appendNodeByName()

Append a node to the give occurrence of the node with the given name attribute.

  • Signature: public function appendNodeByName($node,$name,$occurrence,$relative_node)
  • Parameters:
    • DOMNode $node
    • string $name
    • integer $occurrence @param $relative_node if non null gets the element relative to that node. Defaults to null
  • $relative_node
      • Default Value: null

appendNodesByName()

Append a node to the give occurrence of the node with the given name attribute.

  • 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

appendTextById()

Add a string of text to the document and append it to the node with the given id attribute.

  • Signature: public function appendTextById($text,$tag,$parent_id,$node)
  • Parameters:
    • string $text
    • string $tag
    • string $parent_id @param $node if non null gets the element relative to that node. Defaults to null
  • $node
      • Default Value: null
  • 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.

  • Signature: public function appendTextByName($text,$tag,$parent_name,$occurrence,$node)
  • Parameters:
    • string $text
    • string $tag
    • string $parent_name
    • integer $occurrence @param $node if non null gets the element relative to that node. Defaults to null
  • $node
      • Default Value: null
  • Returns: DOMNode
    the node just created

changeAttributesOnNodes()

  • Signature: public function changeAttributesOnNodes($old,$new,$node)
  • Parameters:
  • $old
  • $new
  • $node
      • Default Value: null

clearHeaders()

Clear all headers currently set for this template.

  • 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.

  • Signature: public function createElement($element_name,$attributes,$value)
  • Parameters:
  • $value
      • Default Value: ""

createTextNode()

Create a text node

  • Signature: public function createTextNode($text)
  • Parameters:
    • string $text
      the value of the text node

evaluate()

evaluates an Xpath expression on the document

  • Signature: public function evaluate($qry,$node)
  • Parameters:
    • string $qry
      an xpath query
    • DOMNode $node
      If non null, the node at wich we we start the query
      • Default Value: null
  • Returns: mixed

findAndRemoveNodes()

Find and remove nodes. Search the document xpath for any matching nodes and remove them from the document.

  • 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.

  • Signature: public function findTemplate($template,$raise_error)
  • Parameters:
    • string $template
      The name of the template file.
    • boolean $raise_error
      Defaults to true. Raise error if template is not found
      • Default Value: true
  • Returns: mixed

getDisplay()

Returns the displayed page as a (tidy!) string

  • Signature: public function getDisplay()
  • Returns: string

getDoc()

Get the DOM for the template

getElementById()

Searches the DOM XPath for the given id. returns the first match found.

  • 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

  • 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

  • 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.

  • Signature: public function getHeaders()
  • Returns: array
    of string

getUser()

Get the user for this template

  • Signature: public function getUser()
  • Returns: I2CE_User
    $user or false if non has been set

importText()

Add a string of text to the document.

  • Signature: public function importText($text,$tag)
  • Parameters:
    • string $text
    • string $tag
      Defaults to "div." If null, all top-level nodes are returned in an array
      • Default Value: "div"
  • 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.

  • Signature: public function loadFile($contentfile,$tag)
  • Parameters:
    • string $contentfile
    • string $tag
      If non-null it is the tagname of a toplevel node we wish to import. if null, we import all nodes.
      • Default Value: "div"
  • 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.

  • Signature: public function loadRootFile($root_file)
  • Parameters:
  • Returns: boolean
    false on failure

loadRootText()

Creates a new document and loads the input text

  • Signature: public function loadRootText($text)
  • Parameters:
  • Returns: boolean.
    false on failure

prepareDisplay()

Called to prepare the display.

  • Signature: public function prepareDisplay()

processArgs()

Process any arguments sent to the page

  • Signature: public function processArgs($args)
  • Parameters:
  • $args
  • Returns: boolean
    true on sucess. false on failure

query()

Run an Xpath query on the document

  • Signature: public function query($qry,$node)
  • Parameters:
    • string $qry
      an xpath query
    • DOMNode $node
      If non null, the node at wich we we start the query
      • Default Value: null
  • 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.

  • 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()

  • 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.

  • Signature: public function removeNode($node)
  • Parameters:

removeNodeById()

Remove a node with the given id attribute.

  • 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()

  • 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.

  • Signature: public function replaceNode($node,$relative_node)
  • Parameters:
    • DOMNode $node
    • DOMNode $relative_node
      if non null gets the element relative to that node. Defaults to null
      • Default Value: null

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.

  • 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.

  • Signature: public function setLoadOptions($options)
  • Parameters:
  • $options

setNodeAttribute()

Sets an attribute on the given node.

  • Signature: public function setNodeAttribute($attr,$value,$node)
  • Parameters:

setUser()

Set the user for this template

  • Signature: public function setUser($user)
  • Parameters:

setVerboseErrors()

Set the verbosity of errors for validation

  • Signature: public function setVerboseErrors($verbose)
  • Parameters:

setWorkingDir()

Set the working directory for the document. Used for validation and document creation.

  • Signature: public function setWorkingDir($working_dir)
  • Parameters:

validate()

Validates the XML of this template.

  • 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

  • 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
  • Returns: string

Inherited Fuzzy Methods

userMessage()

This method is inherited from I2CE_Fuzzy->userMessage()