|
From: <be...@us...> - 2013-10-06 19:12:00
|
Revision: 12153
http://sourceforge.net/p/xoops/svn/12153
Author: beckmi
Date: 2013-10-06 19:11:55 +0000 (Sun, 06 Oct 2013)
Log Message:
-----------
Updating Smarty to 2.6.28
Modified Paths:
--------------
XoopsCore/branches/2.5.x/2.5.7/docs/changelog.250.txt
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty.class.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty_Compiler.class.php
XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/debug.tpl
Modified: XoopsCore/branches/2.5.x/2.5.7/docs/changelog.250.txt
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/docs/changelog.250.txt 2013-10-06 18:36:28 UTC (rev 12152)
+++ XoopsCore/branches/2.5.x/2.5.7/docs/changelog.250.txt 2013-10-06 19:11:55 UTC (rev 12153)
@@ -46,6 +46,7 @@
- jGrowl to 1.2.13 (mamba)
- jQuery Form to 3.42.0 (mamba)
- HTML Purifier to 4.5.0 (mamba)
+ - Smarty to 2.6.28 (mamba)
===============================
2013/04/21: Version 2.5.6 Final
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty.class.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty.class.php 2013-10-06 18:36:28 UTC (rev 12152)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty.class.php 2013-10-06 19:11:55 UTC (rev 12153)
@@ -27,7 +27,7 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <an...@ph...>
* @package Smarty
- * @version 2.6.27
+ * @version 2.6.28
*/
/* $Id$ */
@@ -35,7 +35,7 @@
/**
* DIR_SEP isn't used anymore, but third party apps might
*/
-if (!defined('DIR_SEP')) {
+if(!defined('DIR_SEP')) {
define('DIR_SEP', DIRECTORY_SEPARATOR);
}
@@ -465,7 +465,7 @@
*
* @var string
*/
- var $_version = '2.6.27';
+ var $_version = '2.6.28';
/**
* current template inclusion depth
@@ -576,11 +576,11 @@
* assigns values to template variables
*
* @param array|string $tpl_var the template variable name(s)
- * @param mixed $value the value to assign
+ * @param mixed $value the value to assign
*/
function assign($tpl_var, $value = null)
{
- if (is_array($tpl_var)) {
+ if (is_array($tpl_var)){
foreach ($tpl_var as $key => $val) {
if ($key != '') {
$this->_tpl_vars[$key] = $val;
@@ -596,7 +596,7 @@
* assigns values to template variables by reference
*
* @param string $tpl_var the template variable name
- * @param mixed $value the referenced value to assign
+ * @param mixed $value the referenced value to assign
*/
function assign_by_ref($tpl_var, &$value)
{
@@ -608,7 +608,7 @@
* appends values to template variables
*
* @param array|string $tpl_var the template variable name(s)
- * @param mixed $value the value to append
+ * @param mixed $value the value to append
*/
function append($tpl_var, $value=null, $merge=false)
{
@@ -616,11 +616,11 @@
// $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
- if (!@is_array($this->_tpl_vars[$_key])) {
+ if(!@is_array($this->_tpl_vars[$_key])) {
settype($this->_tpl_vars[$_key],'array');
}
- if ($merge && is_array($_val)) {
- foreach ($_val as $_mkey => $_mval) {
+ if($merge && is_array($_val)) {
+ foreach($_val as $_mkey => $_mval) {
$this->_tpl_vars[$_key][$_mkey] = $_mval;
}
} else {
@@ -630,11 +630,11 @@
}
} else {
if ($tpl_var != '' && isset($value)) {
- if (!@is_array($this->_tpl_vars[$tpl_var])) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
settype($this->_tpl_vars[$tpl_var],'array');
}
- if ($merge && is_array($value)) {
- foreach ($value as $_mkey => $_mval) {
+ if($merge && is_array($value)) {
+ foreach($value as $_mkey => $_mval) {
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
}
} else {
@@ -648,16 +648,16 @@
* appends values to template variables by reference
*
* @param string $tpl_var the template variable name
- * @param mixed $value the referenced value to append
+ * @param mixed $value the referenced value to append
*/
function append_by_ref($tpl_var, &$value, $merge=false)
{
if ($tpl_var != '' && isset($value)) {
- if (!@is_array($this->_tpl_vars[$tpl_var])) {
+ if(!@is_array($this->_tpl_vars[$tpl_var])) {
settype($this->_tpl_vars[$tpl_var],'array');
}
if ($merge && is_array($value)) {
- foreach ($value as $_key => $_val) {
+ foreach($value as $_key => $_val) {
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
}
} else {
@@ -685,7 +685,7 @@
/**
* Registers custom function to be used in templates
*
- * @param string $function the name of the template function
+ * @param string $function the name of the template function
* @param string $function_impl the name of the PHP function to register
*/
function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
@@ -708,10 +708,10 @@
/**
* Registers object to be used in templates
*
- * @param string $object name of template object
- * @param object &$object_impl the referenced PHP object to register
- * @param null|array $allowed list of allowed methods (empty = all)
- * @param boolean $smarty_args smarty argument format, else traditional
+ * @param string $object name of template object
+ * @param object &$object_impl the referenced PHP object to register
+ * @param null|array $allowed list of allowed methods (empty = all)
+ * @param boolean $smarty_args smarty argument format, else traditional
* @param null|array $block_functs list of methods that are block format
*/
function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
@@ -736,7 +736,7 @@
/**
* Registers block function to be used in templates
*
- * @param string $block name of template block
+ * @param string $block name of template block
* @param string $block_impl PHP function to register
*/
function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
@@ -758,7 +758,7 @@
/**
* Registers compiler function
*
- * @param string $function name of template function
+ * @param string $function name of template function
* @param string $function_impl name of PHP function to register
*/
function register_compiler_function($function, $function_impl, $cacheable=true)
@@ -780,7 +780,7 @@
/**
* Registers modifier to be used in templates
*
- * @param string $modifier name of template modifier
+ * @param string $modifier name of template modifier
* @param string $modifier_impl name of PHP function to register
*/
function register_modifier($modifier, $modifier_impl)
@@ -802,8 +802,8 @@
/**
* Registers a resource to fetch a template
*
- * @param string $type name of resource
- * @param array $functions array of functions to handle resource
+ * @param string $type name of resource
+ * @param array $functions array of functions to handle resource
*/
function register_resource($type, $functions)
{
@@ -927,10 +927,10 @@
/**
* clear cached content for the given template and cache id
*
- * @param string $tpl_file name of template file
- * @param string $cache_id name of cache_id
- * @param string $compile_id name of compile_id
- * @param string $exp_time expiration time
+ * @param string $tpl_file name of template file
+ * @param string $cache_id name of cache_id
+ * @param string $compile_id name of compile_id
+ * @param string $exp_time expiration time
* @return boolean
*/
function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
@@ -953,7 +953,6 @@
'auto_id' => $_auto_id,
'exp_time' => $exp_time);
require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
-
return smarty_core_rm_auto($_params, $this);
}
@@ -963,7 +962,7 @@
/**
* clear the entire contents of cache (all templates)
*
- * @param string $exp_time expire time
+ * @param string $exp_time expire time
* @return boolean results of {@link smarty_core_rm_auto()}
*/
function clear_all_cache($exp_time = null)
@@ -975,9 +974,9 @@
/**
* test to see if valid cache exists for this template
*
- * @param string $tpl_file name of template file
- * @param string $cache_id
- * @param string $compile_id
+ * @param string $tpl_file name of template file
+ * @param string $cache_id
+ * @param string $compile_id
* @return string|false results of {@link _read_cache_file()}
*/
function is_cached($tpl_file, $cache_id = null, $compile_id = null)
@@ -994,7 +993,6 @@
'compile_id' => $compile_id
);
require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
-
return smarty_core_read_cache_file($_params, $this);
}
@@ -1013,9 +1011,9 @@
* or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed.
*
- * @param string $tpl_file
- * @param string $compile_id
- * @param string $exp_time
+ * @param string $tpl_file
+ * @param string $compile_id
+ * @param string $exp_time
* @return boolean results of {@link smarty_core_rm_auto()}
*/
function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
@@ -1029,40 +1027,37 @@
'exp_time' => $exp_time,
'extensions' => array('.inc', '.php'));
require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
-
return smarty_core_rm_auto($_params, $this);
}
/**
* Checks whether requested template exists.
*
- * @param string $tpl_file
+ * @param string $tpl_file
* @return boolean
*/
function template_exists($tpl_file)
{
$_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
-
return $this->_fetch_resource_info($_params);
}
/**
* Returns an array containing template variables
*
- * @param string $name
- * @param string $type
+ * @param string $name
+ * @param string $type
* @return array
*/
function &get_template_vars($name=null)
{
- if (!isset($name)) {
+ if(!isset($name)) {
return $this->_tpl_vars;
- } elseif (isset($this->_tpl_vars[$name])) {
+ } elseif(isset($this->_tpl_vars[$name])) {
return $this->_tpl_vars[$name];
} else {
// var non-existant, return valid reference
$_tmp = null;
-
return $_tmp;
}
}
@@ -1070,20 +1065,19 @@
/**
* Returns an array containing config variables
*
- * @param string $name
- * @param string $type
+ * @param string $name
+ * @param string $type
* @return array
*/
function &get_config_vars($name=null)
{
- if (!isset($name) && is_array($this->_config[0])) {
+ if(!isset($name) && is_array($this->_config[0])) {
return $this->_config[0]['vars'];
- } elseif (isset($this->_config[0]['vars'][$name])) {
+ } else if(isset($this->_config[0]['vars'][$name])) {
return $this->_config[0]['vars'][$name];
} else {
// var non-existant, return valid reference
$_tmp = null;
-
return $_tmp;
}
}
@@ -1091,7 +1085,7 @@
/**
* trigger Smarty error
*
- * @param string $error_msg
+ * @param string $error_msg
* @param integer $error_type
*/
function trigger_error($error_msg, $error_type = E_USER_WARNING)
@@ -1116,9 +1110,9 @@
/**
* executes & returns or displays the template results
*
- * @param string $resource_name
- * @param string $cache_id
- * @param string $compile_id
+ * @param string $resource_name
+ * @param string $cache_id
+ * @param string $compile_id
* @param boolean $display
*/
function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
@@ -1144,7 +1138,7 @@
$this->debugging = true;
}
} else {
- $this->debugging = (bool) ($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
+ $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
}
}
@@ -1195,7 +1189,8 @@
if ($display) {
- if ($this->debugging) {
+ if ($this->debugging)
+ {
// capture time for debugging info
$_params = array();
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
@@ -1225,13 +1220,11 @@
error_reporting($_smarty_old_error_level);
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
-
return true;
} else {
error_reporting($_smarty_old_error_level);
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
-
return $_smarty_results;
}
} else {
@@ -1273,7 +1266,7 @@
$_smarty_results = ob_get_contents();
ob_end_clean();
- foreach ((array) $this->_plugins['outputfilter'] as $_output_filter) {
+ foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
$_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
}
}
@@ -1310,7 +1303,6 @@
echo smarty_core_display_debug_console($_params, $this);
}
error_reporting($_smarty_old_error_level);
-
return;
} else {
error_reporting($_smarty_old_error_level);
@@ -1334,7 +1326,7 @@
/**
* return a reference to a registered object
*
- * @param string $name
+ * @param string $name
* @return object
*/
function &get_registered_object($name) {
@@ -1354,7 +1346,7 @@
*/
function clear_config($var = null)
{
- if (!isset($var)) {
+ if(!isset($var)) {
// clear all values
$this->_config = array(array('vars' => array(),
'files' => array()));
@@ -1366,23 +1358,22 @@
/**
* get filepath of requested plugin
*
- * @param string $type
- * @param string $name
+ * @param string $type
+ * @param string $name
* @return string|false
*/
function _get_plugin_filepath($type, $name)
{
$_params = array('type' => $type, 'name' => $name);
require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
-
return smarty_core_assemble_plugin_filepath($_params, $this);
}
/**
* test if resource needs compiling
*
- * @param string $resource_name
- * @param string $compile_path
+ * @param string $resource_name
+ * @param string $compile_path
* @return boolean
*/
function _is_compiled($resource_name, $compile_path)
@@ -1414,8 +1405,8 @@
/**
* compile the template
*
- * @param string $resource_name
- * @param string $compile_path
+ * @param string $resource_name
+ * @param string $compile_path
* @return boolean
*/
function _compile_resource($resource_name, $compile_path)
@@ -1450,9 +1441,9 @@
/**
* compile the given source
*
- * @param string $resource_name
- * @param string $source_content
- * @param string $compiled_content
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
* @return boolean
*/
function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
@@ -1464,6 +1455,7 @@
require_once($this->compiler_file);
}
+
$smarty_compiler = new $this->compiler_class;
$smarty_compiler->template_dir = $this->template_dir;
@@ -1494,6 +1486,7 @@
}
$smarty_compiler->_cache_include = $cache_include_path;
+
$_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
if ($smarty_compiler->_cache_serial) {
@@ -1513,7 +1506,7 @@
/**
* Get the compile path for this resource
*
- * @param string $resource_name
+ * @param string $resource_name
* @return string results of {@link _get_auto_filename()}
*/
function _get_compile_path($resource_name)
@@ -1528,18 +1521,18 @@
*
* sets $source_content to the source of the template, and
* $resource_timestamp to its time stamp
- * @param string $resource_name
- * @param string $source_content
- * @param integer $resource_timestamp
- * @param boolean $get_source
- * @param boolean $quiet
+ * @param string $resource_name
+ * @param string $source_content
+ * @param integer $resource_timestamp
+ * @param boolean $get_source
+ * @param boolean $quiet
* @return boolean
*/
function _fetch_resource_info(&$params)
{
- if (!isset($params['get_source'])) { $params['get_source'] = true; }
- if (!isset($params['quiet'])) { $params['quiet'] = false; }
+ if(!isset($params['get_source'])) { $params['get_source'] = true; }
+ if(!isset($params['quiet'])) { $params['quiet'] = false; }
$_return = false;
$_params = array('resource_name' => $params['resource_name']) ;
@@ -1596,28 +1589,27 @@
if (!$params['quiet']) {
$this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
}
- } elseif ($_return && $this->security) {
+ } else if ($_return && $this->security) {
require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
if (!smarty_core_is_secure($_params, $this)) {
if (!$params['quiet'])
$this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
$params['source_content'] = null;
$params['resource_timestamp'] = null;
-
return false;
}
}
-
return $_return;
}
+
/**
* parse out the type and name from the resource
*
- * @param string $resource_base_path
- * @param string $resource_name
- * @param string $resource_type
- * @param string $resource_name
+ * @param string $resource_base_path
+ * @param string $resource_name
+ * @param string $resource_type
+ * @param string $resource_name
* @return boolean
*/
@@ -1632,7 +1624,7 @@
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $_resource_name_parts[0];
} else {
- if (strlen($_resource_name_parts[0]) == 1) {
+ if(strlen($_resource_name_parts[0]) == 1) {
// 1 char is not resource type, but part of filepath
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $params['resource_name'];
@@ -1646,27 +1638,23 @@
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
// relative pathname to $params['resource_base_path']
// use the first directory where the file is found
- foreach ((array) $params['resource_base_path'] as $_curr_path) {
+ foreach ((array)$params['resource_base_path'] as $_curr_path) {
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
if (file_exists($_fullpath) && is_file($_fullpath)) {
$params['resource_name'] = $_fullpath;
-
return true;
}
// didn't find the file, try include_path
$_params = array('file_path' => $_fullpath);
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
- if (smarty_core_get_include_path($_params, $this)) {
+ if(smarty_core_get_include_path($_params, $this)) {
$params['resource_name'] = $_params['new_file_path'];
-
return true;
}
}
-
return false;
} else {
/* absolute path */
-
return file_exists($params['resource_name']);
}
} elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
@@ -1682,9 +1670,9 @@
/**
* Handle modifiers
*
- * @param string|null $modifier_name
- * @param array|null $map_array
- * @return string result of modifiers
+ * @param string|null $modifier_name
+ * @param array|null $map_array
+ * @return string result of modifiers
*/
function _run_mod_handler()
{
@@ -1698,21 +1686,19 @@
$_args[0] = $_val;
$_var[$_key] = call_user_func_array($_func_name, $_args);
}
-
return $_var;
}
/**
* Remove starting and ending quotes from the string
*
- * @param string $string
+ * @param string $string
* @return string
*/
function _dequote($string)
{
if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == '"') &&
substr($string, -1) == substr($string, 0, 1))
-
return substr($string, 1, -1);
else
return $string;
@@ -1722,7 +1708,7 @@
/**
* read in a file
*
- * @param string $filename
+ * @param string $filename
* @return string
*/
function _read_file($filename)
@@ -1733,7 +1719,6 @@
$contents .= fread($fd, 8192);
}
fclose($fd);
-
return $contents;
} else {
return false;
@@ -1743,9 +1728,9 @@
/**
* get a concrete filename for automagically created content
*
- * @param string $auto_base
- * @param string $auto_source
- * @param string $auto_id
+ * @param string $auto_base
+ * @param string $auto_source
+ * @param string $auto_id
* @return string
* @staticvar string|null
* @staticvar string|null
@@ -1755,14 +1740,14 @@
$_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
$_return = $auto_base . DIRECTORY_SEPARATOR;
- if (isset($auto_id)) {
+ if(isset($auto_id)) {
// make auto_id safe for directory names
$auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
// split into separate directories
$_return .= $auto_id . $_compile_dir_sep;
}
- if (isset($auto_source)) {
+ if(isset($auto_source)) {
// make source name safe for filename
$_filename = urlencode(basename($auto_source));
$_crc32 = sprintf('%08X', crc32($auto_source));
@@ -1779,13 +1764,13 @@
/**
* unlink a file, possibly using expiration time
*
- * @param string $resource
+ * @param string $resource
* @param integer $exp_time
*/
function _unlink($resource, $exp_time = null)
{
- if (isset($exp_time)) {
- if (time() - @filemtime($resource) >= $exp_time) {
+ if(isset($exp_time)) {
+ if(time() - @filemtime($resource) >= $exp_time) {
return @unlink($resource);
}
} else {
@@ -1796,12 +1781,11 @@
/**
* returns an auto_id for auto-file-functions
*
- * @param string $cache_id
- * @param string $compile_id
+ * @param string $cache_id
+ * @param string $compile_id
* @return string|null
*/
- function _get_auto_id($cache_id=null, $compile_id=null)
- {
+ function _get_auto_id($cache_id=null, $compile_id=null) {
if (isset($cache_id))
return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
elseif(isset($compile_id))
@@ -1813,17 +1797,17 @@
/**
* trigger Smarty plugin error
*
- * @param string $error_msg
- * @param string $tpl_file
+ * @param string $error_msg
+ * @param string $tpl_file
* @param integer $tpl_line
- * @param string $file
+ * @param string $file
* @param integer $line
* @param integer $error_type
*/
function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
$file = null, $line = null, $error_type = E_USER_ERROR)
{
- if (isset($file) && isset($line)) {
+ if(isset($file) && isset($line)) {
$info = ' ('.basename($file).", line $line)";
} else {
$info = '';
@@ -1840,14 +1824,12 @@
* callback function for preg_replace, to call a non-cacheable block
* @return string
*/
- function _process_compiled_include_callback($match)
- {
+ function _process_compiled_include_callback($match) {
$_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
ob_start();
$_func($this);
$_ret = ob_get_contents();
ob_end_clean();
-
return $_ret;
}
@@ -1918,13 +1900,11 @@
/* return next set of cache_attrs */
$_return = current($_cache_attrs);
next($_cache_attrs);
-
return $_return;
} else {
/* add a reference to a new set of cache_attrs */
$_cache_attrs[] = array();
-
return $_cache_attrs[count($_cache_attrs)-1];
}
@@ -1958,23 +1938,25 @@
/**
* Extracts the filter name from the given callback
*
- * @param callback $function
+ * @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]);
+ 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;
+ }
+ }
- return $_class_name . '_' . $function[1];
- } else {
- return $function;
- }
- }
-
/**#@-*/
}
/* vim: set expandtab: */
+
+?>
Modified: XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty_Compiler.class.php
===================================================================
--- XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty_Compiler.class.php 2013-10-06 18:36:28 UTC (rev 12152)
+++ XoopsCore/branches/2.5.x/2.5.7/htdocs/class/smarty/Smarty_Compiler.class.php 2013-10-06 19:11:55 UTC (rev 12153)
@@ -32,8 +32,8 @@
* Template compiling class
* @package Smarty
*/
-class Smarty_Compiler extends Smarty
-{
+class Smarty_Compiler extends Smarty {
+
// internal vars
/**#@+
* @access private
@@ -162,7 +162,7 @@
. '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
$this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
$this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
-
+
// matches valid modifier syntax:
// |foo
// |@foo
@@ -217,9 +217,9 @@
* compile a resource
*
* sets $compiled_content to the compiled source
- * @param string $resource_name
- * @param string $source_content
- * @param string $compiled_content
+ * @param string $resource_name
+ * @param string $source_content
+ * @param string $compiled_content
* @return true
*/
function _compile_file($resource_name, $source_content, &$compiled_content)
@@ -263,11 +263,11 @@
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '"
- . $this->_quote_replace($this->left_delimiter) . 'php'
- . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
- . $this->_quote_replace($this->right_delimiter)
- . "';")
- , $source_content);
+ . $this->_quote_replace($this->left_delimiter) . 'php'
+ . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
+ . $this->_quote_replace($this->right_delimiter)
+ . "';")
+ , $source_content);
/* Gather all template tags. */
preg_match_all("~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
@@ -290,10 +290,10 @@
if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
/* echo php contents */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo \''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n", $text_blocks[$curr_tb]);
- } elseif ($this->php_handling == SMARTY_PHP_QUOTE) {
+ } else if ($this->php_handling == SMARTY_PHP_QUOTE) {
/* quote php tags */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
- } elseif ($this->php_handling == SMARTY_PHP_REMOVE) {
+ } else if ($this->php_handling == SMARTY_PHP_REMOVE) {
/* remove php tags */
$text_blocks[$curr_tb] = str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
} else {
@@ -304,7 +304,7 @@
}
}
}
-
+
/* Compile the template tags into PHP code. */
$compiled_tags = array();
for ($i = 0, $for_max = count($template_tags); $i < $for_max; $i++) {
@@ -315,7 +315,6 @@
if (count($this->_tag_stack)>0) {
list($_open_tag, $_line_no) = end($this->_tag_stack);
$this->_syntax_error("unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__);
-
return;
}
@@ -334,7 +333,7 @@
for ($j = $i + 1; $j < $for_max; $j++) {
/* remove leading and trailing whitespaces of each line */
$text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $text_blocks[$j]);
- if ($compiled_tags[$j] == '{/strip}') {
+ if ($compiled_tags[$j] == '{/strip}') {
/* remove trailing whitespaces from the last text_block */
$text_blocks[$j] = rtrim($text_blocks[$j]);
}
@@ -350,9 +349,9 @@
}
}
$compiled_content = '';
-
+
$tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%';
-
+
/* Interleave the compiled contents and text blocks to get the final result. */
for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) {
if ($compiled_tags[$i] == '') {
@@ -362,7 +361,7 @@
// replace legit PHP tags with placeholder
$text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]);
$compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]);
-
+
$compiled_content .= $text_blocks[$i] . $compiled_tags[$i];
}
$compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]);
@@ -372,8 +371,8 @@
$compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~", "<?php echo 'language=php' ?>\n", $compiled_content);
// recover legit tags
- $compiled_content = str_replace($tag_guard, '<?', $compiled_content);
-
+ $compiled_content = str_replace($tag_guard, '<?', $compiled_content);
+
// remove \n from the end of the file, if any
if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) {
$compiled_content = substr($compiled_content, 0, -1);
@@ -424,14 +423,13 @@
}
$compiled_content = $template_header . $compiled_content;
-
return true;
}
/**
* Compile a template tag
*
- * @param string $template_tag
+ * @param string $template_tag
* @return string
*/
function _compile_tag($template_tag)
@@ -439,7 +437,7 @@
/* Matched comment. */
if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*')
return '';
-
+
/* Split tag into two three parts: command, command modifiers and the arguments. */
if(! preg_match('~^(?:(' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp
. '|\/?' . $this->_reg_obj_regexp . '|\/?' . $this->_func_regexp . ')(' . $this->_mod_regexp . '*))
@@ -447,7 +445,7 @@
~xs', $template_tag, $match)) {
$this->_syntax_error("unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
}
-
+
$tag_command = $match[1];
$tag_modifier = isset($match[2]) ? $match[2] : null;
$tag_args = isset($match[3]) ? $match[3] : null;
@@ -455,7 +453,6 @@
if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) {
/* tag name is a variable or object */
$_return = $this->_parse_var_props($tag_command . $tag_modifier);
-
return "<?php echo $_return; ?>" . $this->_additional_newline;
}
@@ -473,7 +470,6 @@
case 'if':
$this->_push_tag('if');
-
return $this->_compile_if_tag($tag_args);
case 'else':
@@ -482,7 +478,6 @@
$this->_syntax_error('unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
else
$this->_push_tag('else');
-
return '<?php else: ?>';
case 'elseif':
@@ -491,12 +486,10 @@
$this->_syntax_error('unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
if ($_open_tag == 'if')
$this->_push_tag('elseif');
-
return $this->_compile_if_tag($tag_args, true);
case '/if':
$this->_pop_tag('if');
-
return '<?php endif; ?>';
case 'capture':
@@ -513,12 +506,10 @@
case 'section':
$this->_push_tag('section');
-
return $this->_compile_section_start($tag_args);
case 'sectionelse':
$this->_push_tag('sectionelse');
-
return "<?php endfor; else: ?>";
break;
@@ -531,13 +522,11 @@
case 'foreach':
$this->_push_tag('foreach');
-
return $this->_compile_foreach_start($tag_args);
break;
case 'foreachelse':
$this->_push_tag('foreachelse');
-
return "<?php endforeach; else: ?>";
case '/foreach':
@@ -554,18 +543,15 @@
$this->_pop_tag('strip');
if (--$this->_strip_depth==0) { /* outermost closing {/strip} */
$this->_additional_newline = "\n";
-
return '{' . $tag_command . '}';
}
} else {
$this->_push_tag('strip');
if ($this->_strip_depth++==0) { /* outermost opening {strip} */
$this->_additional_newline = "";
-
return '{' . $tag_command . '}';
}
}
-
return '';
case 'php':
@@ -576,20 +562,16 @@
determins the type of folded tag that was found */
switch (count($block)) {
case 2: /* comment */
-
return '';
case 3: /* literal */
-
return "<?php echo '" . strtr($block[2], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>" . $this->_additional_newline;
case 4: /* php */
if ($this->security && !$this->security_settings['PHP_TAGS']) {
$this->_syntax_error("(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
-
return;
}
-
return '<?php ' . $block[3] .' ?>';
}
break;
@@ -600,10 +582,10 @@
default:
if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {
return $output;
- } elseif ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
return $output;
- } elseif ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
- return $output;
+ } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ return $output;
} else {
$this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
}
@@ -611,13 +593,14 @@
}
}
+
/**
* compile the custom compiler tag
*
* sets $output to the compiled custom compiler tag
- * @param string $tag_command
- * @param string $tag_args
- * @param string $output
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $output
* @return boolean
*/
function _compile_compiler_tag($tag_command, $tag_args, &$output)
@@ -664,7 +647,7 @@
if ($found) {
if ($have_function) {
$output = call_user_func_array($plugin_func, array($tag_args, &$this));
- if ($output != '') {
+ if($output != '') {
$output = '<?php ' . $this->_push_cacheable_state('compiler', $tag_command)
. $output
. $this->_pop_cacheable_state('compiler', $tag_command) . ' ?>';
@@ -672,7 +655,6 @@
} else {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
}
-
return true;
} else {
return false;
@@ -684,10 +666,10 @@
* compile block function tag
*
* sets $output to compiled block function tag
- * @param string $tag_command
- * @param string $tag_args
- * @param string $tag_modifier
- * @param string $output
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
+ * @param string $output
* @return boolean
*/
function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
@@ -734,9 +716,8 @@
if (!$found) {
return false;
- } elseif (!$have_function) {
+ } else if (!$have_function) {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
-
return true;
}
@@ -773,12 +754,13 @@
return true;
}
+
/**
* compile custom function tag
*
- * @param string $tag_command
- * @param string $tag_args
- * @param string $tag_modifier
+ * @param string $tag_command
+ * @param string $tag_args
+ * @param string $tag_modifier
* @return string
*/
function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output)
@@ -819,9 +801,8 @@
if (!$found) {
return false;
- } elseif (!$have_function) {
+ } else if (!$have_function) {
$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
-
return true;
}
@@ -835,11 +816,11 @@
$arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs);
$output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)";
- if ($tag_modifier != '') {
+ if($tag_modifier != '') {
$this->_parse_modifiers($output, $tag_modifier);
}
- if ($output != '') {
+ if($output != '') {
$output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';'
. $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline;
}
@@ -850,9 +831,9 @@
/**
* compile a registered object tag
*
- * @param string $tag_command
- * @param array $attrs
- * @param string $tag_modifier
+ * @param string $tag_command
+ * @param array $attrs
+ * @param string $tag_modifier
* @return string
*/
function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)
@@ -867,10 +848,10 @@
list($object, $obj_comp) = explode('->', $tag_command);
$arg_list = array();
- if (count($attrs)) {
+ if(count($attrs)) {
$_assign_var = false;
foreach ($attrs as $arg_name => $arg_value) {
- if ($arg_name == 'assign') {
+ if($arg_name == 'assign') {
$_assign_var = $arg_value;
unset($attrs['assign']);
continue;
@@ -881,9 +862,9 @@
}
}
- if ($this->_reg_objects[$object][2]) {
+ if($this->_reg_objects[$object][2]) {
// smarty object argument format
- $args = "array(".implode(',', (array) $arg_list)."), \$this";
+ $args = "array(".implode(',', (array)$arg_list)."), \$this";
} else {
// traditional argument format
$args = implode(',', array_values($attrs));
@@ -895,13 +876,13 @@
$prefix = '';
$postfix = '';
$newline = '';
- if (!is_object($this->_reg_objects[$object][0])) {
+ if(!is_object($this->_reg_objects[$object][0])) {
$this->_trigger_fatal_error("registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
- } elseif (!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
+ } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
$this->_trigger_fatal_error("'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
- } elseif (method_exists($this->_reg_objects[$object][0], $obj_comp)) {
+ } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
// method
- if (in_array($obj_comp, $this->_reg_objects[$object][3])) {
+ if(in_array($obj_comp, $this->_reg_objects[$object][3])) {
// block method
if ($start_tag) {
$prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); ";
@@ -923,12 +904,12 @@
$return = "\$this->_reg_objects['$object'][0]->$obj_comp";
}
- if ($return != null) {
- if ($tag_modifier != '') {
+ if($return != null) {
+ if($tag_modifier != '') {
$this->_parse_modifiers($return, $tag_modifier);
}
- if (!empty($_assign_var)) {
+ if(!empty($_assign_var)) {
$output = "\$this->assign('" . $this->_dequote($_assign_var) ."', $return);";
} else {
$output = 'echo ' . $return . ';';
@@ -944,7 +925,7 @@
/**
* Compile {insert ...} tag
*
- * @param string $tag_args
+ * @param string $tag_args
* @return string
*/
function _compile_insert_tag($tag_args)
@@ -955,7 +936,7 @@
if (empty($name)) {
return $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__);
}
-
+
if (!preg_match('~^\w+$~', $name)) {
return $this->_syntax_error("'insert: 'name' must be an insert function name", E_USER_ERROR, __FILE__, __LINE__);
}
@@ -974,7 +955,7 @@
$this->_add_plugin('insert', $name, $delayed_loading);
- $_params = "array('args' => array(".implode(', ', (array) $arg_list)."))";
+ $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" . $this->_additional_newline;
}
@@ -982,7 +963,7 @@
/**
* Compile {include ...} tag
*
- * @param string $tag_args
+ * @param string $tag_args
* @return string
*/
function _compile_include_tag($tag_args)
@@ -998,7 +979,7 @@
if ($arg_name == 'file') {
$include_file = $arg_value;
continue;
- } elseif ($arg_name == 'assign') {
+ } else if ($arg_name == 'assign') {
$assign_var = $arg_value;
continue;
}
@@ -1016,7 +997,8 @@
$output .=
"\$_smarty_tpl_vars = \$this->_tpl_vars;\n";
- $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array) $arg_list)."))";
+
+ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
$output .= "\$this->_smarty_include($_params);\n" .
"\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
"unset(\$_smarty_tpl_vars);\n";
@@ -1034,7 +1016,7 @@
/**
* Compile {include ...} tag
*
- * @param string $tag_args
+ * @param string $tag_args
* @return string
*/
function _compile_include_php_tag($tag_args)
@@ -1049,8 +1031,8 @@
$once_var = (empty($attrs['once']) || $attrs['once']=='false') ? 'false' : 'true';
$arg_list = array();
- foreach ($attrs as $arg_name => $arg_value) {
- if ($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
+ foreach($attrs as $arg_name => $arg_value) {
+ if($arg_name != 'file' AND $arg_name != 'once' AND $arg_name != 'assign') {
if(is_bool($arg_value))
$arg_value = $arg_value ? 'true' : 'false';
$arg_list[] = "'$arg_name' => $arg_value";
@@ -1062,10 +1044,11 @@
return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" . $this->_additional_newline;
}
+
/**
* Compile {section ...} tag
*
- * @param string $tag_args
+ * @param string $tag_args
* @return string
*/
function _compile_section_start($tag_args)
@@ -1085,14 +1068,14 @@
foreach ($attrs as $attr_name => $attr_value) {
switch ($attr_name) {
case 'loop':
- $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop); unset(\$_loop);\n";
+ $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
break;
case 'show':
if (is_bool($attr_value))
$show_attr_value = $attr_value ? 'true' : 'false';
else
- $show_attr_value = "(bool) $attr_value";
+ $show_attr_value = "(bool)$attr_value";
$output .= "{$section_props}['show'] = $show_attr_value;\n";
break;
@@ -1102,11 +1085,11 @@
case 'max':
case 'start':
- $output .= "{$section_props}['$attr_name'] = (int) $attr_value;\n";
+ $output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n";
break;
case 'step':
- $output .= "{$section_props}['$attr_name'] = ((int) $attr_value) == 0 ? 1 : (int) $attr_value;\n";
+ $output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
break;
default:
@@ -1166,10 +1149,11 @@
return $output;
}
+
/**
* Compile {foreach ...} tag.
*
- * @param string $tag_args
+ * @param string $tag_args
* @return string
*/
function _compile_foreach_start($tag_args)
@@ -1224,11 +1208,12 @@
return $output;
}
+
/**
* Compile {capture} .. {/capture} tags
*
- * @param boolean $start true if this is the {capture} tag
- * @param string $tag_args
+ * @param boolean $start true if this is the {capture} tag
+ * @param string $tag_args
* @return string
*/
@@ -1240,7 +1225,7 @@
$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, $append);
} else {
@@ -1261,8 +1246,8 @@
/**
* Compile {if ...} tag
*
- * @param string $tag_args
- * @param boolean $elseif if true, uses elseif instead of if
+ * @param string $tag_args
+ * @param boolean $elseif if true, uses elseif instead of if
* @return string
*/
function _compile_if_tag($tag_args, $elseif = false)
@@ -1279,15 +1264,16 @@
$tokens = $match[0];
- if (empty($tokens)) {
+ if(empty($tokens)) {
$_error_msg = $elseif ? "'elseif'" : "'if'";
- $_error_msg .= ' statement requires arguments';
+ $_error_msg .= ' statement requires arguments';
$this->_syntax_error($_error_msg, E_USER_ERROR, __FILE__, __LINE__);
}
-
+
+
// make sure we have balanced parenthesis
$token_count = array_count_values($tokens);
- if (isset($token_count['(']) && $token_count['('] != $token_count[')']) {
+ if(isset($token_count['(']) && $token_count['('] != $token_count[')']) {
$this->_syntax_error("unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
}
@@ -1382,8 +1368,8 @@
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
@@ -1392,7 +1378,6 @@
/* Pass all tokens from next one until the end to the
'is' expression parsing function. The function will
-
return modified tokens, where the first one is the result
of the 'is' expression and the rest are the tokens it
didn't touch. */
@@ -1407,19 +1392,19 @@
break;
default:
- if (preg_match('~^' . $this->_func_regexp . '$~', $token) ) {
+ if(preg_match('~^' . $this->_func_regexp . '$~', $token) ) {
// function call
if($this->security &&
!in_array($token, $this->security_settings['IF_FUNCS'])) {
$this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
}
- } elseif (preg_match('~^' . $this->_var_regexp . '$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') {
+ } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') {
// variable function call
- $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
- } elseif (preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) {
+ $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
+ } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) {
// object or variable
$token = $this->_parse_var_props($token);
- } elseif (is_numeric($token)) {
+ } elseif(is_numeric($token)) {
// number, skip it
} else {
$this->_syntax_error("unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
@@ -1434,8 +1419,8 @@
return '<?php if ('.implode(' ', $tokens).'): ?>';
}
- function _compile_arg_list($type, $name, $attrs, &$cache_code)
- {
+
+ function _compile_arg_list($type, $name, $attrs, &$cache_code) {
$arg_list = array();
if (isset($type) && isset($name)
@@ -1465,15 +1450,14 @@
$arg_list[] = "'$arg_name' => $arg_value";
}
}
-
return $arg_list;
}
/**
* Parse is expression
*
- * @param string $is_arg
- * @param array $tokens
+ * @param string $is_arg
+ * @param array $tokens
* @return array
*/
function _parse_is_expr($is_arg, $tokens)
@@ -1530,10 +1514,11 @@
return $tokens;
}
+
/**
* Parse attribute string
*
- * @param string $tag_args
+ * @param string $tag_args
* @return array
*/
function _parse_attrs($tag_args)
@@ -1581,13 +1566,13 @@
boolean value. */
if (preg_match('~^(on|yes|true)$~', $token)) {
$token = 'true';
- } elseif (preg_match('~^(off|no|false)$~', $token)) {
+ } else if (preg_match('~^(off|no|false)$~', $token)) {
$token = 'false';
- } elseif ($token == 'null') {
+ } else if ($token == 'null') {
$token = 'null';
- } elseif (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) {
+ } else if (preg_match('~^' . $this->_num_const_regexp . '|0[xX][0-9a-fA-F]+$~', $token)) {
/* treat integer literally */
- } elseif (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) {
+ } else if (!preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . ')*$~', $token)) {
/* treat as a string, double-quote it escaping quotes */
$token = '"'.addslashes($token).'"';
}
@@ -1601,8 +1586,8 @@
$last_token = $token;
}
- if ($state != 0) {
- if ($state == 1) {
+ if($state != 0) {
+ if($state == 1) {
$this->_syntax_error("expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
} else {
$this->_syntax_error("missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
@@ -1622,7 +1607,7 @@
*/
function _parse_vars_props(&$tokens)
{
- foreach ($tokens as $key => $val) {
+ foreach($tokens as $key => $val) {
$tokens[$key] = $this->_parse_var_props($val);
}
}
@@ -1631,77 +1616,77 @@
* compile single variable and section properties token into
* PHP code
*
- * @param string $val
- * @param string $tag_attrs
+ * @param string $val
+ * @param string $tag_attrs
* @return string
*/
function _parse_var_props($val)
{
$val = trim($val);
- if (preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) {
+ if(preg_match('~^(' . $this->_obj_call_regexp . '|' . $this->_dvar_regexp . ')(' . $this->_mod_regexp . '*)$~', $val, $match)) {
// $ variable or object
$return = $this->_parse_var($match[1]);
$modifiers = $match[2];
if (!empty($this->default_modifiers) && !preg_match('~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) {
- $_default_mod_string = implode('|',(array) $this->default_modifiers);
+ $_default_mod_string = implode('|',(array)$this->default_modifiers);
$modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
}
$this->_parse_mo...
[truncated message content] |