mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- add bootstrap file to load and register Smarty_Autoloader. Change composer.json to make it known to composer
This commit is contained in:
@@ -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.
|
||||
Library.
|
@@ -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
|
||||
|
||||
|
@@ -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": {
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
17
libs/bootstrap.php
Normal file
17
libs/bootstrap.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Smarty package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* 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();
|
Reference in New Issue
Block a user