summaryrefslogtreecommitdiff
path: root/lib/smarty3/Autoloader.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty3/Autoloader.php')
-rw-r--r--lib/smarty3/Autoloader.php41
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/smarty3/Autoloader.php b/lib/smarty3/Autoloader.php
index e888553..e4dc450 100644
--- a/lib/smarty3/Autoloader.php
+++ b/lib/smarty3/Autoloader.php
@@ -2,20 +2,21 @@
/**
* Smarty Autoloader
*
- * @package Smarty
+ * @package Smarty
*/
/**
* Smarty Autoloader
*
- * @package Smarty
- * @author Uwe Tews
+ * @package Smarty
+ * @author Uwe Tews
* Usage:
- * require_once '...path/Autoloader.php';
- * Smarty_Autoloader::register();
- * $smarty = new Smarty();
- * Note: This autoloader is not needed if you use Composer.
- * Composer will automatically add the classes of the Smarty package to it common autoloader.
+ * require_once '...path/Autoloader.php';
+ * Smarty_Autoloader::register();
+ * or
+ * include '...path/bootstrap.php';
+ *
+ * $smarty = new Smarty();
*/
class Smarty_Autoloader
{
@@ -24,14 +25,14 @@ class Smarty_Autoloader
*
* @var string
*/
- public static $SMARTY_DIR = '';
+ public static $SMARTY_DIR = null;
/**
* Filepath to Smarty internal plugins
*
* @var string
*/
- public static $SMARTY_SYSPLUGINS_DIR = '';
+ public static $SMARTY_SYSPLUGINS_DIR = null;
/**
* Array with Smarty core classes and their filename
@@ -53,8 +54,8 @@ class Smarty_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
+ 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' ])) {
@@ -75,7 +76,7 @@ class Smarty_Autoloader
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
- if (version_compare(phpversion(), '5.3.0', '>=')) {
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
spl_autoload_register(array(__CLASS__, 'autoload'));
@@ -89,18 +90,20 @@ class Smarty_Autoloader
*/
public static function autoload($class)
{
- $_class = strtolower($class);
- if (strpos($_class, 'smarty') !== 0) {
+ if ($class[ 0 ] !== 'S' && strpos($class, 'Smarty') !== 0) {
return;
}
- $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
- if (is_file($file)) {
- include $file;
- } else if (isset(self::$rootClasses[ $_class ])) {
+ $_class = strtolower($class);
+ if (isset(self::$rootClasses[ $_class ])) {
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
if (is_file($file)) {
include $file;
}
+ } else {
+ $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
+ if (is_file($file)) {
+ include $file;
+ }
}
return;
}