1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-30 19:00:10 +02:00

[1.3.0] Add Printer_CSSDefinition.

- Added @public identifiers to properties that the Printers are using.
- Augmented Printer::getClass() to include meta-info about the object (contained inside parentheses). Currently supports: enum, composite and multiple.
- Remove all linebreaks from Printer output
- Document Printer_HTMLDefinition's methods.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@581 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-11-25 05:05:32 +00:00
parent b63b0be21f
commit 9bbbb87ffa
6 changed files with 99 additions and 17 deletions

View File

@@ -17,12 +17,12 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
$def =& $this->def;
$ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer'));
$ret .= $this->start('table') . "\n";
$ret .= $this->start('table');
$ret .= $this->element('caption', 'Environment');
$ret .= $this->row('Parent of fragment', $def->info_parent) . "\n";
$ret .= $this->row('Strict mode', $def->strict) . "\n";
if ($def->strict) $ret .= $this->row('Block wrap name', $def->info_block_wrapper) . "\n";
$ret .= $this->row('Parent of fragment', $def->info_parent);
$ret .= $this->row('Strict mode', $def->strict);
if ($def->strict) $ret .= $this->row('Block wrap name', $def->info_block_wrapper);
$ret .= $this->start('tr');
$ret .= $this->element('th', 'Global attributes');
@@ -51,18 +51,23 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
$ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post));
$ret .= $this->end('tr');
$ret .= $this->end('table') . "\n";
$ret .= $this->end('table');
$ret .= $this->renderInfo();
$ret .= $this->renderInfo() . "\n";
$ret .= $this->end('div');
return $ret;
}
/**
* Renders the Elements ($info) table
*/
function renderInfo() {
$ret = '';
$ret .= $this->start('table') . "\n";
$ret .= $this->start('table');
$ret .= $this->element('caption', 'Elements ($info)');
ksort($this->def->info);
$ret .= $this->start('tr');
@@ -114,6 +119,10 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
return $ret;
}
/**
* Renders a row describing the allowed children of an element
* @param $def HTMLPurifier_ChildDef of pertinent element
*/
function renderChildren($def) {
$context = new HTMLPurifier_Context();
$ret = '';
@@ -153,6 +162,10 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
return $ret;
}
/**
* Listifies a tag lookup table.
* @param $array Tag lookup array in form of array('tagname' => true)
*/
function listifyTagLookup($array) {
$list = array();
foreach ($array as $name => $discard) {
@@ -162,6 +175,11 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
return $this->listify($list);
}
/**
* Listifies a list of objects by retrieving class names and internal state
* @param $array List of objects
* @todo Also add information about internal state
*/
function listifyObjectList($array) {
$list = array();
foreach ($array as $discard => $obj) {
@@ -170,6 +188,10 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer
return $this->listify($list);
}
/**
* Listifies a hash of attributes to AttrDef classes
* @param $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef)
*/
function listifyAttr($array) {
$list = array();
foreach ($array as $name => $obj) {