ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
HTMLPurifier_Printer Class Reference
+ Inheritance diagram for HTMLPurifier_Printer:
+ Collaboration diagram for HTMLPurifier_Printer:

Public Member Functions

 __construct ()
 Initialize $generator. More...
 
 prepareGenerator ($config)
 Give generator necessary configuration if possible. More...
 

Protected Member Functions

 start ($tag, $attr=array())
 Main function that renders object or aspect of that object. More...
 
 end ($tag)
 Returns an end tag. More...
 
 element ($tag, $contents, $attr=array(), $escape=true)
 Prints a complete element with content inside. More...
 
 elementEmpty ($tag, $attr=array())
 
 text ($text)
 
 row ($name, $value)
 Prints a simple key/value row in a table. More...
 
 escape ($string)
 Escapes a string for HTML output. More...
 
 listify ($array, $polite=false)
 Takes a list of strings and turns them into a single list. More...
 
 getClass ($obj, $sec_prefix='')
 Retrieves the class of an object without prefixes, as well as metadata. More...
 

Protected Attributes

 $generator
 For HTML generation convenience funcs. More...
 
 $config
 For easy access. More...
 

Detailed Description

Definition at line 6 of file Printer.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_Printer::__construct ( )

Initialize $generator.

Definition at line 24 of file Printer.php.

25 {
26 }

Member Function Documentation

◆ element()

HTMLPurifier_Printer::element (   $tag,
  $contents,
  $attr = array(),
  $escape = true 
)
protected

Prints a complete element with content inside.

Parameters
string$tagTag name
string$contentsElement contents
array$attrTag attributes
bool$escapewhether or not to escape contents
Returns
string

Definition at line 78 of file Printer.php.

79 {
80 return $this->start($tag, $attr) .
81 ($escape ? $this->escape($contents) : $contents) .
82 $this->end($tag);
83 }
end($tag)
Returns an end tag.
Definition: Printer.php:63
escape($string)
Escapes a string for HTML output.
Definition: Printer.php:131
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:51

References end(), escape(), and start().

Referenced by HTMLPurifier_Printer_HTMLDefinition\heavyHeader(), HTMLPurifier_Printer_CSSDefinition\render(), HTMLPurifier_Printer_ConfigForm\render(), HTMLPurifier_Printer_ConfigForm_NullDecorator\render(), HTMLPurifier_Printer_ConfigForm_default\render(), HTMLPurifier_Printer_ConfigForm_bool\render(), HTMLPurifier_Printer_HTMLDefinition\renderChildren(), HTMLPurifier_Printer_HTMLDefinition\renderContentSets(), HTMLPurifier_Printer_HTMLDefinition\renderDoctype(), HTMLPurifier_Printer_HTMLDefinition\renderEnvironment(), HTMLPurifier_Printer_HTMLDefinition\renderInfo(), HTMLPurifier_Printer_ConfigForm\renderNamespace(), and row().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elementEmpty()

HTMLPurifier_Printer::elementEmpty (   $tag,
  $attr = array() 
)
protected
Parameters
string$tag
array$attr
Returns
string

Definition at line 90 of file Printer.php.

91 {
92 return $this->generator->generateFromToken(
93 new HTMLPurifier_Token_Empty($tag, $attr)
94 );
95 }
Concrete empty token class.
Definition: Empty.php:7

Referenced by HTMLPurifier_Printer_ConfigForm\render(), HTMLPurifier_Printer_ConfigForm_NullDecorator\render(), HTMLPurifier_Printer_ConfigForm_default\render(), and HTMLPurifier_Printer_ConfigForm_bool\render().

+ Here is the caller graph for this function:

◆ end()

◆ escape()

HTMLPurifier_Printer::escape (   $string)
protected

Escapes a string for HTML output.

Parameters
string$stringString to escape
Returns
string

Definition at line 131 of file Printer.php.

132 {
133 $string = HTMLPurifier_Encoder::cleanUTF8($string);
134 $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
135 return $string;
136 }
static cleanUTF8($str, $force_php=false)
Cleans a UTF-8 string for well-formedness and SGML validity.
Definition: Encoder.php:127

References HTMLPurifier_Encoder\cleanUTF8().

Referenced by element(), and HTMLPurifier_Printer_HTMLDefinition\renderChildren().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClass()

HTMLPurifier_Printer::getClass (   $obj,
  $sec_prefix = '' 
)
protected

Retrieves the class of an object without prefixes, as well as metadata.

Parameters
object$objObject to determine class of
string$sec_prefixFurther prefix to remove
Returns
string

Definition at line 170 of file Printer.php.

