PHP Класс HTMLPurifier_Injector, yii

This enables "formatter-like" functionality such as auto-paragraphing, smiley-ification and linkification to take place.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$name Advisory name of injector, this is for friendly error messages.
$needed Array of elements and attributes this injector creates and therefore need to be allowed by the definition. Takes form of array('element' => array('attr', 'attr2'), 'element2')

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

Свойство Тип Описание
$currentNesting Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside"
$currentToken Reference to current token.
$htmlDefinition
$inputZipper Reference to InputZipper variable in Context.
$rewindOffset Number of elements to rewind backwards (relative).

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

Метод Описание
allowsElement ( string $name ) : boolean Tests if the context node allows a certain element
checkNeeded ( HTMLPurifier_Config $config ) : boolean | string This function checks if the HTML environment will work with the Injector: if p tags are not allowed, the Auto-Paragraphing injector should not be enabled.
getRewindOffset ( ) : boolean | integer Retrieves rewind offset, and then unsets it.
handleElement ( &$token ) Handler that is called when a start or empty token is processed
handleEnd ( &$token ) Handler that is called when an end token is processed
handleText ( &$token ) Handler that is called when a text token is processed
notifyEnd ( HTMLPurifier_Token $token ) Notifier that is called when an end token is processed
prepare ( HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : boolean | string Prepares the injector by giving it the config and context objects: this allows references to important variables to be made within the injector. This function also checks if the HTML environment will work with the Injector (see checkNeeded()).
rewindOffset ( boolean | integer $offset ) Rewind to a spot to re-perform processing. This is useful if you deleted a node, and now need to see if this change affected any earlier nodes. Rewinding does not affect other injectors, and can result in infinite loops if not used carefully.

Защищенные методы

Метод Описание
backward ( integer &$i, HTMLPurifier_Token &$current ) : boolean Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
forward ( integer &$i, HTMLPurifier_Token &$current ) : boolean Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
forwardUntilEndToken ( integer &$i, HTMLPurifier_Token &$current, integer &$nesting ) : boolean Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and stops when we hit the end tag for the node $this->inputIndex starts in.

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

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

Tests if the context node allows a certain element
public allowsElement ( string $name ) : boolean
$name string Name of element to test for
Результат boolean True if element is allowed, false if it is not

backward() защищенный Метод

Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
protected backward ( integer &$i, HTMLPurifier_Token &$current ) : boolean
$i integer Current integer index variable for inputTokens
$current HTMLPurifier_Token Current token variable. Do NOT use $token, as that variable is also a reference
Результат boolean

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

This function checks if the HTML environment will work with the Injector: if p tags are not allowed, the Auto-Paragraphing injector should not be enabled.
public checkNeeded ( HTMLPurifier_Config $config ) : boolean | string
$config HTMLPurifier_Config
Результат boolean | string Boolean false if success, string of missing needed element/attribute if failure

forward() защищенный Метод

Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
protected forward ( integer &$i, HTMLPurifier_Token &$current ) : boolean
$i integer Current integer index variable for inputTokens
$current HTMLPurifier_Token Current token variable. Do NOT use $token, as that variable is also a reference
Результат boolean

forwardUntilEndToken() защищенный Метод

Similar to _forward, but accepts a third parameter $nesting (which should be initialized at 0) and stops when we hit the end tag for the node $this->inputIndex starts in.
protected forwardUntilEndToken ( integer &$i, HTMLPurifier_Token &$current, integer &$nesting ) : boolean
$i integer Current integer index variable for inputTokens
$current HTMLPurifier_Token Current token variable. Do NOT use $token, as that variable is also a reference
$nesting integer
Результат boolean

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

Retrieves rewind offset, and then unsets it.
public getRewindOffset ( ) : boolean | integer
Результат boolean | integer

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

Handler that is called when a start or empty token is processed
public handleElement ( &$token )

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

Handler that is called when an end token is processed
public handleEnd ( &$token )

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

Handler that is called when a text token is processed
public handleText ( &$token )

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

Notifier that is called when an end token is processed
Устаревший:
public notifyEnd ( HTMLPurifier_Token $token )
$token HTMLPurifier_Token Current token variable.

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

Prepares the injector by giving it the config and context objects: this allows references to important variables to be made within the injector. This function also checks if the HTML environment will work with the Injector (see checkNeeded()).
public prepare ( HTMLPurifier_Config $config, HTMLPurifier_Context $context ) : boolean | string
$config HTMLPurifier_Config
$context HTMLPurifier_Context
Результат boolean | string Boolean false if success, string of missing needed element/attribute if failure

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

Rewind to a spot to re-perform processing. This is useful if you deleted a node, and now need to see if this change affected any earlier nodes. Rewinding does not affect other injectors, and can result in infinite loops if not used carefully.
public rewindOffset ( boolean | integer $offset )
$offset boolean | integer

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

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

Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside"
protected $currentNesting

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

Reference to current token.
protected $currentToken

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

protected $htmlDefinition

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

Reference to InputZipper variable in Context.
protected $inputZipper

$name публичное свойство

Advisory name of injector, this is for friendly error messages.
public $name

$needed публичное свойство

Array of elements and attributes this injector creates and therefore need to be allowed by the definition. Takes form of array('element' => array('attr', 'attr2'), 'element2')
public $needed

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

Number of elements to rewind backwards (relative).
protected $rewindOffset