From 81a4cf6a1492e3dbe6f75aeddbcda343c834565c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Sun, 27 Jan 2008 00:06:10 +0000 Subject: [PATCH] [3.1.0] Preparation for autoload - Factor out getPath from autoload implementation to its own function - Ensure extends is on the same line as class for all files git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1515 48356398-32a2-884e-a903-53898d9a118a --- library/HTMLPurifier.php | 17 ++++++++++++----- library/HTMLPurifier/AttrTransform/BoolToCSS.php | 3 +-- library/HTMLPurifier/ChildDef/StrictBlockquote.php | 3 +-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/library/HTMLPurifier.php b/library/HTMLPurifier.php index 34d4e773..119c6f2a 100644 --- a/library/HTMLPurifier.php +++ b/library/HTMLPurifier.php @@ -232,15 +232,22 @@ class HTMLPurifier * @param $class Class to load */ public static function autoload($class) { + $file = HTMLPurifier::getPath($class); + if (!$file) return false; + require_once $file; + return true; + } + + /** + * Returns the path for a specific class. + */ + public static function getPath($class) { if (strncmp('HTMLPurifier', $class, 12) !== 0) return false; - // Language classes have an unusual directory structure if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) { $code = str_replace('_', '-', substr($class, 22)); - require_once 'HTMLPurifier/Language/classes/' . $code . '.php'; - return true; + return 'HTMLPurifier/Language/classes/' . $code . '.php'; } - require_once str_replace('_', '/', $class) . '.php'; - return true; + return str_replace('_', '/', $class) . '.php'; } diff --git a/library/HTMLPurifier/AttrTransform/BoolToCSS.php b/library/HTMLPurifier/AttrTransform/BoolToCSS.php index bb1b8b65..5cbdd152 100644 --- a/library/HTMLPurifier/AttrTransform/BoolToCSS.php +++ b/library/HTMLPurifier/AttrTransform/BoolToCSS.php @@ -5,8 +5,7 @@ require_once 'HTMLPurifier/AttrTransform.php'; /** * Pre-transform that changes converts a boolean attribute to fixed CSS */ -class HTMLPurifier_AttrTransform_BoolToCSS -extends HTMLPurifier_AttrTransform { +class HTMLPurifier_AttrTransform_BoolToCSS extends HTMLPurifier_AttrTransform { /** * Name of boolean attribute that is trigger diff --git a/library/HTMLPurifier/ChildDef/StrictBlockquote.php b/library/HTMLPurifier/ChildDef/StrictBlockquote.php index 53a3523c..baea9c3a 100644 --- a/library/HTMLPurifier/ChildDef/StrictBlockquote.php +++ b/library/HTMLPurifier/ChildDef/StrictBlockquote.php @@ -5,8 +5,7 @@ require_once 'HTMLPurifier/ChildDef/Required.php'; /** * Takes the contents of blockquote when in strict and reformats for validation. */ -class HTMLPurifier_ChildDef_StrictBlockquote -extends HTMLPurifier_ChildDef_Required +class HTMLPurifier_ChildDef_StrictBlockquote extends HTMLPurifier_ChildDef_Required { protected $real_elements; protected $fake_elements; -- 2.11.4.GIT