Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
HTMLPurifier_Generator Class Reference

Public Member Functions

 __construct ($config, $context)
 
 escape ($string, $quote=null)
 Escapes raw text data.
 
 generateAttributes ($assoc_array_of_attributes, $element='')
 Generates attribute declarations from attribute array.
 
 generateFromToken ($token)
 Generates HTML from a single token.
 
 generateFromTokens ($tokens)
 Generates HTML from an array of tokens.
 
 generateScriptFromToken ($token)
 Special case processor for the contents of script tags.
 

Protected Attributes

 $config
 Configuration for the generator @type HTMLPurifier_Config.
 

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_Generator::__construct ( $config,
$context )
Parameters
HTMLPurifier_Config$config
HTMLPurifier_Context$context

Member Function Documentation

◆ escape()

HTMLPurifier_Generator::escape ( $string,
$quote = null )

Escapes raw text data.

Todo
This really ought to be protected, but until we have a facility for properly generating HTML here w/o using tokens, it stays public.
Parameters
string$stringString data to escape for HTML.
int$quoteQuoting style, like htmlspecialchars. ENT_NOQUOTES is permissible for non-attribute output.
Return values
stringescaped data.

◆ generateAttributes()

HTMLPurifier_Generator::generateAttributes ( $assoc_array_of_attributes,
$element = '' )

Generates attribute declarations from attribute array.

Note
This does not include the leading or trailing space.
Parameters
array$assoc_array_of_attributesAttribute array
string$elementName of element attributes are for, used to check attribute minimization.
Return values
stringGenerated HTML fragment for insertion.

◆ generateFromToken()

HTMLPurifier_Generator::generateFromToken ( $token)

Generates HTML from a single token.

Parameters
HTMLPurifier_Token$tokenHTMLPurifier_Token object.
Return values
stringGenerated HTML

◆ generateFromTokens()

HTMLPurifier_Generator::generateFromTokens ( $tokens)

Generates HTML from an array of tokens.

Parameters
HTMLPurifier_Token[]$tokensArray of HTMLPurifier_Token
Return values
stringGenerated HTML

◆ generateScriptFromToken()

HTMLPurifier_Generator::generateScriptFromToken ( $token)

Special case processor for the contents of script tags.

Parameters
HTMLPurifier_Token$tokenHTMLPurifier_Token object.
Return values
string
Warning
This runs into problems if there's already a literal --> somewhere inside the script contents.

The documentation for this class was generated from the following file: