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;
}
}