0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-22 16:31:53 +00:00

[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
This commit is contained in:
Edward Z. Yang 2008-01-27 00:06:10 +00:00
parent 25551c4b78
commit 81a4cf6a14
3 changed files with 14 additions and 9 deletions

View File

@ -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';
}

View File

@ -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

View File

@ -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;