From fcebb7731df1dc42f0e50bc3b5844429502a6cc3 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Thu, 22 May 2008 19:36:59 +0000 Subject: [PATCH] [3.1.1] Migrate all HTMLModules to use setup($config) rather than __construct git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1761 48356398-32a2-884e-a903-53898d9a118a --- NEWS | 7 +++++-- library/HTMLPurifier/HTMLModule/Bdo.php | 2 +- library/HTMLPurifier/HTMLModule/Edit.php | 2 +- library/HTMLPurifier/HTMLModule/Hypertext.php | 2 +- library/HTMLPurifier/HTMLModule/Image.php | 2 +- library/HTMLPurifier/HTMLModule/Legacy.php | 2 +- library/HTMLPurifier/HTMLModule/List.php | 2 +- library/HTMLPurifier/HTMLModule/Object.php | 2 +- library/HTMLPurifier/HTMLModule/Presentation.php | 2 +- library/HTMLPurifier/HTMLModule/Proprietary.php | 2 +- library/HTMLPurifier/HTMLModule/Ruby.php | 2 +- library/HTMLPurifier/HTMLModule/Scripting.php | 2 +- library/HTMLPurifier/HTMLModule/StyleAttribute.php | 2 +- library/HTMLPurifier/HTMLModule/Tables.php | 2 +- library/HTMLPurifier/HTMLModule/Target.php | 2 +- library/HTMLPurifier/HTMLModule/Text.php | 2 +- 16 files changed, 20 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 1bb85e67..65e19e74 100644 --- a/NEWS +++ b/NEWS @@ -23,9 +23,12 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier to __construct($min, $max). __construct(true) is equivalent to __construct('0'). . Added HTMLPurifier_AttrDef_Switch class -. Rename HTMLPurifier_HTMLModule_Tidy->construct() to setup(), and bubble +. Rename HTMLPurifier_HTMLModule_Tidy->construct() to setup() and bubble method up inheritance hierarchy to HTMLPurifier_HTMLModule. All HTMLModules - get this called with the configuration object. + get this called with the configuration object. All modules now + use this rather than __construct(), although legacy code using constructors + will still work--the new format, however, lets modules access the + configuration object for HTML namespace dependant tweaks. 3.1.0, released 2008-05-18 # Unnecessary references to objects (vestiges of PHP4) removed from method diff --git a/library/HTMLPurifier/HTMLModule/Bdo.php b/library/HTMLPurifier/HTMLModule/Bdo.php index b65057ca..0d643e81 100644 --- a/library/HTMLPurifier/HTMLModule/Bdo.php +++ b/library/HTMLPurifier/HTMLModule/Bdo.php @@ -12,7 +12,7 @@ class HTMLPurifier_HTMLModule_Bdo extends HTMLPurifier_HTMLModule 'I18N' => array('dir' => false) ); - public function __construct() { + public function setup($config) { $bdo = $this->addElement( 'bdo', 'Inline', 'Inline', array('Core', 'Lang'), array( diff --git a/library/HTMLPurifier/HTMLModule/Edit.php b/library/HTMLPurifier/HTMLModule/Edit.php index 07d972e3..157fca16 100644 --- a/library/HTMLPurifier/HTMLModule/Edit.php +++ b/library/HTMLPurifier/HTMLModule/Edit.php @@ -9,7 +9,7 @@ class HTMLPurifier_HTMLModule_Edit extends HTMLPurifier_HTMLModule public $name = 'Edit'; - public function __construct() { + public function setup($config) { $contents = 'Chameleon: #PCDATA | Inline ! #PCDATA | Flow'; $attr = array( 'cite' => 'URI', diff --git a/library/HTMLPurifier/HTMLModule/Hypertext.php b/library/HTMLPurifier/HTMLModule/Hypertext.php index 4a347e6f..4451f2bb 100644 --- a/library/HTMLPurifier/HTMLModule/Hypertext.php +++ b/library/HTMLPurifier/HTMLModule/Hypertext.php @@ -8,7 +8,7 @@ class HTMLPurifier_HTMLModule_Hypertext extends HTMLPurifier_HTMLModule public $name = 'Hypertext'; - public function __construct() { + public function setup($config) { $a = $this->addElement( 'a', 'Inline', 'Inline', 'Common', array( diff --git a/library/HTMLPurifier/HTMLModule/Image.php b/library/HTMLPurifier/HTMLModule/Image.php index 5a7afe62..ee2b94a4 100644 --- a/library/HTMLPurifier/HTMLModule/Image.php +++ b/library/HTMLPurifier/HTMLModule/Image.php @@ -10,7 +10,7 @@ class HTMLPurifier_HTMLModule_Image extends HTMLPurifier_HTMLModule public $name = 'Image'; - public function __construct() { + public function setup($config) { $img = $this->addElement( 'img', 'Inline', 'Empty', 'Common', array( diff --git a/library/HTMLPurifier/HTMLModule/Legacy.php b/library/HTMLPurifier/HTMLModule/Legacy.php index 903273ea..dd1f04e0 100644 --- a/library/HTMLPurifier/HTMLModule/Legacy.php +++ b/library/HTMLPurifier/HTMLModule/Legacy.php @@ -21,7 +21,7 @@ class HTMLPurifier_HTMLModule_Legacy extends HTMLPurifier_HTMLModule public $name = 'Legacy'; - public function __construct() { + public function setup($config) { $this->addElement('basefont', 'Inline', 'Empty', false, array( 'color' => 'Color', diff --git a/library/HTMLPurifier/HTMLModule/List.php b/library/HTMLPurifier/HTMLModule/List.php index 7d4f9cf2..a2cf2f56 100644 --- a/library/HTMLPurifier/HTMLModule/List.php +++ b/library/HTMLPurifier/HTMLModule/List.php @@ -19,7 +19,7 @@ class HTMLPurifier_HTMLModule_List extends HTMLPurifier_HTMLModule public $content_sets = array('Flow' => 'List'); - public function __construct() { + public function setup($config) { $this->addElement('ol', 'List', 'Required: li', 'Common'); $this->addElement('ul', 'List', 'Required: li', 'Common'); $this->addElement('dl', 'List', 'Required: dt | dd', 'Common'); diff --git a/library/HTMLPurifier/HTMLModule/Object.php b/library/HTMLPurifier/HTMLModule/Object.php index 609d3351..7dfd6b31 100644 --- a/library/HTMLPurifier/HTMLModule/Object.php +++ b/library/HTMLPurifier/HTMLModule/Object.php @@ -11,7 +11,7 @@ class HTMLPurifier_HTMLModule_Object extends HTMLPurifier_HTMLModule public $name = 'Object'; public $safe = false; - public function __construct() { + public function setup($config) { $this->addElement('object', 'Inline', 'Optional: #PCDATA | Flow | param', 'Common', array( diff --git a/library/HTMLPurifier/HTMLModule/Presentation.php b/library/HTMLPurifier/HTMLModule/Presentation.php index bd8368a8..857b3abf 100644 --- a/library/HTMLPurifier/HTMLModule/Presentation.php +++ b/library/HTMLPurifier/HTMLModule/Presentation.php @@ -15,7 +15,7 @@ class HTMLPurifier_HTMLModule_Presentation extends HTMLPurifier_HTMLModule public $name = 'Presentation'; - public function __construct() { + public function setup($config) { $this->addElement('b', 'Inline', 'Inline', 'Common'); $this->addElement('big', 'Inline', 'Inline', 'Common'); $this->addElement('hr', 'Block', 'Empty', 'Common'); diff --git a/library/HTMLPurifier/HTMLModule/Proprietary.php b/library/HTMLPurifier/HTMLModule/Proprietary.php index d5c72418..bcbcd124 100644 --- a/library/HTMLPurifier/HTMLModule/Proprietary.php +++ b/library/HTMLPurifier/HTMLModule/Proprietary.php @@ -9,7 +9,7 @@ class HTMLPurifier_HTMLModule_Proprietary extends HTMLPurifier_HTMLModule public $name = 'Proprietary'; - public function __construct() { + public function setup($config) { $this->addElement('marquee', 'Inline', 'Flow', 'Common', array( diff --git a/library/HTMLPurifier/HTMLModule/Ruby.php b/library/HTMLPurifier/HTMLModule/Ruby.php index 21ec79a2..caee035f 100644 --- a/library/HTMLPurifier/HTMLModule/Ruby.php +++ b/library/HTMLPurifier/HTMLModule/Ruby.php @@ -9,7 +9,7 @@ class HTMLPurifier_HTMLModule_Ruby extends HTMLPurifier_HTMLModule public $name = 'Ruby'; - public function __construct() { + public function setup($config) { $this->addElement('ruby', 'Inline', 'Custom: ((rb, (rt | (rp, rt, rp))) | (rbc, rtc, rtc?))', 'Common'); diff --git a/library/HTMLPurifier/HTMLModule/Scripting.php b/library/HTMLPurifier/HTMLModule/Scripting.php index b3371b3a..2b7e2ced 100644 --- a/library/HTMLPurifier/HTMLModule/Scripting.php +++ b/library/HTMLPurifier/HTMLModule/Scripting.php @@ -20,7 +20,7 @@ class HTMLPurifier_HTMLModule_Scripting extends HTMLPurifier_HTMLModule public $content_sets = array('Block' => 'script | noscript', 'Inline' => 'script | noscript'); public $safe = false; - public function __construct() { + public function setup($config) { // TODO: create custom child-definition for noscript that // auto-wraps stray #PCDATA in a similar manner to // blockquote's custom definition (we would use it but diff --git a/library/HTMLPurifier/HTMLModule/StyleAttribute.php b/library/HTMLPurifier/HTMLModule/StyleAttribute.php index 3963e22c..9775536d 100644 --- a/library/HTMLPurifier/HTMLModule/StyleAttribute.php +++ b/library/HTMLPurifier/HTMLModule/StyleAttribute.php @@ -15,7 +15,7 @@ class HTMLPurifier_HTMLModule_StyleAttribute extends HTMLPurifier_HTMLModule 'Core' => array(0 => array('Style')) ); - public function __construct() { + public function setup($config) { $this->attr_collections['Style']['style'] = new HTMLPurifier_AttrDef_CSS(); } diff --git a/library/HTMLPurifier/HTMLModule/Tables.php b/library/HTMLPurifier/HTMLModule/Tables.php index d6a13fff..dd70bddf 100644 --- a/library/HTMLPurifier/HTMLModule/Tables.php +++ b/library/HTMLPurifier/HTMLModule/Tables.php @@ -8,7 +8,7 @@ class HTMLPurifier_HTMLModule_Tables extends HTMLPurifier_HTMLModule public $name = 'Tables'; - public function __construct() { + public function setup($config) { $this->addElement('caption', false, 'Inline', 'Common'); diff --git a/library/HTMLPurifier/HTMLModule/Target.php b/library/HTMLPurifier/HTMLModule/Target.php index 18203d04..042d458c 100644 --- a/library/HTMLPurifier/HTMLModule/Target.php +++ b/library/HTMLPurifier/HTMLModule/Target.php @@ -8,7 +8,7 @@ class HTMLPurifier_HTMLModule_Target extends HTMLPurifier_HTMLModule public $name = 'Target'; - public function __construct() { + public function setup($config) { $elements = array('a'); foreach ($elements as $name) { $e = $this->addBlankElement($name); diff --git a/library/HTMLPurifier/HTMLModule/Text.php b/library/HTMLPurifier/HTMLModule/Text.php index 4b13a80d..9de103d5 100644 --- a/library/HTMLPurifier/HTMLModule/Text.php +++ b/library/HTMLPurifier/HTMLModule/Text.php @@ -20,7 +20,7 @@ class HTMLPurifier_HTMLModule_Text extends HTMLPurifier_HTMLModule 'Flow' => 'Heading | Block | Inline' ); - public function __construct() { + public function setup($config) { // Inline Phrasal ------------------------------------------------- $this->addElement('abbr', 'Inline', 'Inline', 'Common'); -- 2.11.4.GIT