htmlpurifier 4.15.0 버전으로 수정

This commit is contained in:
thisgun
2024-10-25 17:52:55 +09:00
parent 5e6549a22c
commit 0d586e2101
8 changed files with 28429 additions and 28382 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,15 @@
AutoFormat.RemoveEmpty.RemoveNbsp AutoFormat.RemoveEmpty.RemoveNbsp
TYPE: bool TYPE: bool
VERSION: 4.0.0 VERSION: 4.0.0
DEFAULT: false DEFAULT: false
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
When enabled, HTML Purifier will treat any elements that contain only When enabled, HTML Purifier will treat any elements that contain only
non-breaking spaces as well as regular whitespace as empty, and remove non-breaking spaces as well as regular whitespace as empty, and remove
them when %AutoFormat.RemoveEmpty is enabled. them when %AutoFormat.RemoveEmpty is enabled.
</p> </p>
<p> <p>
See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements
that don't have this behavior applied to them. that don't have this behavior applied to them.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4

View File

@ -1,12 +1,12 @@
Core.AllowParseManyTags Core.AllowParseManyTags
TYPE: bool TYPE: bool
DEFAULT: false DEFAULT: false
VERSION: 4.10.1 VERSION: 4.10.1
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
This directive allows parsing of many nested tags. This directive allows parsing of many nested tags.
If you set true, relaxes any hardcoded limit from the parser. If you set true, relaxes any hardcoded limit from the parser.
However, in that case it may cause a Dos attack. However, in that case it may cause a Dos attack.
Be careful when enabling it. Be careful when enabling it.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4

View File

