2008-01-27 01:54:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bootstrap class that contains meta-functionality for HTML Purifier such as
|
|
|
|
* the autoload function.
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* This class may be used without any other files from HTML Purifier.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_Bootstrap
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Autoload function for HTML Purifier
|
|
|
|
* @param $class Class to load
|
|
|
|
*/
|
|
|
|
public static function autoload($class) {
|
|
|
|
$file = HTMLPurifier_Bootstrap::getPath($class);
|
|
|
|
if (!$file) return false;
|
2008-01-27 05:31:06 +00:00
|
|
|
require $file;
|
2008-01-27 01:54:41 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the path for a specific class.
|
|
|
|
*/
|
|
|
|
public static function getPath($class) {
|
|
|
|
if (strncmp('HTMLPurifier', $class, 12) !== 0) return false;
|
2008-01-27 05:31:06 +00:00
|
|
|
// Custom implementations
|
2008-01-27 01:54:41 +00:00
|
|
|
if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) {
|
|
|
|
$code = str_replace('_', '-', substr($class, 22));
|
|
|
|
return 'HTMLPurifier/Language/classes/' . $code . '.php';
|
|
|
|
}
|
2008-01-27 05:31:06 +00:00
|
|
|
// Standard implementation
|
2008-01-27 01:54:41 +00:00
|
|
|
return str_replace('_', '/', $class) . '.php';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|