mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-06 21:44:17 +02:00
Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c7d42e4a32 | |||
| 27928ece9c | |||
| 04a2327c75 | |||
| 91af9d090a | |||
| 05933749c0 | |||
| be054c1727 | |||
| 5b9699b41a | |||
| b745a31a2d | |||
| d120c1fad2 | |||
| e867ae125e | |||
| 7438ac39d0 | |||
| 428a7ad883 | |||
| c4746e9080 | |||
| 2d2be8f57f | |||
| 98efe22e02 | |||
| d79edd2fe0 | |||
| 29cbe10857 | |||
| 6699299767 | |||
| 34e5739fc1 | |||
| 80a024f44e | |||
| f3e0e01266 | |||
| 3c07a28434 | |||
| caceefc300 | |||
| 80af6ea2b5 | |||
| 68ab01dc9e | |||
| 4de72f1acd | |||
| 5b508b7bf3 | |||
| 998c778948 | |||
| 3f0d519daf | |||
| beeec36bb8 | |||
| efa18457f2 | |||
| ec3a00e5ab | |||
| b8acd7ea17 | |||
| d9a6938473 | |||
| a9e7e8881e | |||
| 8835408e0d | |||
| cd28347130 | |||
| f95b81a6f9 | |||
| 58b6472d4f | |||
| 424dca6d24 | |||
| 44189a7531 | |||
| 0a8e47ecb2 | |||
| e62b40c421 | |||
| 7e230713c6 | |||
| 810881c76e | |||
| 62099617ae | |||
| 0e942e4821 | |||
| 21aa211ddb | |||
| 124b333da2 | |||
| bfc1ef8885 | |||
| 0429272370 | |||
| e5bbc052b1 | |||
| e82f966682 | |||
| 51e0d5cd40 | |||
| e1d27d68d7 | |||
| 5580857d9b | |||
| 2003020df9 | |||
| be39cc0121 | |||
| c39abdf83e | |||
| db01627c1c | |||
| 1b6d2a9375 | |||
| fee77dbfb8 | |||
| 7f932e7ac4 |
@@ -20,3 +20,12 @@
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
||||
|
||||
# exclude from git export
|
||||
/travis.ini export-ignore
|
||||
/composer.json export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/.gitignore export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/lexer/ export-ignore
|
||||
/utilities/ export-ignore
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ before_script:
|
||||
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
||||
|
||||
install:
|
||||
- git clone --depth=50 --branch v3.1.30 git://github.com/smarty-php/smarty-phpunit.git
|
||||
- git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git
|
||||
|
||||
script:
|
||||
- cd smarty-phpunit
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
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.
|
||||
|
||||
|
||||
+15
-1
@@ -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.
|
||||
@@ -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}
|
||||
|
||||
+116
-2
@@ -1,4 +1,118 @@
|
||||
===== 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
|
||||
|
||||
+1
-5
@@ -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": {
|
||||
|
||||
@@ -25,7 +25,13 @@ class Smarty_Internal_Configfilelexer
|
||||
* @var string
|
||||
*/
|
||||
public $data;
|
||||
/**
|
||||
/**
|
||||
* Source length
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $dataLength = null;
|
||||
/**
|
||||
* byte counter
|
||||
*
|
||||
* @var int
|
||||
@@ -120,9 +126,8 @@ class Smarty_Internal_Configfilelexer
|
||||
*/
|
||||
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
{
|
||||
// set instance object
|
||||
self::instance($this);
|
||||
$this->data = $data . "\n"; //now all lines are \n-terminated
|
||||
$this->dataLength = strlen($data);
|
||||
$this->counter = 0;
|
||||
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
|
||||
$this->counter += strlen($match[0]);
|
||||
@@ -133,15 +138,6 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->configBooleanize = $this->smarty->config_booleanize;
|
||||
}
|
||||
|
||||
public static function &instance($new_instance = null)
|
||||
{
|
||||
static $instance = null;
|
||||
if (isset($new_instance) && is_object($new_instance)) {
|
||||
$instance = $new_instance;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function PrintTrace()
|
||||
{
|
||||
$this->yyTraceFILE = fopen('php://output', 'w');
|
||||
|
||||
@@ -91,8 +91,6 @@ class Smarty_Internal_Configfileparser
|
||||
*/
|
||||
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
{
|
||||
// set instance object
|
||||
self::instance($this);
|
||||
$this->lex = $lex;
|
||||
$this->smarty = $compiler->smarty;
|
||||
$this->compiler = $compiler;
|
||||
@@ -100,20 +98,6 @@ class Smarty_Internal_Configfileparser
|
||||
$this->configReadHidden = $this->smarty->config_read_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $new_instance
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function &instance($new_instance = null)
|
||||
{
|
||||
static $instance = null;
|
||||
if (isset($new_instance) && is_object($new_instance)) {
|
||||
$instance = $new_instance;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse optional boolean keywords
|
||||
*
|
||||
|
||||
@@ -25,6 +25,13 @@ class Smarty_Internal_Templatelexer
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Source length
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $dataLength = null;
|
||||
|
||||
/**
|
||||
* byte counter
|
||||
*
|
||||
@@ -225,6 +232,7 @@ class Smarty_Internal_Templatelexer
|
||||
function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->dataLength = strlen($data);
|
||||
$this->counter = 0;
|
||||
if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) {
|
||||
$this->counter += strlen($match[0]);
|
||||
@@ -341,8 +349,7 @@ class Smarty_Internal_Templatelexer
|
||||
return false;
|
||||
}
|
||||
phptag {
|
||||
$obj = new Smarty_Internal_Compile_Private_Php();
|
||||
$obj->parsePhp($this);
|
||||
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
|
||||
}
|
||||
ldel literal rdel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
@@ -364,11 +371,10 @@ class Smarty_Internal_Templatelexer
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
phpstart {
|
||||
$obj = new Smarty_Internal_Compile_Private_Php();
|
||||
$obj->parsePhp($this);
|
||||
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
$to = $this->dataLength;
|
||||
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
@@ -608,7 +614,7 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
$to = $this->dataLength;
|
||||
preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
@@ -672,7 +678,7 @@ class Smarty_Internal_Templatelexer
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
$to = $this->dataLength;
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
@@ -271,13 +271,6 @@ template_element(res)::= PHP(o). {
|
||||
}
|
||||
}
|
||||
|
||||
// nocache code
|
||||
template_element(res)::= NOCACHE(c). {
|
||||
$this->compiler->tag_nocache = true;
|
||||
$save = $this->template->compiled->has_nocache_code;
|
||||
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{c}';?>\n", true));
|
||||
$this->template->compiled->has_nocache_code = $save;
|
||||
}
|
||||
// template text
|
||||
template_element(res)::= text_content(t). {
|
||||
res = $this->compiler->processText(t);
|
||||
@@ -534,11 +527,11 @@ tag(res) ::= LDEL SMARTYBLOCKCHILDPARENT(i). {
|
||||
$j = strrpos(i,'.');
|
||||
if (i[$j+1] == 'c') {
|
||||
// {$smarty.block.child}
|
||||
res = SMARTY_INTERNAL_COMPILE_BLOCK::compileChildBlock($this->compiler);
|
||||
res = $this->compiler->compileTag('block_child',array());;
|
||||
} else {
|
||||
// {$smarty.block.parent}
|
||||
res = SMARTY_INTERNAL_COMPILE_BLOCK::compileParentBlock($this->compiler);
|
||||
}
|
||||
res = $this->compiler->compileTag('block_parent',array());;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1083,38 +1076,7 @@ objectelement(res)::= PTR method(f). {
|
||||
// function
|
||||
//
|
||||
function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
|
||||
if (!$this->security || $this->security->isTrustedPhpFunction(f, $this->compiler)) {
|
||||
if (strcasecmp(f,'isset') === 0 || strcasecmp(f,'empty') === 0 || strcasecmp(f,'array') === 0 || is_callable(f)) {
|
||||
$func_name = strtolower(f);
|
||||
if ($func_name == 'isset') {
|
||||
if (count(p) == 0) {
|
||||
$this->compiler->trigger_template_error ('Illegal number of paramer in "isset()"');
|
||||
}
|
||||
$par = implode(',',p);
|
||||
if (strncasecmp($par,'$_smarty_tpl->smarty->ext->_config->_getConfigVariable',strlen('$_smarty_tpl->smarty->ext->_config->_getConfigVariable')) === 0) {
|
||||
$prefixVar = $this->compiler->getNewPrefixVariable();
|
||||
$this->compiler->appendPrefixCode("<?php $prefixVar" .'='.str_replace(')',', false)',$par).';?>');
|
||||
$isset_par = $prefixVar;
|
||||
} else {
|
||||
$isset_par=str_replace("')->value","',null,true,false)->value",$par);
|
||||
}
|
||||
res = f . "(". $isset_par .")";
|
||||
} elseif (in_array($func_name,array('empty','reset','current','end','prev','next'))){
|
||||
if (count(p) != 1) {
|
||||
$this->compiler->trigger_template_error ('Illegal number of paramer in "empty()"');
|
||||
}
|
||||
if ($func_name == 'empty') {
|
||||
res = $func_name.'('.str_replace("')->value","',null,true,false)->value",p[0]).')';
|
||||
} else {
|
||||
res = $func_name.'('.p[0].')';
|
||||
}
|
||||
} else {
|
||||
res = f . "(". implode(',',p) .")";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("unknown function \"" . f . "\"");
|
||||
}
|
||||
}
|
||||
res = $this->compiler->compilePHPFunctionCall(f, p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-13
@@ -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;
|
||||
}
|
||||
|
||||
+62
-42
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
@@ -38,6 +38,9 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
if (Smarty::$_MBSTRING && !is_callable('smarty_mb_wordwrap')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
}
|
||||
|
||||
$style = null;
|
||||
$indent = 0;
|
||||
@@ -92,7 +95,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
$_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, $template)
|
||||
{
|
||||
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 = 'checkbox';
|
||||
$values = null;
|
||||
|
||||
@@ -38,7 +38,9 @@
|
||||
*/
|
||||
function smarty_function_html_image($params, $template)
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -45,7 +45,9 @@
|
||||
*/
|
||||
function smarty_function_html_radios($params, $template)
|
||||
{
|
||||
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 = 'radio';
|
||||
$values = null;
|
||||
|
||||
@@ -6,15 +6,6 @@
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
* Type: function<br>
|
||||
@@ -52,6 +43,12 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
*/
|
||||
function smarty_function_html_select_date($params)
|
||||
{
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
}
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
static $_current_year = null;
|
||||
|
||||
@@ -6,15 +6,6 @@
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
* Type: function<br>
|
||||
@@ -33,6 +24,12 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
*/
|
||||
function smarty_function_html_select_time($params)
|
||||
{
|
||||
if (!is_callable('smarty_function_escape_special_chars')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
}
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
}
|
||||
$prefix = "Time_";
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
|
||||
@@ -58,12 +58,28 @@ function smarty_function_math($params, $template)
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val) == 0) {
|
||||
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
|
||||
|
||||
foreach ($match[ 1 ] as $curr_var) {
|
||||
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
|
||||
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
|
||||
trigger_error("math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -71,17 +87,6 @@ function smarty_function_math($params, $template)
|
||||
|
||||
foreach ($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val) == 0) {
|
||||
trigger_error("math: parameter $key is empty", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);
|
||||
|
||||
return;
|
||||
}
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
/**
|
||||
* require_once the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
if (!is_callable('smarty_make_timestamp')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
}
|
||||
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif ($default_date != '') {
|
||||
@@ -44,7 +46,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
return;
|
||||
}
|
||||
if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
|
||||
if (DS == '\\') {
|
||||
if (Smarty::$_IS_WINDOWS) {
|
||||
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
|
||||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
if (strpos($format, '%e') !== false) {
|
||||
|
||||
@@ -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 . ';';
|
||||
|
||||
@@ -25,8 +25,9 @@
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
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($search, $replace, $string);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
* Type: modifier<br>
|
||||
@@ -28,6 +23,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
function smarty_modifiercompiler_escape($params, $compiler)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if (!is_callable('smarty_literal_compiler_param')) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
|
||||
}
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
$output .= "{\n";
|
||||
foreach ($_block as $property => $value) {
|
||||
$output .= "public \${$property} = {$value};\n";
|
||||
$output .= "public \${$property} = " . var_export($value,true) .";\n";
|
||||
}
|
||||
$output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
//$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Parent Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Child extends Smarty_Internal_CompileBase
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array();
|
||||
|
||||
/**
|
||||
* Saved compiler object
|
||||
*
|
||||
* @var Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $compiler = null;
|
||||
|
||||
/**
|
||||
* Compiles code for the {block_parent} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of Smarty.
|
||||
*
|
||||
* (c) 2015 Uwe Tews
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Parent Class
|
||||
*
|
||||
* @author Uwe Tews <uwe.tews@googlemail.com>
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Parent extends Smarty_Internal_Compile_Shared_Inheritance
|
||||
{
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $option_flags = array();
|
||||
|
||||
/**
|
||||
* Saved compiler object
|
||||
*
|
||||
* @var Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $compiler = null;
|
||||
|
||||
/**
|
||||
* Compiles code for the {block_parent} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
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" .
|
||||
(isset($_attr[ 'name' ]) ? ", {$_attr[ 'name' ]}" : '') . ");\n?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,31 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
list($levels, $foreachLevels) = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php\n";
|
||||
if ($foreachLevels) {
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore($foreachLevels);
|
||||
}
|
||||
$output .= "break {$levels};?>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* check attributes and return array of break and foreach levels
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param string $tag tag name
|
||||
*
|
||||
* @return array
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function checkLevels($args, Smarty_Internal_TemplateCompilerBase $compiler, $tag = 'break')
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
@@ -56,22 +78,33 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$_levels = $_attr[ 'levels' ];
|
||||
$levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
$levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$level_count = $levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
$foreachLevels = 0;
|
||||
$lastTag = '';
|
||||
while ($level_count >= 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$lastTag = $compiler->_tag_stack[ $stack_count ][ 0 ];
|
||||
if ($level_count === 0) {
|
||||
break;
|
||||
}
|
||||
$level_count --;
|
||||
if ($compiler->_tag_stack[ $stack_count ][ 0 ] === 'foreach') {
|
||||
$foreachLevels ++;
|
||||
}
|
||||
}
|
||||
$stack_count --;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot break {$_levels} level(s)", null, true);
|
||||
$compiler->trigger_template_error("cannot {$tag} {$levels} level(s)", null, true);
|
||||
}
|
||||
|
||||
return "<?php break {$_levels};?>";
|
||||
if ($lastTag === 'foreach' && $tag === 'break') {
|
||||
$foreachLevels --;
|
||||
}
|
||||
return array($levels, $foreachLevels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output =
|
||||
"<?php ob_start();\n\$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
"<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||
} else {
|
||||
$_output =
|
||||
"<?php \$_smarty_tpl->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||
"<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
$_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);\n?>\n";
|
||||
$_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
@@ -107,6 +107,6 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
|
||||
|
||||
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
|
||||
|
||||
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);\n?>\n";
|
||||
return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
|
||||
'smarty' => Smarty::SCOPE_SMARTY);
|
||||
'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY);
|
||||
|
||||
/**
|
||||
* Compiles code for the {config_load} tag
|
||||
|
||||
@@ -14,23 +14,8 @@
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
|
||||
class Smarty_Internal_Compile_Continue extends Smarty_Internal_Compile_Break
|
||||
{
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $optional_attributes = array('levels');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
* @var array
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('levels');
|
||||
|
||||
/**
|
||||
* Compiles code for the {continue} tag
|
||||
@@ -44,34 +29,14 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
if ($_attr[ 'nocache' ] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
list($levels, $foreachLevels) = $this->checkLevels($args, $compiler, 'continue');
|
||||
$output = "<?php\n";
|
||||
if ($foreachLevels > 1) {
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore($foreachLevels - 1);
|
||||
}
|
||||
|
||||
if (isset($_attr[ 'levels' ])) {
|
||||
if (!is_numeric($_attr[ 'levels' ])) {
|
||||
$compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
|
||||
}
|
||||
$_levels = $_attr[ 'levels' ];
|
||||
} else {
|
||||
$_levels = 1;
|
||||
}
|
||||
$level_count = $_levels;
|
||||
$stack_count = count($compiler->_tag_stack) - 1;
|
||||
while ($level_count > 0 && $stack_count >= 0) {
|
||||
if (isset($_is_loopy[ $compiler->_tag_stack[ $stack_count ][ 0 ] ])) {
|
||||
$level_count --;
|
||||
}
|
||||
$stack_count --;
|
||||
}
|
||||
if ($level_count != 0) {
|
||||
$compiler->trigger_template_error("cannot continue {$_levels} level(s)", null, true);
|
||||
}
|
||||
|
||||
return "<?php continue {$_levels};?>";
|
||||
$output .= "continue {$levels};?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
||||
$this->compileEndChild($compiler);
|
||||
}
|
||||
} else {
|
||||
$this->compileEndChild($compiler);
|
||||
$this->compileInclude($compiler, $_attr[ 'file' ]);
|
||||
$this->compileEndChild($compiler, $_attr[ 'file' ]);
|
||||
}
|
||||
$compiler->has_code = false;
|
||||
return '';
|
||||
@@ -95,24 +94,35 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh
|
||||
* Add code for inheritance endChild() method to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param null|string $template optional inheritance parent template
|
||||
*/
|
||||
private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler, $template = null)
|
||||
{
|
||||
$inlineUids = '';
|
||||
if (isset($template) && $compiler->smarty->merge_compiled_includes) {
|
||||
$code = $compiler->compileTag('include', array($template, array('scope' => 'parent')));
|
||||
if (preg_match("/([,][\s]*['][a-z0-9]+['][,][\s]*[']content.*['])[)]/", $code, $match)) {
|
||||
$inlineUids = $match[ 1 ];
|
||||
}
|
||||
}
|
||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
"<?php \$_smarty_tpl->inheritance->endChild();\n?>\n");
|
||||
"<?php \$_smarty_tpl->inheritance->endChild(\$_smarty_tpl" .
|
||||
(isset($template) ?
|
||||
', ' . $template . $inlineUids :
|
||||
'') . ");\n?>\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add code for including subtemplate to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param string $file subtemplate name
|
||||
* @param string $template subtemplate name
|
||||
*/
|
||||
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file)
|
||||
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template)
|
||||
{
|
||||
$compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$compiler->compileTag('include',
|
||||
array($file,
|
||||
array($template,
|
||||
array('scope' => 'parent'))));
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
if (isset($itemAttr[ 'last' ])) {
|
||||
$output .= "{$itemVar}->last = {$itemVar}->iteration == {$itemVar}->total;\n";
|
||||
}
|
||||
if ($this->isNamed) {
|
||||
if (isset($foreachVar)) {
|
||||
if (isset($namedAttr[ 'iteration' ])) {
|
||||
$output .= "{$foreachVar}->value['iteration']++;\n";
|
||||
}
|
||||
@@ -252,6 +252,18 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compiles code for to restore saved template variables
|
||||
*
|
||||
* @param int $levels number of levels to restore
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compileRestore($levels)
|
||||
{
|
||||
return "\$_smarty_tpl->smarty->ext->_foreach->restore(\$_smarty_tpl, {$levels});\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,7 +335,9 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
$output .= "}\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
$output .= "\$_smarty_tpl->smarty->ext->_foreach->restore(\$_smarty_tpl);\n";
|
||||
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
|
||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||
$output .= $foreachCompiler->compileRestore(1);
|
||||
$output .= "?>\n";
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -141,14 +141,14 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}";
|
||||
$output .= "\$params = var_export(\$params, true);\n";
|
||||
$output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value, \\\$_smarty_tpl->isRenderingCache);\n}\n?>";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n\";?>";
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
$output));
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
|
||||
@@ -39,27 +39,29 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
}
|
||||
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
if ($compiler->nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
}
|
||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||
$prefixVar = $compiler->getNewPrefixVariable();
|
||||
$_output = "<?php {$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ";?>\n";
|
||||
$assignAttr = array();
|
||||
$assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ];
|
||||
$assignAttr[][ 'value' ] = "{$prefixVar}";
|
||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
$_output = $assignCompiler->compile($assignAttr, $compiler,
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler,
|
||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
||||
} else {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||
$_output = $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
}
|
||||
$_output .= "<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output .= "<?php if ({$prefixVar}) {?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return "<?php if ({$parameter['if condition']}) {?>";
|
||||
@@ -123,27 +125,30 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
}
|
||||
|
||||
$assignCode = '';
|
||||
$var = '';
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
$condition_by_assign = true;
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
if ($compiler->nocache) {
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
} else {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
}
|
||||
$prefixVar = $compiler->getNewPrefixVariable();
|
||||
$assignCode = "<?php {$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ";?>\n";
|
||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||
$assignAttr = array();
|
||||
$assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ];
|
||||
$assignAttr[][ 'value' ] = "{$prefixVar}";
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
$assignCode = $assignCompiler->compile($assignAttr, $compiler,
|
||||
$assignCode .= $assignCompiler->compile($assignAttr, $compiler,
|
||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
||||
} else {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||
$assignCode = $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
$assignCode .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
}
|
||||
} else {
|
||||
$condition_by_assign = false;
|
||||
@@ -154,8 +159,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
if ($condition_by_assign) {
|
||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
$_output = $compiler->appendCode("<?php } else {\n?>", $assignCode);
|
||||
return $compiler->appendCode($_output,
|
||||
"<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>");
|
||||
return $compiler->appendCode($_output, "<?php if ({$prefixVar}) {?>");
|
||||
} else {
|
||||
$this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));
|
||||
return "<?php } elseif ({$parameter['if condition']}) {?>";
|
||||
@@ -165,8 +169,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
if ($condition_by_assign) {
|
||||
$_output = $compiler->appendCode($_output, $assignCode);
|
||||
return $compiler->appendCode($_output,
|
||||
"<?php if (" . $parameter[ 'if condition' ][ 'value' ] . ") {\n?>");
|
||||
return $compiler->appendCode($_output, "<?php if ({$prefixVar}) {?>");
|
||||
} else {
|
||||
return $compiler->appendCode($_output, "<?php if ({$parameter['if condition']}) {?>");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
$compiled->includes[ $fullResourceName ] = 1;
|
||||
}
|
||||
}
|
||||
$fullResourceName = '"' . $fullResourceName . '"';
|
||||
$fullResourceName = $match[ 1 ] . $fullResourceName . $match[ 1 ];
|
||||
}
|
||||
}
|
||||
if (empty($match[ 5 ])) {
|
||||
@@ -295,8 +295,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
{
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] =
|
||||
$tpl->source->uid;
|
||||
$compiler->parent_compiler->mergedSubTemplatesData[ $uid ][ $t_hash ][ 'uid' ] = $tpl->source->uid;
|
||||
if (isset($compiler->template->inheritance)) {
|
||||
$tpl->inheritance = clone $compiler->template->inheritance;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array) $_dir as $_script_dir) {
|
||||
$_path = $compiler->smarty->_realpath($_script_dir . DS . $_file, true);
|
||||
$_path = $compiler->smarty->_realpath($_script_dir . $compiler->smarty->ds . $_file, true);
|
||||
if (file_exists($_path)) {
|
||||
$_filepath = $_path;
|
||||
break;
|
||||
|
||||
@@ -97,7 +97,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
}
|
||||
if (!empty($_dir)) {
|
||||
foreach ((array) $_dir as $_script_dir) {
|
||||
$_script_dir = rtrim($_script_dir, '/\\') . DS;
|
||||
$_script_dir = rtrim($_script_dir, '/\\') . $compiler->smarty->ds;
|
||||
if (file_exists($_script_dir . $_script)) {
|
||||
$_filepath = $_script_dir . $_script;
|
||||
break;
|
||||
|
||||
@@ -63,7 +63,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
$output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n";
|
||||
}
|
||||
$output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n";
|
||||
$output .= "\$_block_repeat{$this->nesting}=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat{$this->nesting});\nwhile (\$_block_repeat{$this->nesting}) {\nob_start();\n?>";
|
||||
$output .= "\$_block_repeat=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat);\nwhile (\$_block_repeat) {\nob_start();\n?>";
|
||||
$this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback));
|
||||
// maybe nocache because of nocache variables or nocache plugin
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
@@ -88,12 +88,11 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
||||
array('modifierlist' => $parameter[ 'modifier_list' ],
|
||||
'value' => 'ob_get_clean()')) . ";\n";
|
||||
}
|
||||
$output = "<?php " . $mod_content . "\$_block_repeat{$this->nesting}=false;\n" . $mod_pre .
|
||||
$output = "<?php " . $mod_content . "\$_block_repeat=false;\n" . $mod_pre .
|
||||
"echo {$callback}({$_params}, " . $mod_content2 .
|
||||
", \$_smarty_tpl, \$_block_repeat{$this->nesting});\n" . $mod_post . "}\n";
|
||||
", \$_smarty_tpl, \$_block_repeat);\n" . $mod_post . "}\n";
|
||||
$output .= "array_pop(\$_smarty_tpl->smarty->_cache['_tag_stack']);";
|
||||
$output .= "?>";
|
||||
$this->nesting --;
|
||||
}
|
||||
return $output . "\n";
|
||||
}
|
||||
|
||||
@@ -67,8 +67,8 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
|
||||
'value' => $output));
|
||||
}
|
||||
//Does tag create output
|
||||
$compiler->has_output = isset($_attr[ 'assign' ]) ? false : true;
|
||||
$output = "<?php " . ($compiler->has_output ? "echo " : '') . "{$output};?>\n";
|
||||
$compiler->has_output = true;
|
||||
$output = "<?php echo {$output};?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$compiler->has_code = false;
|
||||
if ($_attr[ 'type' ] == 'xml') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->compiled->has_nocache_code;
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
@@ -50,7 +49,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$output .
|
||||
"';?>",
|
||||
true)));
|
||||
$compiler->template->compiled->has_nocache_code = $save;
|
||||
return '';
|
||||
}
|
||||
if ($_attr[ 'type' ] != 'tag') {
|
||||
@@ -65,7 +63,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->compiled->has_nocache_code;
|
||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree($compiler->parser,
|
||||
new Smarty_Internal_ParseTree_Tag($compiler->parser,
|
||||
@@ -73,7 +70,6 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$output .
|
||||
"';?>",
|
||||
true)));
|
||||
$compiler->template->compiled->has_nocache_code = $save;
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
@@ -121,7 +117,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$closeTag = '?>';
|
||||
if (strpos($lex->value, '<?xml') === 0) {
|
||||
$lex->is_xml = true;
|
||||
$lex->token = Smarty_Internal_Templateparser::TP_NOCACHE;
|
||||
$lex->phpType = 'xml';
|
||||
return;
|
||||
} elseif (strpos($lex->value, '<?') === 0) {
|
||||
$lex->phpType = 'php';
|
||||
@@ -133,7 +129,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
} elseif (strpos($lex->value, '?>') === 0) {
|
||||
if ($lex->is_xml) {
|
||||
$lex->is_xml = false;
|
||||
$lex->token = Smarty_Internal_Templateparser::TP_NOCACHE;
|
||||
$lex->phpType = 'xml';
|
||||
return;
|
||||
}
|
||||
$lex->phpType = 'unmatched';
|
||||
|
||||
@@ -75,8 +75,8 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
|
||||
'value' => $output));
|
||||
}
|
||||
//Does tag create output
|
||||
$compiler->has_output = isset($_attr[ 'assign' ]) ? false : true;
|
||||
$output = "<?php " . ($compiler->has_output ? "echo " : '') . "{$output};?>\n";
|
||||
$compiler->has_output = true;
|
||||
$output = "<?php echo {$output};?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
if (is_array($parameter[ 'if condition' ])) {
|
||||
if ($compiler->nocache) {
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
@@ -49,20 +48,19 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
$var = $parameter[ 'if condition' ][ 'var' ];
|
||||
}
|
||||
$compiler->setNocacheInVariable($var);
|
||||
} else {
|
||||
$_nocache = '';
|
||||
}
|
||||
$prefixVar = $compiler->getNewPrefixVariable();
|
||||
$assignCompiler = new Smarty_Internal_Compile_Assign();
|
||||
$assignAttr = array();
|
||||
$assignAttr[][ 'value' ] = $parameter[ 'if condition' ][ 'value' ];
|
||||
$assignAttr[][ 'value' ] = "{$prefixVar}";
|
||||
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
||||
$_output = "<?php while (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output = "<?php while ({$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler,
|
||||
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
|
||||
} else {
|
||||
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
||||
$_output = "<?php while (" . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output = "<?php while ({$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
|
||||
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
||||
}
|
||||
|
||||
|
||||
@@ -111,11 +111,11 @@ class Smarty_Internal_Config_File_Compiler
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
// init the lexer/parser to compile the config file
|
||||
/* @var Smarty_Internal_ConfigFileLexer $lex */
|
||||
$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
|
||||
/* @var Smarty_Internal_ConfigFileLexer $this->lex */
|
||||
$this->lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
|
||||
$this);
|
||||
/* @var Smarty_Internal_ConfigFileParser $parser */
|
||||
$parser = new $this->parser_class($lex, $this);
|
||||
/* @var Smarty_Internal_ConfigFileParser $this->parser */
|
||||
$this->parser = new $this->parser_class($this->lex, $this);
|
||||
|
||||
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
@@ -125,17 +125,17 @@ class Smarty_Internal_Config_File_Compiler
|
||||
}
|
||||
|
||||
if ($this->smarty->_parserdebug) {
|
||||
$parser->PrintTrace();
|
||||
$this->parser->PrintTrace();
|
||||
}
|
||||
// get tokens from lexer and parse them
|
||||
while ($lex->yylex()) {
|
||||
while ($this->lex->yylex()) {
|
||||
if ($this->smarty->_parserdebug) {
|
||||
echo "<br>Parsing {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
|
||||
echo "<br>Parsing {$this->parser->yyTokenName[$this->lex->token]} Token {$this->lex->value} Line {$this->lex->line} \n";
|
||||
}
|
||||
$parser->doParse($lex->token, $lex->value);
|
||||
$this->parser->doParse($this->lex->token, $this->lex->value);
|
||||
}
|
||||
// finish parsing process
|
||||
$parser->doParse(0, 0);
|
||||
$this->parser->doParse(0, 0);
|
||||
|
||||
if ($mbEncoding) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
@@ -166,8 +166,6 @@ class Smarty_Internal_Config_File_Compiler
|
||||
*/
|
||||
public function trigger_config_file_error($args = null)
|
||||
{
|
||||
$this->lex = Smarty_Internal_Configfilelexer::instance();
|
||||
$this->parser = Smarty_Internal_Configfileparser::instance();
|
||||
// get config source line which has error
|
||||
$line = $this->lex->line;
|
||||
if (isset($args)) {
|
||||
|
||||
@@ -28,6 +28,13 @@ class Smarty_Internal_Configfilelexer
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* Source length
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $dataLength = null;
|
||||
|
||||
/**
|
||||
* byte counter
|
||||
*
|
||||
@@ -109,7 +116,7 @@ class Smarty_Internal_Configfilelexer
|
||||
/**
|
||||
* storage for assembled token patterns
|
||||
*
|
||||
* @var sring
|
||||
* @var string
|
||||
*/
|
||||
private $yy_global_pattern1 = null;
|
||||
|
||||
@@ -139,9 +146,8 @@ class Smarty_Internal_Configfilelexer
|
||||
*/
|
||||
function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
{
|
||||
// set instance object
|
||||
self::instance($this);
|
||||
$this->data = $data . "\n"; //now all lines are \n-terminated
|
||||
$this->dataLength = strlen($data);
|
||||
$this->counter = 0;
|
||||
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
|
||||
$this->counter += strlen($match[ 0 ]);
|
||||
@@ -152,15 +158,6 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->configBooleanize = $this->smarty->config_booleanize;
|
||||
}
|
||||
|
||||
public static function &instance($new_instance = null)
|
||||
{
|
||||
static $instance = null;
|
||||
if (isset($new_instance) && is_object($new_instance)) {
|
||||
$instance = $new_instance;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
public function PrintTrace()
|
||||
{
|
||||
$this->yyTraceFILE = fopen('php://output', 'w');
|
||||
@@ -223,17 +220,19 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yy_global_pattern1 =
|
||||
"/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -255,7 +254,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
@@ -328,17 +327,19 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yy_global_pattern2 =
|
||||
"/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -360,7 +361,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
@@ -452,17 +453,19 @@ class Smarty_Internal_Configfilelexer
|
||||
if (!isset($this->yy_global_pattern3)) {
|
||||
$this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -484,7 +487,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
@@ -512,17 +515,19 @@ class Smarty_Internal_Configfilelexer
|
||||
if (!isset($this->yy_global_pattern4)) {
|
||||
$this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -544,7 +549,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
@@ -584,17 +589,19 @@ class Smarty_Internal_Configfilelexer
|
||||
if (!isset($this->yy_global_pattern5)) {
|
||||
$this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -616,7 +623,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
@@ -650,17 +657,19 @@ class Smarty_Internal_Configfilelexer
|
||||
if (!isset($this->yy_global_pattern6)) {
|
||||
$this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->dataLength)) {
|
||||
$this->dataLength = strlen($this->data);
|
||||
}
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
|
||||
do {
|
||||
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
if (strlen($yysubmatches[ 0 ]) < 200) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!isset($yymatches[ 0 ][ 1 ])) {
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
|
||||
} else {
|
||||
$yymatches = array_filter($yymatches, 'strlen');
|
||||
$yymatches = array_filter($yymatches);
|
||||
}
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
|
||||
@@ -682,7 +691,7 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= $this->dataLength) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
|
||||
@@ -168,8 +168,6 @@ class Smarty_Internal_Configfileparser
|
||||
*/
|
||||
function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
{
|
||||
// set instance object
|
||||
self::instance($this);
|
||||
$this->lex = $lex;
|
||||
$this->smarty = $compiler->smarty;
|
||||
$this->compiler = $compiler;
|
||||
@@ -177,20 +175,6 @@ class Smarty_Internal_Configfileparser
|
||||
$this->configReadHidden = $this->smarty->config_read_hidden;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $new_instance
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public static function &instance($new_instance = null)
|
||||
{
|
||||
static $instance = null;
|
||||
if (isset($new_instance) && is_object($new_instance)) {
|
||||
$instance = $new_instance;
|
||||
}
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* parse optional boolean keywords
|
||||
*
|
||||
@@ -736,7 +720,7 @@ class Smarty_Internal_Configfileparser
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
#line 255 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 239 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->internalError = true;
|
||||
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
|
||||
@@ -771,27 +755,27 @@ class Smarty_Internal_Configfileparser
|
||||
6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14,
|
||||
15 => 15, 16 => 16, 17 => 17, 18 => 17,);
|
||||
|
||||
#line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 245 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r0()
|
||||
{
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
#line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 250 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r1()
|
||||
{
|
||||
$this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
#line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 264 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r4()
|
||||
{
|
||||
$this->add_section_vars($this->yystack[ $this->yyidx + - 3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 269 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r5()
|
||||
{
|
||||
if ($this->configReadHidden) {
|
||||
@@ -801,75 +785,75 @@ class Smarty_Internal_Configfileparser
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
|
||||
#line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 277 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r6()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[ $this->yyidx + - 1 ]->minor;
|
||||
}
|
||||
|
||||
#line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 281 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r7()
|
||||
{
|
||||
$this->_retvalue =
|
||||
array_merge($this->yystack[ $this->yyidx + - 1 ]->minor, Array($this->yystack[ $this->yyidx + 0 ]->minor));
|
||||
}
|
||||
|
||||
#line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r8()
|
||||
{
|
||||
$this->_retvalue = Array();
|
||||
}
|
||||
|
||||
#line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 291 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r9()
|
||||
{
|
||||
$this->_retvalue = Array("key" => $this->yystack[ $this->yyidx + - 2 ]->minor,
|
||||
"value" => $this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 296 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r10()
|
||||
{
|
||||
$this->_retvalue = (float) $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
}
|
||||
|
||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 300 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r11()
|
||||
{
|
||||
$this->_retvalue = (int) $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
}
|
||||
|
||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 304 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r12()
|
||||
{
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 308 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r13()
|
||||
{
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r14()
|
||||
{
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor);
|
||||
}
|
||||
|
||||
#line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r15()
|
||||
{
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + - 1 ]->minor);
|
||||
}
|
||||
|
||||
#line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r16()
|
||||
{
|
||||
$this->_retvalue = '';
|
||||
}
|
||||
|
||||
#line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r17()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||
@@ -927,7 +911,7 @@ class Smarty_Internal_Configfileparser
|
||||
|
||||
public function yy_syntax_error($yymajor, $TOKEN)
|
||||
{
|
||||
#line 248 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 232 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->internalError = true;
|
||||
$this->yymajor = $yymajor;
|
||||
@@ -942,7 +926,7 @@ class Smarty_Internal_Configfileparser
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
#line 241 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 225 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->successful = !$this->internalError;
|
||||
$this->internalError = false;
|
||||
|
||||
@@ -14,10 +14,12 @@
|
||||
* @package Smarty
|
||||
* @subpackage Template
|
||||
*
|
||||
* @property int $scope
|
||||
* @property int $scope
|
||||
* @property Smarty $smarty
|
||||
* The following methods will be dynamically loaded by the extension handler when they are called.
|
||||
* They are located in a corresponding Smarty_Internal_Method_xxxx class
|
||||
*
|
||||
* @method mixed getConfigVariable(string $varName, bool $errorEnable = true)
|
||||
* @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
|
||||
* @method mixed getGlobal(string $varName = null)
|
||||
* @method mixed getStreamVariable(string $variable)
|
||||
@@ -99,7 +101,7 @@ class Smarty_Internal_Data
|
||||
}
|
||||
} else {
|
||||
if ($tpl_var != '') {
|
||||
if ($this->_objType == 2) {
|
||||
if ($this->_objType === 2) {
|
||||
/** @var Smarty_Internal_Template $this */
|
||||
$this->_assignInScope($tpl_var, $value, $nocache);
|
||||
} else {
|
||||
@@ -227,6 +229,46 @@ class Smarty_Internal_Data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this instance is a Data obj
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _isDataObj()
|
||||
{
|
||||
return $this->_objType === 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this instance is a template obj
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _isTplObj()
|
||||
{
|
||||
return $this->_objType === 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this instance is a Smarty obj
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _isSmartyObj()
|
||||
{
|
||||
return $this->_objType === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Smarty object
|
||||
*
|
||||
* @return Smarty
|
||||
*/
|
||||
public function _getSmartyObj()
|
||||
{
|
||||
return $this->smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle unknown class methods
|
||||
*
|
||||
|
||||
@@ -52,7 +52,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
*/
|
||||
public function start_template(Smarty_Internal_Template $template, $mode = null)
|
||||
{
|
||||
if (isset($mode)) {
|
||||
if (isset($mode) && !$template->_isSubTpl()) {
|
||||
$this->index ++;
|
||||
$this->offset ++;
|
||||
$this->template_data[ $this->index ] = null;
|
||||
@@ -201,11 +201,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$savedIndex = $this->index;
|
||||
$this->index = 9999;
|
||||
}
|
||||
if ($obj->_objType == 1) {
|
||||
$smarty = $obj;
|
||||
} else {
|
||||
$smarty = $obj->smarty;
|
||||
}
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
// create fresh instance of smarty for displaying the debug console
|
||||
// to avoid problems if the application did overload the Smarty class
|
||||
$debObj = new Smarty();
|
||||
@@ -240,7 +236,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$debugging = $smarty->debugging;
|
||||
|
||||
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
|
||||
if ($obj->_objType == 2) {
|
||||
if ($obj->_isTplObj()) {
|
||||
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
||||
}
|
||||
if ($obj->_objType == 1 || $full) {
|
||||
@@ -274,9 +270,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$config_vars = array();
|
||||
foreach ($obj->config_vars as $key => $var) {
|
||||
$config_vars[ $key ][ 'value' ] = $var;
|
||||
if ($obj->_objType == 2) {
|
||||
if ($obj->_isTplObj()) {
|
||||
$config_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
|
||||
} elseif ($obj->_objType == 4) {
|
||||
} elseif ($obj->_isDataObj()) {
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
|
||||
} else {
|
||||
$config_vars[ $key ][ 'scope' ] = 'Smarty object';
|
||||
@@ -299,9 +295,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($obj->_objType == 2) {
|
||||
if ($obj->_isTplObj()) {
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->source->type . ':' . $obj->source->name;
|
||||
} elseif ($obj->_objType == 4) {
|
||||
} elseif ($obj->_isDataObj()) {
|
||||
$tpl_vars[ $key ][ 'scope' ] = $obj->dataObjectName;
|
||||
} else {
|
||||
$tpl_vars[ $key ][ 'scope' ] = 'Smarty object';
|
||||
|
||||
@@ -10,25 +10,31 @@
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
|
||||
* @property Smarty_Internal_Runtime_Foreach $_foreach
|
||||
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
|
||||
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
|
||||
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler
|
||||
* @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath
|
||||
* @property Smarty_Internal_Runtime_UpdateScope $_updateScope
|
||||
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
|
||||
* @property Smarty_Internal_Runtime_UpdateCache $_updateCache
|
||||
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
|
||||
* @property Smarty_Internal_Method_Append $append
|
||||
* @property Smarty_Internal_Method_AppendByRef $appendByRef
|
||||
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
|
||||
* @property Smarty_Internal_Method_AssignByRef $assignByRef
|
||||
* @property Smarty_Internal_Method_LoadFilter $loadFilter
|
||||
* @property Smarty_Internal_Method_LoadPlugin $loadPlugin
|
||||
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
|
||||
* @property Smarty_Internal_Method_RegisterObject $registerObject
|
||||
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
|
||||
* Runtime extensions
|
||||
* @property Smarty_Internal_Runtime_CacheModify $_cacheModify
|
||||
* @property Smarty_Internal_Runtime_CacheResourceFile $_cacheResourceFile
|
||||
* @property Smarty_Internal_Runtime_Capture $_capture
|
||||
* @property Smarty_Internal_Runtime_CodeFrame $_codeFrame
|
||||
* @property Smarty_Internal_Runtime_FilterHandler $_filterHandler
|
||||
* @property Smarty_Internal_Runtime_Foreach $_foreach
|
||||
* @property Smarty_Internal_Runtime_GetIncludePath $_getIncludePath
|
||||
* @property Smarty_Internal_Runtime_Make_Nocache $_make_nocache
|
||||
* @property Smarty_Internal_Runtime_UpdateCache $_updateCache
|
||||
* @property Smarty_Internal_Runtime_UpdateScope $_updateScope
|
||||
* @property Smarty_Internal_Runtime_TplFunction $_tplFunction
|
||||
* @property Smarty_Internal_Runtime_WriteFile $_writeFile
|
||||
*
|
||||
* Method extensions
|
||||
* @property Smarty_Internal_Method_GetTemplateVars $getTemplateVars
|
||||
* @property Smarty_Internal_Method_Append $append
|
||||
* @property Smarty_Internal_Method_AppendByRef $appendByRef
|
||||
* @property Smarty_Internal_Method_AssignGlobal $assignGlobal
|
||||
* @property Smarty_Internal_Method_AssignByRef $assignByRef
|
||||
* @property Smarty_Internal_Method_LoadFilter $loadFilter
|
||||
* @property Smarty_Internal_Method_LoadPlugin $loadPlugin
|
||||
* @property Smarty_Internal_Method_RegisterFilter $registerFilter
|
||||
* @property Smarty_Internal_Method_RegisterObject $registerObject
|
||||
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
|
||||
*/
|
||||
class Smarty_Internal_Extension_Handler
|
||||
{
|
||||
@@ -62,16 +68,17 @@ class Smarty_Internal_Extension_Handler
|
||||
/* @var Smarty $data ->smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
if (!isset($smarty->ext->$name)) {
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||
$class = 'Smarty_Internal_Method_' . $this->upperCase($name);
|
||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||
$pn = '';
|
||||
if (!isset($this->_property_info[ $prop = $match[ 2 ] ])) {
|
||||
// convert camel case to underscored name
|
||||
$this->resolvedProperties[ $prop ] = $pn = strtolower(join('_',
|
||||
preg_split('/([A-Z][^A-Z]*)/', $prop,
|
||||
- 1, PREG_SPLIT_NO_EMPTY |
|
||||
PREG_SPLIT_DELIM_CAPTURE)));
|
||||
$this->_property_info[ $prop ] = property_exists($data, $pn) ? 1 :
|
||||
($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
|
||||
$this->_property_info[ $prop ] =
|
||||
property_exists($data, $pn) ? 1 : ($data->_isTplObj() && property_exists($smarty, $pn) ? 2 : 0);
|
||||
}
|
||||
if ($this->_property_info[ $prop ]) {
|
||||
$pn = $this->resolvedProperties[ $prop ];
|
||||
@@ -98,6 +105,20 @@ class Smarty_Internal_Extension_Handler
|
||||
return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make first character of name parts upper case
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function upperCase($name)
|
||||
{
|
||||
$_name = explode('_', $name);
|
||||
$_name = array_map('ucfirst', $_name);
|
||||
return implode('_', $_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* set extension property
|
||||
*
|
||||
@@ -123,9 +144,12 @@ class Smarty_Internal_Extension_Handler
|
||||
{
|
||||
// object properties of runtime template extensions will start with '_'
|
||||
if ($property_name[ 0 ] == '_') {
|
||||
$class = 'Smarty_Internal_Runtime_' . ucfirst(substr($property_name, 1));
|
||||
$class = 'Smarty_Internal_Runtime' . $this->upperCase($property_name);
|
||||
} else {
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($property_name);
|
||||
$class = 'Smarty_Internal_Method_' . $this->upperCase($property_name);
|
||||
}
|
||||
if (!class_exists($class)) {
|
||||
return $this->$property_name = new Smarty_Internal_Undefined($class);
|
||||
}
|
||||
return $this->$property_name = new $class();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_S
|
||||
*/
|
||||
public function addAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
if (!empty($smarty->autoload_filters[ $type ])) {
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_AddDefaultModifiers
|
||||
*/
|
||||
public function addDefaultModifiers(Smarty_Internal_TemplateBase $obj, $modifiers)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (is_array($modifiers)) {
|
||||
$smarty->default_modifiers = array_merge($smarty->default_modifiers, $modifiers);
|
||||
} else {
|
||||
|
||||
@@ -65,7 +65,7 @@ class Smarty_Internal_Method_Append
|
||||
$data->tpl_vars[ $tpl_var ]->value[] = $value;
|
||||
}
|
||||
}
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
if ($data->_isTplObj() && $data->scope) {
|
||||
$data->ext->_updateScope->_updateScope($data, $tpl_var);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ class Smarty_Internal_Method_AppendByRef
|
||||
} else {
|
||||
$data->tpl_vars[ $tpl_var ]->value[] = &$value;
|
||||
}
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
if ($data->_isTplObj() && $data->scope) {
|
||||
$data->ext->_updateScope->_updateScope($data, $tpl_var);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class Smarty_Internal_Method_AssignByRef
|
||||
if ($tpl_var != '') {
|
||||
$data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache);
|
||||
$data->tpl_vars[ $tpl_var ]->value = &$value;
|
||||
if ($data->_objType == 2 && $data->scope) {
|
||||
if ($data->_isTplObj() && $data->scope) {
|
||||
$data->ext->_updateScope->_updateScope($data, $tpl_var);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class Smarty_Internal_Method_AssignGlobal
|
||||
if ($varName != '') {
|
||||
Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache);
|
||||
$ptr = $data;
|
||||
while ($ptr->_objType == 2) {
|
||||
while ($ptr->_isTplObj()) {
|
||||
$ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
|
||||
@@ -41,15 +41,15 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
||||
return 0;
|
||||
}
|
||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
|
||||
$_dir_sep = $smarty->use_sub_dirs ? DS : '^';
|
||||
$_dir_sep = $smarty->use_sub_dirs ? $smarty->ds : '^';
|
||||
if (isset($resource_name)) {
|
||||
$_save_stat = $smarty->caching;
|
||||
$smarty->caching = false;
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||
$tpl = $smarty->createTemplate($resource_name);
|
||||
$smarty->caching = $_save_stat;
|
||||
if (!$tpl->source->handler->uncompiled && !$tpl->source->handler->recompiled && $tpl->source->exists) {
|
||||
$_resource_part_1 = basename(str_replace('^', DS, $tpl->compiled->filepath));
|
||||
$_resource_part_1 = basename(str_replace('^', $smarty->ds, $tpl->compiled->filepath));
|
||||
$_resource_part_1_length = strlen($_resource_part_1);
|
||||
} else {
|
||||
return 0;
|
||||
@@ -75,18 +75,20 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
||||
}
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($_compile as $_file) {
|
||||
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||
if (substr(basename($_file->getPathname()), 0, 1) == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$_filepath = (string) $_file;
|
||||
|
||||
if ($_file->isDir()) {
|
||||
if (!$_compile->isDot()) {
|
||||
// delete folder if empty
|
||||
@rmdir($_file->getPathname());
|
||||
}
|
||||
} else {
|
||||
// delete only php files
|
||||
if (substr($_filepath, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
$unlink = false;
|
||||
if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =
|
||||
!strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
|
||||
|
||||
@@ -73,7 +73,7 @@ class Smarty_Internal_Method_CompileAllTemplates
|
||||
continue;
|
||||
}
|
||||
if ($_fileinfo->getPath() !== substr($_dir, 0, - 1)) {
|
||||
$_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
|
||||
$_file = substr($_fileinfo->getPath(), strlen($_dir)) . $smarty->ds . $_file;
|
||||
}
|
||||
echo "\n<br>", $_dir, '---', $_file;
|
||||
flush();
|
||||
|
||||
@@ -57,16 +57,15 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
public function _loadConfigFile(Smarty_Internal_Data $data, $config_file, $sections = null, $scope = 0)
|
||||
{
|
||||
/* @var \Smarty $smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
$smarty = $data->_getSmartyObj();
|
||||
/* @var \Smarty_Internal_Template $confObj */
|
||||
$confObj = new Smarty_Internal_Template($config_file, $smarty, $data);
|
||||
$confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true);
|
||||
$confObj->caching = Smarty::CACHING_OFF;
|
||||
$confObj->source = Smarty_Template_Config::load($confObj);
|
||||
$confObj->source->config_sections = $sections;
|
||||
$confObj->source->scope = $scope;
|
||||
$confObj->compiled = Smarty_Template_Compiled::load($confObj);
|
||||
$confObj->compiled->render($confObj);
|
||||
if ($data->_objType == 2) {
|
||||
if ($data->_isTplObj()) {
|
||||
$data->compiled->file_dependency[ $confObj->source->uid ] =
|
||||
array($confObj->source->filepath, $confObj->source->getTimeStamp(), $confObj->source->type);
|
||||
}
|
||||
@@ -91,13 +90,13 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($tpl->parent->_objType == 2 && ($tagScope || $tpl->parent->scope)) {
|
||||
if ($tpl->parent->_isTplObj() && ($tagScope || $tpl->parent->scope)) {
|
||||
$mergedScope = $tagScope | $tpl->scope;
|
||||
if ($mergedScope) {
|
||||
// update scopes
|
||||
foreach ($tpl->smarty->ext->_updateScope->_getAffectedScopes($tpl->parent, $mergedScope) as $ptr) {
|
||||
$this->_assignConfigVars($ptr->config_vars, $tpl, $new_config_vars);
|
||||
if ($tagScope && $ptr->_objType == 2 && isset($tpl->_cache[ 'varStack' ])) {
|
||||
if ($tagScope && $ptr->_isTplObj() && isset($tpl->_cache[ 'varStack' ])) {
|
||||
$this->_updateVarStack($tpl, $new_config_vars);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +108,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
/**
|
||||
* Assign all config variables in given scope
|
||||
*
|
||||
* @param array $config_vars config variables in scope
|
||||
* @param array $config_vars config variables in scope
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param array $new_config_vars loaded config variables
|
||||
*/
|
||||
@@ -158,15 +157,15 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
/**
|
||||
* gets a config variable value
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param string $varName the name of the config variable
|
||||
* @param bool $errorEnable
|
||||
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
||||
* @param string $varName the name of the config variable
|
||||
* @param bool $errorEnable
|
||||
*
|
||||
* @return mixed the value of the config variable
|
||||
* @return null|string the value of the config variable
|
||||
*/
|
||||
public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $errorEnable = true)
|
||||
public function _getConfigVariable(Smarty_Internal_Data $data, $varName, $errorEnable = true)
|
||||
{
|
||||
$_ptr = $tpl;
|
||||
$_ptr = $data;
|
||||
while ($_ptr !== null) {
|
||||
if (isset($_ptr->config_vars[ $varName ])) {
|
||||
// found it, return it
|
||||
@@ -175,7 +174,7 @@ class Smarty_Internal_Method_ConfigLoad
|
||||
// not found, try at parent
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if ($tpl->smarty->error_unassigned && $errorEnable) {
|
||||
if ($data->smarty->error_unassigned && $errorEnable) {
|
||||
// force a notice
|
||||
$x = $$varName;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Smarty_Internal_Method_CreateData
|
||||
public function createData(Smarty_Internal_TemplateBase $obj, Smarty_Internal_Data $parent = null, $name = null)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$dataObj = new Smarty_Data($parent, $smarty, $name);
|
||||
if ($smarty->debugging) {
|
||||
Smarty_Internal_Debug::register_data($dataObj);
|
||||
|
||||
@@ -27,7 +27,7 @@ class Smarty_Internal_Method_GetAutoloadFilters extends Smarty_Internal_Method_S
|
||||
*/
|
||||
public function getAutoloadFilters(Smarty_Internal_TemplateBase $obj, $type = null)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method GetConfigVariable
|
||||
*
|
||||
* Smarty::getConfigVariable() method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Method_GetConfigVariable
|
||||
{
|
||||
/**
|
||||
* Valid for all objects
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $objMap = 7;
|
||||
|
||||
/**
|
||||
* gets a config variable value
|
||||
*
|
||||
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
||||
* @param string $varName the name of the config variable
|
||||
* @param bool $errorEnable
|
||||
*
|
||||
* @return null|string the value of the config variable
|
||||
*/
|
||||
public function getConfigVariable(Smarty_Internal_Data $data, $varName = null, $errorEnable = true)
|
||||
{
|
||||
return $data->ext->configLoad->_getConfigVariable($data, $varName, $errorEnable);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class Smarty_Internal_Method_GetDebugTemplate
|
||||
*/
|
||||
public function getDebugTemplate(Smarty_Internal_TemplateBase $obj)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
return $smarty->debug_tpl;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class Smarty_Internal_Method_GetDefaultModifiers
|
||||
*/
|
||||
public function getDefaultModifiers(Smarty_Internal_TemplateBase $obj)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
return $smarty->default_modifiers;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class Smarty_Internal_Method_GetRegisteredObject
|
||||
*/
|
||||
public function getRegisteredObject(Smarty_Internal_TemplateBase $obj, $object_name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (!isset($smarty->registered_objects[ $object_name ])) {
|
||||
throw new SmartyException("'$object_name' is not a registered object");
|
||||
}
|
||||
|
||||
@@ -33,10 +33,10 @@ class Smarty_Internal_Method_GetTags
|
||||
public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
|
||||
{
|
||||
/* @var Smarty $smarty */
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $obj;
|
||||
if ($obj->_objType == 2 && !isset($template)) {
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($obj->_isTplObj() && !isset($template)) {
|
||||
$tpl = clone $obj;
|
||||
} elseif (isset($template) && $template->_objType == 2) {
|
||||
} elseif (isset($template) && $template->_isTplObj()) {
|
||||
$tpl = clone $template;
|
||||
} elseif (isset($template) && is_string($template)) {
|
||||
/* @var Smarty_Internal_Template $tpl */
|
||||
|
||||
@@ -41,7 +41,7 @@ class Smarty_Internal_Method_LoadFilter
|
||||
*/
|
||||
public function loadFilter(Smarty_Internal_TemplateBase $obj, $type, $name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
$_plugin = "smarty_{$type}filter_{$name}";
|
||||
$_filter_name = $_plugin;
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_MustCompile
|
||||
public function mustCompile(Smarty_Internal_Template $_template)
|
||||
{
|
||||
if (!$_template->source->exists) {
|
||||
if (isset($_template->parent) && $_template->parent->_objType == 2) {
|
||||
if ($_template->_isSubTpl()) {
|
||||
$parent_resource = " in '$_template->parent->template_resource}'";
|
||||
} else {
|
||||
$parent_resource = '';
|
||||
|
||||
@@ -33,7 +33,7 @@ class Smarty_Internal_Method_RegisterCacheResource
|
||||
public function registerCacheResource(Smarty_Internal_TemplateBase $obj, $name,
|
||||
Smarty_CacheResource $resource_handler)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->registered_cache_resources[ $name ] = $resource_handler;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Smarty_Internal_Method_RegisterClass
|
||||
*/
|
||||
public function registerClass(Smarty_Internal_TemplateBase $obj, $class_name, $class_impl)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
// test if exists
|
||||
if (!class_exists($class_impl)) {
|
||||
throw new SmartyException("Undefined class '$class_impl' in register template class");
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_RegisterDefaultConfigHandler
|
||||
*/
|
||||
public function registerDefaultConfigHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (is_callable($callback)) {
|
||||
$smarty->default_config_handler_func = $callback;
|
||||
} else {
|
||||
|
||||
@@ -32,7 +32,7 @@ class Smarty_Internal_Method_RegisterDefaultPluginHandler
|
||||
*/
|
||||
public function registerDefaultPluginHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (is_callable($callback)) {
|
||||
$smarty->default_plugin_handler_func = $callback;
|
||||
} else {
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_RegisterDefaultTemplateHandler
|
||||
*/
|
||||
public function registerDefaultTemplateHandler(Smarty_Internal_TemplateBase $obj, $callback)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (is_callable($callback)) {
|
||||
$smarty->default_template_handler_func = $callback;
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,7 @@ class Smarty_Internal_Method_RegisterFilter
|
||||
*/
|
||||
public function registerFilter(Smarty_Internal_TemplateBase $obj, $type, $callback, $name = null)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
$name = isset($name) ? $name : $this->_getFilterName($callback);
|
||||
if (!is_callable($callback)) {
|
||||
|
||||
@@ -47,7 +47,7 @@ class Smarty_Internal_Method_RegisterObject
|
||||
public function registerObject(Smarty_Internal_TemplateBase $obj, $object_name, $object,
|
||||
$allowed_methods_properties = array(), $format = true, $block_methods = array())
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
// test if allowed methods callable
|
||||
if (!empty($allowed_methods_properties)) {
|
||||
foreach ((array) $allowed_methods_properties as $method) {
|
||||
|
||||
@@ -38,7 +38,7 @@ class Smarty_Internal_Method_RegisterPlugin
|
||||
public function registerPlugin(Smarty_Internal_TemplateBase $obj, $type, $name, $callback, $cacheable = true,
|
||||
$cache_attr = null)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (isset($smarty->registered_plugins[ $type ][ $name ])) {
|
||||
throw new SmartyException("Plugin tag \"{$name}\" already registered");
|
||||
} elseif (!is_callable($callback)) {
|
||||
|
||||
@@ -36,7 +36,7 @@ class Smarty_Internal_Method_RegisterResource
|
||||
*/
|
||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->registered_resources[ $name ] =
|
||||
$resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false);
|
||||
return $obj;
|
||||
|
||||
@@ -41,7 +41,7 @@ class Smarty_Internal_Method_SetAutoloadFilters
|
||||
*/
|
||||
public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
$smarty->autoload_filters[ $type ] = (array) $filters;
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_SetDebugTemplate
|
||||
*/
|
||||
public function setDebugTemplate(Smarty_Internal_TemplateBase $obj, $tpl_name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (!is_readable($tpl_name)) {
|
||||
throw new SmartyException("Unknown file '{$tpl_name}'");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_SetDefaultModifiers
|
||||
*/
|
||||
public function setDefaultModifiers(Smarty_Internal_TemplateBase $obj, $modifiers)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$smarty->default_modifiers = (array) $modifiers;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
|
||||
*/
|
||||
public function unloadFilter(Smarty_Internal_TemplateBase $obj, $type, $name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
if (isset($smarty->registered_filters[ $type ])) {
|
||||
$_filter_name = "smarty_{$type}filter_{$name}";
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_UnregisterCacheResource
|
||||
*/
|
||||
public function unregisterCacheResource(Smarty_Internal_TemplateBase $obj, $name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (isset($smarty->registered_cache_resources[ $name ])) {
|
||||
unset($smarty->registered_cache_resources[ $name ]);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_Reg
|
||||
*/
|
||||
public function unregisterFilter(Smarty_Internal_TemplateBase $obj, $type, $callback)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
if (isset($smarty->registered_filters[ $type ])) {
|
||||
$name = is_string($callback) ? $callback : $this->_getFilterName($callback);
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_UnregisterObject
|
||||
*/
|
||||
public function unregisterObject(Smarty_Internal_TemplateBase $obj, $object_name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (isset($smarty->registered_objects[ $object_name ])) {
|
||||
unset($smarty->registered_objects[ $object_name ]);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class Smarty_Internal_Method_UnregisterPlugin
|
||||
*/
|
||||
public function unregisterPlugin(Smarty_Internal_TemplateBase $obj, $type, $name)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (isset($smarty->registered_plugins[ $type ][ $name ])) {
|
||||
unset($smarty->registered_plugins[ $type ][ $name ]);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class Smarty_Internal_Method_UnregisterResource
|
||||
*/
|
||||
public function unregisterResource(Smarty_Internal_TemplateBase $obj, $type)
|
||||
{
|
||||
$smarty = isset($obj->smarty) ? $obj->smarty : $obj;
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if (isset($smarty->registered_resources[ $type ])) {
|
||||
unset($smarty->registered_resources[ $type ]);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class Smarty_Internal_Nocache_Insert
|
||||
$_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
|
||||
}
|
||||
$_tpl = $_template;
|
||||
while (isset($_tpl->parent) && $_tpl->parent->_objType == 2) {
|
||||
while ($_tpl->_isSubTpl()) {
|
||||
$_tpl = $_tpl->parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,11 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
||||
$uid = '';
|
||||
$sources = array();
|
||||
$components = explode('|', $source->name);
|
||||
$smarty = &$source->smarty;
|
||||
$exists = true;
|
||||
foreach ($components as $component) {
|
||||
/* @var \Smarty_Template_Source $_s */
|
||||
$_s = Smarty_Template_Source::load(null, $source->smarty, $component);
|
||||
$_s = Smarty_Template_Source::load(null, $smarty, $component);
|
||||
if ($_s->type == 'php') {
|
||||
throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
|
||||
}
|
||||
@@ -85,7 +86,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
||||
public function getContent(Smarty_Template_Source $source)
|
||||
{
|
||||
if (!$source->exists) {
|
||||
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
||||
throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'");
|
||||
}
|
||||
|
||||
$_components = array_reverse($source->components);
|
||||
|
||||
@@ -35,7 +35,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
return is_file($file) ? $file : false;
|
||||
}
|
||||
// go relative to a given template?
|
||||
if ($file[ 0 ] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 &&
|
||||
if ($file[ 0 ] == '.' && $_template && $_template->_isSubTpl() &&
|
||||
preg_match('#^[.]{1,2}[\\\/]#', $file)
|
||||
) {
|
||||
if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' &&
|
||||
@@ -44,13 +44,13 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
|
||||
}
|
||||
// normalize path
|
||||
$path = $source->smarty->_realpath(dirname($_template->parent->source->filepath) . DS . $file);
|
||||
$path = $source->smarty->_realpath(dirname($_template->parent->source->filepath) . $source->smarty->ds . $file);
|
||||
// files relative to a template only get one shot
|
||||
return is_file($path) ? $path : false;
|
||||
}
|
||||
// normalize DS
|
||||
if (strpos($file, DS == '/' ? '\\' : '/') !== false) {
|
||||
$file = str_replace(DS == '/' ? '\\' : '/', DS, $file);
|
||||
// normalize $source->smarty->ds
|
||||
if (strpos($file, $source->smarty->ds == '/' ? '\\' : '/') !== false) {
|
||||
$file = str_replace($source->smarty->ds == '/' ? '\\' : '/', $source->smarty->ds, $file);
|
||||
}
|
||||
|
||||
$_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
|
||||
@@ -90,7 +90,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
||||
foreach ($_directories as $_directory) {
|
||||
$path = $_directory . $file;
|
||||
if (is_file($path)) {
|
||||
return (strpos($path, '.' . DS) !== false) ? $source->smarty->_realpath($path) : $path;
|
||||
return (strpos($path, '.' . $source->smarty->ds) !== false) ? $source->smarty->_realpath($path) : $path;
|
||||
}
|
||||
}
|
||||
if (!isset($_index_dirs)) {
|
||||
|
||||
@@ -71,9 +71,8 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
|
||||
throw new SmartyException("PHP templates are disabled");
|
||||
}
|
||||
if (!$source->exists) {
|
||||
$parentIsTpl = isset($this->parent) && $this->parent->_objType == 2;
|
||||
throw new SmartyException("Unable to load template {$source->type} '{$source->name}'" .
|
||||
($parentIsTpl ? " in '{$this->parent->template_resource}'" : ''));
|
||||
($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : ''));
|
||||
}
|
||||
|
||||
// prepare variables
|
||||
|
||||
+20
-10
@@ -1,15 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension Clear
|
||||
*
|
||||
* $smarty->clear() method file cache file resource
|
||||
* Smarty cache resource file clear method
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Extension_Clear
|
||||
|
||||
/**
|
||||
* Smarty Internal Runtime Cache Resource File Class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
*/
|
||||
class Smarty_Internal_Runtime_CacheResourceFile
|
||||
{
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
@@ -22,7 +27,7 @@ class Smarty_Internal_Extension_Clear
|
||||
*
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
public static function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
|
||||
{
|
||||
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
|
||||
$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
|
||||
@@ -38,7 +43,7 @@ class Smarty_Internal_Extension_Clear
|
||||
$_cache_id_parts_count = count($_cache_id_parts);
|
||||
if ($smarty->use_sub_dirs) {
|
||||
foreach ($_cache_id_parts as $id_part) {
|
||||
$_dir .= $id_part . DS;
|
||||
$_dir .= $id_part . $smarty->ds;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,9 +68,10 @@ class Smarty_Internal_Extension_Clear
|
||||
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
|
||||
foreach ($_cache as $_file) {
|
||||
if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
|
||||
if (substr(basename($_file->getPathname()), 0, 1) == '.') {
|
||||
continue;
|
||||
}
|
||||
$_filepath = (string) $_file;
|
||||
// directory ?
|
||||
if ($_file->isDir()) {
|
||||
if (!$_cache->isDot()) {
|
||||
@@ -73,7 +79,11 @@ class Smarty_Internal_Extension_Clear
|
||||
@rmdir($_file->getPathname());
|
||||
}
|
||||
} else {
|
||||
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
|
||||
// delete only php files
|
||||
if (substr($_filepath, -4) !== '.php') {
|
||||
continue;
|
||||
}
|
||||
$_parts = explode($_dir_sep, str_replace('\\', '/', substr($_filepath, $_dir_length)));
|
||||
$_parts_count = count($_parts);
|
||||
// check name
|
||||
if (isset($resource_name)) {
|
||||
@@ -114,9 +124,9 @@ class Smarty_Internal_Extension_Clear
|
||||
}
|
||||
}
|
||||
}
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
$_count += @unlink($_filepath) ? 1 : 0;
|
||||
if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
|
||||
opcache_invalidate((string) $_file, true);
|
||||
opcache_invalidate($_filepath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,12 +49,12 @@ class Smarty_Internal_Runtime_CodeFrame
|
||||
$output .= "if ({$dec}) {\n";
|
||||
$output .= "function {$properties['unifunc']} (Smarty_Internal_Template \$_smarty_tpl) {\n";
|
||||
if (!$cache && !empty($compiler->tpl_function)) {
|
||||
$output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
|
||||
$output .= "\$_smarty_tpl->smarty->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
|
||||
var_export($compiler->tpl_function, true) . ");\n";
|
||||
}
|
||||
if ($cache && isset($_template->ext->_tplFunction)) {
|
||||
$output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
|
||||
var_export($_template->ext->_tplFunction->getTplFunction(), true) . ");\n";
|
||||
if ($cache && isset($_template->smarty->ext->_tplFunction)) {
|
||||
$output .= "\$_smarty_tpl->smarty->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
|
||||
var_export($_template->smarty->ext->_tplFunction->getTplFunction($_template), true) . ");\n";
|
||||
|
||||
}
|
||||
// include code for plugins
|
||||
|
||||
@@ -38,35 +38,38 @@ class Smarty_Internal_Runtime_Foreach
|
||||
$properties = array())
|
||||
{
|
||||
$saveVars = array();
|
||||
if (!is_array($from) && !is_object($from)) {
|
||||
settype($from, 'array');
|
||||
$total = null;
|
||||
if (!is_array($from)) {
|
||||
if (is_object($from)) {
|
||||
$total = $this->count($from);
|
||||
} else {
|
||||
settype($from, 'array');
|
||||
}
|
||||
}
|
||||
if (!isset($total)) {
|
||||
$total = empty($from) ? 0 : (($needTotal || isset($properties[ 'total' ])) ? count($from) : 1);
|
||||
}
|
||||
$total = ($needTotal || isset($properties[ 'total' ])) ? $this->count($from) : 1;
|
||||
if (isset($tpl->tpl_vars[ $item ])) {
|
||||
$saveVars[ $item ] = $tpl->tpl_vars[ $item ];
|
||||
$saveVars[ 'item' ] = array($item, $tpl->tpl_vars[ $item ]);
|
||||
}
|
||||
$tpl->tpl_vars[ $item ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
||||
if (empty($from)) {
|
||||
if ($total === 0) {
|
||||
$from = null;
|
||||
$total = 0;
|
||||
if ($needTotal) {
|
||||
$tpl->tpl_vars[ $item ]->total = 0;
|
||||
}
|
||||
} else {
|
||||
if ($key) {
|
||||
if (isset($tpl->tpl_vars[ $key ])) {
|
||||
$saveVars[ $key ] = $tpl->tpl_vars[ $key ];
|
||||
$saveVars[ 'key' ] = array($key, $tpl->tpl_vars[ $key ]);
|
||||
}
|
||||
$tpl->tpl_vars[ $key ] = new Smarty_Variable(null, $tpl->isRenderingCache);
|
||||
}
|
||||
if ($needTotal) {
|
||||
$tpl->tpl_vars[ $item ]->total = $total;
|
||||
}
|
||||
}
|
||||
if ($needTotal) {
|
||||
$tpl->tpl_vars[ $item ]->total = $total;
|
||||
}
|
||||
if ($name) {
|
||||
$namedVar = "__smarty_foreach_{$name}";
|
||||
if (isset($tpl->tpl_vars[ $namedVar ])) {
|
||||
$saveVars[ $namedVar ] = $tpl->tpl_vars[ $namedVar ];
|
||||
$saveVars[ 'named' ] = array($namedVar, $tpl->tpl_vars[ $namedVar ]);
|
||||
}
|
||||
$namedProp = array();
|
||||
if (isset($properties[ 'total' ])) {
|
||||
@@ -90,12 +93,28 @@ class Smarty_Internal_Runtime_Foreach
|
||||
/**
|
||||
* Restore saved variables
|
||||
*
|
||||
* will be called by {break n} or {continue n} for the required number of levels
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param int $levels number of levels
|
||||
*/
|
||||
public function restore(Smarty_Internal_Template $tpl)
|
||||
public function restore(Smarty_Internal_Template $tpl, $levels = 1)
|
||||
{
|
||||
foreach (array_pop($this->stack) as $k => $v) {
|
||||
$tpl->tpl_vars[ $k ] = $v;
|
||||
while ($levels) {
|
||||
$saveVars = array_pop($this->stack);
|
||||
if (!empty($saveVars)) {
|
||||
if (isset($saveVars[ 'item' ])) {
|
||||
$item = &$saveVars[ 'item' ];
|
||||
$tpl->tpl_vars[ $item[ 0 ] ]->value = $item[ 1 ]->value;
|
||||
}
|
||||
if (isset($saveVars[ 'key' ])) {
|
||||
$tpl->tpl_vars[ $saveVars[ 'key' ][ 0 ] ] = $saveVars[ 'key' ][ 1 ];
|
||||
}
|
||||
if (isset($saveVars[ 'named' ])) {
|
||||
$tpl->tpl_vars[ $saveVars[ 'named' ][ 0 ] ] = $saveVars[ 'named' ][ 1 ];
|
||||
}
|
||||
}
|
||||
$levels--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,28 +129,21 @@ class Smarty_Internal_Runtime_Foreach
|
||||
*/
|
||||
public function count($value)
|
||||
{
|
||||
if (is_array($value) === true || $value instanceof Countable) {
|
||||
if ($value instanceof Countable) {
|
||||
return count($value);
|
||||
} elseif ($value instanceof IteratorAggregate) {
|
||||
// Note: getIterator() returns a Traversable, not an Iterator
|
||||
// thus rewind() and valid() methods may not be present
|
||||
return iterator_count($value->getIterator());
|
||||
} elseif ($value instanceof Iterator) {
|
||||
if ($value instanceof Generator) {
|
||||
return 1;
|
||||
}
|
||||
return iterator_count($value);
|
||||
return $value instanceof Generator ? 1 : iterator_count($value);
|
||||
} elseif ($value instanceof PDOStatement) {
|
||||
return $value->rowCount();
|
||||
} elseif ($value instanceof Traversable) {
|
||||
return iterator_count($value);
|
||||
} elseif ($value instanceof ArrayAccess) {
|
||||
if ($value->offsetExists(0)) {
|
||||
return 1;
|
||||
}
|
||||
} elseif (is_object($value)) {
|
||||
return count($value);
|
||||
return $value->offsetExists(0) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
return count((array) $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class Smarty_Internal_Runtime_GetIncludePath
|
||||
$_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
|
||||
foreach ($_dirs as $_path) {
|
||||
if (is_dir($_path)) {
|
||||
$this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
|
||||
$this->_include_dirs[] = $smarty->_realpath($_path . $smarty->ds, true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -99,14 +99,22 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
* End of child template(s)
|
||||
* - if outer level is reached flush output buffer and switch to wait for parent template state
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param null|string $template optinal name of inheritance parent template
|
||||
* @param null|string $uid uid of inline template
|
||||
* @param null|string $func function call name of inline template
|
||||
*/
|
||||
public function endChild()
|
||||
public function endChild(Smarty_Internal_Template $tpl, $template = null, $uid = null, $func = null)
|
||||
{
|
||||
$this->inheritanceLevel --;
|
||||
if (!$this->inheritanceLevel) {
|
||||
ob_end_clean();
|
||||
$this->state = 2;
|
||||
}
|
||||
if (isset($template) && (($tpl->parent->_isTplObj() && $tpl->parent->source->type !== 'extends') || $tpl->smarty->extends_recursion)) {
|
||||
$tpl->_subTemplateRender($template, $tpl->cache_id, $tpl->compile_id, $tpl->caching ? 9999 : 0,
|
||||
$tpl->cache_lifetime, array(), 2, false, $uid, $func);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +129,7 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
*/
|
||||
public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
|
||||
{
|
||||
$block = new $className($name, $tplIndex ? $tplIndex : $this->tplIndex);
|
||||
$block = new $className($name, isset($tplIndex) ? $tplIndex : $this->tplIndex);
|
||||
if (isset($this->childRoot[ $name ])) {
|
||||
$block->child = $this->childRoot[ $name ];
|
||||
}
|
||||
@@ -197,11 +205,22 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param \Smarty_Internal_Block $block
|
||||
*
|
||||
* @param null $name
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
|
||||
public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $name = null)
|
||||
{
|
||||
if (isset($block->parent)) {
|
||||
if (isset($name)) {
|
||||
$block = $block->parent;
|
||||
while (isset($block)) {
|
||||
if (isset($block->subBlocks[ $name ])) {
|
||||
} else {
|
||||
$block = $block->parent;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (isset($block->parent)) {
|
||||
$this->callBlock($block->parent, $tpl);
|
||||
} else {
|
||||
throw new SmartyException("inheritance: illegal {\$smarty.block.parent} or {block append/prepend} used in parent template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
|
||||
|
||||
@@ -23,14 +23,14 @@ class Smarty_Internal_Runtime_Make_Nocache
|
||||
public function save(Smarty_Internal_Template $tpl, $var)
|
||||
{
|
||||
if (isset($tpl->tpl_vars[ $var ])) {
|
||||
$export = preg_replace('/^Smarty_Variable::__set_state[(]|\s|[)]$/', '',
|
||||
var_export($tpl->tpl_vars[ $var ], true));
|
||||
$export =
|
||||
preg_replace('/^Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true));
|
||||
if (preg_match('/(\w+)::__set_state/', $export, $match)) {
|
||||
throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'");
|
||||
}
|
||||
echo "/*%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/<?php " .
|
||||
addcslashes("\$_smarty_tpl->smarty->ext->_make_nocache->store(\$_smarty_tpl, '{$var}', " . $export,
|
||||
'\\') . ");?>\n/*/%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/";
|
||||
addcslashes("\$_smarty_tpl->smarty->ext->_make_nocache->store(\$_smarty_tpl, '{$var}', ", '\\') .
|
||||
$export . ");?>\n/*/%%SmartyNocache:{$tpl->compiled->nocache_hash}%%*/";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Tplfunc Runtime Methods callTemplateFunction
|
||||
* TplFunction Runtime Methods callTemplateFunction
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
@@ -10,13 +10,6 @@
|
||||
**/
|
||||
class Smarty_Internal_Runtime_TplFunction
|
||||
{
|
||||
/**
|
||||
* Array of source information for known template functions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $tplFunctions = array();
|
||||
|
||||
/**
|
||||
* Call template function
|
||||
*
|
||||
@@ -29,14 +22,16 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
*/
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
if (isset($this->tplFunctions[ $name ])) {
|
||||
$funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $this->tplFunctions[ $name ][ 'call_name' ];
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
} else {
|
||||
if (isset($this->tplFunctions[ $name ][ 'call_name_caching' ])) {
|
||||
$function = $this->tplFunctions[ $name ][ 'call_name_caching' ];
|
||||
if (isset($funcParam[ 'call_name_caching' ])) {
|
||||
$function = $funcParam[ 'call_name_caching' ];
|
||||
} else {
|
||||
$function = $this->tplFunctions[ $name ][ 'call_name' ];
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
}
|
||||
}
|
||||
if (function_exists($function)) {
|
||||
@@ -59,33 +54,38 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
/**
|
||||
* Register template functions defined by template
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param array $tplFunctions source information array of template functions defined in template
|
||||
* @param \Smarty|\Smarty_Internal_Template|\Smarty_Internal_TemplateBase $obj
|
||||
* @param array $tplFunctions source information array of template functions defined in template
|
||||
* @param bool $override if true replace existing functions with same name
|
||||
*/
|
||||
public function registerTplFunctions(Smarty_Internal_Template $tpl, $tplFunctions)
|
||||
public function registerTplFunctions(Smarty_Internal_TemplateBase $obj, $tplFunctions, $override = true)
|
||||
{
|
||||
$this->tplFunctions = array_merge($this->tplFunctions, $tplFunctions);
|
||||
$ptr = $tpl;
|
||||
$obj->tplFunctions =
|
||||
$override ? array_merge($obj->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $obj->tplFunctions);
|
||||
// make sure that the template functions are known in parent templates
|
||||
while (isset($ptr->parent) && $ptr->parent->_objType === 2 && !isset($ptr->ext->_tplFunction)) {
|
||||
$ptr->ext->_tplFunction = $this;
|
||||
$ptr = $ptr->parent;
|
||||
if ($obj->_isSubTpl()) {
|
||||
$obj->smarty->ext->_tplFunction->registerTplFunctions($obj->parent, $tplFunctions, false);
|
||||
} else {
|
||||
$obj->smarty->tplFunctions = $override ? array_merge($obj->smarty->tplFunctions, $tplFunctions) :
|
||||
array_merge($tplFunctions, $obj->smarty->tplFunctions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return source parameter array for single or all template functions
|
||||
*
|
||||
* @param null|string $name template function name
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param null|string $name template function name
|
||||
*
|
||||
* @return array|bool|mixed
|
||||
*/
|
||||
public function getTplFunction($name = null)
|
||||
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return $this->tplFunctions[ $name ] ? $this->tplFunctions[ $name ] : false;
|
||||
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
|
||||
} else {
|
||||
return $this->tplFunctions;
|
||||
return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
*/
|
||||
public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function)
|
||||
{
|
||||
$funcParam = $this->tplFunctions[ $_name ];
|
||||
$funcParam = $tpl->tplFunctions[ $_name ];
|
||||
if (is_file($funcParam[ 'compiled_filepath' ])) {
|
||||
// read compiled file
|
||||
$code = file_get_contents($funcParam[ 'compiled_filepath' ]);
|
||||
@@ -120,7 +120,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
}
|
||||
// add template function code to cache file
|
||||
if (isset($tplPtr->cached)) {
|
||||
/* @var Smarty_CacheResource $cache */
|
||||
/* @var Smarty_Template_Cached $cache */
|
||||
$cache = $tplPtr->cached;
|
||||
$content = $cache->read($tplPtr);
|
||||
if ($content) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user