diff --git a/COPYING.lib b/LICENSE similarity index 93% rename from COPYING.lib rename to LICENSE index 02bbb60b..fb8ca6c6 100644 --- a/COPYING.lib +++ b/LICENSE @@ -1,3 +1,17 @@ +Smarty: the PHP compiling template engine + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Lesser General Public License below for more details. + + GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -162,4 +176,4 @@ General Public License ever published by the Free Software Foundation. whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the -Library. \ No newline at end of file +Library. diff --git a/change_log.txt b/change_log.txt index 751b0e6f..6459e381 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== 3.1.31-dev ===== (xx.xx.xx) + 08.11.2016 + - add bootstrap file to load and register Smarty_Autoloader. Change composer.json to make it known to composer + 07.11.2016 - optimization of lexer speed https://github.com/smarty-php/smarty/issues/311 diff --git a/composer.json b/composer.json index 2a1a43ae..5064c8ce 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,7 @@ "php": ">=5.2" }, "autoload": { - "classmap": [ - "libs/Smarty.class.php", - "libs/SmartyBC.class.php", - "libs/sysplugins/" - ] + "files": ["libs/bootstrap.php"] }, "extra": { "branch-alias": { diff --git a/libs/Autoloader.php b/libs/Autoloader.php index e8885532..d3b039ca 100644 --- a/libs/Autoloader.php +++ b/libs/Autoloader.php @@ -11,11 +11,12 @@ * @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/bootstarp.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 @@ -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; } diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 86c497e3..f4564e25 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -66,23 +66,16 @@ if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { } /** - * Try loading the Smarty_Internal_Data class - * If we fail we must load Smarty's autoloader. - * Otherwise we may have a global autoloader like Composer + * Load Smarty_Autoloader */ -if (!class_exists('Smarty_Autoloader', false)) { - if (!class_exists('Smarty_Internal_Data', true)) { - require_once dirname(__FILE__) . '/Autoloader.php'; - Smarty_Autoloader::registerBC(); - } +if (!class_exists('Smarty_Autoloader')) { + include __DIR__ . '/bootstrap.php'; } /** * Load always needed external class files */ -if (!class_exists('Smarty_Internal_Data', false)) { - require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; -} +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; @@ -90,6 +83,7 @@ require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php'; require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; /** * This is the main Smarty class @@ -114,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.31-dev/41'; + const SMARTY_VERSION = '3.1.31-dev/42'; /** * define variable scopes diff --git a/libs/bootstrap.php b/libs/bootstrap.php new file mode 100644 index 00000000..32096087 --- /dev/null +++ b/libs/bootstrap.php @@ -0,0 +1,17 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/* + * Load and register Smarty Autoloader + */ +if (!class_exists('Smarty_Autoloader')) { + require __DIR__ . '/Autoloader.php'; +} +Smarty_Autoloader::register();