ILIAS  release_4-4 Revision
HTMLPurifier_Printer_HTMLDefinition Class Reference
+ Inheritance diagram for HTMLPurifier_Printer_HTMLDefinition:
+ Collaboration diagram for HTMLPurifier_Printer_HTMLDefinition:

Public Member Functions

 render ($config)
 
- Public Member Functions inherited from HTMLPurifier_Printer
 __construct ()
 Initialize $generator. More...
 
 prepareGenerator ($config)
 Give generator necessary configuration if possible. More...
 

Protected Member Functions

 renderDoctype ()
 Renders the Doctype table. More...
 
 renderEnvironment ()
 Renders environment table, which is miscellaneous info. More...
 
 renderContentSets ()
 Renders the Content Sets table. More...
 
 renderInfo ()
 Renders the Elements ($info) table. More...
 
 renderChildren ($def)
 Renders a row describing the allowed children of an element. More...
 
 listifyTagLookup ($array)
 Listifies a tag lookup table. More...
 
 listifyObjectList ($array)
 Listifies a list of objects by retrieving class names and internal state. More...
 
 listifyAttr ($array)
 Listifies a hash of attributes to AttrDef classes. More...
 
 heavyHeader ($text, $num=1)
 Creates a heavy header row. More...
 
- Protected Member Functions inherited from HTMLPurifier_Printer
 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

 $def
 Instance of HTMLPurifier_HTMLDefinition, for easy access. More...
 
- Protected Attributes inherited from HTMLPurifier_Printer
 $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 3 of file HTMLDefinition.php.

Member Function Documentation

◆ heavyHeader()

HTMLPurifier_Printer_HTMLDefinition::heavyHeader (   $text,
  $num = 1 
)
protected

Creates a heavy header row.

Definition at line 262 of file HTMLDefinition.php.

References $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), and HTMLPurifier_Printer\start().

Referenced by renderContentSets(), and renderInfo().

262  {
263  $ret = '';
264  $ret .= $this->start('tr');
265  $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy'));
266  $ret .= $this->end('tr');
267  return $ret;
268  }
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:

◆ listifyAttr()

HTMLPurifier_Printer_HTMLDefinition::listifyAttr (   $array)
protected

Listifies a hash of attributes to AttrDef classes.

Parameters
$arrayArray hash in form of array('attrname' => HTMLPurifier_AttrDef)

Definition at line 249 of file HTMLDefinition.php.

References HTMLPurifier_Printer\getClass(), and HTMLPurifier_Printer\listify().

Referenced by renderEnvironment(), and renderInfo().

249  {
250  ksort($array);
251  $list = array();
252  foreach ($array as $name => $obj) {
253  if ($obj === false) continue;
254  $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>';
255  }
256  return $this->listify($list);
257  }
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:116
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listifyObjectList()

HTMLPurifier_Printer_HTMLDefinition::listifyObjectList (   $array)
protected

Listifies a list of objects by retrieving class names and internal state.

Parameters
$arrayList of objects
Todo:
Also add information about internal state

Definition at line 236 of file HTMLDefinition.php.

References HTMLPurifier_Printer\getClass(), and HTMLPurifier_Printer\listify().

Referenced by renderEnvironment(), and renderInfo().

236  {
237  ksort($array);
238  $list = array();
239  foreach ($array as $discard => $obj) {
240  $list[] = $this->getClass($obj, 'AttrTransform_');
241  }
242  return $this->listify($list);
243  }
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:116
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:134
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listifyTagLookup()

HTMLPurifier_Printer_HTMLDefinition::listifyTagLookup (   $array)
protected

Listifies a tag lookup table.

Parameters
$arrayTag lookup array in form of array('tagname' => true)

Definition at line 221 of file HTMLDefinition.php.

References HTMLPurifier_Printer\listify().

Referenced by renderChildren(), renderContentSets(), and renderInfo().

