\HTMLPurifier_Injector

Injects tokens into the document while parsing for well-formedness.

This enables "formatter-like" functionality such as auto-paragraphing, smiley-ification and linkification to take place.

A note on how handlers create changes; this is done by assigning a new value to the $token reference. These values can take a variety of forms and are best described HTMLPurifier_Strategy_MakeWellFormed->processToken() documentation.

Summary

Methods
Properties
Constants
rewindOffset()
getRewindOffset()
prepare()
checkNeeded()
allowsElement()
handleText()
handleElement()
handleEnd()
notifyEnd()
$name
$needed
No constants found
forward()
forwardUntilEndToken()
backward()
$htmlDefinition
$currentNesting
$currentToken
$inputZipper
$rewindOffset
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name

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

$needed

$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')

$htmlDefinition

$htmlDefinition

$currentNesting

$currentNesting

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

$currentToken

$currentToken

Reference to current token.

$inputZipper

$inputZipper

Reference to InputZipper variable in Context.

$rewindOffset

$rewindOffset

Number of elements to rewind backwards (relative).

Methods

rewindOffset()

rewindOffset(bool|int  $offset) : mixed

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.

Parameters

bool|int $offset

Returns

mixed —

getRewindOffset()

getRewindOffset() : bool|int

Retrieves rewind offset, and then unsets it.

Returns

bool|int —

prepare()

prepare(\HTMLPurifier_Config  $config, \HTMLPurifier_Context  $context) : bool|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()).

Parameters

\HTMLPurifier_Config $config
\HTMLPurifier_Context $context

Returns

bool|string —

Boolean false if success, string of missing needed element/attribute if failure

checkNeeded()

checkNeeded(\HTMLPurifier_Config  $config) : bool|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.

Parameters

\HTMLPurifier_Config $config

Returns

bool|string —

Boolean false if success, string of missing needed element/attribute if failure

allowsElement()

allowsElement(string  $name) : bool

Tests if the context node allows a certain element

Parameters

string $name

Name of element to test for

Returns

bool —

True if element is allowed, false if it is not

handleText()

handleText(mixed  $token) : mixed

Handler that is called when a text token is processed

Parameters

mixed $token

Returns

mixed —

handleElement()

handleElement(mixed  $token) : mixed

Handler that is called when a start or empty token is processed

Parameters

mixed $token

Returns

mixed —

handleEnd()

handleEnd(mixed  $token) : mixed

Handler that is called when an end token is processed

Parameters

mixed $token

Returns

mixed —

notifyEnd()

notifyEnd(\HTMLPurifier_Token  $token) : mixed

Notifier that is called when an end token is processed

Parameters

\HTMLPurifier_Token $token

Current token variable.

Returns

mixed —

forward()

forward(int  $i, \HTMLPurifier_Token  $current) : bool

Iterator function, which starts with the next token and continues until you reach the end of the input tokens.

Parameters

int $i

Current integer index variable for inputTokens

\HTMLPurifier_Token $current

Current token variable. Do NOT use $token, as that variable is also a reference

Returns

bool —

forwardUntilEndToken()

forwardUntilEndToken(int  $i, \HTMLPurifier_Token  $current, int  $nesting) : bool

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.

Parameters

int $i

Current integer index variable for inputTokens

\HTMLPurifier_Token $current

Current token variable. Do NOT use $token, as that variable is also a reference

int $nesting

Returns

bool —

backward()

backward(int  $i, \HTMLPurifier_Token  $current) : bool

Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.

Parameters

int $i

Current integer index variable for inputTokens

\HTMLPurifier_Token $current

Current token variable. Do NOT use $token, as that variable is also a reference

Returns

bool —