PHP Class HTMLPurifier_Injector, yii

This enables "formatter-like" functionality such as auto-paragraphing, smiley-ification and linkification to take place.
ファイルを表示 Open project: yiisoft/yii Class Usage Examples

Public Properties

Property Type Description
$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 Properties

Property Type Description
$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).

Public Methods

Method Description
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.

Protected Methods

Method Description
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.

Method Details

allowsElement() public method

Tests if the context node allows a certain element
public allowsElement ( string $name ) : boolean
$name string Name of element to test for
return boolean True if element is allowed, false if it is not

backward() protected method

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
return boolean

checkNeeded() public method

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
return boolean | string Boolean false if success, string of missing needed element/attribute if failure

forward() protected method

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
return boolean

forwardUntilEndToken() protected method

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
return boolean

getRewindOffset() public method

Retrieves rewind offset, and then unsets it.
public getRewindOffset ( ) : boolean | integer
return boolean | integer

handleElement() public method

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

handleEnd() public method

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

handleText() public method

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

notifyEnd() public method

Notifier that is called when an end token is processed
Deprecation:
public notifyEnd ( HTMLPurifier_Token $token )
$token HTMLPurifier_Token Current token variable.

prepare() public method

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
return boolean | string Boolean false if success, string of missing needed element/attribute if failure

rewindOffset() public method

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

Property Details

$currentNesting protected_oe property

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

$currentToken protected_oe property

Reference to current token.
protected $currentToken

$htmlDefinition protected_oe property

protected $htmlDefinition

$inputZipper protected_oe property

Reference to InputZipper variable in Context.
protected $inputZipper

$name public_oe property

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

$needed public_oe property

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 protected_oe property

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