@ -1,160 +1,160 @@
Core.ColorKeywords Core.ColorKeywords
TYPE: hash TYPE: hash
VERSION: 2.0.0 VERSION: 2.0.0
--DEFAULT-- --DEFAULT--
array ( array (
'aliceblue' => '#F0F8FF', 'aliceblue' => '#F0F8FF',
'antiquewhite' => '#FAEBD7', 'antiquewhite' => '#FAEBD7',
'aqua' => '#00FFFF', 'aqua' => '#00FFFF',
'aquamarine' => '#7FFFD4', 'aquamarine' => '#7FFFD4',
'azure' => '#F0FFFF', 'azure' => '#F0FFFF',
'beige' => '#F5F5DC', 'beige' => '#F5F5DC',
'bisque' => '#FFE4C4', 'bisque' => '#FFE4C4',
'black' => '#000000', 'black' => '#000000',
'blanchedalmond' => '#FFEBCD', 'blanchedalmond' => '#FFEBCD',
'blue' => '#0000FF', 'blue' => '#0000FF',
'blueviolet' => '#8A2BE2', 'blueviolet' => '#8A2BE2',
'brown' => '#A52A2A', 'brown' => '#A52A2A',
'burlywood' => '#DEB887', 'burlywood' => '#DEB887',
'cadetblue' => '#5F9EA0', 'cadetblue' => '#5F9EA0',
'chartreuse' => '#7FFF00', 'chartreuse' => '#7FFF00',
'chocolate' => '#D2691E', 'chocolate' => '#D2691E',
'coral' => '#FF7F50', 'coral' => '#FF7F50',
'cornflowerblue' => '#6495ED', 'cornflowerblue' => '#6495ED',
'cornsilk' => '#FFF8DC', 'cornsilk' => '#FFF8DC',
'crimson' => '#DC143C', 'crimson' => '#DC143C',
'cyan' => '#00FFFF', 'cyan' => '#00FFFF',
'darkblue' => '#00008B', 'darkblue' => '#00008B',
'darkcyan' => '#008B8B', 'darkcyan' => '#008B8B',
'darkgoldenrod' => '#B8860B', 'darkgoldenrod' => '#B8860B',
'darkgray' => '#A9A9A9', 'darkgray' => '#A9A9A9',
'darkgrey' => '#A9A9A9', 'darkgrey' => '#A9A9A9',
'darkgreen' => '#006400', 'darkgreen' => '#006400',
'darkkhaki' => '#BDB76B', 'darkkhaki' => '#BDB76B',
'darkmagenta' => '#8B008B', 'darkmagenta' => '#8B008B',
'darkolivegreen' => '#556B2F', 'darkolivegreen' => '#556B2F',
'darkorange' => '#FF8C00', 'darkorange' => '#FF8C00',
'darkorchid' => '#9932CC', 'darkorchid' => '#9932CC',
'darkred' => '#8B0000', 'darkred' => '#8B0000',
'darksalmon' => '#E9967A', 'darksalmon' => '#E9967A',
'darkseagreen' => '#8FBC8F', 'darkseagreen' => '#8FBC8F',
'darkslateblue' => '#483D8B', 'darkslateblue' => '#483D8B',
'darkslategray' => '#2F4F4F', 'darkslategray' => '#2F4F4F',
'darkslategrey' => '#2F4F4F', 'darkslategrey' => '#2F4F4F',
'darkturquoise' => '#00CED1', 'darkturquoise' => '#00CED1',
'darkviolet' => '#9400D3', 'darkviolet' => '#9400D3',
'deeppink' => '#FF1493', 'deeppink' => '#FF1493',
'deepskyblue' => '#00BFFF', 'deepskyblue' => '#00BFFF',
'dimgray' => '#696969', 'dimgray' => '#696969',
'dimgrey' => '#696969', 'dimgrey' => '#696969',
'dodgerblue' => '#1E90FF', 'dodgerblue' => '#1E90FF',
'firebrick' => '#B22222', 'firebrick' => '#B22222',
'floralwhite' => '#FFFAF0', 'floralwhite' => '#FFFAF0',
'forestgreen' => '#228B22', 'forestgreen' => '#228B22',
'fuchsia' => '#FF00FF', 'fuchsia' => '#FF00FF',
'gainsboro' => '#DCDCDC', 'gainsboro' => '#DCDCDC',
'ghostwhite' => '#F8F8FF', 'ghostwhite' => '#F8F8FF',
'gold' => '#FFD700', 'gold' => '#FFD700',
'goldenrod' => '#DAA520', 'goldenrod' => '#DAA520',
'gray' => '#808080', 'gray' => '#808080',
'grey' => '#808080', 'grey' => '#808080',
'green' => '#008000', 'green' => '#008000',
'greenyellow' => '#ADFF2F', 'greenyellow' => '#ADFF2F',
'honeydew' => '#F0FFF0', 'honeydew' => '#F0FFF0',
'hotpink' => '#FF69B4', 'hotpink' => '#FF69B4',
'indianred' => '#CD5C5C', 'indianred' => '#CD5C5C',
'indigo' => '#4B0082', 'indigo' => '#4B0082',
'ivory' => '#FFFFF0', 'ivory' => '#FFFFF0',
'khaki' => '#F0E68C', 'khaki' => '#F0E68C',
'lavender' => '#E6E6FA', 'lavender' => '#E6E6FA',
'lavenderblush' => '#FFF0F5', 'lavenderblush' => '#FFF0F5',
'lawngreen' => '#7CFC00', 'lawngreen' => '#7CFC00',
'lemonchiffon' => '#FFFACD', 'lemonchiffon' => '#FFFACD',
'lightblue' => '#ADD8E6', 'lightblue' => '#ADD8E6',
'lightcoral' => '#F08080', 'lightcoral' => '#F08080',
'lightcyan' => '#E0FFFF', 'lightcyan' => '#E0FFFF',
'lightgoldenrodyellow' => '#FAFAD2', 'lightgoldenrodyellow' => '#FAFAD2',
'lightgray' => '#D3D3D3', 'lightgray' => '#D3D3D3',
'lightgrey' => '#D3D3D3', 'lightgrey' => '#D3D3D3',
'lightgreen' => '#90EE90', 'lightgreen' => '#90EE90',
'lightpink' => '#FFB6C1', 'lightpink' => '#FFB6C1',
'lightsalmon' => '#FFA07A', 'lightsalmon' => '#FFA07A',
'lightseagreen' => '#20B2AA', 'lightseagreen' => '#20B2AA',
'lightskyblue' => '#87CEFA', 'lightskyblue' => '#87CEFA',
'lightslategray' => '#778899', 'lightslategray' => '#778899',
'lightslategrey' => '#778899', 'lightslategrey' => '#778899',
'lightsteelblue' => '#B0C4DE', 'lightsteelblue' => '#B0C4DE',
'lightyellow' => '#FFFFE0', 'lightyellow' => '#FFFFE0',
'lime' => '#00FF00', 'lime' => '#00FF00',
'limegreen' => '#32CD32', 'limegreen' => '#32CD32',
'linen' => '#FAF0E6', 'linen' => '#FAF0E6',
'magenta' => '#FF00FF', 'magenta' => '#FF00FF',
'maroon' => '#800000', 'maroon' => '#800000',
'mediumaquamarine' => '#66CDAA', 'mediumaquamarine' => '#66CDAA',
'mediumblue' => '#0000CD', 'mediumblue' => '#0000CD',
'mediumorchid' => '#BA55D3', 'mediumorchid' => '#BA55D3',
'mediumpurple' => '#9370DB', 'mediumpurple' => '#9370DB',
'mediumseagreen' => '#3CB371', 'mediumseagreen' => '#3CB371',
'mediumslateblue' => '#7B68EE', 'mediumslateblue' => '#7B68EE',
'mediumspringgreen' => '#00FA9A', 'mediumspringgreen' => '#00FA9A',
'mediumturquoise' => '#48D1CC', 'mediumturquoise' => '#48D1CC',
'mediumvioletred' => '#C71585', 'mediumvioletred' => '#C71585',
'midnightblue' => '#191970', 'midnightblue' => '#191970',
'mintcream' => '#F5FFFA', 'mintcream' => '#F5FFFA',
'mistyrose' => '#FFE4E1', 'mistyrose' => '#FFE4E1',
'moccasin' => '#FFE4B5', 'moccasin' => '#FFE4B5',
'navajowhite' => '#FFDEAD', 'navajowhite' => '#FFDEAD',
'navy' => '#000080', 'navy' => '#000080',
'oldlace' => '#FDF5E6', 'oldlace' => '#FDF5E6',
'olive' => '#808000', 'olive' => '#808000',
'olivedrab' => '#6B8E23', 'olivedrab' => '#6B8E23',
'orange' => '#FFA500', 'orange' => '#FFA500',
'orangered' => '#FF4500', 'orangered' => '#FF4500',
'orchid' => '#DA70D6', 'orchid' => '#DA70D6',
'palegoldenrod' => '#EEE8AA', 'palegoldenrod' => '#EEE8AA',
'palegreen' => '#98FB98', 'palegreen' => '#98FB98',
'paleturquoise' => '#AFEEEE', 'paleturquoise' => '#AFEEEE',
'palevioletred' => '#DB7093', 'palevioletred' => '#DB7093',
'papayawhip' => '#FFEFD5', 'papayawhip' => '#FFEFD5',
'peachpuff' => '#FFDAB9', 'peachpuff' => '#FFDAB9',
'peru' => '#CD853F', 'peru' => '#CD853F',
'pink' => '#FFC0CB', 'pink' => '#FFC0CB',
'plum' => '#DDA0DD', 'plum' => '#DDA0DD',
'powderblue' => '#B0E0E6', 'powderblue' => '#B0E0E6',
'purple' => '#800080', 'purple' => '#800080',
'rebeccapurple' => '#663399', 'rebeccapurple' => '#663399',
'red' => '#FF0000', 'red' => '#FF0000',
'rosybrown' => '#BC8F8F', 'rosybrown' => '#BC8F8F',
'royalblue' => '#4169E1', 'royalblue' => '#4169E1',
'saddlebrown' => '#8B4513', 'saddlebrown' => '#8B4513',
'salmon' => '#FA8072', 'salmon' => '#FA8072',
'sandybrown' => '#F4A460', 'sandybrown' => '#F4A460',
'seagreen' => '#2E8B57', 'seagreen' => '#2E8B57',
'seashell' => '#FFF5EE', 'seashell' => '#FFF5EE',
'sienna' => '#A0522D', 'sienna' => '#A0522D',
'silver' => '#C0C0C0', 'silver' => '#C0C0C0',
'skyblue' => '#87CEEB', 'skyblue' => '#87CEEB',
'slateblue' => '#6A5ACD', 'slateblue' => '#6A5ACD',
'slategray' => '#708090', 'slategray' => '#708090',
'slategrey' => '#708090', 'slategrey' => '#708090',
'snow' => '#FFFAFA', 'snow' => '#FFFAFA',
'springgreen' => '#00FF7F', 'springgreen' => '#00FF7F',
'steelblue' => '#4682B4', 'steelblue' => '#4682B4',
'tan' => '#D2B48C', 'tan' => '#D2B48C',
'teal' => '#008080', 'teal' => '#008080',
'thistle' => '#D8BFD8', 'thistle' => '#D8BFD8',
'tomato' => '#FF6347', 'tomato' => '#FF6347',
'turquoise' => '#40E0D0', 'turquoise' => '#40E0D0',
'violet' => '#EE82EE', 'violet' => '#EE82EE',
'wheat' => '#F5DEB3', 'wheat' => '#F5DEB3',
'white' => '#FFFFFF', 'white' => '#FFFFFF',
'whitesmoke' => '#F5F5F5', 'whitesmoke' => '#F5F5F5',
'yellow' => '#FFFF00', 'yellow' => '#FFFF00',
'yellowgreen' => '#9ACD32' 'yellowgreen' => '#9ACD32'
) )
--DESCRIPTION-- --DESCRIPTION--
Lookup array of color names to six digit hexadecimal number corresponding Lookup array of color names to six digit hexadecimal number corresponding
to color, with preceding hash mark. Used when parsing colors. The lookup to color, with preceding hash mark. Used when parsing colors. The lookup
is done in a case-insensitive manner. is done in a case-insensitive manner.
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4

