HumHub Documentation (unofficial)

HTMLPurifier_Generator
in package

Generates HTML from tokens.

Tags
todo

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

todo

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

Table of Contents

Properties

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

Methods

__construct()  : mixed
escape()  : string
Escapes raw text data.
generateAttributes()  : string
Generates attribute declarations from attribute array.
generateFromToken()  : string
Generates HTML from a single token.
generateFromTokens()  : string
Generates HTML from an array of tokens.
generateScriptFromToken()  : string
Special case processor for the contents of script tags

Properties

$config

Configuration for the generator

protected mixed $config
Tags
type

HTMLPurifier_Config

$_def

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

private mixed $_def
Tags
type

HTMLPurifier_HTMLDefinition

$_flashCompat

Cache of %Output.FlashCompat.

private mixed $_flashCompat
Tags
type

bool

$_flashStack

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

private mixed $_flashStack = array()
Tags
type

array

$_innerHTMLFix

Cache of %Output.FixInnerHTML.

private mixed $_innerHTMLFix
Tags
type

bool

$_scriptFix

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

private mixed $_scriptFix = \false
Tags
type

bool

$_sortAttr

Cache of %Output.SortAttr.

private mixed $_sortAttr
Tags
type

bool

$_xhtml

Whether or not generator should produce XML output.

private mixed $_xhtml = \true
Tags
type

bool

Methods

escape()

Escapes raw text data.

public escape(string $string[, int $quote = null ]) : string
Parameters
$string : string

String data to escape for HTML.

$quote : int = null

Quoting style, like htmlspecialchars. ENT_NOQUOTES is permissible for non-attribute output.

Tags
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.

Return values
string

escaped data.

generateAttributes()

Generates attribute declarations from attribute array.

public generateAttributes(array<string|int, mixed> $assoc_array_of_attributes[, string $element = '' ]) : string
Parameters
$assoc_array_of_attributes : array<string|int, mixed>

Attribute array

$element : string = ''

Name of element attributes are for, used to check attribute minimization.

Tags
note

This does not include the leading or trailing space.

Return values
string

Generated HTML fragment for insertion.

generateFromToken()

Generates HTML from a single token.

public generateFromToken(HTMLPurifier_Token $token) : string
Parameters
$token : HTMLPurifier_Token

HTMLPurifier_Token object.

Return values
string

Generated HTML

generateFromTokens()

Generates HTML from an array of tokens.

public generateFromTokens(array<string|int, HTMLPurifier_Token$tokens) : string
Parameters
$tokens : array<string|int, HTMLPurifier_Token>

Array of HTMLPurifier_Token

Return values
string

Generated HTML

generateScriptFromToken()

Special case processor for the contents of script tags

public generateScriptFromToken(HTMLPurifier_Token $token) : string
Parameters
$token : HTMLPurifier_Token

HTMLPurifier_Token object.

Tags
warning

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

Return values
string

        
On this page

Search results