PHP Class DOMTemplateNode, NoNonsenseForum

Datei anzeigen Open project: Kroc/NoNonsenseForum Class Usage Examples

Public Properties

Property Type Description
$entities a table of HTML entites to reverse, '&', '<' and '>' are exlcuded so we don’t turn user text into working HTML!

Protected Properties

Property Type Description
$DOMNode
$namespaces an internal XPath object so you don't have to manage one externally

Public Methods

Method Description
__construct ( $DOMNode, $namespaces = [] ) from different documents! DOMTemplateNodes _must_ come from DOMDocument kept privately inside DOMTemplate
__toString ( ) * output the source code (cast the object to a string, i.e. echo $template;) --------------------------------------------------------------------------------------------------------------
addClass ( $query, $new_class ) * addClass : add a className to an element, appending it to existing classes if they exist --------------------------------------------------------------------------------------------------------------
html_entity_decode ( $html ) * html_entity_decode : convert HTML entities back to UTF-8 --------------------------------------------------------------------------------------------------------------
query ( $query ) DOMNodeList and therefore can't create APIs that affect all the nodes returned by an XPath query
remove ( $query ) * remove : remove all the elements / attributes that match an xpath query --------------------------------------------------------------------------------------------------------------
repeat ( $query ) * $item = $DOMTemplate->repeat ('.list-item'); foreach ($data as $value) $item->setValue ('.', $value)->next ();
set ( $queries, $asHTML = false ) * set : change multiple nodes in a simple fashion --------------------------------------------------------------------------------------------------------------
setValue ( $query, $value, $asHTML = false ) * setValue : set the text on the results of a single xpath query --------------------------------------------------------------------------------------------------------------
shorthand2xpath ( $query, $use_relative = true ) * an index-number can be provided after the element name, e.g. 'li[1]'
toXML ( $text ) * toXML : convert string input to safe XML for inporting into DOM --------------------------------------------------------------------------------------------------------------

Private Methods

Method Description
setClassNode ( $DOMNode, $class ) add a className to an existing class attribute (this is shared between setValue & addClass

Method Details

__construct() public method

from different documents! DOMTemplateNodes _must_ come from DOMDocument kept privately inside DOMTemplate
public __construct ( $DOMNode, $namespaces = [] )

__toString() public method

* output the source code (cast the object to a string, i.e. echo $template;) --------------------------------------------------------------------------------------------------------------
public __toString ( )

addClass() public method

* addClass : add a className to an element, appending it to existing classes if they exist --------------------------------------------------------------------------------------------------------------
public addClass ( $query, $new_class )

html_entity_decode() public static method

* html_entity_decode : convert HTML entities back to UTF-8 --------------------------------------------------------------------------------------------------------------
public static html_entity_decode ( $html )

query() public method

DOMNodeList and therefore can't create APIs that affect all the nodes returned by an XPath query
public query ( $query )

remove() public method

* remove : remove all the elements / attributes that match an xpath query --------------------------------------------------------------------------------------------------------------
public remove ( $query )

repeat() public method

* $item = $DOMTemplate->repeat ('.list-item'); foreach ($data as $value) $item->setValue ('.', $value)->next ();
public repeat ( $query )

set() public method

* set : change multiple nodes in a simple fashion --------------------------------------------------------------------------------------------------------------
public set ( $queries, $asHTML = false )

setValue() public method

* setValue : set the text on the results of a single xpath query --------------------------------------------------------------------------------------------------------------
public setValue ( $query, $value, $asHTML = false )

shorthand2xpath() public static method

* an index-number can be provided after the element name, e.g. 'li[1]'
public static shorthand2xpath ( $query, $use_relative = true )

toXML() public static method

* toXML : convert string input to safe XML for inporting into DOM --------------------------------------------------------------------------------------------------------------
public static toXML ( $text )

Property Details

$DOMNode protected_oe property

protected $DOMNode

$entities public_oe static_oe property

a table of HTML entites to reverse, '&', '<' and '>' are exlcuded so we don’t turn user text into working HTML!
public static $entities

$namespaces protected_oe property

an internal XPath object so you don't have to manage one externally
protected $namespaces