Ignore:
Timestamp:
Dec 9, 2008, 5:08:48 PM (15 years ago)
Author:
patdenice
Message:

Update Smarty to 2.6.21

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/smarty/libs/Smarty_Compiler.class.php

    r2538 r2961  
    1919 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2020 *
    21  * @link http://smarty.php.net/
     21 * @link http://www.smarty.net/
    2222 * @author Monte Ohrt <monte at ohrt dot com>
    2323 * @author Andrei Zmievski <andrei@php.net>
    24  * @version 2.6.20
     24 * @version 2.6.21
    2525 * @copyright 2001-2005 New Digital Group, Inc.
    2626 * @package Smarty
    2727 */
    2828
    29 /* $Id: Smarty_Compiler.class.php 2773 2008-08-12 18:17:51Z Uwe.Tews $ */
     29/* $Id: Smarty_Compiler.class.php 2797 2008-09-22 19:26:32Z monte.ohrt $ */
    3030
    3131/**
     
    7474    var $_strip_depth           =   0;
    7575    var $_additional_newline    =   "\n";
     76   
     77    var $_phpversion            =   0;
     78
    7679
    7780    /**#@-*/
     
    8184    function Smarty_Compiler()
    8285    {
     86        $this->_phpversion = substr(phpversion(),0,1);
     87
    8388        // matches double quoted strings:
    8489        // "foobar"
     
    153158        // $foo->bar($foo->bar())
    154159        // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar))
     160        // $foo->getBar()->getFoo()
     161        // $foo->getBar()->foo
    155162        $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')';
    156163        $this->_obj_restricted_param_regexp = '(?:'
    157                 . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
    158                 . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
    159         $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
     164             . '(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')(?:' . $this->_obj_ext_regexp . '(?:\((?:(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . ')'
     165             . '(?:\s*,\s*(?:' . $this->_var_regexp . '|' . $this->_num_const_regexp . '))*)?\))?)*)';
     166
     167       $this->_obj_single_param_regexp = '(?:\w+|' . $this->_obj_restricted_param_regexp . '(?:\s*,\s*(?:(?:\w+|'
    160168                . $this->_var_regexp . $this->_obj_restricted_param_regexp . ')))*)';
    161         $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
     169
     170       $this->_obj_params_regexp = '\((?:' . $this->_obj_single_param_regexp
    162171                . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)';
    163         $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
    164         $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 . ')*)?)';
     172       $this->_obj_start_regexp = '(?:' . $this->_dvar_regexp . '(?:' . $this->_obj_ext_regexp . ')+)';
     173       $this->_obj_call_regexp = '(?:' . $this->_obj_start_regexp . '(?:' . $this->_obj_params_regexp . '(?:' . $this->_obj_ext_regexp . '(?:'.$this->_obj_params_regexp . ')?)*' . ')?(?:' . $this->_dvar_math_regexp . '(?:' . $this->_num_const_regexp . '|' . $this->_dvar_math_var_regexp . ')*)?)';
    165174       
    166175        // matches valid modifier syntax:
     
    16971706        // replace double quoted literal string with single quotes
    16981707        $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return);
     1708        // escape dollar sign if not printing a var
     1709        $_return = preg_replace('~\$(\W)~',"\\\\\$\\1",$_return);
    16991710        return $_return;
    17001711    }
     
    17101721    {
    17111722        $_has_math = false;
     1723        $_has_php4_method_chaining = false;
    17121724        $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
    17131725
     
    18221834                        }
    18231835                    } else {
     1836                       if ($this->_phpversion < 5) {
     1837                         $_has_php4_method_chaining = true;
     1838                         $_output .= "; \$_foo = \$_foo";
     1839                       }
    18241840                        $_output .= $_index;
    18251841                    }
     
    18331849        }
    18341850
    1835         return $_output;
     1851        if ($_has_php4_method_chaining) {
     1852           $_tmp = str_replace("'","\'",'$_foo = '.$_output.'; return $_foo;');
     1853           return "eval('".$_tmp."')";
     1854        } else {
     1855           return $_output;
     1856        }
    18361857    }
    18371858
Note: See TracChangeset for help on using the changeset viewer.