Dom_Template
public class Dom_Template
| Field Summary | |
|---|---|
| protected DOMElement | The body tag of a html page |
| protected array | An array of choice DOMElement objects |
| protected array | Comment tags to be removed |
| protected DOMDocument | |
| protected DOMElement | An array of form DOMElement objects |
| protected array | An array of formElement DOMElement objects |
| protected DOMElement | The head tag of a html page |
| protected array | Header elements to be added |
| protected array | An array of DOMElement objects |
| protected Dom_Template | |
| protected boolean | Set to true if this template has been parsed |
| protected array | An array of repeat DOMElement objects |
| protected DOMElement | The head tag of a html page |
| protected array | An array of var DOMElement objects |
| Constructor Summary | |
|---|---|
__construct(DOMDocument doc) The constructor |
|
| Method Summary | |
|---|---|
| boolean | appendDoc(string var, DOMDocument doc) Append documents before the $var element |
| void | appendHeadElement(string elementName, array attributes, string value) Appends an element to the widgets of the HTML head element. |
| boolean | appendTemplate(string var, Dom_Template template) Append a template before the $var elementThis wil also grab any headers in the $template. |
| static string | cleanXml(string xml) Get the xml and return the cleaned string A good place to clean any nasty html entities and other non valid XML/XHTML elements |
| string | getAttr(string var, string attr) Retreive the text contained within an attribute of a node. |
| DOMElement | Return the body node. |
| DOMDocument | getDocument(boolean parse) Return a parsed Dom document. |
| DOMElement | getElementById(string id) Get a DOMElement from the document based on its unique ID ID attributes should be unique for XHTML documents, multiple names are ignored and only the first node found is returned. |
| Dom_Form | getForm(string id) Return a form object from the document. |
| array | Return the current list of header nodes |
| protected DOMElement | getNextSibling(string var) ?? Used by the repeat region. |
| Dom_Repeat | getRepeat(string repeat) Get a repeating region from a document. |
| DOMElement | getRepeatElement(string repeat) Get a repeat element node from the document. |
| string | getText(string var) Get the text inside a var node. |
| string | Gets the page title text. |
| DOMElement | getVarElement(string var) Get a var element node from the document. |
| private void | init(DOMElement node, string form) A private method to initalise the template. |
| boolean | insertDoc(string var, DOMDocument doc) Insert a doc into a var in this objects doc The DOMDocument will replace the var tag |
| static boolean | insertHTML(DOMElement element, string html, string encoding) Insert some HTML formatted text into a dom node. |
| boolean | insertTemplate(string var, Dom_Template template) Insert a template into a var in this objects doc The DOMDocument will replace the var tagThis will also grab any headers in the supplied template. |
| boolean | isParsed() Get the parsed state of the template. |
| void | keyExists(string property, string key) Check if a repeat,choice,var,form (template property) Exists. |
| static Dom_Template | load(string xmlFile) Make a template from an xml file |
| static Dom_Template | loadXml(string xmlStr) Make a template from an xml string |
| static void | objectToString(mixed obj) Return a string from an object. |
| protected void | preInit(DOMElement node, string form) This function is used when subclassing the template implement this function to capture nodes. |
| protected void | removeChildren(DOMNode node) Removes all children from a node. |
| void | replaceAttr(string var, string attr, string value) Replace an attribute value. |
| boolean | replaceHTML(string var, string html, string encoding) Insert some HTML formatted text into a var node. |
| void | replaceText(string var, string value) Replace the text of one or more var nodes |
| void | setChoice(string choice) Set a choice node to become visible in a document. |
| void | setHeaderList(mixed arr, array ) Set the current list of header nodes |
| protected void | setNextSibling(string var, DOMElement nextSibling) ??? Used by the repeat region. |
| void | setTitleText(mixed value, string The) Sets the document title text if available. |
| string | toString(string type) Recive the document in the format of 'xml' or 'html'. |
| void | unsetChoice(string choice) Set a choice node to become invisible in a document. |
protected DOMElement $body = null
The body tag of a html page
protected array $choice = array()
An array of choice DOMElement objects
protected array $comments = array()
Comment tags to be removed
protected DOMDocument $document = null
protected DOMElement $form = array()
An array of form DOMElement objects
protected array $formElement = array()
An array of formElement DOMElement objects
protected DOMElement $head = null
The head tag of a html page
protected array $headers = array()
Header elements to be added
protected array $nextSibling = array()
An array of DOMElement objects
protected Dom_Template $parent = null
protected boolean $parsed = false
Set to true if this template has been parsed
protected array $repeat = array()
An array of repeat DOMElement objects
protected DOMElement $title = null
The head tag of a html page
protected array $var = array()
An array of var DOMElement objects
public __construct(DOMDocument doc)
The constructor
public boolean appendDoc(string var, DOMDocument doc)
Append documents before the $var element
public void appendHeadElement(string elementName, array attributes, string value)
Appends an element to the widgets of the HTML head element.
In the form of: <$elementName $attributes[$key]="$attributes[$key].$value">$value$elementName>
NOTE: Only allows unique headers. An md5 hash is refrenced from all input parameters. Any duplicate headers are discarded.
public boolean appendTemplate(string var, Dom_Template template)
Append a template before the $var element
This wil also grab any headers in the $template.
public static string cleanXml(string xml)
Get the xml and return the cleaned string A good place to clean any nasty html entities and other non valid XML/XHTML elements
public string getAttr(string var, string attr)
Retreive the text contained within an attribute of a node.
public DOMElement getBodyElement()
Return the body node.
public DOMDocument getDocument(boolean parse)
Return a parsed Dom document. After using this call you can no longer use the template render functions as no changes will be made to the template unless you use DOM functions
public DOMElement getElementById(string id)
Get a DOMElement from the document based on its unique ID ID attributes should be unique for XHTML documents, multiple names are ignored and only the first node found is returned.
public Dom_Form getForm(string id)
Return a form object from the document.
public array getHeaderList()
Return the current list of header nodes
protected DOMElement getNextSibling(string var)
?? Used by the repeat region.
public Dom_Repeat getRepeat(string repeat)
Get a repeating region from a document.
public DOMElement getRepeatElement(string repeat)
Get a repeat element node from the document.
public string getText(string var)
Get the text inside a var node.
public string getTitleText()
Gets the page title text.
public DOMElement getVarElement(string var)
Get a var element node from the document.
private void init(DOMElement node, string form)
A private method to initalise the template.
public boolean insertDoc(string var, DOMDocument doc)
Insert a doc into a var in this objects doc The DOMDocument will replace the var tag
public static boolean insertHTML(DOMElement element, string html, string encoding)
Insert some HTML formatted text into a dom node.
public boolean insertTemplate(string var, Dom_Template template)
Insert a template into a var in this objects doc The DOMDocument will replace the var tag
This will also grab any headers in the supplied template.
public boolean isParsed()
Get the parsed state of the template. If true then no more changes can be made to the template
public void keyExists(string property, string key)
Check if a repeat,choice,var,form (template property) Exists.
public static Dom_Template load(string xmlFile)
Make a template from an xml file
public static Dom_Template loadXml(string xmlStr)
Make a template from an xml string
public static void objectToString(mixed obj)
Return a string from an object.
protected void preInit(DOMElement node, string form)
This function is used when subclassing the template implement this function to capture nodes.
protected void removeChildren(DOMNode node)
Removes all children from a node.
public void replaceAttr(string var, string attr, string value)
Replace an attribute value.
public boolean replaceHTML(string var, string html, string encoding)
Insert some HTML formatted text into a var node.
public void replaceText(string var, string value)
Replace the text of one or more var nodes
public void setChoice(string choice)
Set a choice node to become visible in a document.
public void setHeaderList(mixed arr, array )
Set the current list of header nodes
protected void setNextSibling(string var, DOMElement nextSibling)
??? Used by the repeat region.
public void setTitleText(mixed value, string The)
Sets the document title text if available.
public string toString(string type)
Recive the document in the format of 'xml' or 'html'. NOTE: This method does not parse the template document.
public void unsetChoice(string choice)
Set a choice node to become invisible in a document.
A PHP5 DOM Template Library
TODO: Add documentation on how to use this lib
NOTE: Var attribute values cannot begin with '__' because they are reserved for the template system's internal functions.