From eaea42f8275f7074e36e168e2e1b946d29dab740 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 11 May 2007 00:54:04 +0000 Subject: [PATCH] [1.7.0] Migrate Presentation module to new syntax, compactify Edit, Legacy and List declarations. git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1044 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier/HTMLModule/Edit.php | 8 ++----- library/HTMLPurifier/HTMLModule/Legacy.php | 12 +++------- library/HTMLPurifier/HTMLModule/List.php | 24 +++++-------------- .../HTMLPurifier/HTMLModule/Presentation.php | 23 +++++++----------- 4 files changed, 19 insertions(+), 48 deletions(-) diff --git a/library/HTMLPurifier/HTMLModule/Edit.php b/library/HTMLPurifier/HTMLModule/Edit.php index 720e4927..1d14ce8d 100644 --- a/library/HTMLPurifier/HTMLModule/Edit.php +++ b/library/HTMLPurifier/HTMLModule/Edit.php @@ -18,12 +18,8 @@ class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule 'cite' => 'URI', // 'datetime' => 'Datetime', // not implemented ); - $this->addElement( - 'del', true, 'Inline', $contents, 'Common', $attr - ); - $this->addElement( - 'ins', true, 'Inline', $contents, 'Common', $attr - ); + $this->addElement('del', true, 'Inline', $contents, 'Common', $attr); + $this->addElement('ins', true, 'Inline', $contents, 'Common', $attr); } // HTML 4.01 specifies that ins/del must not contain block diff --git a/library/HTMLPurifier/HTMLModule/Legacy.php b/library/HTMLPurifier/HTMLModule/Legacy.php index 357a4f40..930c714a 100644 --- a/library/HTMLPurifier/HTMLModule/Legacy.php +++ b/library/HTMLPurifier/HTMLModule/Legacy.php @@ -24,15 +24,9 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule var $name = 'Legacy'; function HTMLPurifier_HTMLModule_Legacy() { - $this->addElement( - 'u', true, 'Inline', 'Inline', 'Common' - ); - $this->addElement( - 's', true, 'Inline', 'Inline', 'Common' - ); - $this->addElement( - 'strike', true, 'Inline', 'Inline', 'Common' - ); + $this->addElement('u', true, 'Inline', 'Inline', 'Common'); + $this->addElement('s', true, 'Inline', 'Inline', 'Common'); + $this->addElement('strike', true, 'Inline', 'Inline', 'Common'); // setup modifications to old elements // perhaps we could make some convenience functions for these... diff --git a/library/HTMLPurifier/HTMLModule/List.php b/library/HTMLPurifier/HTMLModule/List.php index 28c943e1..84d1cd38 100644 --- a/library/HTMLPurifier/HTMLModule/List.php +++ b/library/HTMLPurifier/HTMLModule/List.php @@ -22,27 +22,15 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule var $content_sets = array('Flow' => 'List'); function HTMLPurifier_HTMLModule_List() { - $this->addElement( - 'ol', true, 'List', 'Required: li', 'Common' - ); - $this->addElement( - 'ul', true, 'List', 'Required: li', 'Common' - ); - $this->addElement( - 'dl', true, 'List', 'Required: dt | dd', 'Common' - ); + $this->addElement('ol', true, 'List', 'Required: li', 'Common'); + $this->addElement('ul', true, 'List', 'Required: li', 'Common'); + $this->addElement('dl', true, 'List', 'Required: dt | dd', 'Common'); - $this->addElement( - 'li', true, false, 'Flow', 'Common' - ); + $this->addElement('li', true, false, 'Flow', 'Common'); $this->info['li']->auto_close = array('li' => true); - $this->addElement( - 'dd', true, false, 'Flow', 'Common' - ); - $this->addElement( - 'dt', true, false, 'Inline', 'Common' - ); + $this->addElement('dd', true, false, 'Flow', 'Common'); + $this->addElement('dt', true, false, 'Inline', 'Common'); } } diff --git a/library/HTMLPurifier/HTMLModule/Presentation.php b/library/HTMLPurifier/HTMLModule/Presentation.php index 5c80db40..36eeeb0e 100644 --- a/library/HTMLPurifier/HTMLModule/Presentation.php +++ b/library/HTMLPurifier/HTMLModule/Presentation.php @@ -16,23 +16,16 @@ class HTMLPurifier_HTMLModule_Presentation extends HTMLPurifier_HTMLModule { var $name = 'Presentation'; - var $elements = array('b', 'big', 'hr', 'i', 'small', 'sub', 'sup', 'tt'); - var $content_sets = array( - 'Block' => 'hr', - 'Inline' => 'b | big | i | small | sub | sup | tt' - ); function HTMLPurifier_HTMLModule_Presentation() { - foreach ($this->elements as $element) { - $this->info[$element] = new HTMLPurifier_ElementDef(); - $this->info[$element]->attr = array(0 => array('Common')); - if ($element == 'hr') { - $this->info[$element]->content_model_type = 'empty'; - } else { - $this->info[$element]->content_model = '#PCDATA | Inline'; - $this->info[$element]->content_model_type = 'optional'; - } - } + $this->addElement('hr', true, 'Block', 'Empty', 'Common'); + $this->addElement('b', true, 'Inline', 'Inline', 'Common'); + $this->addElement('big', true, 'Inline', 'Inline', 'Common'); + $this->addElement('i', true, 'Inline', 'Inline', 'Common'); + $this->addElement('small', true, 'Inline', 'Inline', 'Common'); + $this->addElement('sub', true, 'Inline', 'Inline', 'Common'); + $this->addElement('sup', true, 'Inline', 'Inline', 'Common'); + $this->addElement('tt', true, 'Inline', 'Inline', 'Common'); } }