mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-01 11:50:28 +02: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:
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user