\HTMLPurifier_Injector_PurifierLinkify

Injector that converts configuration directive syntax %Namespace.Directive to links

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
$docURL
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.

Type

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

Type

$docURL

$docURL : 

Type

$htmlDefinition

$htmlDefinition : 

Type

$currentNesting

$currentNesting : 

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

Type

$currentToken

$currentToken : 

Reference to current token.

Type

$inputZipper

$inputZipper : 

Reference to InputZipper variable in Context.

Type

$rewindOffset

$rewindOffset : 

Number of elements to rewind backwards (relative).

Type

Methods

rewindOffset()

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.

Parameters

boolean|integer $offset

getRewindOffset()

getRewindOffset() : boolean|integer

Retrieves rewind offset, and then unsets it.

Returns

boolean|integer

prepare()

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

string

checkNeeded()

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.

Parameters

\HTMLPurifier_Config $config

Returns

boolean|string —

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

allowsElement()

allowsElement(string  $name) : boolean

Tests if the context node allows a certain element

Parameters

string $name

Name of element to test for

Returns

boolean —

True if element is allowed, false if it is not

handleText()

handleText(\HTMLPurifier_Token  $token) 

Handler that is called when a text token is processed

Parameters

\HTMLPurifier_Token $token

handleElement()

handleElement(  $token) 

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

Parameters

$token

handleEnd()

handleEnd(  $token) 

Handler that is called when an end token is processed

Parameters

$token

notifyEnd()

notifyEnd(\HTMLPurifier_Token  $token) 

Notifier that is called when an end token is processed

Parameters

\HTMLPurifier_Token $token

Current token variable.

forward()

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.

Parameters

integer $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

boolean

forwardUntilEndToken()

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.

Parameters

integer $i

Current integer index variable for inputTokens

\HTMLPurifier_Token $current

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

integer $nesting

Returns

boolean

backward()

backward(integer  $i, \HTMLPurifier_Token  $current) : boolean

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

Parameters

integer $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

boolean