Smarty 3.1.13 - see changelog
This commit is contained in:
parent
9674ffb106
commit
9012161c8b
@ -1,4 +1,4 @@
|
||||
Smarty 3.1.12
|
||||
Smarty 3.1.13
|
||||
|
||||
Author: Monte Ohrt <monte at ohrt dot com >
|
||||
Author: Uwe Tews
|
||||
|
@ -1,4 +1,35 @@
|
||||
===== Smarty-3.1.12 =====
|
||||
===== Smarty-3.1.13 =====
|
||||
13.01.2013
|
||||
- enhancement allow to disable exception message escaping by SmartyException::$escape = false; (Issue #130)
|
||||
|
||||
09.01.2013
|
||||
- bugfix compilation did fail when a prefilter did modify an {extends} tag (Forum Topic 23966)
|
||||
- bugfix template inheritance could fail if nested {block} tags in childs did contain {$smarty.block.child} (Issue #127)
|
||||
- bugfix template inheritance could fail if {block} tags in childs did have similar name as used plugins (Issue #128)
|
||||
- added abstract method declaration doCompile() in Smarty_Internal_TemplateCompilerBase (Forum Topic 23969)
|
||||
|
||||
06.01.2013
|
||||
- Allow '://' URL syntax in template names of stream resources (Issue #129)
|
||||
|
||||
27.11.2012
|
||||
- bugfix wrong variable usage in smarty_internal_utility.php (Issue #125)
|
||||
|
||||
26.11.2012
|
||||
- bugfix global variable assigned within template function are not seen after template function exit (Forum Topic 23800)
|
||||
|
||||
24.11.2012
|
||||
- made SmartyBC loadable via composer (Issue #124)
|
||||
|
||||
20.11.2012
|
||||
- bugfix assignGlobal() called from plugins did not work (Forum Topic 23771)
|
||||
|
||||
13.11.2012
|
||||
- adding attribute "strict" to html_options, html_checkboxes, html_radios to only print disabled/readonly attributes if their values are true or "disabled"/"readonly" (Issue #120)
|
||||
|
||||
01.11.2012
|
||||
- bugfix muteExcpetedErrors() would screw up for non-readable paths (Issue #118)
|
||||
|
||||
===== Smarty-3.1.12 =====
|
||||
14.09.2012
|
||||
- bugfix template inheritance failed to compile with delimiters {/ and /} (Forum Topic 23008)
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: Smarty.class.php
|
||||
* SVN: $Id: Smarty.class.php 4658 2012-09-11 16:23:30Z uwe.tews@googlemail.com $
|
||||
* SVN: $Id: Smarty.class.php 4694 2013-01-13 21:13:14Z uwe.tews@googlemail.com $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -28,7 +28,7 @@
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
* @version 3.1.12
|
||||
* @version 3.1.13
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -113,7 +113,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = 'Smarty-3.1.12';
|
||||
const SMARTY_VERSION = 'Smarty-3.1.13';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
@ -1392,10 +1392,12 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
// add the SMARTY_DIR to the list of muted directories
|
||||
if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
|
||||
$smarty_dir = realpath(SMARTY_DIR);
|
||||
Smarty::$_muted_directories[SMARTY_DIR] = array(
|
||||
'file' => $smarty_dir,
|
||||
'length' => strlen($smarty_dir),
|
||||
);
|
||||
if ($smarty_dir !== false) {
|
||||
Smarty::$_muted_directories[SMARTY_DIR] = array(
|
||||
'file' => $smarty_dir,
|
||||
'length' => strlen($smarty_dir),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// walk the muted directories and test against $errfile
|
||||
@ -1403,6 +1405,11 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
if (!$dir) {
|
||||
// resolve directory and length for speedy comparisons
|
||||
$file = realpath($key);
|
||||
if ($file === false) {
|
||||
// this directory does not exist, remove and skip it
|
||||
unset(Smarty::$_muted_directories[$key]);
|
||||
continue;
|
||||
}
|
||||
$dir = array(
|
||||
'file' => $file,
|
||||
'length' => strlen($file),
|
||||
@ -1481,8 +1488,9 @@ if (Smarty::$_CHARSET !== 'UTF-8') {
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyException extends Exception {
|
||||
public static $escape = true;
|
||||
public function __construct($message) {
|
||||
$this->message = htmlentities($message);
|
||||
$this->message = self::$escape ? htmlentities($message) : $message;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,23 @@ function smarty_function_html_checkboxes($params, $template)
|
||||
case 'assign':
|
||||
break;
|
||||
|
||||
case 'strict': break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
|
@ -90,7 +90,24 @@ function smarty_function_html_options($params, $template)
|
||||
$selected = smarty_function_escape_special_chars((string) $_val);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case 'strict': break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
|
@ -102,6 +102,23 @@ function smarty_function_html_radios($params, $template)
|
||||
case 'assign':
|
||||
break;
|
||||
|
||||
case 'strict': break;
|
||||
|
||||
case 'disabled':
|
||||
case 'readonly':
|
||||
if (!empty($params['strict'])) {
|
||||
if (!is_scalar($_val)) {
|
||||
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($_val === true || $_val === $_key) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// omit break; to fall through!
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
|
@ -89,8 +89,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
} else {
|
||||
$_name = trim($_match[3], '\'"');
|
||||
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
||||
// do we have {$smart.block.child} in nested {block} tags?
|
||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})([\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", $block_content, $_match2)) {
|
||||
// get nested block tags
|
||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)(.*)?({$_ldl}{$al}/block\s*{$_rdl})!", $block_content, $_match2)) {
|
||||
foreach ($_match2[3] as $key => $name) {
|
||||
// get it's replacement
|
||||
$_name2 = trim($name, '\'"');
|
||||
@ -101,12 +101,17 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
$replacement = '';
|
||||
}
|
||||
// replace {$smarty.block.child} tag
|
||||
$search = array("!({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}/block\s*{$_rdl})!", "/§§§child§§§/");
|
||||
$replace = array('\2§§§child§§§\4', $replacement);
|
||||
$block_content = preg_replace($search, $replace, $block_content);
|
||||
if (preg_match("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!",$_match2[7][$key])) {
|
||||
$replacement = preg_replace("!({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})!", $replacement, $_match2[7][$key]);
|
||||
$block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl}))!", $replacement, $block_content);
|
||||
}
|
||||
if (preg_match("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!",$_match2[8][$key])) {
|
||||
$replacement = preg_replace("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!", $replacement, $_match2[8][$key]);
|
||||
$block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl})(.*)?({$_ldl}{$al}/block\s*{$_rdl}))!", $replacement, $block_content);
|
||||
}
|
||||
} else {
|
||||
// remove hidden blocks
|
||||
$block_content = preg_replace("!({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", '', $block_content);
|
||||
$block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl}))!", '', $block_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
||||
$compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
|
||||
}
|
||||
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
|
||||
$_content = ($this->mbstring_overload ? mb_substr($compiler->template->source->content, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->template->source->content, $compiler->lex->counter - 1));
|
||||
$_content = ($this->mbstring_overload ? mb_substr($compiler->lex->data, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->lex->data, $compiler->lex->counter - 1));
|
||||
if (preg_match_all("!({$this->_ldl}{$al}block\s(.+?)\s*{$this->_rdl})!", $_content, $s) !=
|
||||
preg_match_all("!({$this->_ldl}{$al}/block\s*{$this->_rdl})!", $_content, $c)) {
|
||||
$compiler->trigger_template_error('unmatched {block} {/block} pairs');
|
||||
|
@ -149,7 +149,8 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$compiler->has_code = false;
|
||||
$output = true;
|
||||
} else {
|
||||
$output = $plugins_string . $compiler->parser->current_buffer->to_smarty_php() . "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}}?>\n";
|
||||
$output = $plugins_string . $compiler->parser->current_buffer->to_smarty_php() . "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;
|
||||
foreach (Smarty::\$global_tpl_vars as \$key => \$value) if(!isset(\$_smarty_tpl->tpl_vars[\$key])) \$_smarty_tpl->tpl_vars[\$key] = \$value;}}?>\n";
|
||||
}
|
||||
// reset flag that we are compiling a template function
|
||||
$compiler->compiles_template_function = false;
|
||||
|
@ -77,7 +77,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||
break;
|
||||
}
|
||||
return '@' . trim($_index[1], "'");
|
||||
return "@constant({$_index[1]})";
|
||||
|
||||
case 'config':
|
||||
if (isset($_index[2])) {
|
||||
|
@ -80,6 +80,11 @@ class Smarty_Internal_Data {
|
||||
{
|
||||
if ($varname != '') {
|
||||
Smarty::$global_tpl_vars[$varname] = new Smarty_variable($value, $nocache);
|
||||
$ptr = $this;
|
||||
while ($ptr instanceof Smarty_Internal_Template) {
|
||||
$ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
|
||||
$ptr = $ptr->parent;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -1,36 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Stream
|
||||
*
|
||||
* Implements the streams as resource for Smarty template
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
* Smarty Internal Plugin Resource Stream
|
||||
*
|
||||
* Implements the streams as resource for Smarty template
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Resource Stream
|
||||
*
|
||||
* Implements the streams as resource for Smarty template
|
||||
*
|
||||
* @link http://php.net/streams
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
*/
|
||||
* Smarty Internal Plugin Resource Stream
|
||||
*
|
||||
* Implements the streams as resource for Smarty template
|
||||
*
|
||||
* @link http://php.net/streams
|
||||
* @package Smarty
|
||||
* @subpackage TemplateResources
|
||||
*/
|
||||
class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled {
|
||||
|
||||
/**
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @return void
|
||||
*/
|
||||
* populate Source Object with meta data from Resource
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @return void
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
|
||||
{
|
||||
$source->filepath = str_replace(':', '://', $source->resource);
|
||||
if(strpos($source->resource, '://') !== false) {
|
||||
$source->filepath = $source->resource;
|
||||
} else {
|
||||
$source->filepath = str_replace(':', '://', $source->resource);
|
||||
}
|
||||
$source->uid = false;
|
||||
$source->content = $this->getContent($source);
|
||||
$source->timestamp = false;
|
||||
@ -38,12 +42,12 @@ class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load template's source from stream into current template object
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @return string template source
|
||||
* @throws SmartyException if source cannot be loaded
|
||||
*/
|
||||
* Load template's source from stream into current template object
|
||||
*
|
||||
* @param Smarty_Template_Source $source source object
|
||||
* @return string template source
|
||||
* @throws SmartyException if source cannot be loaded
|
||||
*/
|
||||
public function getContent(Smarty_Template_Source $source)
|
||||
{
|
||||
$t = '';
|
||||
@ -59,18 +63,16 @@ class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* modify resource_name according to resource handlers specifications
|
||||
*
|
||||
* @param Smarty $smarty Smarty instance
|
||||
* @param string $resource_name resource_name to make unique
|
||||
* @return string unique resource name
|
||||
*/
|
||||
* modify resource_name according to resource handlers specifications
|
||||
*
|
||||
* @param Smarty $smarty Smarty instance
|
||||
* @param string $resource_name resource_name to make unique
|
||||
* @return string unique resource name
|
||||
*/
|
||||
protected function buildUniqueResourceName(Smarty $smarty, $resource_name)
|
||||
{
|
||||
return get_class($this) . '#' . $resource_name;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -136,6 +136,14 @@ abstract class Smarty_Internal_TemplateCompilerBase {
|
||||
*/
|
||||
public $known_modifier_type = array();
|
||||
|
||||
/**
|
||||
* Methode to compile a Smarty template
|
||||
*
|
||||
* @param mixed $_content template source
|
||||
* @return bool true if compiling succeeded, false if it failed
|
||||
*/
|
||||
abstract protected function doCompile($_content);
|
||||
|
||||
/**
|
||||
* Initialize compiler
|
||||
*/
|
||||
|
@ -72,8 +72,8 @@ class Smarty_Internal_Utility {
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs);
|
||||
foreach ($_compile as $_fileinfo) {
|
||||
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
$_file = $_fileinfo->getFilename();
|
||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||
$_template_file = $_file;
|
||||
@ -136,8 +136,8 @@ class Smarty_Internal_Utility {
|
||||
$_compileDirs = new RecursiveDirectoryIterator($_dir);
|
||||
$_compile = new RecursiveIteratorIterator($_compileDirs);
|
||||
foreach ($_compile as $_fileinfo) {
|
||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_fileinfo, '.svn') !== false) continue;
|
||||
$_file = $_fileinfo->getFilename();
|
||||
if (substr(basename($_fileinfo->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
|
||||
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
|
||||
if ($_fileinfo->getPath() == substr($_dir, 0, -1)) {
|
||||
$_config_file = $_file;
|
||||
|
Loading…
x
Reference in New Issue
Block a user