2008-01-27 01:54:41 +00:00
|
|
|
<?php
|
|
|
|
|
2008-02-11 00:27:35 +00:00
|
|
|
// constants are slow, so we use as few as possible
|
2008-02-11 00:15:04 +00:00
|
|
|
if (!defined('HTMLPURIFIER_PREFIX')) {
|
|
|
|
define('HTMLPURIFIER_PREFIX', realpath(dirname(__FILE__) . '/..'));
|
|
|
|
}
|
2008-02-10 22:29:01 +00:00
|
|
|
|
2008-02-11 00:27:35 +00:00
|
|
|
// accomodations for versions earlier than 5.0.2
|
|
|
|
// borrowed from PHP_Compat, LGPL licensed, by Aidan Lister <aidan@php.net>
|
|
|
|
if (!defined('PHP_EOL')) {
|
|
|
|
switch (strtoupper(substr(PHP_OS, 0, 3))) {
|
|
|
|
case 'WIN':
|
|
|
|
define('PHP_EOL', "\r\n");
|
|
|
|
break;
|
|
|
|
case 'DAR':
|
|
|
|
define('PHP_EOL', "\r");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
define('PHP_EOL', "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-27 01:54:41 +00:00
|
|
|
/**
|
|
|
|
* 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';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|