function cms_autoloader($classname)
{
    $config = cmsms()->GetConfig();
    // standard classes
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $lowercase = strtolower($classname);
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php");
    if (file_exists($fn) && $classname != 'Content') {
        __cms_load($fn);
        return;
    }
    // standard interfaces
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // standard content types
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // module loaded content types
    $contentops = cmsms()->GetContentOperations();
    $types = $contentops->ListContentTypes();
    if (in_array(strtolower($classname), array_keys($types))) {
        $contentops->LoadContentType(strtolower($classname));
        return;
    }
    $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php";
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $list = ModuleOperations::get_instance()->GetLoadedModules();
    if (is_array($list) && count($list)) {
        foreach (array_keys($list) as $modname) {
            $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php";
            if (file_exists($fn)) {
                __cms_load($fn);
                return;
            }
        }
    }
    // module classes
}
Exemple #2
0
function cms_autoloader($classname)
{
    //if( $classname != 'Smarty_CMS' && $classname != 'Smarty_Parser' && startswith($classname,'Smarty') ) return;
    $config = cmsms()->GetConfig();
    // standard classes
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $lowercase = strtolower($classname);
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "class.{$lowercase}.inc.php");
    if (file_exists($fn) && $classname != 'Content') {
        __cms_load($fn);
        return;
    }
    // standard interfaces
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', "interface.{$classname}.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    global $CMS_LAZYLOAD_MODULES;
    global $CMS_INSTALL_PAGE;
    if (!isset($CMS_LAZYLOAD_MODULES) || isset($CMS_INSTALL_PAGE)) {
        return;
    }
    // standard content types
    $fn = cms_join_path($config['root_path'], 'lib', 'classes', 'contenttypes', "{$classname}.inc.php");
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    // module loaded content types
    $contentops = ContentOperations::get_instance();
    if ($contentops) {
        // why would this ever NOT be true.. dunno, but hey.
        $types = $contentops->ListContentTypes();
        if (in_array(strtolower($classname), array_keys($types))) {
            $contentops->LoadContentType(strtolower($classname));
            return;
        }
    }
    $fn = $config['root_path'] . "/modules/{$classname}/{$classname}.module.php";
    if (file_exists($fn)) {
        __cms_load($fn);
        return;
    }
    $list = ModuleOperations::get_instance()->GetLoadedModules();
    if (is_array($list) && count($list)) {
        foreach (array_keys($list) as $modname) {
            $fn = $config['root_path'] . "/modules/{$modname}/lib/class.{$classname}.php";
            if (file_exists($fn)) {
                __cms_load($fn);
                return;
            }
        }
    }
    // module classes
}