mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- optimize autoloader
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
===== 3.1.28-dev===== (xx.xx.2015)
|
||||
01.09.2015
|
||||
14.09.2015
|
||||
- optimize autoloader
|
||||
|
||||
30.08.2015
|
||||
- size optimization move some runtime functions into extension
|
||||
- optimize inline template processing
|
||||
- optimization merge inheritance child and parent templates into one compiled template file
|
||||
|
||||
29.08.2015
|
||||
- improvement convert template inheritance into runtime processing
|
||||
- bugfix {$smarty.block.parent} did always reference the root parent block https://github.com/smarty-php/smarty/issues/68
|
||||
- move subtemplate code into runtime extension and optimize for size and speed
|
||||
- move template function code into runtime extension
|
||||
- remove unneeded code and properties, minor fixes
|
||||
|
||||
23.08.2015
|
||||
- introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop
|
||||
@@ -322,8 +327,8 @@
|
||||
- bugfix Debug Console did not include all data from merged compiled subtemplates
|
||||
|
||||
04.11.2014
|
||||
- new feature $smarty->debug = true; => overwrite existing Debug Console window (old behaviour)
|
||||
$smarty->debug = 2; => individual Debug Console window by template name
|
||||
- new feature $smarty->debugging = true; => overwrite existing Debug Console window (old behaviour)
|
||||
$smarty->debugging = 2; => individual Debug Console window by template name
|
||||
|
||||
03.11.2014
|
||||
- bugfix Debug Console did not show included subtemplates since 3.1.17 (forum 25301)
|
||||
|
@@ -40,15 +40,6 @@ class Smarty_Autoloader
|
||||
*/
|
||||
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
|
||||
|
||||
/**
|
||||
* Array of often auto loaded classes which may skip is_file() test
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $classes = array('smarty_config_source' => true, 'smarty_security' => true,
|
||||
'smarty_cacheresource' => true, 'smarty_compiledresource' => true,
|
||||
'smarty_template_config' => true,);
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||
*
|
||||
@@ -89,9 +80,6 @@ class Smarty_Autoloader
|
||||
} else {
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'));
|
||||
}
|
||||
foreach (self::$rootClasses as $class => $file) {
|
||||
self::$classes[$class] = self::$SMARTY_DIR . $file;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,28 +90,33 @@ class Smarty_Autoloader
|
||||
public static function autoload($class)
|
||||
{
|
||||
$_class = strtolower($class);
|
||||
if (0 !== strpos($_class, 'smarty')) {
|
||||
return;
|
||||
}
|
||||
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
if (0 === strpos($_class, 'smarty_internal')) {
|
||||
if (0 === strpos($_class, 'smarty_internal_compile')) {
|
||||
if (is_file($file)) {
|
||||
require_once $file;
|
||||
if (preg_match('/^(smarty_((internal_(compile_)?)|((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/', $_class, $match)) {
|
||||
$file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
if (!empty($match[3])) {
|
||||
if (!empty($match[4])) {
|
||||
if (is_file($file)) {
|
||||
require $file;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
@include $file;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
} elseif (!empty($match[5])) {
|
||||
@include $file;
|
||||
return;
|
||||
} elseif (!empty($match[11]) && isset(self::$rootClasses[$_class])) {
|
||||
$file = self::$rootClasses[$_class];
|
||||
require $file;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isset(self::$classes[$_class])) {
|
||||
$file = self::$classes[$_class] === true ? $file : self::$classes[$_class];
|
||||
require_once $file;
|
||||
if (0 !== strpos($_class, 'smarty')) {
|
||||
return;
|
||||
}
|
||||
$file = isset($file) ? $file : self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
if (is_file($file)) {
|
||||
require_once $file;
|
||||
require $file;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
@@ -94,6 +94,7 @@ if (!class_exists('Smarty_Internal_Data', false)) {
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php';
|
||||
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.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';
|
||||
@@ -118,7 +119,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.28-dev/54';
|
||||
const SMARTY_VERSION = '3.1.28-dev/55';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -197,9 +197,6 @@ abstract class Smarty_CacheResource
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[$type])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
if (!class_exists($cache_resource_class, false)) {
|
||||
require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
|
||||
}
|
||||
return $smarty->_cache['cacheresource_handlers'][$type] = new $cache_resource_class();
|
||||
}
|
||||
// try plugins dir
|
||||
|
@@ -35,12 +35,12 @@ abstract class Smarty_Resource
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $sysplugins = array('file' => 'smarty_internal_resource_file.php',
|
||||
'string' => 'smarty_internal_resource_string.php',
|
||||
'extends' => 'smarty_internal_resource_extends.php',
|
||||
'stream' => 'smarty_internal_resource_stream.php',
|
||||
'eval' => 'smarty_internal_resource_eval.php',
|
||||
'php' => 'smarty_internal_resource_php.php');
|
||||
public static $sysplugins = array('file' => 'smarty_internal_resource_file.php',
|
||||
'string' => 'smarty_internal_resource_string.php',
|
||||
'extends' => 'smarty_internal_resource_extends.php',
|
||||
'stream' => 'smarty_internal_resource_stream.php',
|
||||
'eval' => 'smarty_internal_resource_eval.php',
|
||||
'php' => 'smarty_internal_resource_php.php');
|
||||
|
||||
/**
|
||||
* Flag if resource does implement populateCompiledFilepath() method
|
||||
@@ -152,16 +152,14 @@ abstract class Smarty_Resource
|
||||
|
||||
// try registered resource
|
||||
if (isset($smarty->registered_resources[$type])) {
|
||||
return $smarty->_cache['resource_handlers'][$type] = $smarty->registered_resources[$type] instanceof
|
||||
Smarty_Resource ? $smarty->registered_resources[$type] : new Smarty_Internal_Resource_Registered();
|
||||
return $smarty->_cache['resource_handlers'][$type] =
|
||||
$smarty->registered_resources[$type] instanceof Smarty_Resource ? $smarty->registered_resources[$type] :
|
||||
new Smarty_Internal_Resource_Registered();
|
||||
}
|
||||
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[$type])) {
|
||||
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
|
||||
if (!class_exists($_resource_class, false)) {
|
||||
require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
|
||||
}
|
||||
return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
|
||||
}
|
||||
|
||||
@@ -171,10 +169,9 @@ abstract class Smarty_Resource
|
||||
if (class_exists($_resource_class, false)) {
|
||||
return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
|
||||
} else {
|
||||
$smarty->registerResource($type, array("smarty_resource_{$type}_source",
|
||||
"smarty_resource_{$type}_timestamp",
|
||||
"smarty_resource_{$type}_secure",
|
||||
"smarty_resource_{$type}_trusted"));
|
||||
$smarty->registerResource($type,
|
||||
array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp",
|
||||
"smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted"));
|
||||
// give it another try, now that the resource is registered properly
|
||||
return self::load($smarty, $type);
|
||||
}
|
||||
@@ -263,7 +260,8 @@ abstract class Smarty_Resource
|
||||
*
|
||||
* @return Smarty_Template_Source Source Object
|
||||
*/
|
||||
public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null)
|
||||
public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null,
|
||||
$template_resource = null)
|
||||
{
|
||||
return Smarty_Template_Source::load($_template, $smarty, $template_resource);
|
||||
}
|
||||
|
Reference in New Issue
Block a user