Changeset 2961 for trunk/include/smarty/libs/Smarty_Compiler.class.php
- Timestamp:
- Dec 9, 2008, 5:08:48 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/smarty/libs/Smarty_Compiler.class.php
r2538 r2961 19 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 20 * 21 * @link http:// smarty.php.net/21 * @link http://www.smarty.net/ 22 22 * @author Monte Ohrt <monte at ohrt dot com> 23 23 * @author Andrei Zmievski <andrei@php.net> 24 * @version 2.6.2 024 * @version 2.6.21 25 25 * @copyright 2001-2005 New Digital Group, Inc. 26 26 * @package Smarty 27 27 */ 28 28 29 /* $Id: Smarty_Compiler.class.php 27 73 2008-08-12 18:17:51Z Uwe.Tews$ */29 /* $Id: Smarty_Compiler.class.php 2797 2008-09-22 19:26:32Z monte.ohrt $ */ 30 30 31 31 /** … … 74 74 var $_strip_depth = 0; 75 75 var $_additional_newline = "\n"; 76 77 var $_phpversion = 0; 78 76 79 77 80 /**#@-*/ … … 81 84 function Smarty_Compiler() 82 85 { 86 $this->_phpversion = substr(phpversion(),0,1); 87 83 88 // matches double quoted strings: 84 89 // "foobar" … … 153 158 // $foo->bar($foo->bar()) 154 159 // $foo->bar($foo->bar($blah,$foo,44,"foo",$foo[0].bar)) 160 // $foo->getBar()->getFoo() 161 // $foo->getBar()->foo 155 162 $this->_obj_ext_regexp = '\->(?:\$?' . $this->_dvar_guts_regexp . ')'; 156 163 $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+|' 160 168 . $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 162 171 . '(?:\s*,\s*' . $this->_obj_single_param_regexp . ')*)?\)'; 163 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 . ')*)?)'; 165 174 166 175 // matches valid modifier syntax: … … 1697 1706 // replace double quoted literal string with single quotes 1698 1707 $_return = preg_replace('~^"([\s\w]+)"$~',"'\\1'",$_return); 1708 // escape dollar sign if not printing a var 1709 $_return = preg_replace('~\$(\W)~',"\\\\\$\\1",$_return); 1699 1710 return $_return; 1700 1711 } … … 1710 1721 { 1711 1722 $_has_math = false; 1723 $_has_php4_method_chaining = false; 1712 1724 $_math_vars = preg_split('~('.$this->_dvar_math_regexp.'|'.$this->_qstr_regexp.')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE); 1713 1725 … … 1822 1834 } 1823 1835 } else { 1836 if ($this->_phpversion < 5) { 1837 $_has_php4_method_chaining = true; 1838 $_output .= "; \$_foo = \$_foo"; 1839 } 1824 1840 $_output .= $_index; 1825 1841 } … … 1833 1849 } 1834 1850 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 } 1836 1857 } 1837 1858
Note: See TracChangeset
for help on using the changeset viewer.