'Smarty.class.php', 'SmartyBC' => 'SmartyBC.class.php', ); /** * Registers Smarty_Autoloader backward compatible to older installations. * * @param bool $prepend Whether to prepend the autoloader or not. */ public static function registerBC($prepend = false) { /** * register the class autoloader */ if (!defined('SMARTY_SPL_AUTOLOAD')) { define('SMARTY_SPL_AUTOLOAD', 0); } if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { $registeredAutoLoadFunctions = spl_autoload_functions(); if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { spl_autoload_register(); } } else { self::register($prepend); } } /** * Registers Smarty_Autoloader as an SPL autoloader. * * @param bool $prepend Whether to prepend the autoloader or not. */ public static function register($prepend = false) { self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . '/'; self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins/'; if (version_compare(phpversion(), '5.3.0', '>=')) { spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); } else { spl_autoload_register(array(__CLASS__, 'autoload')); } } /** * Handles autoloading of classes. * * @param string $class A class name. */ public static function autoload($class) { // Request for Smarty or already unknown class if (0 !== strpos($class, 'Smarty') || isset(self::$unknown[$class])) { return; } if (isset(self::$rootClasses[$class]) && is_file($file = self::$SMARTY_DIR . self::$rootClasses[$class])) { require $file; return; } $_class = strtolower($class); if (is_file($file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php')) { require $file; } else { self::$unknown[$class] = true; } } }