Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

(no description)

File Size: 283 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

HTMLPurifier_Injector:: (12 methods):
  rewindOffset()
  getRewindOffset()
  prepare()
  checkNeeded()
  allowsElement()
  forward()
  forwardUntilEndToken()
  backward()
  handleText()
  handleElement()
  handleEnd()
  notifyEnd()


Class: HTMLPurifier_Injector  - X-Ref

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.

rewindOffset($offset)   X-Ref
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.

param: bool|int $offset

getRewindOffset()   X-Ref
Retrieves rewind offset, and then unsets it.

return: bool|int

prepare($config, $context)   X-Ref
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: bool|string Boolean false if success, string of missing needed element/attribute if failure
param: HTMLPurifier_Config $config
param: HTMLPurifier_Context $context

checkNeeded($config)   X-Ref
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: bool|string Boolean false if success, string of missing needed element/attribute if failure
param: HTMLPurifier_Config $config

allowsElement($name)   X-Ref
Tests if the context node allows a certain element

return: bool True if element is allowed, false if it is not
param: string $name Name of element to test for

forward(&$i, &$current)   X-Ref
Iterator function, which starts with the next token and continues until
you reach the end of the input tokens.

return: bool
param: int $i Current integer index variable for inputTokens
param: HTMLPurifier_Token $current Current token variable.

forwardUntilEndToken(&$i, &$current, &$nesting)   X-Ref
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.

return: bool
param: int $i Current integer index variable for inputTokens
param: HTMLPurifier_Token $current Current token variable.
param: int $nesting

backward(&$i, &$current)   X-Ref
Iterator function, starts with the previous token and continues until
you reach the beginning of input tokens.

return: bool
param: int $i Current integer index variable for inputTokens
param: HTMLPurifier_Token $current Current token variable.

handleText(&$token)   X-Ref
Handler that is called when a text token is processed


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


handleEnd(&$token)   X-Ref
Handler that is called when an end token is processed


notifyEnd($token)   X-Ref
Notifier that is called when an end token is processed

param: HTMLPurifier_Token $token Current token variable.