Class HTMLPurifier_Injector

Description

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.

  • todo: Allow injectors to request a re-run on their output. This would help if an operation is recursive.
  • abstract:

Located in /lib/core/Parsers/htmlpurifier/HTMLPurifier.standalone.php (line 5152)


	
			
Direct descendents
Class Description
HTMLPurifier_Injector_AutoParagraph Injector that auto paragraphs text in the root node based on double-spacing.
HTMLPurifier_Injector_DisplayLinkURI Injector that displays the URL of an anchor instead of linking to it, in addition to showing the text of the link.
HTMLPurifier_Injector_Linkify Injector that converts http, https and ftp text URLs to actual links.
HTMLPurifier_Injector_PurifierLinkify Injector that converts configuration directive syntax %Namespace.Directive
HTMLPurifier_Injector_RemoveEmpty Injects tokens into the document while parsing for well-formedness.
HTMLPurifier_Injector_RemoveSpansWithoutAttributes Injector that removes spans with no attributes
HTMLPurifier_Injector_SafeObject Adds important param elements to inside of object in order to make things safe.
Variable Summary
mixed $inputIndex
mixed $inputTokens
mixed $name
mixed $needed
mixed $rewind
Method Summary
True allowsElement ($name $name)
void backward (&$i &$i, &$current &$current)
Boolean checkNeeded ($config $config, $context 1)
void current (&$i &$i, &$current &$current)
void forward (&$i &$i, &$current &$current)
void forwardUntilEndToken ( &$i,  &$current,  &$nesting)
void getRewind ()
void handleElement ( &$token)
void handleEnd ( &$token)
void handleText ( &$token)
void notifyEnd ( $token)
Boolean prepare ($config $config, $context $context)
void rewind ( $index)
Variables
mixed $currentNesting (line 5169)

Reference to CurrentNesting variable in Context. This is an array

list of tokens that we are currently "inside"

  • access: protected
mixed $htmlDefinition (line 5163)

Instance of HTMLPurifier_HTMLDefinition

  • access: protected
mixed $inputIndex (line 5182)

Reference to InputIndex variable in Context. This is an integer array index for $this->inputTokens that indicates what token is currently being processed.

  • access: protected
mixed $inputTokens (line 5175)

Reference to InputTokens variable in Context. This is an array list of the input tokens that are being processed.

  • access: protected
mixed $needed = array() (line 5189)

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

  • access: public

Redefined in descendants as:
mixed $rewind = false (line 5194)

Index of inputTokens to rewind to.

  • access: protected
Methods
allowsElement (line 5265)

Tests if the context node allows a certain element

  • return: if element is allowed, false if it is not
  • access: public
True allowsElement ($name $name)
  • $name $name: Name of element to test for
backward (line 5326)

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

  • access: protected
void backward (&$i &$i, &$current &$current)
  • &$i &$i: Current integer index variable for inputTokens
  • &$current &$current: Current token variable. Do NOT use $token, as that variable is also a reference
checkNeeded (line 5247)

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.

  • return: false if success, string of missing needed element/attribute if failure
  • access: public
Boolean checkNeeded ($config $config, $context 1)
  • $context 1: Instance of HTMLPurifier_Context
  • $config $config: Instance of HTMLPurifier_Config
current (line 5343)

Initializes the iterator at the current position. Use in a do {} while; loop to force the _forward and _backward functions to start at the current location.

  • access: protected
void current (&$i &$i, &$current &$current)
  • &$i &$i: Current integer index variable for inputTokens
  • &$current &$current: Current token variable. Do NOT use $token, as that variable is also a reference
forward (line 5293)

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

  • access: protected
void forward (&$i &$i, &$current &$current)
  • &$i &$i: Current integer index variable for inputTokens
  • &$current &$current: Current token variable. Do NOT use $token, as that variable is also a reference
forwardUntilEndToken (line 5306)

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.

  • access: protected
void forwardUntilEndToken ( &$i,  &$current,  &$nesting)
  • &$i
  • &$current
  • &$nesting
getRewind (line 5211)

Retrieves rewind, and then unsets it.

  • access: public
void getRewind ()
handleEnd (line 5361)

Handler that is called when an end token is processed

  • access: public
void handleEnd ( &$token)
  • &$token

Redefined in descendants as:
handleText (line 5351)

Handler that is called when a text token is processed

  • access: public
void handleText ( &$token)
  • &$token

Redefined in descendants as:
notifyEnd (line 5370)

Notifier that is called when an end token is processed

  • deprecated:
  • access: public
void notifyEnd ( $token)
  • $token
prepare (line 5226)

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()).

  • return: false if success, string of missing needed element/attribute if failure
  • access: public
Boolean prepare ($config $config, $context $context)
  • $config $config: Instance of HTMLPurifier_Config
  • $context $context: Instance of HTMLPurifier_Context

Redefined in descendants as:
rewind (line 5204)

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.

  • access: public
void rewind ( $index)
  • $index

Documentation generated on Sun, 06 Mar 2011 00:24:09 -0500 by phpDocumentor 1.4.3