Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

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

Defines 1 class

HTMLPurifier_Lexer_DOMLex:: (12 methods):
  __construct()
  tokenizeHTML()
  tokenizeDOM()
  getTagName()
  getData()
  createStartNode()
  createEndNode()
  transformAttrToAssoc()
  muteErrorHandler()
  callbackUndoCommentSubst()
  callbackArmorCommentEntities()
  wrapHTML()


Class: HTMLPurifier_Lexer_DOMLex  - X-Ref

Parser that uses PHP 5's DOM extension (part of the core).

In PHP 5, the DOM XML extension was revamped into DOM and added to the core.
It gives us a forgiving HTML parser, which we use to transform the HTML
into a DOM, and then into the tokens.  It is blazingly fast (for large
documents, it performs twenty times faster than
HTMLPurifier_Lexer_DirectLex,and is the default choice for PHP 5.

__construct()   X-Ref


tokenizeHTML($html, $config, $context)   X-Ref

param: string $html
param: HTMLPurifier_Config $config
param: HTMLPurifier_Context $context
return: HTMLPurifier_Token[]

tokenizeDOM($node, &$tokens, $config)   X-Ref
Iterative function that tokenizes a node, putting it into an accumulator.
To iterate is human, to recurse divine - L. Peter Deutsch

param: DOMNode $node DOMNode to be tokenized.
param: HTMLPurifier_Token[] $tokens   Array-list of already tokenized tokens.
return: HTMLPurifier_Token of node appended to previously passed tokens.

getTagName($node)   X-Ref
Portably retrieve the tag name of a node; deals with older versions
of libxml like 2.7.6

param: DOMNode $node

getData($node)   X-Ref
Portably retrieve the data of a node; deals with older versions
of libxml like 2.7.6

param: DOMNode $node

createStartNode($node, &$tokens, $collect, $config)   X-Ref

param: DOMNode $node DOMNode to be tokenized.
param: HTMLPurifier_Token[] $tokens   Array-list of already tokenized tokens.
param: bool $collect  Says whether or start and close are collected, set to
return: bool if the token needs an endtoken

createEndNode($node, &$tokens)   X-Ref

param: DOMNode $node
param: HTMLPurifier_Token[] $tokens

transformAttrToAssoc($node_map)   X-Ref
Converts a DOMNamedNodeMap of DOMAttr objects into an assoc array.

param: DOMNamedNodeMap $node_map DOMNamedNodeMap of DOMAttr objects.
return: array Associative array of attributes.

muteErrorHandler($errno, $errstr)   X-Ref
An error handler that mutes all errors

param: int $errno
param: string $errstr

callbackUndoCommentSubst($matches)   X-Ref
Callback function for undoing escaping of stray angled brackets
in comments

param: array $matches
return: string

callbackArmorCommentEntities($matches)   X-Ref
Callback function that entity-izes ampersands in comments so that
callbackUndoCommentSubst doesn't clobber them

param: array $matches
return: string

wrapHTML($html, $config, $context, $use_div = true)   X-Ref
Wraps an HTML fragment in the necessary HTML

param: string $html
param: HTMLPurifier_Config $config
param: HTMLPurifier_Context $context
return: string