221  {
222  ksort($array);
223  $list = array();
224  foreach ($array as $name => $discard) {
225  if ($name !== '#PCDATA' && !isset($this->def->info[$name])) continue;
226  $list[] = $name;
227  }
228  return $this->listify($list);
229  }
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

HTMLPurifier_Printer_HTMLDefinition::render (   $config)

Definition at line 11 of file HTMLDefinition.php.

References HTMLPurifier_Printer\$config, $ret, HTMLPurifier_Printer\end(), renderContentSets(), renderDoctype(), renderEnvironment(), renderInfo(), and HTMLPurifier_Printer\start().

11  {
12  $ret = '';
13  $this->config =& $config;
14 
15  $this->def = $config->getHTMLDefinition();
16 
17  $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer'));
18 
19  $ret .= $this->renderDoctype();
20  $ret .= $this->renderEnvironment();
21  $ret .= $this->renderContentSets();
22  $ret .= $this->renderInfo();
23 
24  $ret .= $this->end('div');
25 
26  return $ret;
27  }
renderContentSets()
Renders the Content Sets table.
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
renderInfo()
Renders the Elements ($info) table.
end($tag)
Returns an end teg.
Definition: Printer.php:55
renderEnvironment()
Renders environment table, which is miscellaneous info.
renderDoctype()
Renders the Doctype table.
$config
Instance of HTMLPurifier_Config, for easy access.
Definition: Printer.php:17
+ Here is the call graph for this function:

◆ renderChildren()

HTMLPurifier_Printer_HTMLDefinition::renderChildren (   $def)
protected

Renders a row describing the allowed children of an element.

Parameters
$defHTMLPurifier_ChildDef of pertinent element

Definition at line 170 of file HTMLDefinition.php.

References $def, $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), HTMLPurifier_Printer\escape(), listifyTagLookup(), and HTMLPurifier_Printer\start().

Referenced by renderEnvironment(), and renderInfo().

170  {
171  $context = new HTMLPurifier_Context();
172  $ret = '';
173  $ret .= $this->start('tr');
174  $elements = array();
175  $attr = array();
176  if (isset($def->elements)) {
177  if ($def->type == 'strictblockquote') {
178  $def->validateChildren(array(), $this->config, $context);
179  }
180  $elements = $def->elements;
181  }
182  if ($def->type == 'chameleon') {
183  $attr['rowspan'] = 2;
184  } elseif ($def->type == 'empty') {
185  $elements = array();
186  } elseif ($def->type == 'table') {
187  $elements = array_flip(array('col', 'caption', 'colgroup', 'thead',
188  'tfoot', 'tbody', 'tr'));
189  }
190  $ret .= $this->element('th', 'Allowed children', $attr);
191 
192  if ($def->type == 'chameleon') {
193 
194  $ret .= $this->element('td',
195  '<em>Block</em>: ' .
196  $this->escape($this->listifyTagLookup($def->block->elements)),0,0);
197  $ret .= $this->end('tr');
198  $ret .= $this->start('tr');
199  $ret .= $this->element('td',
200  '<em>Inline</em>: ' .
201  $this->escape($this->listifyTagLookup($def->inline->elements)),0,0);
202 
203  } elseif ($def->type == 'custom') {
204 
205  $ret .= $this->element('td', '<em>'.ucfirst($def->type).'</em>: ' .
206  $def->dtd_regex);
207 
208  } else {
209  $ret .= $this->element('td',
210  '<em>'.ucfirst($def->type).'</em>: ' .
211  $this->escape($this->listifyTagLookup($elements)),0,0);
212  }
213  $ret .= $this->end('tr');
214  return $ret;
215  }
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
listifyTagLookup($array)
Listifies a tag lookup table.
end($tag)
Returns an end teg.
Definition: Printer.php:55
$def
Instance of HTMLPurifier_HTMLDefinition, for easy access.
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:68
Registry object that contains information about the current context.
Definition: Context.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderContentSets()

