ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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

 $def
 @type HTMLPurifier_HTMLDefinition, for easy access More...
 
- Protected Attributes inherited from HTMLPurifier_Printer
 $generator
 For HTML generation convenience funcs. More...
 
 $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.

Parameters
string$text
int$num
Returns
string

Definition at line 314 of file HTMLDefinition.php.

315 {
316 $ret = '';
317 $ret .= $this->start('tr');
318 $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy'));
319 $ret .= $this->end('tr');
320 return $ret;
321 }
element($tag, $contents, $attr=array(), $escape=true)
Prints a complete element with content inside.
Definition: Printer.php:78
end($tag)
Returns an end tag.
Definition: Printer.php:63
start($tag, $attr=array())
Main function that renders object or aspect of that object.
Definition: Printer.php:51
$text

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

Referenced by renderContentSets(), and renderInfo().

+ 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
array$arrayArray hash in form of array('attrname' => HTMLPurifier_AttrDef)
Returns
string

Definition at line 295 of file HTMLDefinition.php.

296 {
297 ksort($array);
298 $list = array();
299 foreach ($array as $name => $obj) {
300 if ($obj === false) {
301 continue;
302 }
303 $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>';
304 }
305 return $this->listify($list);
306 }
listify($array, $polite=false)
Takes a list of strings and turns them into a single list.
Definition: Printer.php:144
getClass($obj, $sec_prefix='')
Retrieves the class of an object without prefixes, as well as metadata.
Definition: Printer.php:170

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

Referenced by renderEnvironment(), and renderInfo().

+ 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
array$arrayList of objects
Returns
string
Todo:
Also add information about internal state

Definition at line 280 of file HTMLDefinition.php.

281 {
282 ksort($array);
283 $list = array();
284 foreach ($array as $obj) {
285 $list[] = $this->getClass($obj, 'AttrTransform_');
286 }
287 return $this->listify($list);
288 }

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

Referenced by renderEnvironment(), and renderInfo().

+ 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
array$arrayTag lookup array in form of array('tagname' => true)
Returns
string

Definition at line 261 of file HTMLDefinition.php.

262 {
263 ksort($array);
264 $list = array();
265 foreach ($array as $name => $discard) {
266 if ($name !== '#PCDATA' && !isset($this->def->info[$name])) {
267 continue;
268 }
269 $list[] = $name;
270 }
271 return $this->listify($list);
272 }

References HTMLPurifier_Printer\listify().

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

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

◆ render()

HTMLPurifier_Printer_HTMLDefinition::render (   $config)
Parameters
HTMLPurifier_Config$config
Returns
string

Definition at line 15 of file HTMLDefinition.php.

16 {
17 $ret = '';
18 $this->config =& $config;
19
20 $this->def = $config->getHTMLDefinition();
21
22 $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer'));
23
24 $ret .= $this->renderDoctype();
25 $ret .= $this->renderEnvironment();
26 $ret .= $this->renderContentSets();
27 $ret .= $this->renderInfo();
28
29 $ret .= $this->end('div');
30
31 return $ret;
32 }
renderEnvironment()
Renders environment table, which is miscellaneous info.
renderDoctype()
Renders the Doctype table.
renderInfo()
Renders the Elements ($info) table.
renderContentSets()
Renders the Content Sets table.
$config
For easy access.
Definition: Printer.php:19

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

+ 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
HTMLPurifier_ChildDef$defHTMLPurifier_ChildDef of pertinent element
Returns
string

Definition at line 184 of file HTMLDefinition.php.

185 {
186 $context = new HTMLPurifier_Context();
187 $ret = '';
188 $ret .= $this->start('tr');
189 $elements = array();
190 $attr = array();
191 if (isset($def->elements)) {
192 if ($def->type == 'strictblockquote') {
193 $def->validateChildren(array(), $this->config, $context);
194 }
195 $elements = $def->elements;
196 }
197 if ($def->type == 'chameleon') {
198 $attr['rowspan'] = 2;
199 } elseif ($def->type == 'empty') {
200 $elements = array();
201 } elseif ($def->type == 'table') {
202 $elements = array_flip(
203 array(
204 'col',
205 'caption',
206 'colgroup',
207 'thead',
208 'tfoot',
209 'tbody',
210 'tr'
211 )
212 );
213 }
214 $ret .= $this->element('th', 'Allowed children', $attr);
215
216 if ($def->type == 'chameleon') {
217
218 $ret .= $this->element(
219 'td',
220 '<em>Block</em>: ' .
221 $this->escape($this->listifyTagLookup($def->block->elements)),
222 null,
223 0
224 );
225 $ret .= $this->end('tr');
226 $ret .= $this->start('tr');
227 $ret .= $this->element(
228 'td',
229 '<em>Inline</em>: ' .
230 $this->escape($this->listifyTagLookup($def->inline->elements)),
231 null,
232 0
233 );
234
235 } elseif ($def->type == 'custom') {
236
237 $ret .= $this->element(
238 'td',
239 '<em>' . ucfirst($def->type) . '</em>: ' .
240 $def->dtd_regex
241 );
242
243 } else {
244 $ret .= $this->element(
245 'td',
246 '<em>' . ucfirst($def->type) . '</em>: ' .
247 $this->escape($this->listifyTagLookup($elements)),
248 null,
249 0
250 );
251 }
252 $ret .= $this->end('tr');
253 return $ret;
254 }
Registry object that contains information about the current context.
Definition: Context.php:11
listifyTagLookup($array)
Listifies a tag lookup table.
$def
@type HTMLPurifier_HTMLDefinition, for easy access
escape($string)
Escapes a string for HTML output.
Definition: Printer.php:131

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

