cvs: smarty /libs Smarty_Compiler.class.php

"Monte Ohrt" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmohrt1094861660@cvsserver>
mohrt		Fri Sep 10 20:14:20 2004 EDT

  Modified files:              
    /smarty/libs	Smarty_Compiler.class.php 
  Log:
  fix more object calling syntax issues
  
  
http://cvs.php.net/diff.php/smarty/libs/Smarty_Compiler.class.php?r1=1.342&r2=1.343&ty=u
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.342 smarty/libs/Smarty_Compiler.class.php:1.343
--- smarty/libs/Smarty_Compiler.class.php:1.342	Fri Sep 10 15:15:01 2004
+++ smarty/libs/Smarty_Compiler.class.php	Fri Sep 10 20:14:20 2004
@@ -26,7 +26,7 @@
  * @package Smarty
  */
 
-/* $Id: Smarty_Compiler.class.php,v 1.342 2004/09/10 19:15:01 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.343 2004/09/11 00:14:20 mohrt Exp $ */
 
 /**
  * Template compiling class
@@ -159,7 +159,7 @@
         $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
                 . '(?:\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->_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
@@ -406,7 +406,7 @@
         /* Matched comment. */
         if ($template_tag{0} == '*' && $template_tag{strlen($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 . '*))
@@ -414,7 +414,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;
@@ -1667,46 +1667,42 @@
     function _parse_var($var_expr)
     {
         $_has_math = false;
-        
-        if(!preg_match('~^' . $this->_obj_call_regexp . '$~', $var_expr)) {
-            // not an object call, see if there is math to parse
-            $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
-
-            if(count($_math_vars) > 1) {
-                $_first_var = '';
-                $_complete_var = '';
-                $_output = '';
-                // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
-                foreach($_math_vars as $_k => $_math_var) {
-                    $_math_var = $_math_vars[$_k];
-
-                    if(!empty($_math_var) || is_numeric($_math_var)) {
-                        // hit a math operator, so process the stuff which came before it
-                        if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) {
-                            $_has_math = true;
-                            if(!empty($_complete_var) || is_numeric($_complete_var)) {
-                                $_output .= $this->_parse_var($_complete_var);
-                            }
+        $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
+
+        if(count($_math_vars) > 1) {
+            $_first_var = "";
+            $_complete_var = "";
+            $_output = "";
+            // simple check if there is any math, to stop recursion (due to modifiers with "xx % yy" as parameter)
+            foreach($_math_vars as $_k => $_math_var) {
+                $_math_var = $_math_vars[$_k];
+
+                if(!empty($_math_var) || is_numeric($_math_var)) {
+                    // hit a math operator, so process the stuff which came before it
+                    if(preg_match('~^' . $this->_dvar_math_regexp . '$~', $_math_var)) {
+                        $_has_math = true;
+                        if(!empty($_complete_var) || is_numeric($_complete_var)) {
+                            $_output .= $this->_parse_var($_complete_var);
+                        }
 
-                            // just output the math operator to php
-                            $_output .= $_math_var;
+                        // just output the math operator to php
+                        $_output .= $_math_var;
 
-                            if(empty($_first_var))
-                                $_first_var = $_complete_var;
+                        if(empty($_first_var))
+                            $_first_var = $_complete_var;
 
-                            $_complete_var = '';
-                        } else {
-                            $_complete_var .= $_math_var;
-                        }
+                        $_complete_var = "";
+                    } else {
+                        $_complete_var .= $_math_var;
                     }
                 }
-                if($_has_math) {
-                    if(!empty($_complete_var) || is_numeric($_complete_var))
-                        $_output .= $this->_parse_var($_complete_var);
+            }
+            if($_has_math) {
+                if(!empty($_complete_var) || is_numeric($_complete_var))
+                    $_output .= $this->_parse_var($_complete_var);
 
-                    // get the modifiers working (only the last var from math + modifier is left)
-                    $var_expr = $_complete_var;
-                }
+                // get the modifiers working (only the last var from math + modifier is left)
+                $var_expr = $_complete_var;
             }
         }
 
@@ -1717,10 +1713,11 @@
             $_var_ref = substr($var_expr, 1);
         
         if(!$_has_math) {
-            // get [foo] and .foo and ->foo and (...) pieces
-            preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $_match);
             
-            $_indexes = $_match[0];
+            // get [foo] and .foo and ->foo and (...) pieces
+            preg_match_all('~(?:^\w+)|' . $this->_obj_params_regexp . '|(?:' . $this->_var_bracket_regexp . ')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match);
+                        
+            $_indexes = $match[0];
             $_var_name = array_shift($_indexes);
 
             /* Handle $smarty.* variable references as a special case. */

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.