171 {
172 static $five = null;
173 if ($five === null) {
174 $five = version_compare(PHP_VERSION, '5', '>=');
175 }
176 $prefix = 'HTMLPurifier_' . $sec_prefix;
177 if (!$five) {
178 $prefix = strtolower($prefix);
179 }
180 $class = str_replace($prefix, '', get_class($obj));
181 $lclass = strtolower($class);
182 $class .= '(';
183 switch ($lclass) {
184 case 'enum':
185 $values = array();
186 foreach ($obj->valid_values as $value => $bool) {
187 $values[] = $value;
188 }
189 $class .= implode(', ', $values);
190 break;
191 case 'css_composite':
192 $values = array();
193 foreach ($obj->defs as $def) {
194 $values[] = $this->getClass($def, $sec_prefix);
195 }
196 $class .= implode(', ', $values);
197 break;
198 case 'css_multiple':
199 $class .= $this->getClass($obj->single, $sec_prefix) . ', ';
200 $class .= $obj->max;
201 break;
202 case 'css_denyelementdecorator':
203 $class .= $this->getClass($obj->def, $sec_prefix) . ', ';
204 $class .= $obj->element;
205 break;
206 case 'css_importantdecorator':
207 $class .= $this->getClass($obj->def, $sec_prefix);
208 if ($obj->allow) {
209 $class .= ', !important';
210 }
211 break;
212 }
213 $class .= ')';
214 return $class;
215 }
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:170

References getClass().

Referenced by getClass(), HTMLPurifier_Printer_HTMLDefinition\listifyAttr(), HTMLPurifier_Printer_HTMLDefinition\listifyObjectList(), HTMLPurifier_Printer_CSSDefinition\render(), and HTMLPurifier_Printer_HTMLDefinition\renderEnvironment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listify()

HTMLPurifier_Printer::listify (   $array,
  $polite = false 
)
protected

Takes a list of strings and turns them into a single list.

Parameters
string[]$arrayList of strings
bool$politeBool whether or not to add an end before the last
Returns
string

Definition at line 144 of file Printer.php.

145 {
146 if (empty($array)) {
147 return 'None';
148 }
149 $ret = '';
150 $i = count($array);
151 foreach ($array as $value) {
152 $i--;
153 $ret .= $value;
154 if ($i > 0 && !($polite && $i == 1)) {
155 $ret .= ', ';
156 }
157 if ($polite && $i == 1) {
158 $ret .= 'and ';
159 }
160 }
161 return $ret;
162 }

References $ret.

Referenced by HTMLPurifier_Printer_HTMLDefinition\listifyAttr(), HTMLPurifier_Printer_HTMLDefinition\listifyObjectList(), HTMLPurifier_Printer_HTMLDefinition\listifyTagLookup(), HTMLPurifier_Printer_HTMLDefinition\renderEnvironment(), and HTMLPurifier_Printer_HTMLDefinition\renderInfo().

+ Here is the caller graph for this function:

◆ prepareGenerator()

HTMLPurifier_Printer::prepareGenerator (   $config)

Give generator necessary configuration if possible.

Parameters
HTMLPurifier_Config$config

Definition at line 32 of file Printer.php.

33 {
34 $all = $config->getAll();
35 $context = new HTMLPurifier_Context();
36 $this->generator = new HTMLPurifier_Generator($config, $context);
37 }
Registry object that contains information about the current context.
Definition: Context.php:11
Generates HTML from tokens.
Definition: Generator.php:11
$config
For easy access.
Definition: Printer.php:19

References $config.

Referenced by HTMLPurifier_Printer_ConfigForm\render(), HTMLPurifier_Printer_ConfigForm_NullDecorator\render(), HTMLPurifier_Printer_ConfigForm_default\render(), and HTMLPurifier_Printer_ConfigForm_bool\render().

+ Here is the caller graph for this function:

◆ row()

HTMLPurifier_Printer::row (   $name,
  $value 
)
protected

Prints a simple key/value row in a table.

Parameters
string$nameKey
mixed$valueValue
Returns
string

Definition at line 114 of file Printer.php.

115 {
116 if (is_bool($value)) {
117 $value = $value ? 'On' : 'Off';
118 }
119 return
120 $this->start('tr') . "\n" .
121 $this->element('th', $name) . "\n" .
122 $this->element('td', $value) . "\n" .
123 $this->end('tr');
124 }
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:78

References element(), end(), and start().

Referenced by HTMLPurifier_Printer_CSSDefinition\render(), HTMLPurifier_Printer_HTMLDefinition\renderDoctype(), HTMLPurifier_Printer_HTMLDefinition\renderEnvironment(), and HTMLPurifier_Printer_HTMLDefinition\renderInfo().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

HTMLPurifier_Printer::start (   $tag,
  $attr = array() 
)
protected

◆ text()

HTMLPurifier_Printer::text (   $text)
protected
Parameters
string$text
Returns
string

Definition at line 101 of file Printer.php.

102 {
103 return $this->generator->generateFromToken(
105 );
106 }
Concrete text token class.
Definition: Text.php:13
$text

References $text.

Referenced by HTMLPurifier_Printer_ConfigForm_NullDecorator\render(), HTMLPurifier_Printer_ConfigForm_default\render(), and HTMLPurifier_Printer_ConfigForm_bool\render().

+ Here is the caller graph for this function:

Field Documentation

◆ $config

◆ $generator

HTMLPurifier_Printer::$generator
protected

For HTML generation convenience funcs.

@type HTMLPurifier_Generator

Definition at line 13 of file Printer.php.


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