HTMLPurifier_Printer_HTMLDefinition::renderContentSets ( )
protected

Renders the Content Sets table.

Definition at line 93 of file HTMLDefinition.php.

References $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), heavyHeader(), listifyTagLookup(), and HTMLPurifier_Printer\start().

Referenced by render().

93  {
94  $ret = '';
95  $ret .= $this->start('table');
96  $ret .= $this->element('caption', 'Content Sets');
97  foreach ($this->def->info_content_sets as $name => $lookup) {
98  $ret .= $this->heavyHeader($name);
99  $ret .= $this->start('tr');
100  $ret .= $this->element('td', $this->listifyTagLookup($lookup));
101  $ret .= $this->end('tr');
102  }
103  $ret .= $this->end('table');
104  return $ret;
105  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
listifyTagLookup($array)
Listifies a tag lookup table.
heavyHeader($text, $num=1)
Creates a heavy header row.
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:

◆ renderDoctype()

HTMLPurifier_Printer_HTMLDefinition::renderDoctype ( )
protected

Renders the Doctype table.

Definition at line 32 of file HTMLDefinition.php.

References $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), HTMLPurifier_Printer\row(), and HTMLPurifier_Printer\start().

Referenced by render().

32  {
33  $doctype = $this->def->doctype;
34  $ret = '';
35  $ret .= $this->start('table');
36  $ret .= $this->element('caption', 'Doctype');
37  $ret .= $this->row('Name', $doctype->name);
38  $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No');
39  $ret .= $this->row('Default Modules', implode($doctype->modules, ', '));
40  $ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', '));
41  $ret .= $this->end('table');
42  return $ret;
43  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
row($name, $value)
Prints a simple key/value row in a table.
Definition: Printer.php:91
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:

◆ renderEnvironment()

HTMLPurifier_Printer_HTMLDefinition::renderEnvironment ( )
protected

Renders environment table, which is miscellaneous info.

Definition at line 49 of file HTMLDefinition.php.

References $def, $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), HTMLPurifier_Printer\getClass(), HTMLPurifier_Printer\listify(), listifyAttr(), listifyObjectList(), renderChildren(), HTMLPurifier_Printer\row(), and HTMLPurifier_Printer\start().

Referenced by render().

49  {
50  $def = $this->def;
51 
52  $ret = '';
53 
54  $ret .= $this->start('table');
55  $ret .= $this->element('caption', 'Environment');
56 
57  $ret .= $this->row('Parent of fragment', $def->info_parent);
58  $ret .= $this->renderChildren($def->info_parent_def->child);
59  $ret .= $this->row('Block wrap name', $def->info_block_wrapper);
60 
61  $ret .= $this->start('tr');
62  $ret .= $this->element('th', 'Global attributes');
63  $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr),0,0);
64  $ret .= $this->end('tr');
65 
66  $ret .= $this->start('tr');
67  $ret .= $this->element('th', 'Tag transforms');
68  $list = array();
69  foreach ($def->info_tag_transform as $old => $new) {
70  $new = $this->getClass($new, 'TagTransform_');
71  $list[] = "<$old> with $new";
72  }
73  $ret .= $this->element('td', $this->listify($list));
74  $ret .= $this->end('tr');
75 
76  $ret .= $this->start('tr');
77  $ret .= $this->element('th', 'Pre-AttrTransform');
78  $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre));
79  $ret .= $this->end('tr');
80 
81  $ret .= $this->start('tr');
82  $ret .= $this->element('th', 'Post-AttrTransform');
83  $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post));
84  $ret .= $this->end('tr');
85 
86  $ret .= $this->end('table');
87  return $ret;
88  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:116
row($name, $value)
Prints a simple key/value row in a table.
Definition: Printer.php:91
listifyObjectList($array)
Listifies a list of objects by retrieving class names and internal state.
end($tag)
Returns an end teg.
Definition: Printer.php:55
$def
Instance of HTMLPurifier_HTMLDefinition, for easy access.
listifyAttr($array)
Listifies a hash of attributes to AttrDef classes.
renderChildren($def)
Renders a row describing the allowed children of an element.
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:134
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:

◆ renderInfo()

HTMLPurifier_Printer_HTMLDefinition::renderInfo ( )
protected

Renders the Elements ($info) table.

Definition at line 110 of file HTMLDefinition.php.

References $def, $ret, HTMLPurifier_Printer\element(), HTMLPurifier_Printer\end(), heavyHeader(), HTMLPurifier_Printer\listify(), listifyAttr(), listifyObjectList(), listifyTagLookup(), renderChildren(), HTMLPurifier_Printer\row(), and HTMLPurifier_Printer\start().

Referenced by render().

110  {
111  $ret = '';
112  $ret .= $this->start('table');
113  $ret .= $this->element('caption', 'Elements ($info)');
114  ksort($this->def->info);
115  $ret .= $this->heavyHeader('Allowed tags', 2);
116  $ret .= $this->start('tr');
117  $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2));
118  $ret .= $this->end('tr');
119  foreach ($this->def->info as $name => $def) {
120  $ret .= $this->start('tr');
121  $ret .= $this->element('th', "<$name>", array('class'=>'heavy', 'colspan' => 2));
122  $ret .= $this->end('tr');
123  $ret .= $this->start('tr');
124  $ret .= $this->element('th', 'Inline content');
125  $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No');
126  $ret .= $this->end('tr');
127  if (!empty($def->excludes)) {
128  $ret .= $this->start('tr');
129  $ret .= $this->element('th', 'Excludes');
130  $ret .= $this->element('td', $this->listifyTagLookup($def->excludes));
131  $ret .= $this->end('tr');
132  }
133  if (!empty($def->attr_transform_pre)) {
134  $ret .= $this->start('tr');
135  $ret .= $this->element('th', 'Pre-AttrTransform');
136  $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre));
137  $ret .= $this->end('tr');
138  }
139  if (!empty($def->attr_transform_post)) {
140  $ret .= $this->start('tr');
141  $ret .= $this->element('th', 'Post-AttrTransform');
142  $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post));
143  $ret .= $this->end('tr');
144  }
145  if (!empty($def->auto_close)) {
146  $ret .= $this->start('tr');
147  $ret .= $this->element('th', 'Auto closed by');
148  $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close));
149  $ret .= $this->end('tr');
150  }
151  $ret .= $this->start('tr');
152  $ret .= $this->element('th', 'Allowed attributes');
153  $ret .= $this->element('td',$this->listifyAttr($def->attr), array(), 0);
154  $ret .= $this->end('tr');
155 
156  if (!empty($def->required_attr)) {
157  $ret .= $this->row('Required attributes', $this->listify($def->required_attr));
158  }
159 
160  $ret .= $this->renderChildren($def->child);
161  }
162  $ret .= $this->end('table');
163  return $ret;
164  }
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:45
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:116
listifyTagLookup($array)
Listifies a tag lookup table.
row($name, $value)
Prints a simple key/value row in a table.
Definition: Printer.php:91
listifyObjectList($array)
Listifies a list of objects by retrieving class names and internal state.
heavyHeader($text, $num=1)
Creates a heavy header row.
end($tag)
Returns an end teg.
Definition: Printer.php:55
$def
Instance of HTMLPurifier_HTMLDefinition, for easy access.
listifyAttr($array)
Listifies a hash of attributes to AttrDef classes.
renderChildren($def)
Renders a row describing the allowed children of an element.
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:

Field Documentation

◆ $def

HTMLPurifier_Printer_HTMLDefinition::$def
protected

Instance of HTMLPurifier_HTMLDefinition, for easy access.

Definition at line 9 of file HTMLDefinition.php.

Referenced by renderChildren(), renderEnvironment(), and renderInfo().


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