~ubuntu-branches/ubuntu/dapper/smarty/dapper-updates

« back to all changes in this revision

Viewing changes to libs/Smarty_Compiler.class.php

  • Committer: Bazaar Package Importer
  • Author(s): Igor Genibel
  • Date: 2006-01-12 11:21:13 UTC
  • mfrom: (0.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060112112113-jnj3qjevq3otksra
Tags: 2.6.11-1
* New upstream release
* Added myself to Uploaders
* Ack previous NMU (Closes: #332098)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 * @link http://smarty.php.net/
22
22
 * @author Monte Ohrt <monte at ohrt dot com>
23
23
 * @author Andrei Zmievski <andrei@php.net>
24
 
 * @version 2.6.10
 
24
 * @version 2.6.11
25
25
 * @copyright 2001-2005 New Digital Group, Inc.
26
26
 * @package Smarty
27
27
 */
28
28
 
29
 
/* $Id: Smarty_Compiler.class.php,v 1.370 2005/08/04 19:43:21 messju Exp $ */
 
29
/* $Id: Smarty_Compiler.class.php,v 1.373 2005/11/29 12:22:54 messju Exp $ */
30
30
 
31
31
/**
32
32
 * Template compiling class
361
361
        $compiled_content .= $text_blocks[$i];
362
362
 
363
363
        // remove \n from the end of the file, if any
364
 
        if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) {
 
364
        if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) {
365
365
            $compiled_content = substr($compiled_content, 0, -1);
366
366
        }
367
367
 
425
425
    function _compile_tag($template_tag)
426
426
    {
427
427
        /* Matched comment. */
428
 
        if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*')
 
428
        if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*')
429
429
            return '';
430
430
        
431
431
        /* Split tag into two three parts: command, command modifiers and the arguments. */
529
529
 
530
530
            case 'strip':
531
531
            case '/strip':
532
 
                if ($tag_command{0}=='/') {
 
532
                if (substr($tag_command, 0, 1)=='/') {
533
533
                    $this->_pop_tag('strip');
534
534
                    if (--$this->_strip_depth==0) { /* outermost closing {/strip} */
535
535
                        $this->_additional_newline = "\n";
664
664
     */
665
665
    function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output)
666
666
    {
667
 
        if ($tag_command{0} == '/') {
 
667
        if (substr($tag_command, 0, 1) == '/') {
668
668
            $start_tag = false;
669
669
            $tag_command = substr($tag_command, 1);
670
670
        } else
826
826
     */
827
827
    function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier)
828
828
    {
829
 
        if ($tag_command{0} == '/') {
 
829
        if (substr($tag_command, 0, 1) == '/') {
830
830
            $start_tag = false;
831
831
            $tag_command = substr($tag_command, 1);
832
832
        } else {
1730
1730
        }
1731
1731
 
1732
1732
        // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit)
1733
 
        if(is_numeric($var_expr{0}))
 
1733
        if(is_numeric(substr($var_expr, 0, 1)))
1734
1734
            $_var_ref = $var_expr;
1735
1735
        else
1736
1736
            $_var_ref = substr($var_expr, 1);
1756
1756
                    $_var_name = substr(array_shift($_indexes), 1);
1757
1757
                    $_output = "\$this->_smarty_vars['$_var_name']";
1758
1758
                }
1759
 
            } elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) {
 
1759
            } elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) {
1760
1760
                // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers
1761
1761
                if(count($_indexes) > 0)
1762
1762
                {
1769
1769
            }
1770
1770
 
1771
1771
            foreach ($_indexes as $_index) {
1772
 
                if ($_index{0} == '[') {
 
1772
                if (substr($_index, 0, 1) == '[') {
1773
1773
                    $_index = substr($_index, 1, -1);
1774
1774
                    if (is_numeric($_index)) {
1775
1775
                        $_output .= "[$_index]";
1776
 
                    } elseif ($_index{0} == '$') {
 
1776
                    } elseif (substr($_index, 0, 1) == '$') {
1777
1777
                        if (strpos($_index, '.') !== false) {
1778
1778
                            $_output .= '[' . $this->_parse_var($_index) . ']';
1779
1779
                        } else {
1785
1785
                        $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] : 'index';
1786
1786
                        $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]";
1787
1787
                    }
1788
 
                } else if ($_index{0} == '.') {
1789
 
                    if ($_index{1} == '$')
 
1788
                } else if (substr($_index, 0, 1) == '.') {
 
1789
                    if (substr($_index, 1, 1) == '$')
1790
1790
                        $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]";
1791
1791
                    else
1792
1792
                        $_output .= "['" . substr($_index, 1) . "']";
1795
1795
                        $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1796
1796
                    } elseif($this->security && substr($_index, 2, 1) == '_') {
1797
1797
                        $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1798
 
                    } elseif ($_index{2} == '$') {
 
1798
                    } elseif (substr($_index, 2, 1) == '$') {
1799
1799
                        if ($this->security) {
1800
1800
                            $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1801
1801
                        } else {
1804
1804
                    } else {
1805
1805
                        $_output .= $_index;
1806
1806
                    }
1807
 
                } elseif ($_index{0} == '(') {
 
1807
                } elseif (substr($_index, 0, 1) == '(') {
1808
1808
                    $_index = $this->_parse_parenth_args($_index);
1809
1809
                    $_output .= $_index;
1810
1810
                } else {
1901
1901
            preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match);
1902
1902
            $_modifier_args = $_match[1];
1903
1903
 
1904
 
            if ($_modifier_name{0} == '@') {
 
1904
            if (substr($_modifier_name, 0, 1) == '@') {
1905
1905
                $_map_array = false;
1906
1906
                $_modifier_name = substr($_modifier_name, 1);
1907
1907
            } else {
1923
1923
 
1924
1924
            if($_modifier_name == 'default') {
1925
1925
                // supress notifications of default modifier vars and args
1926
 
                if($output{0} == '$') {
 
1926
                if(substr($output, 0, 1) == '$') {
1927
1927
                    $output = '@' . $output;
1928
1928
                }
1929
 
                if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') {
 
1929
                if(isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') {
1930
1930
                    $_modifier_args[0] = '@' . $_modifier_args[0];
1931
1931
                }
1932
1932
            }
1978
1978
        /* Extract the reference name. */
1979
1979
        $_ref = substr($indexes[0], 1);
1980
1980
        foreach($indexes as $_index_no=>$_index) {
1981
 
            if ($_index{0} != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) {
 
1981
            if (substr($_index, 0, 1) != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) {
1982
1982
                $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
1983
1983
            }
1984
1984
        }
2216
2216
        if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty'));
2217
2217
        $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:'
2218
2218
            . $this->_cache_serial . '#' . $this->_nocache_count
2219
 
            . '}\';}';
 
2219
            . '}\'; };';
2220
2220
        return $_ret;
2221
2221
    }
2222
2222
 
2233
2233
            || --$this->_cacheable_state>0) return '';
2234
2234
        return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
2235
2235
            . $this->_cache_serial . '#' . ($this->_nocache_count++)
2236
 
            . '}\';}';
 
2236
            . '}\'; };';
2237
2237
    }
2238
2238
 
2239
2239