From 047b30c37792227724c1f9188fa7bb27663e526e Mon Sep 17 00:00:00 2001 From: andrey Date: Tue, 15 May 2001 14:24:06 +0000 Subject: [PATCH] Fixed a few E_NOTICE warnings. --- NEWS | 2 +- Smarty_Compiler.class.php | 21 ++++++++++++++------- demo/index.php | 1 + index.php | 1 + libs/Smarty_Compiler.class.php | 21 ++++++++++++++------- 5 files changed, 31 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 97ea29db..ba86aec6 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ + - fixed indexing by section properties with the new syntax. (Andrei) - fix LOCK_EX logic once and for all (not used under windows) (Monte) - updated Smarty to use absolute paths when requiring/including Smarty components. (Andrei, John Lim) @@ -6,7 +7,6 @@ Version 1.4.0 ------------- - added {capture}{/capture} function, documented (Monte) - added {counter} function, documented (Monte) - - fixed indexing by section properties with the new syntax. (Andrei) Version 1.4.0b2 --------------- diff --git a/Smarty_Compiler.class.php b/Smarty_Compiler.class.php index 9e415d30..7598b988 100644 --- a/Smarty_Compiler.class.php +++ b/Smarty_Compiler.class.php @@ -171,7 +171,8 @@ class Smarty_Compiler extends Smarty { ) (?:\s+(.*))? /xs', $template_tag, $match); - list(, $tag_command, $tag_args) = $match; + $tag_command = $match[1]; + $tag_args = isset($match[2]) ? $match[2] : ''; /* If the tag name matches a variable or section property definition, we simply process it. */ @@ -722,7 +723,9 @@ class Smarty_Compiler extends Smarty { \*======================================================================*/ function _parse_var($var_expr) { - list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2); + $parts = explode('|', substr($var_expr, 1), 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; preg_match_all('!\[\w+(\.\w+)?\]|(->|\.)\w+|^\w+!', $var_ref, $match); $indexes = $match[0]; @@ -732,9 +735,9 @@ class Smarty_Compiler extends Smarty { foreach ($indexes as $index) { if ($index{0} == '[') { - list($section, $section_prop) = explode('.', substr($index, 1, -1)); - if (!isset($section_prop)) - $section_prop = 'index'; + $parts = explode('.', substr($index, 1, -1)); + $section = $parts[0]; + $section_prop = isset($parts[1]) ? $parts[1] : 'index'; $output .= "[\$_smarty_sections['$section']['properties']['$section_prop']]"; } else if ($index{0} == '.') { $output .= "['" . substr($index, 1) . "']"; @@ -754,7 +757,9 @@ class Smarty_Compiler extends Smarty { \*======================================================================*/ function _parse_conf_var($conf_var_expr) { - list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2); + $parts = explode('|', $conf_var_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; $var_name = substr($var_ref, 1, -1); @@ -771,7 +776,9 @@ class Smarty_Compiler extends Smarty { \*======================================================================*/ function _parse_section_prop($section_prop_expr) { - list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2); + $parts = explode('|', $section_prop_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match); $section_name = $match[1]; diff --git a/demo/index.php b/demo/index.php index f1ae8877..bea81ee4 100644 --- a/demo/index.php +++ b/demo/index.php @@ -1,5 +1,6 @@ |\.)\w+|^\w+!', $var_ref, $match); $indexes = $match[0]; @@ -732,9 +735,9 @@ class Smarty_Compiler extends Smarty { foreach ($indexes as $index) { if ($index{0} == '[') { - list($section, $section_prop) = explode('.', substr($index, 1, -1)); - if (!isset($section_prop)) - $section_prop = 'index'; + $parts = explode('.', substr($index, 1, -1)); + $section = $parts[0]; + $section_prop = isset($parts[1]) ? $parts[1] : 'index'; $output .= "[\$_smarty_sections['$section']['properties']['$section_prop']]"; } else if ($index{0} == '.') { $output .= "['" . substr($index, 1) . "']"; @@ -754,7 +757,9 @@ class Smarty_Compiler extends Smarty { \*======================================================================*/ function _parse_conf_var($conf_var_expr) { - list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2); + $parts = explode('|', $conf_var_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; $var_name = substr($var_ref, 1, -1); @@ -771,7 +776,9 @@ class Smarty_Compiler extends Smarty { \*======================================================================*/ function _parse_section_prop($section_prop_expr) { - list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2); + $parts = explode('|', $section_prop_expr, 2); + $var_ref = $parts[0]; + $modifiers = isset($parts[1]) ? $parts[1] : ''; preg_match('!%(\w+)\.(\w+)%!', $var_ref, $match); $section_name = $match[1];