HTMLPurifier 4.4.0
HTMLPurifier_Generator Class Reference

Generates HTML from tokens. More...

List of all members.

Public Member Functions

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

Protected Attributes

 $config
 Configuration for the generator.

Private Attributes

 $_xhtml = true
 Whether or not generator should produce XML output.
 $_scriptFix = false
 :HACK: Whether or not generator should comment the insides of <script> tags
 $_def
 Cache of HTMLDefinition during HTML output to determine whether or not attributes should be minimized.
 $_sortAttr
 Cache of Output.SortAttr.
 $_flashCompat
 Cache of Output.FlashCompat.
 $_innerHTMLFix
 Cache of Output.FixInnerHTML.
 $_flashStack = array()
 Stack for keeping track of object information when outputting IE compatibility code.

Detailed Description

Generates HTML from tokens.

Todo:

Refactor interface so that configuration/context is determined upon instantiation, no need for messy generateFromTokens() calls

Make some of the more internal functions protected, and have unit tests work around that

Todo:

Refactor interface so that configuration/context is determined upon instantiation, no need for messy generateFromTokens() calls

Make some of the more internal functions protected, and have unit tests work around that

Definition at line 10 of file Generator.php.


Constructor & Destructor Documentation

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

Definition at line 59 of file Generator.php.

References $config.

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

Definition at line 4137 of file HTMLPurifier.standalone.php.

References $config.


Member Function Documentation

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:
$stringString data to escape for HTML.
$quoteQuoting style, like htmlspecialchars. ENT_NOQUOTES is permissible for non-attribute output.
Returns:
String escaped data.

Definition at line 245 of file Generator.php.

Referenced by generateAttributes(), and generateFromToken().

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:
$stringString data to escape for HTML.
$quoteQuoting style, like htmlspecialchars. ENT_NOQUOTES is permissible for non-attribute output.
Returns:
String escaped data.

Definition at line 4323 of file HTMLPurifier.standalone.php.

HTMLPurifier_Generator::generateAttributes ( assoc_array_of_attributes,
element = false 
)

Generates attribute declarations from attribute array.

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

Definition at line 4264 of file HTMLPurifier.standalone.php.

References $html, and escape().

HTMLPurifier_Generator::generateAttributes ( assoc_array_of_attributes,
element = false 
)

Generates attribute declarations from attribute array.

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

Definition at line 186 of file Generator.php.

References $html, and escape().

Referenced by generateFromToken().

HTMLPurifier_Generator::generateFromToken ( token)

Generates HTML from a single token.

Parameters:
$tokenHTMLPurifier_Token object.
Returns:
Generated HTML

Definition at line 120 of file Generator.php.

References escape(), and generateAttributes().

Referenced by generateFromTokens(), and generateScriptFromToken().

HTMLPurifier_Generator::generateFromToken ( token)

Generates HTML from a single token.

Parameters:
$tokenHTMLPurifier_Token object.
Returns:
Generated HTML

Definition at line 4198 of file HTMLPurifier.standalone.php.

References escape(), and generateAttributes().

HTMLPurifier_Generator::generateFromTokens ( tokens)

Generates HTML from an array of tokens.

Parameters:
$tokensArray of HTMLPurifier_Token
$configHTMLPurifier_Config object
Returns:
Generated HTML

Definition at line 75 of file Generator.php.

References $html, generateFromToken(), generateScriptFromToken(), and PHP_EOL.

HTMLPurifier_Generator::generateFromTokens ( tokens)

Generates HTML from an array of tokens.

Parameters:
$tokensArray of HTMLPurifier_Token
$configHTMLPurifier_Config object
Returns:
Generated HTML

Definition at line 4153 of file HTMLPurifier.standalone.php.

References $html, generateFromToken(), generateScriptFromToken(), and PHP_EOL.

HTMLPurifier_Generator::generateScriptFromToken ( token)

Special case processor for the contents of script tags.

Warning:
This runs into problems if there's already a literal --> somewhere inside the script contents.

Definition at line 171 of file Generator.php.

References $data, and generateFromToken().

Referenced by generateFromTokens().

HTMLPurifier_Generator::generateScriptFromToken ( token)

Special case processor for the contents of script tags.

Warning:
This runs into problems if there's already a literal --> somewhere inside the script contents.

Definition at line 4249 of file HTMLPurifier.standalone.php.

References $data, and generateFromToken().


Member Data Documentation

HTMLPurifier_Generator::$_def [private]

Cache of HTMLDefinition during HTML output to determine whether or not attributes should be minimized.

Definition at line 27 of file Generator.php.

HTMLPurifier_Generator::$_flashCompat [private]

Cache of Output.FlashCompat.

Definition at line 37 of file Generator.php.

HTMLPurifier_Generator::$_flashStack = array() [private]

Stack for keeping track of object information when outputting IE compatibility code.

Definition at line 48 of file Generator.php.

HTMLPurifier_Generator::$_innerHTMLFix [private]

Cache of Output.FixInnerHTML.

Definition at line 42 of file Generator.php.

HTMLPurifier_Generator::$_scriptFix = false [private]

:HACK: Whether or not generator should comment the insides of <script> tags

Definition at line 21 of file Generator.php.

HTMLPurifier_Generator::$_sortAttr [private]

Cache of Output.SortAttr.

Definition at line 32 of file Generator.php.

HTMLPurifier_Generator::$_xhtml = true [private]

Whether or not generator should produce XML output.

Definition at line 16 of file Generator.php.

HTMLPurifier_Generator::$config [protected]

Configuration for the generator.

Definition at line 53 of file Generator.php.

Referenced by __construct().


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