Referenced by renderEnvironment(), and renderInfo().

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

Returns
string

Definition at line 103 of file HTMLDefinition.php.

104 {
105 $ret = '';
106 $ret .= $this->start('table');
107 $ret .= $this->element('caption', 'Content Sets');
108 foreach ($this->def->info_content_sets as $name => $lookup) {
109 $ret .= $this->heavyHeader($name);
110 $ret .= $this->start('tr');
111 $ret .= $this->element('td', $this->listifyTagLookup($lookup));
112 $ret .= $this->end('tr');
113 }
114 $ret .= $this->end('table');
115 return $ret;
116 }
heavyHeader($text, $num=1)
Creates a heavy header row.

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

Referenced by render().

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

Returns
string

Definition at line 38 of file HTMLDefinition.php.

39 {
40 $doctype = $this->def->doctype;
41 $ret = '';
42 $ret .= $this->start('table');
43 $ret .= $this->element('caption', 'Doctype');
44 $ret .= $this->row('Name', $doctype->name);
45 $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No');
46 $ret .= $this->row('Default Modules', implode($doctype->modules, ', '));
47 $ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', '));
48 $ret .= $this->end('table');
49 return $ret;
50 }
row($name, $value)
Prints a simple key/value row in a table.
Definition: Printer.php:114

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

Referenced by render().

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

Returns
string

Definition at line 57 of file HTMLDefinition.php.

58 {
60
61 $ret = '';
62
63 $ret .= $this->start('table');
64 $ret .= $this->element('caption', 'Environment');
65
66 $ret .= $this->row('Parent of fragment', $def->info_parent);
67 $ret .= $this->renderChildren($def->info_parent_def->child);
68 $ret .= $this->row('Block wrap name', $def->info_block_wrapper);
69
70 $ret .= $this->start('tr');
71 $ret .= $this->element('th', 'Global attributes');
72 $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0);
73 $ret .= $this->end('tr');
74
75 $ret .= $this->start('tr');
76 $ret .= $this->element('th', 'Tag transforms');
77 $list = array();
78 foreach ($def->info_tag_transform as $old => $new) {
79 $new = $this->getClass($new, 'TagTransform_');
80 $list[] = "<$old> with $new";
81 }
82 $ret .= $this->element('td', $this->listify($list));
83 $ret .= $this->end('tr');
84
85 $ret .= $this->start('tr');
86 $ret .= $this->element('th', 'Pre-AttrTransform');
87 $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre));
88 $ret .= $this->end('tr');
89
90 $ret .= $this->start('tr');
91 $ret .= $this->element('th', 'Post-AttrTransform');
92 $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post));
93 $ret .= $this->end('tr');
94
95 $ret .= $this->end('table');
96 return $ret;
97 }
renderChildren($def)
Renders a row describing the allowed children of an element.
listifyObjectList($array)
Listifies a list of objects by retrieving class names and internal state.
listifyAttr($array)
Listifies a hash of attributes to AttrDef classes.

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

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

Returns
string

Definition at line 122 of file HTMLDefinition.php.

123 {
124 $ret = '';
125 $ret .= $this->start('table');
126 $ret .= $this->element('caption', 'Elements ($info)');
127 ksort($this->def->info);
128 $ret .= $this->heavyHeader('Allowed tags', 2);
129 $ret .= $this->start('tr');
130 $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2));
131 $ret .= $this->end('tr');
132 foreach ($this->def->info as $name => $def) {
133 $ret .= $this->start('tr');
134 $ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2));
135 $ret .= $this->end('tr');
136 $ret .= $this->start('tr');
137 $ret .= $this->element('th', 'Inline content');
138 $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No');
139 $ret .= $this->end('tr');
140 if (!empty($def->excludes)) {
141 $ret .= $this->start('tr');
142 $ret .= $this->element('th', 'Excludes');
143 $ret .= $this->element('td', $this->listifyTagLookup($def->excludes));
144 $ret .= $this->end('tr');
145 }
146 if (!empty($def->attr_transform_pre)) {
147 $ret .= $this->start('tr');
148 $ret .= $this->element('th', 'Pre-AttrTransform');
149 $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre));
150 $ret .= $this->end('tr');
151 }
152 if (!empty($def->attr_transform_post)) {
153 $ret .= $this->start('tr');
154 $ret .= $this->element('th', 'Post-AttrTransform');
155 $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post));
156 $ret .= $this->end('tr');
157 }
158 if (!empty($def->auto_close)) {
159 $ret .= $this->start('tr');
160 $ret .= $this->element('th', 'Auto closed by');
161 $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close));
162 $ret .= $this->end('tr');
163 }
164 $ret .= $this->start('tr');
165 $ret .= $this->element('th', 'Allowed attributes');
166 $ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0);
167 $ret .= $this->end('tr');
168
169 if (!empty($def->required_attr)) {
170 $ret .= $this->row('Required attributes', $this->listify($def->required_attr));
171 }
172
173 $ret .= $this->renderChildren($def->child);
174 }
175 $ret .= $this->end('table');
176 return $ret;
177 }

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

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

Field Documentation

◆ $def

HTMLPurifier_Printer_HTMLDefinition::$def
protected

@type 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: