PHP Class DOMTemplateNode, NoNonsenseForum

Afficher le fichier Open project: Kroc/NoNonsenseForum Class Usage Examples

Méthodes publiques

Свойство 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

Свойство Type Description
$DOMNode
$namespaces an internal XPath object so you don't have to manage one externally

Méthodes publiques

Méthode 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

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

Method Details

__construct() public méthode

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

__toString() public méthode

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

addClass() public méthode

* 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 méthode

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

query() public méthode

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

remove() public méthode

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

repeat() public méthode

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

set() public méthode

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

setValue() public méthode

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

shorthand2xpath() public static méthode

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

toXML() public static méthode

* 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