ILIAS  release_4-4 Revision
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 teg. 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
 Instance of HTMLPurifier_Generator for HTML generation convenience funcs. More...
 
 $config
 Instance of HTMLPurifier_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 22 of file Printer.php.

22  {
23  }

Member Function Documentation

◆ element()

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

Prints a complete element with content inside.

Parameters
$tagTag name
$contentsElement contents
$attrTag attributes
$escapeBool whether or not to escape contents

Definition at line 68 of file Printer.php.

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().

68  {
69  return $this->start($tag, $attr) .
70  ($escape ? $this->escape($contents) : $contents) .
71  $this->end($tag);
72  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
escape($string)
Escapes a string for HTML output.
Definition: Printer.php:105
end($tag)
Returns an end teg.
Definition: Printer.php:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ elementEmpty()

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

Definition at line 74 of file Printer.php.

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

74  {
75  return $this->generator->generateFromToken(
76  new HTMLPurifier_Token_Empty($tag, $attr)
77  );
78  }
Concrete empty token class.
Definition: Empty.php:6
+ Here is the caller graph for this function:

◆ end()

◆ escape()

HTMLPurifier_Printer::escape (   $string)
protected

Escapes a string for HTML output.

Parameters
$stringString to escape

Definition at line 105 of file Printer.php.

References HTMLPurifier_Encoder\cleanUTF8().

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

105  {
106  $string = HTMLPurifier_Encoder::cleanUTF8($string);
107  $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
108  return $string;
109  }
static cleanUTF8($str, $force_php=false)
Cleans a UTF-8 string for well-formedness and SGML validity.
Definition: Encoder.php:109
+ 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
$objObject to determine class of
$prefixFurther prefix to remove

Definition at line 134 of file Printer.php.

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

134  {
135  static $five = null;
136  if ($five === null) $five = version_compare(PHP_VERSION, '5', '>=');
137  $prefix = 'HTMLPurifier_' . $sec_prefix;
138  if (!$five) $prefix = strtolower($prefix);
139  $class = str_replace($prefix, '', get_class($obj));
140  $lclass = strtolower($class);
141  $class .= '(';
142  switch ($lclass) {
143  case 'enum':
144  $values = array();
145  foreach ($obj->valid_values as $value => $bool) {
146  $values[] = $value;
147  }
148  $class .= implode(', ', $values);
149  break;
150  case 'css_composite':
151  $values = array();
152  foreach ($obj->defs as $def) {
153  $values[] = $this->getClass($def, $sec_prefix);
154  }
155  $class .= implode(', ', $values);
156  break;
157  case 'css_multiple':
158  $class .= $this->getClass($obj->single, $sec_prefix) . ', ';
159  $class .= $obj->max;
160  break;
161  case 'css_denyelementdecorator':
162  $class .= $this->getClass($obj->def, $sec_prefix) . ', ';
163  $class .= $obj->element;
164  break;
165  case 'css_importantdecorator':
166  $class .= $this->getClass($obj->def, $sec_prefix);
167  if ($obj->allow) $class .= ', !important';
168  break;
169  }
170  $class .= ')';
171  return $class;
172  }
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:134
+ 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
$arrayList of strings
$politeBool whether or not to add an end before the last

Definition at line 116 of file Printer.php.

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().

116  {
117  if (empty($array)) return 'None';
118  $ret = '';
119  $i = count($array);
120  foreach ($array as $value) {
121  $i--;
122  $ret .= $value;
123  if ($i > 0 && !($polite && $i == 1)) $ret .= ', ';
124  if ($polite && $i == 1) $ret .= 'and ';
125  }
126  return $ret;
127  }
+ Here is the caller graph for this function:

◆ prepareGenerator()

HTMLPurifier_Printer::prepareGenerator (   $config)

Give generator necessary configuration if possible.

Definition at line 28 of file Printer.php.

References $config.

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

28  {
29  $all = $config->getAll();
30  $context = new HTMLPurifier_Context();
31  $this->generator = new HTMLPurifier_Generator($config, $context);
32  }
Generates HTML from tokens.
Definition: Generator.php:10
Registry object that contains information about the current context.
Definition: Context.php:10
$config
Instance of HTMLPurifier_Config, for easy access.
Definition: Printer.php:17
+ 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
$nameKey
$valueValue

Definition at line 91 of file Printer.php.

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

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

91  {
92  if (is_bool($value)) $value = $value ? 'On' : 'Off';
93  return
94  $this->start('tr') . "\n" .
95  $this->element('th', $name) . "\n" .
96  $this->element('td', $value) . "\n" .
97  $this->end('tr')
98  ;
99  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
end($tag)
Returns an end teg.
Definition: Printer.php:55
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:68
+ 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

Definition at line 80 of file Printer.php.

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

80  {
81  return $this->generator->generateFromToken(
82  new HTMLPurifier_Token_Text($text)
83  );
84  }
Concrete text token class.
Definition: Text.php:12
+ Here is the caller graph for this function:

Field Documentation

◆ $config

◆ $generator

HTMLPurifier_Printer::$generator
protected

Instance of HTMLPurifier_Generator for HTML generation convenience funcs.

Definition at line 12 of file Printer.php.


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