Abstract Class 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.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$name | Advisory name of injector, this is for friendly error messages. | HTMLPurifier_Injector | |
$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') | HTMLPurifier_Injector |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$currentNesting | Reference to CurrentNesting variable in Context. This is an array list of tokens that we are currently "inside" | HTMLPurifier_Injector | |
$currentToken | Reference to current token. | HTMLPurifier_Injector | |
$htmlDefinition | HTMLPurifier_Injector | ||
$inputZipper | Reference to InputZipper variable in Context. | HTMLPurifier_Injector | |
$rewindOffset | Number of elements to rewind backwards (relative). | HTMLPurifier_Injector |
Public Methods
Method | Description | Defined By |
---|---|---|
allowsElement() | Tests if the context node allows a certain element | HTMLPurifier_Injector |
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. | HTMLPurifier_Injector |
getRewindOffset() | Retrieves rewind offset, and then unsets it. | HTMLPurifier_Injector |
handleElement() | Handler that is called when a start or empty token is processed | HTMLPurifier_Injector |
handleEnd() | Handler that is called when an end token is processed | HTMLPurifier_Injector |
handleText() | Handler that is called when a text token is processed | HTMLPurifier_Injector |
notifyEnd() | Notifier that is called when an end token is processed | HTMLPurifier_Injector |
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()). | HTMLPurifier_Injector |
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. | HTMLPurifier_Injector |
Protected Methods
Method | Description | Defined By |
---|---|---|
backward() | Iterator function, starts with the previous token and continues until you reach the beginning of input tokens. | HTMLPurifier_Injector |
forward() | Iterator function, which starts with the next token and continues until you reach the end of the input tokens. | HTMLPurifier_Injector |
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. | HTMLPurifier_Injector |
Property Details
Method Details
Tests if the context node allows a certain element
public bool allowsElement ( $name ) | ||
$name | string | Name of element to test for |
return | bool | True if element is allowed, false if it is not |
---|
Iterator function, starts with the previous token and continues until you reach the beginning of input tokens.
protected bool backward ( <b>&</b>$i, <b>&</b>$current ) | ||
$i | int | Current integer index variable for inputTokens |
$current | HTMLPurifier_Token | Current token variable.
|
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 bool|string checkNeeded ( $config ) | ||
$config | HTMLPurifier_Config | |
return | bool|string | Boolean false if success, string of missing needed element/attribute if failure |
---|
Iterator function, which starts with the next token and continues until you reach the end of the input tokens.
protected bool forward ( <b>&</b>$i, <b>&</b>$current ) | ||
$i | int | Current integer index variable for inputTokens |
$current | HTMLPurifier_Token | Current token variable.
|
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 bool forwardUntilEndToken ( <b>&</b>$i, <b>&</b>$current, <b>&</b>$nesting ) | ||
$i | int | Current integer index variable for inputTokens |
$current | HTMLPurifier_Token | Current token variable.
|
$nesting | int |
Retrieves rewind offset, and then unsets it.
public bool|int getRewindOffset ( ) |
Handler that is called when a start or empty token is processed
public void handleElement ( <b>&</b>$token ) | ||
$token |
Handler that is called when an end token is processed
public void handleEnd ( <b>&</b>$token ) | ||
$token |
Handler that is called when a text token is processed
public void handleText ( <b>&</b>$token ) | ||
$token |
Notifier that is called when an end token is processed
public void notifyEnd ( $token ) | ||
$token | HTMLPurifier_Token | Current token variable. |
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 bool|string prepare ( $config, $context ) | ||
$config | HTMLPurifier_Config | |
$context | HTMLPurifier_Context | |
return | bool|string | Boolean false if success, string of missing needed element/attribute if failure |
---|
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 void rewindOffset ( $offset ) | ||
$offset | bool|int |