PHP Класс DOMTemplateNode, NoNonsenseForum

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$entities a table of HTML entites to reverse, '&', '<' and '>' are exlcuded so we don’t turn user text into working HTML!

Защищенные свойства (Protected)

Свойство Тип Описание
$DOMNode
$namespaces an internal XPath object so you don't have to manage one externally

Открытые методы

Метод Описание
__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 --------------------------------------------------------------------------------------------------------------

Приватные методы

Метод Описание
setClassNode ( $DOMNode, $class ) add a className to an existing class attribute (this is shared between setValue & addClass

Описание методов

__construct() публичный Метод

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

__toString() публичный Метод

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

addClass() публичный Метод

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

html_entity_decode() публичный статический Метод

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

query() публичный Метод

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

remove() публичный Метод

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

repeat() публичный Метод

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

set() публичный Метод

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

setValue() публичный Метод

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

shorthand2xpath() публичный статический Метод

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

toXML() публичный статический Метод

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

Описание свойств

$DOMNode защищенное свойство

protected $DOMNode

$entities публичное статическое свойство

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

$namespaces защищенное свойство

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