HTMLPurifier_Bootstrap::autoload PHP Method

autoload() public static method

Autoload function for HTML Purifier
public static autoload ( string $class ) : boolean
$class string Class to load
return boolean
    public static function autoload($class)
    {
        $file = HTMLPurifier_Bootstrap::getPath($class);
        if (!$file) {
            return false;
        }
        // Technically speaking, it should be ok and more efficient to
        // just do 'require', but Antonio Parraga reports that with
        // Zend extensions such as Zend debugger and APC, this invariant
        // may be broken.  Since we have efficient alternatives, pay
        // the cost here and avoid the bug.
        require_once HTMLPURIFIER_PREFIX . '/' . $file;
        return true;
    }

Usage Example

示例#1
0
function __autoload($ClassName)
{
    // echo $ClassName;
    if (class_exists('HTMLPurifier_Bootstrap', FALSE) && HTMLPurifier_Bootstrap::autoload($ClassName)) {
        return true;
    }
    if (!class_exists('Gdn_FileSystem', FALSE)) {
        return false;
    }
    if (substr($ClassName, 0, 4) === 'Gdn_') {
        $LibraryFileName = 'class.' . strtolower(substr($ClassName, 4)) . '.php';
    } else {
        $LibraryFileName = 'class.' . strtolower($ClassName) . '.php';
    }
    if (!is_null($ApplicationManager = Gdn::Factory('ApplicationManager'))) {
        $ApplicationWhiteList = Gdn::Factory('ApplicationManager')->EnabledApplicationFolders();
    } else {
        $ApplicationWhiteList = NULL;
    }
    $LibraryPath = FALSE;
    // If this is a model, look in the models folder(s)
    if (strtolower(substr($ClassName, -5)) == 'model') {
        $LibraryPath = Gdn_FileSystem::FindByMapping('library_mappings.php', 'Library', PATH_APPLICATIONS, $ApplicationWhiteList, 'models' . DS . $LibraryFileName);
    }
    if ($LibraryPath === FALSE) {
        $LibraryPath = Gdn_FileSystem::FindByMapping('library_mappings.php', 'Library', PATH_LIBRARY, array('core', 'database', 'vendors' . DS . 'phpmailer', 'vendors' . DS . 'htmlpurifier'), $LibraryFileName);
    }
    // If it still hasn't been found, check for modules
    if ($LibraryPath === FALSE) {
        $LibraryPath = Gdn_FileSystem::FindByMapping('library_mappings.php', 'Library', PATH_APPLICATIONS, $ApplicationWhiteList, 'modules' . DS . $LibraryFileName);
    }
    if ($LibraryPath !== FALSE) {
        include_once $LibraryPath;
    }
}
All Usage Examples Of HTMLPurifier_Bootstrap::autoload