updated smarty to last stable build

This commit is contained in:
real_nowhereman 2011-04-12 08:18:10 +00:00
parent 0e962daf68
commit 10a56bc3d0
9 changed files with 137 additions and 64 deletions

View File

@ -17,15 +17,19 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://smarty.php.net/
* @version 2.6.18
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @version 2.6.26
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net>
* @access public
* @package Smarty
*/
/* $Id: Config_File.class.php,v 1.88 2007/03/06 10:40:06 messju Exp $ */
/* $Id: Config_File.class.php 3149 2009-05-23 20:59:25Z monte.ohrt $ */
/**
* Config file reading class

View File

@ -20,17 +20,17 @@
*
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-general-subscribe@lists.php.net
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://smarty.php.net/
* @link http://www.smarty.net/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.18
* @version 2.6.26
*/
/* $Id: Smarty.class.php,v 1.528 2007/03/06 10:40:06 messju Exp $ */
/* $Id: Smarty.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
@ -107,7 +107,7 @@ class Smarty
/**
* When set, smarty does uses this value as error_reporting-level.
*
* @var boolean
* @var integer
*/
var $error_reporting = null;
@ -236,7 +236,8 @@ class Smarty
'INCLUDE_ANY' => false,
'PHP_TAGS' => false,
'MODIFIER_FUNCS' => array('count'),
'ALLOW_CONSTANTS' => false
'ALLOW_CONSTANTS' => false,
'ALLOW_SUPER_GLOBALS' => true
);
/**
@ -464,7 +465,7 @@ class Smarty
*
* @var string
*/
var $_version = '2.6.18';
var $_version = '2.6.26';
/**
* current template inclusion depth
@ -838,69 +839,66 @@ class Smarty
* Registers a prefilter function to apply
* to a template before compiling
*
* @param string $function name of PHP function to register
* @param callback $function
*/
function register_prefilter($function)
{
$_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['prefilter'][$_name]
$this->_plugins['prefilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a prefilter function
*
* @param string $function name of PHP function
* @param callback $function
*/
function unregister_prefilter($function)
{
unset($this->_plugins['prefilter'][$function]);
unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
}
/**
* Registers a postfilter function to apply
* to a compiled template after compilation
*
* @param string $function name of PHP function to register
* @param callback $function
*/
function register_postfilter($function)
{
$_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['postfilter'][$_name]
$this->_plugins['postfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters a postfilter function
*
* @param string $function name of PHP function
* @param callback $function
*/
function unregister_postfilter($function)
{
unset($this->_plugins['postfilter'][$function]);
unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
}
/**
* Registers an output filter function to apply
* to a template output
*
* @param string $function name of PHP function
* @param callback $function
*/
function register_outputfilter($function)
{
$_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['outputfilter'][$_name]
$this->_plugins['outputfilter'][$this->_get_filter_name($function)]
= array($function, null, null, false);
}
/**
* Unregisters an outputfilter function
*
* @param string $function name of PHP function
* @param callback $function
*/
function unregister_outputfilter($function)
{
unset($this->_plugins['outputfilter'][$function]);
unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
}
/**
@ -1551,7 +1549,7 @@ class Smarty
$params['source_content'] = $this->_read_file($_resource_name);
}
$params['resource_timestamp'] = filemtime($_resource_name);
$_return = is_file($_resource_name);
$_return = is_file($_resource_name) && is_readable($_resource_name);
break;
default:
@ -1714,7 +1712,7 @@ class Smarty
*/
function _read_file($filename)
{
if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
if ( file_exists($filename) && is_readable($filename) && ($fd = @fopen($filename, 'rb')) ) {
$contents = '';
while (!feof($fd)) {
$contents .= fread($fd, 8192);
@ -1935,6 +1933,25 @@ class Smarty
{
return eval($code);
}
/**
* Extracts the filter name from the given callback
*
* @param callback $function
* @return string
*/
function _get_filter_name($function)
{
if (is_array($function)) {
$_class_name = (is_object($function[0]) ?
get_class($function[0]) : $function[0]);
return $_class_name . '_' . $function[1];
}
else {
return $function;
}
}
/**#@-*/
}

View File

@ -21,12 +21,12 @@
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @version 2.6.18
* @version 2.6.26
* @copyright 2001-2005 New Digital Group, Inc.
* @package Smarty
*/
/* $Id: Smarty_Compiler.class.php,v 1.395 2007/03/06 10:40:06 messju Exp $ */
/* $Id: Smarty_Compiler.class.php 3163 2009-06-17 14:39:24Z monte.ohrt $ */
/**
* Template compiling class
@ -869,7 +869,7 @@ class Smarty_Compiler extends Smarty {
// traditional argument format
$args = implode(',', array_values($attrs));
if (empty($args)) {
$args = 'null';
$args = '';
}
}
@ -1171,7 +1171,7 @@ class Smarty_Compiler extends Smarty {
}
$item = $this->_dequote($attrs['item']);
if (!preg_match('~^\w+$~', $item)) {
return $this->_syntax_error("'foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
return $this->_syntax_error("foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
}
if (isset($attrs['key'])) {
@ -1222,23 +1222,21 @@ class Smarty_Compiler extends Smarty {
$attrs = $this->_parse_attrs($tag_args);
if ($start) {
if (isset($attrs['name']))
$buffer = $attrs['name'];
else
$buffer = "'default'";
if (isset($attrs['assign']))
$assign = $attrs['assign'];
else
$assign = null;
$buffer = isset($attrs['name']) ? $attrs['name'] : "'default'";
$assign = isset($attrs['assign']) ? $attrs['assign'] : null;
$append = isset($attrs['append']) ? $attrs['append'] : null;
$output = "<?php ob_start(); ?>";
$this->_capture_stack[] = array($buffer, $assign);
$this->_capture_stack[] = array($buffer, $assign, $append);
} else {
list($buffer, $assign) = array_pop($this->_capture_stack);
list($buffer, $assign, $append) = array_pop($this->_capture_stack);
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
if (isset($assign)) {
$output .= " \$this->assign($assign, ob_get_contents());";
}
if (isset($append)) {
$output .= " \$this->append($append, ob_get_contents());";
}
$output .= "ob_end_clean(); ?>";
}
@ -1365,9 +1363,14 @@ class Smarty_Compiler extends Smarty {
/* If last token was a ')', we operate on the parenthesized
expression. The start of the expression is on the stack.
Otherwise, we operate on the last encountered token. */
if ($tokens[$i-1] == ')')
if ($tokens[$i-1] == ')') {
$is_arg_start = array_pop($is_arg_stack);
else
if ($is_arg_start != 0) {
if (preg_match('~^' . $this->_func_regexp . '$~', $tokens[$is_arg_start-1])) {
$is_arg_start--;
}
}
} else
$is_arg_start = $i-1;
/* Construct the argument for 'is' expression, so it knows
what to operate on. */
@ -2044,27 +2047,57 @@ class Smarty_Compiler extends Smarty {
break;
case 'get':
$compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_GET";
break;
case 'post':
$compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_POST";
break;
case 'cookies':
$compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_COOKIE";
break;
case 'env':
$compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_ENV";
break;
case 'server':
$compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_SERVER";
break;
case 'session':
$compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']";
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
$compiled_ref = "\$_SESSION";
break;
/*
@ -2072,8 +2105,13 @@ class Smarty_Compiler extends Smarty {
* compiler.
*/
case 'request':
if ($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
$this->_syntax_error("(secure mode) super global access not permitted",
E_USER_WARNING, __FILE__, __LINE__);
return;
}
if ($this->request_use_auto_globals) {
$compiled_ref = '$_REQUEST';
$compiled_ref = "\$_REQUEST";
break;
} else {
$this->_init_smarty_vars = true;

View File

@ -25,7 +25,7 @@ function smarty_core_process_compiled_include($params, &$smarty)
$smarty->_include($_include_file_path, true);
}
foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) {
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
array(&$smarty, '_process_compiled_include_callback'),
$_return);

View File

@ -68,7 +68,7 @@ function smarty_core_write_cache_file($params, &$smarty)
if (!empty($smarty->cache_handler_func)) {
// use cache_handler function
call_user_func_array($smarty->cache_handler_func,
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], $smarty->_cache_info['expires']));
} else {
// use local cache file

View File

@ -14,7 +14,7 @@
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> (initial author)
* @auther messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
* @author messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function)
* @param string containing var-attribute and value-attribute
* @param Smarty_Compiler
*/

View File

@ -27,7 +27,8 @@ function smarty_function_math($params, &$smarty)
return;
}
$equation = $params['equation'];
// strip out backticks, not necessary for math
$equation = str_replace('`','',$params['equation']);
// make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) {

View File

@ -22,12 +22,25 @@
*/
function smarty_modifier_regex_replace($string, $search, $replace)
{
if(is_array($search)) {
foreach($search as $idx => $s)
$search[$idx] = _smarty_regex_replace_check($s);
} else {
$search = _smarty_regex_replace_check($search);
}
return preg_replace($search, $replace, $string);
}
function _smarty_regex_replace_check($search)
{
if (($pos = strpos($search,"\0")) !== false)
$search = substr($search,0,$pos);
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
/* remove eval-modifier from $search */
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
}
return preg_replace($search, $replace, $string);
return $search;
}
/* vim: set expandtab: */

View File

@ -28,21 +28,21 @@
function smarty_outputfilter_trimwhitespace($source, &$smarty)
{
// Pull out the script blocks
preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
$_script_blocks = $match[0];
$source = preg_replace("!<script[^>]+>.*?</script>!is",
$source = preg_replace("!<script[^>]*?>.*?</script>!is",
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
// Pull out the pre blocks
preg_match_all("!<pre>.*?</pre>!is", $source, $match);
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
$_pre_blocks = $match[0];
$source = preg_replace("!<pre>.*?</pre>!is",
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is",
'@@@SMARTY:TRIM:PRE@@@', $source);
// Pull out the textarea blocks
preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
$_textarea_blocks = $match[0];
$source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is",
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
// remove all leading spaces, tabs and carriage returns NOT