aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty')
-rw-r--r--library/Smarty/NEW_FEATURES.txt15
-rw-r--r--library/Smarty/change_log.txt16
-rw-r--r--library/Smarty/libs/Smarty.class.php10
-rw-r--r--library/Smarty/libs/plugins/modifiercompiler.strip_tags.php2
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_function.php12
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_foreachsection.php13
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php2
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_debug.php18
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php54
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php3
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_runtime_tplfunc.php97
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_template.php6
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php61
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_testinstall.php61
14 files changed, 173 insertions, 197 deletions
diff --git a/library/Smarty/NEW_FEATURES.txt b/library/Smarty/NEW_FEATURES.txt
index 67d391a52..595dc4d3c 100644
--- a/library/Smarty/NEW_FEATURES.txt
+++ b/library/Smarty/NEW_FEATURES.txt
@@ -21,13 +21,18 @@ Smarty 3.1.28
fetch() and display()
=====================
The fetch() and display() methods of the template object accept now optionally the same parameter
- as the corresponding Smarty methods the get tne content of another template.
+ as the corresponding Smarty methods to get tne content of another template.
+ Example:
+ $template->display(); Does display template of template object
+ $template->dispaly('foo.tpl'); Does display template 'foo.bar'
File: resource
==============
Multiple template_dir entries can now be selected by a comma separated list of indices.
- The template_dir array is searched in the order of the indices. (could be used to change the default search order)
-
+ The template_dir array is searched in the order of the indices. (Could be used to change the default search order)
+ Example:
+ $smarty->display([1],[0]foo.bar');
+
Filter support
==============
Optional filter names
@@ -40,8 +45,8 @@ Smarty 3.1.28
- $smarty->registerFilter('pre', function($source) {return $source;});
If no optional filter name was specified it gets the default name 'closure'.
If you register multiple closures register each with a unique filter name.
- - $smarty->registerFilter('pre', function($source) {return $source;}, 'clousre_1');
- - $smarty->registerFilter('pre', function($source) {return $source;}, 'clousre_2');
+ - $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_1');
+ - $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_2');
Smarty 3.1.22
diff --git a/library/Smarty/change_log.txt b/library/Smarty/change_log.txt
index 2bcdfd024..cecda63d1 100644
--- a/library/Smarty/change_log.txt
+++ b/library/Smarty/change_log.txt
@@ -1,4 +1,18 @@
- ===== 3.1.28-dev===== (xx.xx.2015)
+ ===== 3.1.28 ===== (13.12.2015)
+ 13.12.2015
+ - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819)
+ - bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811)
+ - bugfix Debug Console could display incorrect data when using subtemplates
+
+ 09.12.2015
+ - bugix Smarty did fail under PHP 7.0.0 with use_include_path = true;
+
+ 09.12.2015
+ -bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111
+
+ 08.12.2015
+ - bugfix internal template function data got stored in wrong compiled file https://github.com/smarty-php/smarty/issues/114
+
05.12.2015
-bugfix {strip} should insert a single space https://github.com/smarty-php/smarty/issues/111
diff --git a/library/Smarty/libs/Smarty.class.php b/library/Smarty/libs/Smarty.class.php
index ac09d0a43..17457131c 100644
--- a/library/Smarty/libs/Smarty.class.php
+++ b/library/Smarty/libs/Smarty.class.php
@@ -27,7 +27,7 @@
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
- * @version 3.1.28-dev
+ * @version 3.1.28
*/
/**
@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '3.1.28-dev/77';
+ const SMARTY_VERSION = '3.1.28';
/**
* define variable scopes
@@ -1094,8 +1094,12 @@ class Smarty extends Smarty_Internal_TemplateBase
$tpl->tpl_vars[$_key] = new Smarty_Variable($_val);
}
}
- if ($this->debugging) {
+ if ($this->debugging || $this->debugging_ctrl == 'URL') {
$tpl->smarty->_debug = new Smarty_Internal_Debug();
+ // check URL debugging control
+ if (!$this->debugging && $this->debugging_ctrl == 'URL') {
+ $tpl->smarty->_debug->debugUrl($tpl->smarty);
+ }
}
return $tpl;
}
diff --git a/library/Smarty/libs/plugins/modifiercompiler.strip_tags.php b/library/Smarty/libs/plugins/modifiercompiler.strip_tags.php
index 3e6e13048..da5d364cb 100644
--- a/library/Smarty/libs/plugins/modifiercompiler.strip_tags.php
+++ b/library/Smarty/libs/plugins/modifiercompiler.strip_tags.php
@@ -12,7 +12,7 @@
* Name: strip_tags<br>
* Purpose: strip html tags from text
*
- * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
+ * @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
index 26804b6ac..28f335949 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
@@ -62,7 +62,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
}
unset($_attr['nocache']);
$_name = trim($_attr['name'], "'\"");
- $compiler->parent_compiler->template->tpl_function[$_name] = array();
+ $compiler->parent_compiler->tpl_function[$_name] = $compiler->parent_compiler->template->tpl_function[$_name] = array();
$save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
$compiler->template->caching);
$this->openTag($compiler, 'function', $save);
@@ -105,9 +105,9 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$saved_data = $this->closeTag($compiler, array('function'));
$_attr = $saved_data[0];
$_name = trim($_attr['name'], "'\"");
- $compiler->parent_compiler->template->tpl_function[$_name]['called_functions'] = $compiler->called_functions;
- $compiler->parent_compiler->template->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath;
- $compiler->parent_compiler->template->tpl_function[$_name]['uid'] = $compiler->template->source->uid;
+ $compiler->parent_compiler->tpl_function[$_name]['called_functions'] = $compiler->parent_compiler->template->tpl_function[$_name]['called_functions'] = $compiler->called_functions;
+ $compiler->parent_compiler->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath;
+ $compiler->parent_compiler->tpl_function[$_name]['uid'] = $compiler->parent_compiler->template->tpl_function[$_name]['uid'] = $compiler->template->source->uid;
$compiler->called_functions = array();
$_parameter = $_attr;
unset($_parameter['name']);
@@ -133,7 +133,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
$_funcNameCaching = $_funcName . '_nocache';
if ($compiler->template->compiled->has_nocache_code) {
- $compiler->parent_compiler->template->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
+ $compiler->parent_compiler->tpl_function[$_name]['call_name_caching'] = $compiler->parent_compiler->template->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
$output = "<?php\n";
$output .= "/* {$_funcNameCaching} */\n";
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
@@ -162,7 +162,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", array($this,
'removeNocache'), $_functionCode->to_smarty_php($compiler->parser)));
}
- $compiler->parent_compiler->template->tpl_function[$_name]['call_name'] = $_funcName;
+ $compiler->parent_compiler->tpl_function[$_name]['call_name'] = $compiler->parent_compiler->template->tpl_function[$_name]['call_name'] = $_funcName;
$output = "<?php\n";
$output .= "/* {$_funcName} */\n";
$output .= "if (!function_exists('{$_funcName}')) {\n";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_foreachsection.php
index 25b35e861..50c25bdb6 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_foreachsection.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_foreachsection.php
@@ -206,16 +206,15 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
*/
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
- // make all lower case
- $parameter = array_map('strtolower', $parameter);
- $tag = trim($parameter[0], '"\'');
- if (!isset($parameter[1]) || false === $name = $compiler->getId($parameter[1])) {
+ $tag = strtolower(trim($parameter[ 0 ], '"\''));
+ $name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
+ if (!$name) {
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
}
+ /* @var Smarty_Internal_Compile_Foreach|Smarty_Internal_Compile_Section $className */
$className = 'Smarty_Internal_Compile_' . ucfirst($tag);
- if ((!isset($parameter[2]) || false === $property = $compiler->getId($parameter[2])) ||
- !in_array($property, $className::$nameProperties)
- ) {
+ $property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
+ if (!$property || !in_array($property, $className::$nameProperties)) {
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
}
$tagVar = "'__smarty_{$tag}_{$name}'";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
index 584f70b0e..3ca63a548 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
@@ -79,7 +79,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
} else {
$compiler->has_code = true;
if (!($compiler->smarty instanceof SmartyBC)) {
- $compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', null, true);
+ $compiler->trigger_template_error('{php}{/php} tags not allowed. Use SmartyBC to enable them', null, true);
}
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_debug.php b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
index e330a35c1..0cbd54955 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_debug.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
@@ -399,31 +399,31 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
/**
* handle 'URL' debugging mode
*
- * @param Smarty_Internal_Template $_template
+ * @param Smarty $smarty
*/
- public function debugUrl(Smarty_Internal_Template $_template)
+ public function debugUrl(Smarty $smarty)
{
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
- if (false !== strpos($_query_string, $_template->smarty->smarty_debug_id)) {
- if (false !== strpos($_query_string, $_template->smarty->smarty_debug_id . '=on')) {
+ if (false !== strpos($_query_string, $smarty->smarty_debug_id)) {
+ if (false !== strpos($_query_string, $smarty->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
- $_template->smarty->debugging = true;
- } elseif (false !== strpos($_query_string, $_template->smarty->smarty_debug_id . '=off')) {
+ $smarty->debugging = true;
+ } elseif (false !== strpos($_query_string, $smarty->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
- $_template->smarty->debugging = false;
+ $smarty->debugging = false;
} else {
// enable debugging for this page
- $_template->smarty->debugging = true;
+ $smarty->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
- $_template->smarty->debugging = true;
+ $smarty->debugging = true;
}
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php b/library/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php
index a3be60d40..21e6e5221 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php
@@ -17,43 +17,49 @@ class Smarty_Internal_Runtime_CodeFrame
/**
* Create code frame for compiled and cached templates
*
- * @param Smarty_Internal_Template $_template
- * @param string $content optional template content
- * @param bool $cache flag for cache file
+ * @param Smarty_Internal_Template $_template
+ * @param string $content optional template content
+ * @param string $functions compiled template function and block code
+ * @param bool $cache flag for cache file
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler
*
* @return string
*/
- public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false)
+ public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false,
+ Smarty_Internal_TemplateCompilerBase $compiler = null)
{
// build property code
- $properties['has_nocache_code'] = $_template->compiled->has_nocache_code;
- $properties['version'] = Smarty::SMARTY_VERSION;
- $properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
- if (!empty($_template->tpl_function)) {
- $properties['tpl_function'] = $_template->tpl_function;
- }
+ $properties[ 'has_nocache_code' ] = $_template->compiled->has_nocache_code;
+ $properties[ 'version' ] = Smarty::SMARTY_VERSION;
+ $properties[ 'unifunc' ] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
if (!$cache) {
- $properties['file_dependency'] = $_template->compiled->file_dependency;
- $properties['includes'] = $_template->compiled->includes;
+ $properties[ 'file_dependency' ] = $_template->compiled->file_dependency;
+ $properties[ 'includes' ] = $_template->compiled->includes;
+ if (!empty($compiler->tpl_function)) {
+ $properties[ 'tpl_function' ] = $compiler->tpl_function;
+ }
} else {
- $properties['file_dependency'] = $_template->cached->file_dependency;
- $properties['cache_lifetime'] = $_template->cache_lifetime;
+ $properties[ 'file_dependency' ] = $_template->cached->file_dependency;
+ $properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
+ if (!empty($_template->tpl_function)) {
+ $properties[ 'tpl_function' ] = $_template->tpl_function;
+ }
}
$output = "<?php\n";
$output .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
"\n from \"" . $_template->source->filepath . "\" */\n\n";
- $dec = "\$_smarty_tpl->smarty->ext->_validateCompiled->decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
- ($cache ? 'true' : 'false') . ")";
+ $dec = "\$_smarty_tpl->smarty->ext->_validateCompiled->decodeProperties(\$_smarty_tpl, " .
+ var_export($properties, true) . ',' . ($cache ? 'true' : 'false') . ")";
$output .= "if ({$dec}) {\n";
$output .= "function {$properties['unifunc']} (\$_smarty_tpl) {\n";
// include code for plugins
if (!$cache) {
- if (!empty($_template->compiled->required_plugins['compiled'])) {
- foreach ($_template->compiled->required_plugins['compiled'] as $tmp) {
+ if (!empty($_template->compiled->required_plugins[ 'compiled' ])) {
+ foreach ($_template->compiled->required_plugins[ 'compiled' ] as $tmp) {
foreach ($tmp as $data) {
- $file = addslashes($data['file']);
- if (is_array($data['function'])) {
+ $file = addslashes($data[ 'file' ]);
+ if (is_array($data[ 'function' ])) {
$output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
} else {
$output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
@@ -61,13 +67,13 @@ class Smarty_Internal_Runtime_CodeFrame
}
}
}
- if ($_template->caching && !empty($_template->compiled->required_plugins['nocache'])) {
+ if ($_template->caching && !empty($_template->compiled->required_plugins[ 'nocache' ])) {
$_template->compiled->has_nocache_code = true;
$output .= "echo '/*%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
- foreach ($_template->compiled->required_plugins['nocache'] as $tmp) {
+ foreach ($_template->compiled->required_plugins[ 'nocache' ] as $tmp) {
foreach ($tmp as $data) {
- $file = addslashes($data['file']);
- if (is_Array($data['function'])) {
+ $file = addslashes($data[ 'file' ]);
+ if (is_Array($data[ 'function' ])) {
$output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
} else {
$output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php b/library/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php
index 965c95f8b..72149cd35 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php
@@ -86,9 +86,6 @@ class Smarty_Internal_Runtime_GetIncludePath
$this->_include_path = $_i_path;
$_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
foreach ($_dirs as $_path) {
- if ($_path[0] != '/' && isset($dir[1]) && $dir[1] != ':') {
- $_path = $smarty->_realpath($_path . DS, true);
- }
if (is_dir($_path)) {
$this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_runtime_tplfunc.php b/library/Smarty/libs/sysplugins/smarty_internal_runtime_tplfunc.php
deleted file mode 100644
index ec9d8da6b..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_runtime_tplfunc.php
+++ /dev/null
@@ -1,97 +0,0 @@
-<?php
-
-/**
- * Tplfunc Runtime Methods callTemplateFunction
- *
- * @package Smarty
- * @subpackage PluginsInternal
- * @author Uwe Tews
- *
- **/
-class Smarty_Internal_Runtime_Tplfunc
-{
- /**
- * Call template function
- *
- * @param \Smarty_Internal_Template $tpl template object
- * @param string $name template function name
- * @param array $params parameter array
- * @param bool $nocache true if called nocache
- *
- * @throws \SmartyException
- */
- public function callTemplateFunction(\Smarty_Internal_Template $tpl, $name, $params, $nocache)
- {
- if (isset($tpl->tpl_function[$name])) {
- if (!$tpl->caching || ($tpl->caching && $nocache)) {
- $function = $tpl->tpl_function[$name]['call_name'];
- } else {
- if (isset($tpl->tpl_function[$name]['call_name_caching'])) {
- $function = $tpl->tpl_function[$name]['call_name_caching'];
- } else {
- $function = $tpl->tpl_function[$name]['call_name'];
- }
- }
- if (function_exists($function)) {
- $function ($tpl, $params);
- return;
- }
- // try to load template function dynamically
- if ($this->addTplFuncToCache($tpl, $name, $function)) {
- $function ($tpl, $params);
- return;
- }
- }
- throw new SmartyException("Unable to find template function '{$name}'");
- }
-
- /**
- *
- * Add template function to cache file for nocache calls
- *
- * @param Smarty_Internal_Template $tpl
- * @param string $_name template function name
- * @param string $_function PHP function name
- *
- * @return bool
- */
- public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function)
- {
- $funcParam = $tpl->tpl_function[$_name];
- if (is_file($funcParam['compiled_filepath'])) {
- // read compiled file
- $code = file_get_contents($funcParam['compiled_filepath']);
- // grab template function
- if (preg_match("/\/\* {$_function} \*\/([\S\s]*?)\/\*\/ {$_function} \*\//", $code, $match)) {
- // grab source info from file dependency
- preg_match("/\s*'{$funcParam['uid']}'([\S\s]*?)\),/", $code, $match1);
- unset($code);
- // make PHP function known
- eval($match[0]);
- if (function_exists($_function)) {
- // search cache file template
- $tplPtr = $tpl;
- while (!isset($tplPtr->cached) && isset($tplPtr->parent)) {
- $tplPtr = $tplPtr->parent;
- }
- // add template function code to cache file
- if (isset($tplPtr->cached)) {
- $cache = $tplPtr->cached;
- $content = $cache->read($tplPtr);
- if ($content) {
- // check if we must update file dependency
- if (!preg_match("/'{$funcParam['uid']}'(.*?)'nocache_hash'/", $content, $match2)) {
- $content = preg_replace("/('file_dependency'(.*?)\()/", "\\1{$match1[0]}", $content);
- }
- $cache->write($tplPtr, preg_replace('/\s*\?>\s*$/', "\n", $content) . "\n" .
- preg_replace(array('/^\s*<\?php\s+/', '/\s*\?>\s*$/'), "\n",
- $match[0]));
- }
- }
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_template.php b/library/Smarty/libs/sysplugins/smarty_internal_template.php
index 52c7391b1..7c16a53db 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_template.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_template.php
@@ -138,10 +138,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
}
- // check URL debugging control
- if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
- $this->smarty->_debug->debugUrl($this);
- }
// disable caching for evaluated code
if ($this->source->handler->recompiled) {
$this->caching = false;
@@ -188,7 +184,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
} else {
if ($this->smarty->debugging) {
$this->smarty->_debug->end_template($this);
- if ($this->smarty->debugging == 2 and !$display) {
+ if ($this->smarty->debugging === 2 && $display === false) {
$this->smarty->_debug->display_debug($this, true);
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php b/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
index 9487c3454..04584a40f 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
@@ -150,6 +150,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $write_compiled_code = true;
/**
+ * Template functions
+ *
+ * @var array
+ */
+ public $tpl_function = array();
+
+ /**
* called sub functions from template function
*
* @var array
@@ -321,7 +328,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->compileTemplateSource($template, $nocache,
$parent_compiler),
$this->postFilter($this->blockOrFunctionCode) .
- join('', $this->mergedSubTemplatesCode));
+ join('', $this->mergedSubTemplatesCode), false, $this);
return $_compiled_code;
}
@@ -776,12 +783,58 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public function processText($text)
{
+ $store = array();
+ $_store = 0;
+ $_offset = 0;
if ($this->parser->strip) {
- return new Smarty_Internal_ParseTree_Text(preg_replace($this->stripRegEx, ' ', $text));
- } else {
+ if (strpos($text, '<') !== false) {
+ // capture html elements not to be messed with
+ $_offset = 0;
+ if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
+ $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $store[] = $match[ 0 ][ 0 ];
+ $_length = strlen($match[ 0 ][ 0 ]);
+ $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
+ $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
+
+ $_offset += $_length - strlen($replace);
+ $_store ++;
+ }
+ }
+
+ $expressions = array(// replace multiple spaces between tags by a single space
+ // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
+ '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
+ // remove spaces between attributes (but not in attribute values!)
+ '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
+ '#^\s+<#Ss' => '<',
+ '#>\s+$#Ss' => '>',
+ $this->stripRegEx => ''
+ );
+
+ $text = preg_replace(array_keys($expressions), array_values($expressions), $text);
+ $_offset = 0;
+ if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
+ PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
+ foreach ($matches as $match) {
+ $_length = strlen($match[ 0 ][ 0 ]);
+ $replace = $store[ $match[ 1 ][ 0 ] ];
+ $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
+
+ $_offset += strlen($replace) - $_length;
+ $_store ++;
+ }
+ }
+ } else {
+ $text = preg_replace($this->stripRegEx, '', $text);
+ }
+ }
+ if ($text) {
return new Smarty_Internal_ParseTree_Text($text);
}
- }
+ return null;
+ }
/**
* lazy loads internal compile plugin for tag and calls the compile method
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php b/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
index 5b6475ccc..72d9a5211 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
@@ -63,7 +63,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['template_dir'] = $message;
+ $errors[ 'template_dir' ] = $message;
}
continue;
@@ -74,7 +74,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['template_dir'] = $message;
+ $errors[ 'template_dir' ] = $message;
}
continue;
@@ -87,7 +87,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['template_dir'] = $message;
+ $errors[ 'template_dir' ] = $message;
}
} elseif (!is_readable($template_dir)) {
$status = false;
@@ -95,7 +95,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['template_dir'] = $message;
+ $errors[ 'template_dir' ] = $message;
}
} else {
if ($errors === null) {
@@ -117,7 +117,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['compile_dir'] = $message;
+ $errors[ 'compile_dir' ] = $message;
}
} elseif (!is_dir($_compile_dir)) {
$status = false;
@@ -125,7 +125,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['compile_dir'] = $message;
+ $errors[ 'compile_dir' ] = $message;
}
} elseif (!is_readable($_compile_dir)) {
$status = false;
@@ -133,7 +133,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['compile_dir'] = $message;
+ $errors[ 'compile_dir' ] = $message;
}
} elseif (!is_writable($_compile_dir)) {
$status = false;
@@ -141,7 +141,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['compile_dir'] = $message;
+ $errors[ 'compile_dir' ] = $message;
}
} else {
if ($errors === null) {
@@ -182,7 +182,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins_dir'] = $message;
+ $errors[ 'plugins_dir' ] = $message;
}
continue;
@@ -193,7 +193,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins_dir'] = $message;
+ $errors[ 'plugins_dir' ] = $message;
}
continue;
@@ -206,7 +206,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins_dir'] = $message;
+ $errors[ 'plugins_dir' ] = $message;
}
} elseif (!is_readable($plugin_dir)) {
$status = false;
@@ -214,7 +214,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins_dir'] = $message;
+ $errors[ 'plugins_dir' ] = $message;
}
} elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) {
$_core_plugins_available = true;
@@ -232,8 +232,8 @@ class Smarty_Internal_TestInstall
$message = "WARNING: Smarty's own libs/plugins is not available";
if ($errors === null) {
echo $message . ".\n";
- } elseif (!isset($errors['plugins_dir'])) {
- $errors['plugins_dir'] = $message;
+ } elseif (!isset($errors[ 'plugins_dir' ])) {
+ $errors[ 'plugins_dir' ] = $message;
}
}
@@ -250,7 +250,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['cache_dir'] = $message;
+ $errors[ 'cache_dir' ] = $message;
}
} elseif (!is_dir($_cache_dir)) {
$status = false;
@@ -258,7 +258,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['cache_dir'] = $message;
+ $errors[ 'cache_dir' ] = $message;
}
} elseif (!is_readable($_cache_dir)) {
$status = false;
@@ -266,7 +266,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['cache_dir'] = $message;
+ $errors[ 'cache_dir' ] = $message;
}
} elseif (!is_writable($_cache_dir)) {
$status = false;
@@ -274,7 +274,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['cache_dir'] = $message;
+ $errors[ 'cache_dir' ] = $message;
}
} else {
if ($errors === null) {
@@ -311,7 +311,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['config_dir'] = $message;
+ $errors[ 'config_dir' ] = $message;
}
continue;
@@ -322,7 +322,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['config_dir'] = $message;
+ $errors[ 'config_dir' ] = $message;
}
continue;
@@ -335,7 +335,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['config_dir'] = $message;
+ $errors[ 'config_dir' ] = $message;
}
} elseif (!is_readable($config_dir)) {
$status = false;
@@ -343,7 +343,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['config_dir'] = $message;
+ $errors[ 'config_dir' ] = $message;
}
} else {
if ($errors === null) {
@@ -476,7 +476,6 @@ class Smarty_Internal_TestInstall
'smarty_internal_runtime_getincludepath.php' => true,
'smarty_internal_runtime_hhvm.php' => true,
'smarty_internal_runtime_inheritance.php' => true,
- 'smarty_internal_runtime_iscached.php' => true,
'smarty_internal_runtime_subtemplate.php' => true,
'smarty_internal_runtime_tplfunction.php' => true,
'smarty_internal_runtime_updatecache.php' => true,
@@ -508,8 +507,8 @@ class Smarty_Internal_TestInstall
foreach ($iterator as $file) {
if (!$file->isDot()) {
$filename = $file->getFilename();
- if (isset($expectedSysplugins[$filename])) {
- unset($expectedSysplugins[$filename]);
+ if (isset($expectedSysplugins[ $filename ])) {
+ unset($expectedSysplugins[ $filename ]);
}
}
}
@@ -519,7 +518,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['sysplugins'] = $message;
+ $errors[ 'sysplugins' ] = $message;
}
} elseif ($errors === null) {
echo "... OK\n";
@@ -530,7 +529,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['sysplugins_dir_constant'] = $message;
+ $errors[ 'sysplugins_dir_constant' ] = $message;
}
}
@@ -569,8 +568,8 @@ class Smarty_Internal_TestInstall
foreach ($iterator as $file) {
if (!$file->isDot()) {
$filename = $file->getFilename();
- if (isset($expectedPlugins[$filename])) {
- unset($expectedPlugins[$filename]);
+ if (isset($expectedPlugins[ $filename ])) {
+ unset($expectedPlugins[ $filename ]);
}
}
}
@@ -580,7 +579,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins'] = $message;
+ $errors[ 'plugins' ] = $message;
}
} elseif ($errors === null) {
echo "... OK\n";
@@ -591,7 +590,7 @@ class Smarty_Internal_TestInstall
if ($errors === null) {
echo $message . ".\n";
} else {
- $errors['plugins_dir_constant'] = $message;
+ $errors[ 'plugins_dir_constant' ] = $message;
}
}