mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
Add support for autoload. We're not, however, using it by default.
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1511 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
ff72b2d012
commit
43a5ef3cc6
3
NEWS
3
NEWS
@ -9,7 +9,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
. Internal change
|
||||
==========================
|
||||
|
||||
3.0.1, unknown release date
|
||||
3.1.0, unknown release date
|
||||
! Autoload support added
|
||||
- Autoclose now operates iteratively, i.e. <span><span><div> now has
|
||||
both span tags closed.
|
||||
. Plugins now get their own changelogs according to project conventions.
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
|
||||
require_once 'HTMLPurifier.php';
|
||||
|
||||
require_once 'HTMLPurifier.autoload.php';
|
||||
|
7
library/HTMLPurifier.autoload.php
Normal file
7
library/HTMLPurifier.autoload.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (function_exists('spl_autoload_register')) {
|
||||
spl_autoload_register(array('HTMLPurifier', 'autoload'));
|
||||
} elseif (!function_exists('__autoload')) {
|
||||
function __autoload($class) {return HTMLPurifier::autoload($class);}
|
||||
}
|
@ -227,7 +227,21 @@ class HTMLPurifier
|
||||
return $htmlpurifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload function for HTML Purifier
|
||||
* @param $class Class to load
|
||||
*/
|
||||
public static function autoload($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;
|
||||
}
|
||||
require_once str_replace('_', '/', $class) . '.php';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,12 +109,12 @@ class HTMLPurifier_LanguageFactory
|
||||
// PHP5/APC deps bug workaround can go here
|
||||
// you can bypass the conditional include by loading the
|
||||
// file yourself
|
||||
if (file_exists($file) && !class_exists($class)) {
|
||||
if (file_exists($file) && !class_exists($class, false)) {
|
||||
include_once $file;
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists($class)) {
|
||||
if (!class_exists($class, false)) {
|
||||
// go fallback
|
||||
$fallback = HTMLPurifier_LanguageFactory::getFallbackFor($code);
|
||||
$depth++;
|
||||
|
@ -4,7 +4,7 @@
|
||||
// a little jumping through hoops to generate them
|
||||
function generate_mock_once($name) {
|
||||
$mock_name = $name . 'Mock';
|
||||
if (class_exists($mock_name)) return false;
|
||||
if (class_exists($mock_name, false)) return false;
|
||||
Mock::generate($name, $mock_name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user