Commit bec81990 authored by Bozosoft's avatar Bozosoft

Mise à jour de Smarty à la version 3.1.31 du 14.12.2016

parent ce5baf27
......@@ -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;
}
......
3.1.31-dev
New tags for inheritance parent and child
{block_parent} == {$smarty.block.parent}
{block_child} == {$smarty.block.child}
Since 3.1.28 you can mix inheritance by extends resource with the {extends} tag.
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false.
3.1.28
Starting with version 3.1.28 template inheritance is no longer a compile time process.
All {block} tag parent/child relations are resolved at run time.
This does resolve all known existing restrictions (see below).
......@@ -37,8 +48,8 @@ Any code outside root {block} tags in child templates is now executed but any ou
....
{/block}
Starting with 3.1.28 you can mix inheritance by extends resuorce with the {extends} tag.
A template called by extends resoure can extend a subtemple or chain buy the {extends} tag.
Starting with 3.1.28 you can mix inheritance by extends resource with the {extends} tag.
A template called by extends resource can extend a subtemplate or chain buy the {extends} tag.
NOTE There is a BC break. If you used the extends resource {extends} tags have been ignored.
......
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.
......@@ -2,6 +2,12 @@
This file contains a brief description of new features which have been added to Smarty 3.1
Smarty 3.1.31
New tags for inheritance parent and child
=========================================
{block_parent} == {$smarty.block.parent}
{block_child} == {$smarty.block.child}
Smarty 3.1.30
Loop optimization {foreach} and {section}
......
......@@ -27,22 +27,15 @@
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
* @version 3.1.30
* @version 3.1.31
*/
/**
* define shorthand directory separator constant
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* set SMARTY_DIR to absolute path to Smarty library files.
* Sets SMARTY_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_DIR')) {
define('SMARTY_DIR', dirname(__FILE__) . DS);
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}
/**
......@@ -50,10 +43,10 @@ if (!defined('SMARTY_DIR')) {
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_SYSPLUGINS_DIR')) {
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR);
}
if (!defined('SMARTY_PLUGINS_DIR')) {
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DIRECTORY_SEPARATOR);
}
if (!defined('SMARTY_MBSTRING')) {
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
......@@ -73,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';
......@@ -97,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
......@@ -121,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.30';
const SMARTY_VERSION = '3.1.31';
/**
* define variable scopes
......@@ -439,6 +426,15 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public $merge_compiled_includes = false;
/*
* flag for behaviour when extends: resource and {extends} tag are used simultaneous
* if false disable execution of {extends} in templates called by extends resource.
* (behaviour as versions < 3.1.28)
*
* @var boolean
*/
public $extends_recursion = true;
/**
* force cache file creation
*
......@@ -718,6 +714,13 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public $_debug = null;
/**
* Directory separator
*
* @var string
*/
public $ds = DIRECTORY_SEPARATOR;
/**
* removed properties
*
......@@ -743,6 +746,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function __construct()
{
$this->_clearTemplateCache();
parent::__construct();
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(Smarty::$_CHARSET);
......@@ -974,7 +978,7 @@ class Smarty extends Smarty_Internal_TemplateBase
$this->plugins_dir = (array) $this->plugins_dir;
}
foreach ($this->plugins_dir as $k => $v) {
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . DS, true);
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, "/\\") . $this->ds, true);
}
$this->_cache[ 'plugin_files' ] = array();
$this->_pluginsDirNormalized = true;
......@@ -1045,7 +1049,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
private function _normalizeDir($dirName, $dir)
{
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DS, true);
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . $this->ds, true);
if (!isset(Smarty::$_muted_directories[ $this->{$dirName} ])) {
Smarty::$_muted_directories[ $this->{$dirName} ] = null;
}
......@@ -1071,7 +1075,7 @@ class Smarty extends Smarty_Internal_TemplateBase
}
foreach ($dir as $k => $v) {
if (!isset($processed[ $k ])) {
$dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DS, true);
$dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . $this->ds, true);
$processed[ $k ] = true;
}
}
......@@ -1103,14 +1107,20 @@ class Smarty extends Smarty_Internal_TemplateBase
} else {
$data = null;
}
if (!$this->_templateDirNormalized) {
$this->_nomalizeTemplateConfig(false);
}
$_templateId = $this->_getTemplateId($template, $cache_id, $compile_id);
$tpl = null;
if ($this->caching && isset($this->_cache[ 'isCached' ][ $_templateId ])) {
$tpl = $do_clone ? clone $this->_cache[ 'isCached' ][ $_templateId ] :
$this->_cache[ 'isCached' ][ $_templateId ];
if ($this->caching && isset(Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) {
$tpl = $do_clone ? clone Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] :
Smarty_Internal_Template::$isCacheTplObj[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
} else if (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) {
$tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ];
$tpl->inheritance = null;
$tpl->tpl_vars = $tpl->config_vars = array();
} else if (!$do_clone && isset($this->_cache[ 'tplObjects' ][ $_templateId ])) {
$tpl = clone $this->_cache[ 'tplObjects' ][ $_templateId ];
} else {
/* @var Smarty_Internal_Template $tpl */
$tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null);
......@@ -1200,9 +1210,9 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function _realpath($path, $realpath = null)
{
$nds = DS == '/' ? '\\' : '/';
// normalize DS
$path = str_replace($nds, DS, $path);
$nds = $this->ds == '/' ? '\\' : '/';
// normalize $this->ds
$path = str_replace($nds, $this->ds, $path);
preg_match('%^(?<root>(?:[[:alpha:]]:[\\\\]|/|[\\\\]{2}[[:alpha:]]+|[[:print:]]{2,}:[/]{2}|[\\\\])?)(?<path>(?:[[:print:]]*))$%',
$path, $parts);
$path = $parts[ 'path' ];
......@@ -1210,13 +1220,13 @@ class Smarty extends Smarty_Internal_TemplateBase
$parts[ 'root' ] = substr(getcwd(), 0, 2) . $parts[ 'root' ];
} else {
if ($realpath !== null && !$parts[ 'root' ]) {
$path = getcwd() . DS . $path;
$path = getcwd() . $this->ds . $path;
}
}
// remove noop 'DS DS' and 'DS.DS' patterns
$path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#', DS, $path);
// resolve '..DS' pattern, smallest first
if (strpos($path, '..' . DS) != false &&
// remove noop 'DIRECTORY_SEPARATOR DIRECTORY_SEPARATOR' and 'DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR' patterns
$path = preg_replace('#([\\\\/]([.]?[\\\\/])+)#', $this->ds, $path);
// resolve '..DIRECTORY_SEPARATOR' pattern, smallest first
if (strpos($path, '..' . $this->ds) != false &&
preg_match_all('#(([.]?[\\\\/])*([.][.])[\\\\/]([.]?[\\\\/])*)+#', $path, $match)
) {
$counts = array();
......@@ -1227,7 +1237,7 @@ class Smarty extends Smarty_Internal_TemplateBase
foreach ($counts as $count) {
$path = preg_replace('#(([\\\\/]([.]?[\\\\/])*[^\\\\/.]+){' . $count .
'}[\\\\/]([.]?[\\\\/])*([.][.][\\\\/]([.]?[\\\\/])*){' . $count . '})(?=[^.])#',
DS, $path);
$this->ds, $path);
}
}
......@@ -1239,8 +1249,18 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function _clearTemplateCache()
{
$this->_cache[ 'isCached' ] = array();
$this->_cache[ 'tplObjects' ] = array();
Smarty_Internal_Template::$isCacheTplObj = array();
Smarty_Internal_Template::$tplObjCache = array();
}
/**
* Get Smarty object
*
* @return Smarty
*/
public function _getSmartyObj()
{
return $this;
}
/**
......
<?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();
===== 3.1.30 ===== (07.08.2016)
===== 3.1.31 ===== (14.12.2016)
23.11.2016
- move template object cache into static variables
19.11.2016
- bugfix inheritance root child templates containing nested {block}{/block} could call sub-bock content from parent
template https://github.com/smarty-php/smarty/issues/317
- change version checking
11.11.2016
- bugfix when Smarty is using a cached template object on Smarty::fetch() or Smarty::isCached() the inheritance data
must be removed https://github.com/smarty-php/smarty/issues/312
- smaller speed optimization
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
27.10.2016
- bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls
https://github.com/smarty-php/smarty/issues/301
23.10.2016
- improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property
should be copied to the called template object
21.10.2016
- bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308
20.10.2016
- bugfix nocache code was not removed in cache file when subtemplate did contain PHP short tags in text but no other
nocache code https://github.com/smarty-php/smarty/issues/300
19.10.2016
- bugfix {make_nocache $var} did fail when variable value did contain '\' https://github.com/smarty-php/smarty/issues/305
- bugfix {make_nocache $var} remove spaces from variable value https://github.com/smarty-php/smarty/issues/304
12.10.2016
- bugfix {include} with template names including variable or constants could fail after bugfix from
28.09.2016 https://github.com/smarty-php/smarty/issues/302
08.10.2016
- optimization move runtime extension for template functions into Smarty objects
29.09.2016
- improvement new Smarty::$extends_recursion property to disable execution of {extends} in templates called by extends resource
https://github.com/smarty-php/smarty/issues/296
28.09.2016
- bugfix the generated code for calling a subtemplate must pass the template resource name in single quotes https://github.com/smarty-php/smarty/issues/299
- bugfix nocache hash was not removed for <?xml ?> tags in subtemplates https://github.com/smarty-php/smarty/issues/300
27.09.2016
- bugfix when Smarty does use an internally cached template object on Smarty::fetch() calls
the template and config variables must be cleared https://github.com/smarty-php/smarty/issues/297
20.09.2016
- bugfix some $smarty special template variables are no longer accessed as real variable.
using them on calls like {if isset($smarty.foo)} or {if empty($smarty.foo)} will fail
http://www.smarty.net/forums/viewtopic.php?t=26222
- temporary fix for https://github.com/smarty-php/smarty/issues/293 main reason still under investigation
- improvement new tags {block_parent} {block_child} in template inheritance
19.09.2016
- optimization clear compiled and cached folder completely on detected version change
- cleanup convert cache resource file method clear into runtime extension
15.09.2016
- bugfix assigning a variable in if condition by function like {if $value = array_shift($array)} the function got called twice https://github.com/smarty-php/smarty/issues/291
- bugfix function plugins called with assign attribute like {foo assign='bar'} did not output returned content because
because assumption was made that it was assigned to a variable https://github.com/smarty-php/smarty/issues/292
- bugfix calling $smarty->isCached() on a not existing cache file with $smarty->cache_locking = true; could cause a 10 second delay http://www.smarty.net/forums/viewtopic.php?t=26282
- improvement make Smarty::clearCompiledTemplate() on custom resource independent from changes of templateId computation
11.09.2016
- improvement {math} misleading E_USER_WARNING messages when parameter value = null https://github.com/smarty-php/smarty/issues/288
- improvement move often used code snippets into methods
- performance Smarty::configLoad() did load unneeded template source object
09.09.2016
- bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287
- bugfix {foreach} must keep the @properties when restoring a saved $item variable as the properties might be used outside {foreach} https://github.com/smarty-php/smarty/issues/267
- improvement {foreach} observe {break n} and {continue n} nesting levels when restoring saved $item and $key variables
08.09.2016
- bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286
07.09.2016
- bugfix using nocache like attribute with value true like {plugin nocache=true} did not work https://github.com/smarty-php/smarty/issues/285
- bugfix uppercase TRUE, FALSE and NULL did not work when security was enabled https://github.com/smarty-php/smarty/issues/282
- bugfix when {foreach} was looping over an object the total property like {$item@total} did always return 1 https://github.com/smarty-php/smarty/issues/281
- bugfix {capture}{/capture} did add in 3.1.30 unintended additional blank lines https://github.com/smarty-php/smarty/issues/268
01.09.2016
- performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280
26.08.2016
- bugfix change of 23.08.2016 failed on linux when use_include_path = true
23.08.2016
- bugfix remove constant DS as shortcut for DIRECTORY_SEPARATOR as the user may have defined it to something else https://github.com/smarty-php/smarty/issues/277
20.08-2016
- bugfix {config_load ... scope="global"} shall not throw an arror but fallback to scope="smarty" https://github.com/smarty-php/smarty/issues/274
- bugfix {make_nocache} failed when using composer autoloader https://github.com/smarty-php/smarty/issues/275
14.08.2016
- bugfix $smarty_>debugging = true; did E_NOTICE messages when {eval} tag was used https://github.com/smarty-php/smarty/issues/266
- bugfix Class 'Smarty_Internal_Runtime_ValidateCompiled' not found when upgrading from some older Smarty versions with existing
compiled or cached template files https://github.com/smarty-php/smarty/issues/269
- optimization remove unneeded call to update acopes when {assign} scope and template scope was local (default)
===== 3.1.30 ===== (07.08.2016)
07.08.2016
- bugfix update of 04.08.2016 was incomplete
......@@ -19,7 +133,7 @@
23.07.2016
- bugfix setTemplateDir('/') and setTemplateDir('') did create wrong absolute filepath https://github.com/smarty-php/smarty/issues/245
- optimization of filepath normalization
- improvement remove double funtion declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229
- improvement remove double function declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229
19.07.2016
- bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246
......
......@@ -35,7 +35,9 @@
*/
function smarty_function_html_options($params)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
if (!is_callable('smarty_function_escape_special_chars')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
}
$name = null;
$values = null;
......
......@@ -116,7 +116,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'hexentity':
$return = '';
if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
}
$return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
......@@ -135,7 +137,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'decentity':
$return = '';
if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
}
$return = '';
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
$return .= '&#' . $unicode . ';';
......@@ -158,8 +162,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
case 'mail':
if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
if (!is_callable('smarty_mb_str_replace')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
}
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
}
// no MBString fallback
......@@ -169,7 +174,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
// escape non-standard chars, such as ms document quotes
$return = '';
if (Smarty::$_MBSTRING) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
if (!is_callable('smarty_mb_to_unicode')) {
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
}
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
if ($unicode >= 126) {
$return .= '&#' . $unicode . ';';
......
......@@ -29,7 +29,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
{
$source = &$_template->source;
$smarty = &$_template->smarty;
$_compile_dir_sep = $smarty->use_sub_dirs ? DS : '^';
$_compile_dir_sep = $smarty->use_sub_dirs ? $smarty->ds : '^';
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
$cached->filepath = $smarty->getCacheDir();
if (isset($_template->cache_id)) {
......@@ -41,8 +41,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
}
// if use_sub_dirs, break file into directories
if ($smarty->use_sub_dirs) {
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . DS . $_filepath[ 2 ] . $_filepath[ 3 ] . DS .
$_filepath[ 4 ] . $_filepath[ 5 ] . DS;
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . $smarty->ds . $_filepath[ 2 ] . $_filepath[ 3 ] . $smarty->ds .
$_filepath[ 4 ] . $_filepath[ 5 ] . $smarty->ds;
}
$cached->filepath .= $_filepath;
$basename = $source->handler->getBasename($source);
......@@ -148,7 +148,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
return Smarty_Internal_Extension_Clear::clear($smarty, null, null, null, $exp_time);
return $smarty->ext->_cacheResourceFile->clear($smarty, null, null, null, $exp_time);
}
/**
......@@ -164,7 +164,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
return Smarty_Internal_Extension_Clear::clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
return $smarty->ext->_cacheResourceFile->clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
}
/**
......
......@@ -47,13 +47,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
*/
public $optional_attributes = array('assign');
/**
* nesting level of block tags
*
* @var int
*/
public static $blockTagNestingLevel = 0;
/**
* Saved compiler object
*
......@@ -85,8 +78,11 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$compiler->_cache[ 'blockNesting' ] ++;
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true));
$compiler->_cache[ 'blockName' ][ $compiler->_cache[ 'blockNesting' ] ] = $_attr[ 'name' ];
$compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ] = $_className;
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ] = array();
$compiler->_cache[ 'blockParams' ][ 1 ][ 'subBlocks' ][ trim($_attr[ 'name' ], '"\'') ][] = $_className;
$this->openTag($compiler, 'block', array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
$compiler->template->compiled->has_nocache_code,
$compiler->template->caching));
......@@ -103,47 +99,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
$compiler->template->compiled->has_nocache_code = false;
$compiler->suppressNocacheProcessing = true;
}
/**
* Compile saved child block source
*
* @param \Smarty_Internal_TemplateCompilerBase compiler object
* @param string $_name optional name of child block
*
* @return string compiled code of child block
*/
static function compileChildBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null)
{
if (!isset($compiler->_cache[ 'blockNesting' ])) {
$compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ',
$compiler->parser->lex->taglineno);
}
$compiler->has_code = true;
$compiler->suppressNocacheProcessing = true;
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
$output = "<?php \n\$_smarty_tpl->inheritance->callChild(\$_smarty_tpl, \$this);\n?>\n";
return $output;
}
/**
* Compile $smarty.block.parent
*
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param string $_name optional name of child block
*
* @return string compiled code of child block
*/
static function compileParentBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null)
{
if (!isset($compiler->_cache[ 'blockNesting' ])) {
$compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ',
$compiler->parser->lex->taglineno);
}
$compiler->suppressNocacheProcessing = true;
$compiler->has_code = true;
$output = "<?php \n\$_smarty_tpl->inheritance->callParent(\$_smarty_tpl, \$this);\n?>\n";
return $output;
}
}
/**
......@@ -175,7 +130,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$_block[ $name ] = 'true';
}
}
$_className = 'Block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true));
$_className = $compiler->_cache[ 'blockClass' ][ $compiler->_cache[ 'blockNesting' ] ];
// get compiled block code
$_functionCode = $compiler->parser->current_buffer;
// setup buffer for template function code
......@@ -186,7 +141,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$output .= "class {$_className} extends Smarty_Internal_Block\n";