updated smarty to last stable build
This commit is contained in:
parent
0e962daf68
commit
10a56bc3d0
@ -17,15 +17,19 @@
|
|||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/
|
* For questions, help, comments, discussion, etc., please join the
|
||||||
* @version 2.6.18
|
* 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.
|
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
* @package Smarty
|
* @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
|
* Config file reading class
|
||||||
|
@ -20,17 +20,17 @@
|
|||||||
*
|
*
|
||||||
* For questions, help, comments, discussion, etc., please join the
|
* For questions, help, comments, discussion, etc., please join the
|
||||||
* Smarty mailing list. Send a blank e-mail to
|
* 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.
|
* @copyright 2001-2005 New Digital Group, Inc.
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @package Smarty
|
* @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
|
* 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.
|
* When set, smarty does uses this value as error_reporting-level.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var integer
|
||||||
*/
|
*/
|
||||||
var $error_reporting = null;
|
var $error_reporting = null;
|
||||||
|
|
||||||
@ -236,7 +236,8 @@ class Smarty
|
|||||||
'INCLUDE_ANY' => false,
|
'INCLUDE_ANY' => false,
|
||||||
'PHP_TAGS' => false,
|
'PHP_TAGS' => false,
|
||||||
'MODIFIER_FUNCS' => array('count'),
|
'MODIFIER_FUNCS' => array('count'),
|
||||||
'ALLOW_CONSTANTS' => false
|
'ALLOW_CONSTANTS' => false,
|
||||||
|
'ALLOW_SUPER_GLOBALS' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -464,7 +465,7 @@ class Smarty
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $_version = '2.6.18';
|
var $_version = '2.6.26';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* current template inclusion depth
|
* current template inclusion depth
|
||||||
@ -838,69 +839,66 @@ class Smarty
|
|||||||
* Registers a prefilter function to apply
|
* Registers a prefilter function to apply
|
||||||
* to a template before compiling
|
* to a template before compiling
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function to register
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function register_prefilter($function)
|
function register_prefilter($function)
|
||||||
{
|
{
|
||||||
$_name = (is_array($function)) ? $function[1] : $function;
|
$this->_plugins['prefilter'][$this->_get_filter_name($function)]
|
||||||
$this->_plugins['prefilter'][$_name]
|
|
||||||
= array($function, null, null, false);
|
= array($function, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a prefilter function
|
* Unregisters a prefilter function
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function unregister_prefilter($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
|
* Registers a postfilter function to apply
|
||||||
* to a compiled template after compilation
|
* to a compiled template after compilation
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function to register
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function register_postfilter($function)
|
function register_postfilter($function)
|
||||||
{
|
{
|
||||||
$_name = (is_array($function)) ? $function[1] : $function;
|
$this->_plugins['postfilter'][$this->_get_filter_name($function)]
|
||||||
$this->_plugins['postfilter'][$_name]
|
|
||||||
= array($function, null, null, false);
|
= array($function, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a postfilter function
|
* Unregisters a postfilter function
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function unregister_postfilter($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
|
* Registers an output filter function to apply
|
||||||
* to a template output
|
* to a template output
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function register_outputfilter($function)
|
function register_outputfilter($function)
|
||||||
{
|
{
|
||||||
$_name = (is_array($function)) ? $function[1] : $function;
|
$this->_plugins['outputfilter'][$this->_get_filter_name($function)]
|
||||||
$this->_plugins['outputfilter'][$_name]
|
|
||||||
= array($function, null, null, false);
|
= array($function, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters an outputfilter function
|
* Unregisters an outputfilter function
|
||||||
*
|
*
|
||||||
* @param string $function name of PHP function
|
* @param callback $function
|
||||||
*/
|
*/
|
||||||
function unregister_outputfilter($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['source_content'] = $this->_read_file($_resource_name);
|
||||||
}
|
}
|
||||||
$params['resource_timestamp'] = filemtime($_resource_name);
|
$params['resource_timestamp'] = filemtime($_resource_name);
|
||||||
$_return = is_file($_resource_name);
|
$_return = is_file($_resource_name) && is_readable($_resource_name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1714,7 +1712,7 @@ class Smarty
|
|||||||
*/
|
*/
|
||||||
function _read_file($filename)
|
function _read_file($filename)
|
||||||
{
|
{
|
||||||
if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
|
if ( file_exists($filename) && is_readable($filename) && ($fd = @fopen($filename, 'rb')) ) {
|
||||||
$contents = '';
|
$contents = '';
|
||||||
while (!feof($fd)) {
|
while (!feof($fd)) {
|
||||||
$contents .= fread($fd, 8192);
|
$contents .= fread($fd, 8192);
|
||||||
@ -1935,6 +1933,25 @@ class Smarty
|
|||||||
{
|
{
|
||||||
return eval($code);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
* @link http://smarty.php.net/
|
* @link http://smarty.php.net/
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Andrei Zmievski <andrei@php.net>
|
* @author Andrei Zmievski <andrei@php.net>
|
||||||
* @version 2.6.18
|
* @version 2.6.26
|
||||||
* @copyright 2001-2005 New Digital Group, Inc.
|
* @copyright 2001-2005 New Digital Group, Inc.
|
||||||
* @package Smarty
|
* @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
|
* Template compiling class
|
||||||
@ -869,7 +869,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
// traditional argument format
|
// traditional argument format
|
||||||
$args = implode(',', array_values($attrs));
|
$args = implode(',', array_values($attrs));
|
||||||
if (empty($args)) {
|
if (empty($args)) {
|
||||||
$args = 'null';
|
$args = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,7 +1171,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
}
|
}
|
||||||
$item = $this->_dequote($attrs['item']);
|
$item = $this->_dequote($attrs['item']);
|
||||||
if (!preg_match('~^\w+$~', $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'])) {
|
if (isset($attrs['key'])) {
|
||||||
@ -1222,23 +1222,21 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$attrs = $this->_parse_attrs($tag_args);
|
$attrs = $this->_parse_attrs($tag_args);
|
||||||
|
|
||||||
if ($start) {
|
if ($start) {
|
||||||
if (isset($attrs['name']))
|
$buffer = isset($attrs['name']) ? $attrs['name'] : "'default'";
|
||||||
$buffer = $attrs['name'];
|
$assign = isset($attrs['assign']) ? $attrs['assign'] : null;
|
||||||
else
|
$append = isset($attrs['append']) ? $attrs['append'] : null;
|
||||||
$buffer = "'default'";
|
|
||||||
|
|
||||||
if (isset($attrs['assign']))
|
|
||||||
$assign = $attrs['assign'];
|
|
||||||
else
|
|
||||||
$assign = null;
|
|
||||||
$output = "<?php ob_start(); ?>";
|
$output = "<?php ob_start(); ?>";
|
||||||
$this->_capture_stack[] = array($buffer, $assign);
|
$this->_capture_stack[] = array($buffer, $assign, $append);
|
||||||
} else {
|
} 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(); ";
|
$output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
|
||||||
if (isset($assign)) {
|
if (isset($assign)) {
|
||||||
$output .= " \$this->assign($assign, ob_get_contents());";
|
$output .= " \$this->assign($assign, ob_get_contents());";
|
||||||
}
|
}
|
||||||
|
if (isset($append)) {
|
||||||
|
$output .= " \$this->append($append, ob_get_contents());";
|
||||||
|
}
|
||||||
$output .= "ob_end_clean(); ?>";
|
$output .= "ob_end_clean(); ?>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1365,9 +1363,14 @@ class Smarty_Compiler extends Smarty {
|
|||||||
/* If last token was a ')', we operate on the parenthesized
|
/* If last token was a ')', we operate on the parenthesized
|
||||||
expression. The start of the expression is on the stack.
|
expression. The start of the expression is on the stack.
|
||||||
Otherwise, we operate on the last encountered token. */
|
Otherwise, we operate on the last encountered token. */
|
||||||
if ($tokens[$i-1] == ')')
|
if ($tokens[$i-1] == ')') {
|
||||||
$is_arg_start = array_pop($is_arg_stack);
|
$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;
|
$is_arg_start = $i-1;
|
||||||
/* Construct the argument for 'is' expression, so it knows
|
/* Construct the argument for 'is' expression, so it knows
|
||||||
what to operate on. */
|
what to operate on. */
|
||||||
@ -2044,27 +2047,57 @@ class Smarty_Compiler extends Smarty {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'get':
|
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;
|
break;
|
||||||
|
|
||||||
case 'post':
|
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;
|
break;
|
||||||
|
|
||||||
case 'cookies':
|
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;
|
break;
|
||||||
|
|
||||||
case 'env':
|
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;
|
break;
|
||||||
|
|
||||||
case 'server':
|
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;
|
break;
|
||||||
|
|
||||||
case 'session':
|
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;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2072,8 +2105,13 @@ class Smarty_Compiler extends Smarty {
|
|||||||
* compiler.
|
* compiler.
|
||||||
*/
|
*/
|
||||||
case 'request':
|
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) {
|
if ($this->request_use_auto_globals) {
|
||||||
$compiled_ref = '$_REQUEST';
|
$compiled_ref = "\$_REQUEST";
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
$this->_init_smarty_vars = true;
|
$this->_init_smarty_vars = true;
|
||||||
|
@ -25,7 +25,7 @@ function smarty_core_process_compiled_include($params, &$smarty)
|
|||||||
$smarty->_include($_include_file_path, true);
|
$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',
|
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
|
||||||
array(&$smarty, '_process_compiled_include_callback'),
|
array(&$smarty, '_process_compiled_include_callback'),
|
||||||
$_return);
|
$_return);
|
||||||
|
@ -68,7 +68,7 @@ function smarty_core_write_cache_file($params, &$smarty)
|
|||||||
if (!empty($smarty->cache_handler_func)) {
|
if (!empty($smarty->cache_handler_func)) {
|
||||||
// use cache_handler function
|
// use cache_handler function
|
||||||
call_user_func_array($smarty->cache_handler_func,
|
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 {
|
} else {
|
||||||
// use local cache file
|
// use local cache file
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
|
* @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com> (initial author)
|
* @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 string containing var-attribute and value-attribute
|
||||||
* @param Smarty_Compiler
|
* @param Smarty_Compiler
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +27,8 @@ function smarty_function_math($params, &$smarty)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$equation = $params['equation'];
|
// strip out backticks, not necessary for math
|
||||||
|
$equation = str_replace('`','',$params['equation']);
|
||||||
|
|
||||||
// make sure parenthesis are balanced
|
// make sure parenthesis are balanced
|
||||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||||
|
@ -22,12 +22,25 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
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)) {
|
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||||
/* remove eval-modifier from $search */
|
/* remove eval-modifier from $search */
|
||||||
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||||
}
|
}
|
||||||
|
return $search;
|
||||||
return preg_replace($search, $replace, $string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@ -28,21 +28,21 @@
|
|||||||
function smarty_outputfilter_trimwhitespace($source, &$smarty)
|
function smarty_outputfilter_trimwhitespace($source, &$smarty)
|
||||||
{
|
{
|
||||||
// Pull out the script blocks
|
// 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];
|
$_script_blocks = $match[0];
|
||||||
$source = preg_replace("!<script[^>]+>.*?</script>!is",
|
$source = preg_replace("!<script[^>]*?>.*?</script>!is",
|
||||||
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
|
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
|
||||||
|
|
||||||
// Pull out the pre blocks
|
// 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];
|
$_pre_blocks = $match[0];
|
||||||
$source = preg_replace("!<pre>.*?</pre>!is",
|
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is",
|
||||||
'@@@SMARTY:TRIM:PRE@@@', $source);
|
'@@@SMARTY:TRIM:PRE@@@', $source);
|
||||||
|
|
||||||
// Pull out the textarea blocks
|
// 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];
|
$_textarea_blocks = $match[0];
|
||||||
$source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
|
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is",
|
||||||
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
|
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
|
||||||
|
|
||||||
// remove all leading spaces, tabs and carriage returns NOT
|
// remove all leading spaces, tabs and carriage returns NOT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user