View File

@ -1,11 +1,11 @@
HTML.Forms HTML.Forms
TYPE: bool TYPE: bool
VERSION: 4.13.0 VERSION: 4.13.0
DEFAULT: false DEFAULT: false
--DESCRIPTION-- --DESCRIPTION--
<p> <p>
Whether or not to permit form elements in the user input, regardless of Whether or not to permit form elements in the user input, regardless of
%HTML.Trusted value. Please be very careful when using this functionality, as %HTML.Trusted value. Please be very careful when using this functionality, as
enabling forms in untrusted documents may allow for phishing attacks. enabling forms in untrusted documents may allow for phishing attacks.
</p> </p>
--# vim: et sw=4 sts=4 --# vim: et sw=4 sts=4

File diff suppressed because it is too large Load Diff

View File

@ -1,451 +1,451 @@
<?php <?php
/** /**
* @todo Rewrite to use Interchange objects * @todo Rewrite to use Interchange objects
*/ */
class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm extends HTMLPurifier_Printer
{ {
/** /**
* Printers for specific fields. * Printers for specific fields.
* @type HTMLPurifier_Printer[] * @type HTMLPurifier_Printer[]
*/ */
protected $fields = array(); protected $fields = array();
/** /**
* Documentation URL, can have fragment tagged on end. * Documentation URL, can have fragment tagged on end.
* @type string * @type string
*/ */
protected $docURL; protected $docURL;
/** /**
* Name of form element to stuff config in. * Name of form element to stuff config in.
* @type string * @type string
*/ */
protected $name; protected $name;
/** /**
* Whether or not to compress directive names, clipping them off * Whether or not to compress directive names, clipping them off
* after a certain amount of letters. False to disable or integer letters * after a certain amount of letters. False to disable or integer letters
* before clipping. * before clipping.
* @type bool * @type bool
*/ */
protected $compress = false; protected $compress = false;
/** /**
* @param string $name Form element name for directives to be stuffed into * @param string $name Form element name for directives to be stuffed into
* @param string $doc_url String documentation URL, will have fragment tagged on * @param string $doc_url String documentation URL, will have fragment tagged on
* @param bool $compress Integer max length before compressing a directive name, set to false to turn off * @param bool $compress Integer max length before compressing a directive name, set to false to turn off
*/ */
public function __construct( public function __construct(
$name, $name,
$doc_url = null, $doc_url = null,
$compress = false $compress = false
) { ) {
parent::__construct(); parent::__construct();
$this->docURL = $doc_url; $this->docURL = $doc_url;
$this->name = $name; $this->name = $name;
$this->compress = $compress; $this->compress = $compress;
// initialize sub-printers // initialize sub-printers
$this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default(); $this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default();
$this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool(); $this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool();
} }
/** /**
* Sets default column and row size for textareas in sub-printers * Sets default column and row size for textareas in sub-printers
* @param $cols Integer columns of textarea, null to use default * @param $cols Integer columns of textarea, null to use default
* @param $rows Integer rows of textarea, null to use default * @param $rows Integer rows of textarea, null to use default
*/ */
public function setTextareaDimensions($cols = null, $rows = null) public function setTextareaDimensions($cols = null, $rows = null)
{ {
if ($cols) { if ($cols) {
$this->fields['default']->cols = $cols; $this->fields['default']->cols = $cols;
} }
if ($rows) { if ($rows) {
$this->fields['default']->rows = $rows; $this->fields['default']->rows = $rows;
} }
} }
/** /**
* Retrieves styling, in case it is not accessible by webserver * Retrieves styling, in case it is not accessible by webserver
*/ */
public static function getCSS() public static function getCSS()
{ {
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css');
} }
/** /**
* Retrieves JavaScript, in case it is not accessible by webserver * Retrieves JavaScript, in case it is not accessible by webserver
*/ */
public static function getJavaScript() public static function getJavaScript()
{ {
return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js');
} }
/** /**
* Returns HTML output for a configuration form * Returns HTML output for a configuration form
* @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array * @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array
* where [0] has an HTML namespace and [1] is being rendered. * where [0] has an HTML namespace and [1] is being rendered.
* @param array|bool $allowed Optional namespace(s) and directives to restrict form to. * @param array|bool $allowed Optional namespace(s) and directives to restrict form to.
* @param bool $render_controls * @param bool $render_controls
* @return string * @return string
*/ */
public function render($config, $allowed = true, $render_controls = true) public function render($config, $allowed = true, $render_controls = true)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->config = $config; $this->config = $config;
$this->genConfig = $gen_config; $this->genConfig = $gen_config;
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def); $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def);
$all = array(); $all = array();
foreach ($allowed as $key) { foreach ($allowed as $key) {
list($ns, $directive) = $key; list($ns, $directive) = $key;
$all[$ns][$directive] = $config->get($ns . '.' . $directive); $all[$ns][$directive] = $config->get($ns . '.' . $directive);
} }
$ret = ''; $ret = '';
$ret .= $this->start('table', array('class' => 'hp-config')); $ret .= $this->start('table', array('class' => 'hp-config'));
$ret .= $this->start('thead'); $ret .= $this->start('thead');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Directive', array('class' => 'hp-directive')); $ret .= $this->element('th', 'Directive', array('class' => 'hp-directive'));
$ret .= $this->element('th', 'Value', array('class' => 'hp-value')); $ret .= $this->element('th', 'Value', array('class' => 'hp-value'));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('thead'); $ret .= $this->end('thead');
foreach ($all as $ns => $directives) { foreach ($all as $ns => $directives) {
$ret .= $this->renderNamespace($ns, $directives); $ret .= $this->renderNamespace($ns, $directives);
} }
if ($render_controls) { if ($render_controls) {
$ret .= $this->start('tbody'); $ret .= $this->start('tbody');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls')); $ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls'));
$ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit')); $ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit'));
$ret .= '[<a href="?">Reset</a>]'; $ret .= '[<a href="?">Reset</a>]';
$ret .= $this->end('td'); $ret .= $this->end('td');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders a single namespace * Renders a single namespace
* @param $ns String namespace name * @param $ns String namespace name
* @param array $directives array of directives to values * @param array $directives array of directives to values
* @return string * @return string
*/ */
protected function renderNamespace($ns, $directives) protected function renderNamespace($ns, $directives)
{ {
$ret = ''; $ret = '';
$ret .= $this->start('tbody', array('class' => 'namespace')); $ret .= $this->start('tbody', array('class' => 'namespace'));
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', $ns, array('colspan' => 2)); $ret .= $this->element('th', $ns, array('colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
$ret .= $this->start('tbody'); $ret .= $this->start('tbody');
foreach ($directives as $directive => $value) { foreach ($directives as $directive => $value) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->start('th'); $ret .= $this->start('th');
if ($this->docURL) { if ($this->docURL) {
$url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL); $url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL);
$ret .= $this->start('a', array('href' => $url)); $ret .= $this->start('a', array('href' => $url));
} }
$attr = array('for' => "{$this->name}:$ns.$directive"); $attr = array('for' => "{$this->name}:$ns.$directive");
// crop directive name if it's too long // crop directive name if it's too long
if (!$this->compress || (strlen($directive) < $this->compress)) { if (!$this->compress || (strlen($directive) < $this->compress)) {
$directive_disp = $directive; $directive_disp = $directive;
} else { } else {
$directive_disp = substr($directive, 0, $this->compress - 2) . '...'; $directive_disp = substr($directive, 0, $this->compress - 2) . '...';
$attr['title'] = $directive; $attr['title'] = $directive;
} }
$ret .= $this->element( $ret .= $this->element(
'label', 'label',
$directive_disp, $directive_disp,
// component printers must create an element with this id // component printers must create an element with this id
$attr $attr
); );
if ($this->docURL) { if ($this->docURL) {
$ret .= $this->end('a'); $ret .= $this->end('a');
} }
$ret .= $this->end('th'); $ret .= $this->end('th');
$ret .= $this->start('td'); $ret .= $this->start('td');
$def = $this->config->def->info["$ns.$directive"]; $def = $this->config->def->info["$ns.$directive"];
if (is_int($def)) { if (is_int($def)) {
$allow_null = $def < 0; $allow_null = $def < 0;
$type = abs($def); $type = abs($def);
} else { } else {
$type = $def->type; $type = $def->type;
$allow_null = isset($def->allow_null); $allow_null = isset($def->allow_null);
} }
if (!isset($this->fields[$type])) { if (!isset($this->fields[$type])) {
$type = 0; $type = 0;
} // default } // default
$type_obj = $this->fields[$type]; $type_obj = $this->fields[$type];
if ($allow_null) { if ($allow_null) {
$type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj); $type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj);
} }
$ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config)); $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config));
$ret .= $this->end('td'); $ret .= $this->end('td');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->end('tbody'); $ret .= $this->end('tbody');
return $ret; return $ret;
} }
} }
/** /**
* Printer decorator for directives that accept null * Printer decorator for directives that accept null
*/ */
class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer
{ {
/** /**
* Printer being decorated * Printer being decorated
* @type HTMLPurifier_Printer * @type HTMLPurifier_Printer
*/ */
protected $obj; protected $obj;
/** /**
* @param HTMLPurifier_Printer $obj Printer to decorate * @param HTMLPurifier_Printer $obj Printer to decorate
*/ */
public function __construct($obj) public function __construct($obj)
{ {
parent::__construct(); parent::__construct();
$this->obj = $obj; $this->obj = $obj;
} }
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$ret = ''; $ret = '';
$ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' Null/Disabled'); $ret .= $this->text(' Null/Disabled');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'checkbox', 'type' => 'checkbox',
'value' => '1', 'value' => '1',
'class' => 'null-toggle', 'class' => 'null-toggle',
'name' => "$name" . "[Null_$ns.$directive]", 'name' => "$name" . "[Null_$ns.$directive]",
'id' => "$name:Null_$ns.$directive", 'id' => "$name:Null_$ns.$directive",
'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!! 'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!!
); );
if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) { if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) {
// modify inline javascript slightly // modify inline javascript slightly
$attr['onclick'] = $attr['onclick'] =
"toggleWriteability('$name:Yes_$ns.$directive',checked);" . "toggleWriteability('$name:Yes_$ns.$directive',checked);" .
"toggleWriteability('$name:No_$ns.$directive',checked)"; "toggleWriteability('$name:No_$ns.$directive',checked)";
} }
if ($value === null) { if ($value === null) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->text(' or '); $ret .= $this->text(' or ');
$ret .= $this->elementEmpty('br'); $ret .= $this->elementEmpty('br');
$ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config)); $ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config));
return $ret; return $ret;
} }
} }
/** /**
* Swiss-army knife configuration form field printer * Swiss-army knife configuration form field printer
*/ */
class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer
{ {
/** /**
* @type int * @type int
*/ */
public $cols = 18; public $cols = 18;
/** /**
* @type int * @type int
*/ */
public $rows = 5; public $rows = 5;
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
// this should probably be split up a little // this should probably be split up a little
$ret = ''; $ret = '';
$def = $config->def->info["$ns.$directive"]; $def = $config->def->info["$ns.$directive"];
if (is_int($def)) { if (is_int($def)) {
$type = abs($def); $type = abs($def);
} else { } else {
$type = $def->type; $type = $def->type;
} }
if (is_array($value)) { if (is_array($value)) {
switch ($type) { switch ($type) {
case HTMLPurifier_VarParser::LOOKUP: case HTMLPurifier_VarParser::LOOKUP:
$array = $value; $array = $value;
$value = array(); $value = array();
foreach ($array as $val => $b) { foreach ($array as $val => $b) {
$value[] = $val; $value[] = $val;
} }
//TODO does this need a break? //TODO does this need a break?
case HTMLPurifier_VarParser::ALIST: case HTMLPurifier_VarParser::ALIST:
$value = implode(PHP_EOL, $value); $value = implode(PHP_EOL, $value);
break; break;
case HTMLPurifier_VarParser::HASH: case HTMLPurifier_VarParser::HASH:
$nvalue = ''; $nvalue = '';
foreach ($value as $i => $v) { foreach ($value as $i => $v) {
if (is_array($v)) { if (is_array($v)) {
// HACK // HACK
$v = implode(";", $v); $v = implode(";", $v);
} }
$nvalue .= "$i:$v" . PHP_EOL; $nvalue .= "$i:$v" . PHP_EOL;
} }
$value = $nvalue; $value = $nvalue;
break; break;
default: default:
$value = ''; $value = '';
} }
} }
if ($type === HTMLPurifier_VarParser::C_MIXED) { if ($type === HTMLPurifier_VarParser::C_MIXED) {
return 'Not supported'; return 'Not supported';
$value = serialize($value); $value = serialize($value);
} }
$attr = array( $attr = array(
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:$ns.$directive" 'id' => "$name:$ns.$directive"
); );
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
if (isset($def->allowed)) { if (isset($def->allowed)) {
$ret .= $this->start('select', $attr); $ret .= $this->start('select', $attr);
foreach ($def->allowed as $val => $b) { foreach ($def->allowed as $val => $b) {
$attr = array(); $attr = array();
if ($value == $val) { if ($value == $val) {
$attr['selected'] = 'selected'; $attr['selected'] = 'selected';
} }
$ret .= $this->element('option', $val, $attr); $ret .= $this->element('option', $val, $attr);
} }
$ret .= $this->end('select'); $ret .= $this->end('select');
} elseif ($type === HTMLPurifier_VarParser::TEXT || } elseif ($type === HTMLPurifier_VarParser::TEXT ||
$type === HTMLPurifier_VarParser::ITEXT || $type === HTMLPurifier_VarParser::ITEXT ||
$type === HTMLPurifier_VarParser::ALIST || $type === HTMLPurifier_VarParser::ALIST ||
$type === HTMLPurifier_VarParser::HASH || $type === HTMLPurifier_VarParser::HASH ||
$type === HTMLPurifier_VarParser::LOOKUP) { $type === HTMLPurifier_VarParser::LOOKUP) {
$attr['cols'] = $this->cols; $attr['cols'] = $this->cols;
$attr['rows'] = $this->rows; $attr['rows'] = $this->rows;
$ret .= $this->start('textarea', $attr); $ret .= $this->start('textarea', $attr);
$ret .= $this->text($value); $ret .= $this->text($value);
$ret .= $this->end('textarea'); $ret .= $this->end('textarea');
} else { } else {
$attr['value'] = $value; $attr['value'] = $value;
$attr['type'] = 'text'; $attr['type'] = 'text';
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
} }
return $ret; return $ret;
} }
} }
/** /**
* Bool form field printer * Bool form field printer
*/ */
class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer
{ {
/** /**
* @param string $ns * @param string $ns
* @param string $directive * @param string $directive
* @param string $value * @param string $value
* @param string $name * @param string $name
* @param HTMLPurifier_Config|array $config * @param HTMLPurifier_Config|array $config
* @return string * @return string
*/ */
public function render($ns, $directive, $value, $name, $config) public function render($ns, $directive, $value, $name, $config)
{ {
if (is_array($config) && isset($config[0])) { if (is_array($config) && isset($config[0])) {
$gen_config = $config[0]; $gen_config = $config[0];
$config = $config[1]; $config = $config[1];
} else { } else {
$gen_config = $config; $gen_config = $config;
} }
$this->prepareGenerator($gen_config); $this->prepareGenerator($gen_config);
$ret = ''; $ret = '';
$ret .= $this->start('div', array('id' => "$name:$ns.$directive")); $ret .= $this->start('div', array('id' => "$name:$ns.$directive"));
$ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' Yes'); $ret .= $this->text(' Yes');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'radio', 'type' => 'radio',
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:Yes_$ns.$directive", 'id' => "$name:Yes_$ns.$directive",
'value' => '1' 'value' => '1'
); );
if ($value === true) { if ($value === true) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->start('label', array('for' => "$name:No_$ns.$directive")); $ret .= $this->start('label', array('for' => "$name:No_$ns.$directive"));
$ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose'));
$ret .= $this->text(' No'); $ret .= $this->text(' No');
$ret .= $this->end('label'); $ret .= $this->end('label');
$attr = array( $attr = array(
'type' => 'radio', 'type' => 'radio',
'name' => "$name" . "[$ns.$directive]", 'name' => "$name" . "[$ns.$directive]",
'id' => "$name:No_$ns.$directive", 'id' => "$name:No_$ns.$directive",
'value' => '0' 'value' => '0'
); );
if ($value === false) { if ($value === false) {
$attr['checked'] = 'checked'; $attr['checked'] = 'checked';
} }
if ($value === null) { if ($value === null) {
$attr['disabled'] = 'disabled'; $attr['disabled'] = 'disabled';
} }
$ret .= $this->elementEmpty('input', $attr); $ret .= $this->elementEmpty('input', $attr);
$ret .= $this->end('div'); $ret .= $this->end('div');
return $ret; return $ret;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4

View File

@ -1,324 +1,324 @@
<?php <?php
class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
{ {
/** /**
* @type HTMLPurifier_HTMLDefinition, for easy access * @type HTMLPurifier_HTMLDefinition, for easy access
*/ */
protected $def; protected $def;
/** /**
* @param HTMLPurifier_Config $config * @param HTMLPurifier_Config $config
* @return string * @return string
*/ */
public function render($config) public function render($config)
{ {
$ret = ''; $ret = '';
$this->config =& $config; $this->config =& $config;
$this->def = $config->getHTMLDefinition(); $this->def = $config->getHTMLDefinition();
$ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer'));
$ret .= $this->renderDoctype(); $ret .= $this->renderDoctype();
$ret .= $this->renderEnvironment(); $ret .= $this->renderEnvironment();
$ret .= $this->renderContentSets(); $ret .= $this->renderContentSets();
$ret .= $this->renderInfo(); $ret .= $this->renderInfo();
$ret .= $this->end('div'); $ret .= $this->end('div');
return $ret; return $ret;
} }
/** /**
* Renders the Doctype table * Renders the Doctype table
* @return string * @return string
*/ */
protected function renderDoctype() protected function renderDoctype()
{ {
$doctype = $this->def->doctype; $doctype = $this->def->doctype;
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Doctype'); $ret .= $this->element('caption', 'Doctype');
$ret .= $this->row('Name', $doctype->name); $ret .= $this->row('Name', $doctype->name);
$ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No');
$ret .= $this->row('Default Modules', implode(', ', $doctype->modules)); $ret .= $this->row('Default Modules', implode(', ', $doctype->modules));
$ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules)); $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules));
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders environment table, which is miscellaneous info * Renders environment table, which is miscellaneous info
* @return string * @return string
*/ */
protected function renderEnvironment() protected function renderEnvironment()
{ {
$def = $this->def; $def = $this->def;
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Environment'); $ret .= $this->element('caption', 'Environment');
$ret .= $this->row('Parent of fragment', $def->info_parent); $ret .= $this->row('Parent of fragment', $def->info_parent);
$ret .= $this->renderChildren($def->info_parent_def->child); $ret .= $this->renderChildren($def->info_parent_def->child);
$ret .= $this->row('Block wrap name', $def->info_block_wrapper); $ret .= $this->row('Block wrap name', $def->info_block_wrapper);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Global attributes'); $ret .= $this->element('th', 'Global attributes');
$ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0);
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Tag transforms'); $ret .= $this->element('th', 'Tag transforms');
$list = array(); $list = array();
foreach ($def->info_tag_transform as $old => $new) { foreach ($def->info_tag_transform as $old => $new) {
$new = $this->getClass($new, 'TagTransform_'); $new = $this->getClass($new, 'TagTransform_');
$list[] = "<$old> with $new"; $list[] = "<$old> with $new";
} }
$ret .= $this->element('td', $this->listify($list)); $ret .= $this->element('td', $this->listify($list));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('th', 'Pre-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('th', 'Post-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders the Content Sets table * Renders the Content Sets table
* @return string * @return string
*/ */
protected function renderContentSets() protected function renderContentSets()
{ {
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Content Sets'); $ret .= $this->element('caption', 'Content Sets');
foreach ($this->def->info_content_sets as $name => $lookup) { foreach ($this->def->info_content_sets as $name => $lookup) {
$ret .= $this->heavyHeader($name); $ret .= $this->heavyHeader($name);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('td', $this->listifyTagLookup($lookup)); $ret .= $this->element('td', $this->listifyTagLookup($lookup));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders the Elements ($info) table * Renders the Elements ($info) table
* @return string * @return string
*/ */
protected function renderInfo() protected function renderInfo()
{ {
$ret = ''; $ret = '';
$ret .= $this->start('table'); $ret .= $this->start('table');
$ret .= $this->element('caption', 'Elements ($info)'); $ret .= $this->element('caption', 'Elements ($info)');
ksort($this->def->info); ksort($this->def->info);
$ret .= $this->heavyHeader('Allowed tags', 2); $ret .= $this->heavyHeader('Allowed tags', 2);
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2)); $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
foreach ($this->def->info as $name => $def) { foreach ($this->def->info as $name => $def) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2)); $ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Inline content'); $ret .= $this->element('th', 'Inline content');
$ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No'); $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No');
$ret .= $this->end('tr'); $ret .= $this->end('tr');
if (!empty($def->excludes)) { if (!empty($def->excludes)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Excludes'); $ret .= $this->element('th', 'Excludes');
$ret .= $this->element('td', $this->listifyTagLookup($def->excludes)); $ret .= $this->element('td', $this->listifyTagLookup($def->excludes));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->attr_transform_pre)) { if (!empty($def->attr_transform_pre)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('th', 'Pre-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre)); $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->attr_transform_post)) { if (!empty($def->attr_transform_post)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('th', 'Post-AttrTransform');
$ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post)); $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
if (!empty($def->auto_close)) { if (!empty($def->auto_close)) {
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Auto closed by'); $ret .= $this->element('th', 'Auto closed by');
$ret .= $this->element('td', $this->listifyTagLookup($def->auto_close)); $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
} }
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', 'Allowed attributes'); $ret .= $this->element('th', 'Allowed attributes');
$ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0); $ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0);
$ret .= $this->end('tr'); $ret .= $this->end('tr');
if (!empty($def->required_attr)) { if (!empty($def->required_attr)) {
$ret .= $this->row('Required attributes', $this->listify($def->required_attr)); $ret .= $this->row('Required attributes', $this->listify($def->required_attr));
} }
$ret .= $this->renderChildren($def->child); $ret .= $this->renderChildren($def->child);
} }
$ret .= $this->end('table'); $ret .= $this->end('table');
return $ret; return $ret;
} }
/** /**
* Renders a row describing the allowed children of an element * Renders a row describing the allowed children of an element
* @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element * @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element
* @return string * @return string
*/ */
protected function renderChildren($def) protected function renderChildren($def)
{ {
$context = new HTMLPurifier_Context(); $context = new HTMLPurifier_Context();
$ret = ''; $ret = '';
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$elements = array(); $elements = array();
$attr = array(); $attr = array();
if (isset($def->elements)) { if (isset($def->elements)) {
if ($def->type == 'strictblockquote') { if ($def->type == 'strictblockquote') {
$def->validateChildren(array(), $this->config, $context); $def->validateChildren(array(), $this->config, $context);
} }
$elements = $def->elements; $elements = $def->elements;
} }
if ($def->type == 'chameleon') { if ($def->type == 'chameleon') {
$attr['rowspan'] = 2; $attr['rowspan'] = 2;
} elseif ($def->type == 'empty') { } elseif ($def->type == 'empty') {
$elements = array(); $elements = array();
} elseif ($def->type == 'table') { } elseif ($def->type == 'table') {
$elements = array_flip( $elements = array_flip(
array( array(
'col', 'col',
'caption', 'caption',
'colgroup', 'colgroup',
'thead', 'thead',
'tfoot', 'tfoot',
'tbody', 'tbody',
'tr' 'tr'
) )
); );
} }
$ret .= $this->element('th', 'Allowed children', $attr); $ret .= $this->element('th', 'Allowed children', $attr);
if ($def->type == 'chameleon') { if ($def->type == 'chameleon') {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>Block</em>: ' . '<em>Block</em>: ' .
$this->escape($this->listifyTagLookup($def->block->elements)), $this->escape($this->listifyTagLookup($def->block->elements)),
null, null,
0 0
); );
$ret .= $this->end('tr'); $ret .= $this->end('tr');
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>Inline</em>: ' . '<em>Inline</em>: ' .
$this->escape($this->listifyTagLookup($def->inline->elements)), $this->escape($this->listifyTagLookup($def->inline->elements)),
null, null,
0 0
); );
} elseif ($def->type == 'custom') { } elseif ($def->type == 'custom') {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>' . ucfirst($def->type) . '</em>: ' . '<em>' . ucfirst($def->type) . '</em>: ' .
$def->dtd_regex $def->dtd_regex
); );
} else { } else {
$ret .= $this->element( $ret .= $this->element(
'td', 'td',
'<em>' . ucfirst($def->type) . '</em>: ' . '<em>' . ucfirst($def->type) . '</em>: ' .
$this->escape($this->listifyTagLookup($elements)), $this->escape($this->listifyTagLookup($elements)),
null, null,
0 0
); );
} }
$ret .= $this->end('tr'); $ret .= $this->end('tr');
return $ret; return $ret;
} }
/** /**
* Listifies a tag lookup table. * Listifies a tag lookup table.
* @param array $array Tag lookup array in form of array('tagname' => true) * @param array $array Tag lookup array in form of array('tagname' => true)
* @return string * @return string
*/ */
protected function listifyTagLookup($array) protected function listifyTagLookup($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $name => $discard) { foreach ($array as $name => $discard) {
if ($name !== '#PCDATA' && !isset($this->def->info[$name])) { if ($name !== '#PCDATA' && !isset($this->def->info[$name])) {
continue; continue;
} }
$list[] = $name; $list[] = $name;
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Listifies a list of objects by retrieving class names and internal state * Listifies a list of objects by retrieving class names and internal state
* @param array $array List of objects * @param array $array List of objects
* @return string * @return string
* @todo Also add information about internal state * @todo Also add information about internal state
*/ */
protected function listifyObjectList($array) protected function listifyObjectList($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $obj) { foreach ($array as $obj) {
$list[] = $this->getClass($obj, 'AttrTransform_'); $list[] = $this->getClass($obj, 'AttrTransform_');
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Listifies a hash of attributes to AttrDef classes * Listifies a hash of attributes to AttrDef classes
* @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef) * @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef)
* @return string * @return string
*/ */
protected function listifyAttr($array) protected function listifyAttr($array)
{ {
ksort($array); ksort($array);
$list = array(); $list = array();
foreach ($array as $name => $obj) { foreach ($array as $name => $obj) {
if ($obj === false) { if ($obj === false) {
continue; continue;
} }
$list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>'; $list[] = "$name&nbsp;=&nbsp;<i>" . $this->getClass($obj, 'AttrDef_') . '</i>';
} }
return $this->listify($list); return $this->listify($list);
} }
/** /**
* Creates a heavy header row * Creates a heavy header row
* @param string $text * @param string $text
* @param int $num * @param int $num
* @return string * @return string
*/ */
protected function heavyHeader($text, $num = 1) protected function heavyHeader($text, $num = 1)
{ {
$ret = ''; $ret = '';
$ret .= $this->start('tr'); $ret .= $this->start('tr');
$ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy'));
$ret .= $this->end('tr'); $ret .= $this->end('tr');
return $ret; return $ret;
} }
} }
// vim: et sw=4 sts=4 // vim: et sw=4 sts=4