PHP Class HTMLPurifier_Lexer_DOMLex, yii

In PHP 5, the DOM XML extension was revamped into DOM and added to the core. It gives us a forgiving HTML parser, which we use to transform the HTML into a DOM, and then into the tokens. It is blazingly fast (for large documents, it performs twenty times faster than HTMLPurifier_Lexer_DirectLex,and is the default choice for PHP 5.
Inheritance: extends HTMLPurifier_Lexer
显示文件 Open project: yiisoft/yii

Public Methods

Method Description
__construct ( )
callbackArmorCommentEntities ( array $matches ) : string Callback function that entity-izes ampersands in comments so that callbackUndoCommentSubst doesn't clobber them
callbackUndoCommentSubst ( array $matches ) : string Callback function for undoing escaping of stray angled brackets in comments
muteErrorHandler ( integer $errno, string $errstr ) An error handler that mutes all errors
tokenizeHTML ( string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : HTMLPurifier_Token[]

Protected Methods

Method Description
createEndNode ( DOMNode $node, HTMLPurifier_Token[] &$tokens )
createStartNode ( DOMNode $node, HTMLPurifier_Token[] &$tokens, boolean $collect ) : boolean
tokenizeDOM ( DOMNode $node, HTMLPurifier_Token[] &$tokens ) : HTMLPurifier_Token Iterative function that tokenizes a node, putting it into an accumulator.
transformAttrToAssoc ( DOMNamedNodeMap $node_map ) : array Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.
wrapHTML ( string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string Wraps an HTML fragment in the necessary HTML

Method Details

__construct() public method

public __construct ( )

callbackArmorCommentEntities() public method

Callback function that entity-izes ampersands in comments so that callbackUndoCommentSubst doesn't clobber them
public callbackArmorCommentEntities ( array $matches ) : string
$matches array
return string

callbackUndoCommentSubst() public method

Callback function for undoing escaping of stray angled brackets in comments
public callbackUndoCommentSubst ( array $matches ) : string
$matches array
return string

createEndNode() protected method

protected createEndNode ( DOMNode $node, HTMLPurifier_Token[] &$tokens )
$node DOMNode
$tokens HTMLPurifier_Token[]

createStartNode() protected method

protected createStartNode ( DOMNode $node, HTMLPurifier_Token[] &$tokens, boolean $collect ) : boolean
$node DOMNode DOMNode to be tokenized.
$tokens HTMLPurifier_Token[] Array-list of already tokenized tokens.
$collect boolean Says whether or start and close are collected, set to false at first recursion because it's the implicit DIV tag you're dealing with.
return boolean if the token needs an endtoken

muteErrorHandler() public method

An error handler that mutes all errors
public muteErrorHandler ( integer $errno, string $errstr )
$errno integer
$errstr string

tokenizeDOM() protected method

To iterate is human, to recurse divine - L. Peter Deutsch
protected tokenizeDOM ( DOMNode $node, HTMLPurifier_Token[] &$tokens ) : HTMLPurifier_Token
$node DOMNode DOMNode to be tokenized.
$tokens HTMLPurifier_Token[] Array-list of already tokenized tokens.
return HTMLPurifier_Token of node appended to previously passed tokens.

tokenizeHTML() public method

public tokenizeHTML ( string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : HTMLPurifier_Token[]
$html string
$config HTMLPurifier_Config
$context HTMLPurifier_Context
return HTMLPurifier_Token[]

transformAttrToAssoc() protected method

Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.
protected transformAttrToAssoc ( DOMNamedNodeMap $node_map ) : array
$node_map DOMNamedNodeMap DOMNamedNodeMap of DOMAttr objects.
return array Associative array of attributes.

wrapHTML() protected method

Wraps an HTML fragment in the necessary HTML
protected wrapHTML ( string $html, HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : string
$html string
$config HTMLPurifier_Config
$context HTMLPurifier_Context
return string