logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1343084 [9/13] - in /logging/site/branches/cms/trunk: ./ content/ content/pages/ content/resources/ content/resources/css/ content/resources/img/ content/resources/js/ libs/ libs/Twig/ libs/Twig/lib/ libs/Twig/lib/Twig/ libs/Twig/lib/Twig/...
Date Sun, 27 May 2012 19:59:52 GMT
Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Lexer.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Lexer.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Lexer.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Lexer.php Sun May 27 19:59:46 2012
@@ -0,0 +1,406 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Lexes a template string.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Lexer implements Twig_LexerInterface
+{
+    protected $tokens;
+    protected $code;
+    protected $cursor;
+    protected $lineno;
+    protected $end;
+    protected $state;
+    protected $states;
+    protected $brackets;
+    protected $env;
+    protected $filename;
+    protected $options;
+    protected $regexes;
+    protected $position;
+    protected $positions;
+
+    const STATE_DATA            = 0;
+    const STATE_BLOCK           = 1;
+    const STATE_VAR             = 2;
+    const STATE_STRING          = 3;
+    const STATE_INTERPOLATION   = 4;
+
+    const REGEX_NAME            = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
+    const REGEX_NUMBER          = '/[0-9]+(?:\.[0-9]+)?/A';
+    const REGEX_STRING          = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
+    const REGEX_DQ_STRING_DELIM = '/"/A';
+    const REGEX_DQ_STRING_PART  = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
+    const PUNCTUATION           = '()[]{}?:.,|';
+
+    public function __construct(Twig_Environment $env, array $options = array())
+    {
+        $this->env = $env;
+
+        $this->options = array_merge(array(
+            'tag_comment'     => array('{#', '#}'),
+            'tag_block'       => array('{%', '%}'),
+            'tag_variable'    => array('{{', '}}'),
+            'whitespace_trim' => '-',
+            'interpolation'   => array('#{', '}'),
+        ), $options);
+
+        $this->regexes = array(
+            'lex_var'             => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
+            'lex_block'           => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
+            'lex_raw_data'        => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*endraw\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
+            'operator'            => $this->getOperatorRegex(),
+            'lex_comment'         => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s',
+            'lex_block_raw'       => '/\s*raw\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As',
+            'lex_block_line'      => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As',
+            'lex_tokens_start'    => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
+            'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
+            'interpolation_end'   => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
+        );
+    }
+
+    /**
+     * Tokenizes a source code.
+     *
+     * @param  string $code     The source code
+     * @param  string $filename A unique identifier for the source code
+     *
+     * @return Twig_TokenStream A token stream instance
+     */
+    public function tokenize($code, $filename = null)
+    {
+        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
+            $mbEncoding = mb_internal_encoding();
+            mb_internal_encoding('ASCII');
+        }
+
+        $this->code = str_replace(array("\r\n", "\r"), "\n", $code);
+        $this->filename = $filename;
+        $this->cursor = 0;
+        $this->lineno = 1;
+        $this->end = strlen($this->code);
+        $this->tokens = array();
+        $this->state = self::STATE_DATA;
+        $this->states = array();
+        $this->brackets = array();
+        $this->position = -1;
+
+        // find all token starts in one go
+        preg_match_all($this->regexes['lex_tokens_start'], $this->code, $matches, PREG_OFFSET_CAPTURE);
+        $this->positions = $matches;
+
+        while ($this->cursor < $this->end) {
+            // dispatch to the lexing functions depending
+            // on the current state
+            switch ($this->state) {
+                case self::STATE_DATA:
+                    $this->lexData();
+                    break;
+
+                case self::STATE_BLOCK:
+                    $this->lexBlock();
+                    break;
+
+                case self::STATE_VAR:
+                    $this->lexVar();
+                    break;
+
+                case self::STATE_STRING:
+                    $this->lexString();
+                    break;
+
+                case self::STATE_INTERPOLATION:
+                    $this->lexInterpolation();
+                    break;
+            }
+        }
+
+        $this->pushToken(Twig_Token::EOF_TYPE);
+
+        if (!empty($this->brackets)) {
+            list($expect, $lineno) = array_pop($this->brackets);
+            throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+        }
+
+        if (isset($mbEncoding)) {
+            mb_internal_encoding($mbEncoding);
+        }
+
+        return new Twig_TokenStream($this->tokens, $this->filename);
+    }
+
+    protected function lexData()
+    {
+        // if no matches are left we return the rest of the template as simple text token
+        if ($this->position == count($this->positions[0]) - 1) {
+            $this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
+            $this->cursor = $this->end;
+
+            return;
+        }
+
+        // Find the first token after the current cursor
+        $position = $this->positions[0][++$this->position];
+        while ($position[1] < $this->cursor) {
+            if ($this->position == count($this->positions[0]) - 1) {
+                return;
+            }
+            $position = $this->positions[0][++$this->position];
+        }
+
+        // push the template text first
+        $text = $textContent = substr($this->code, $this->cursor, $position[1] - $this->cursor);
+        if (isset($this->positions[2][$this->position][0])) {
+            $text = rtrim($text);
+        }
+        $this->pushToken(Twig_Token::TEXT_TYPE, $text);
+        $this->moveCursor($textContent.$position[0]);
+
+        switch ($this->positions[1][$this->position][0]) {
+            case $this->options['tag_comment'][0]:
+                $this->lexComment();
+                break;
+
+            case $this->options['tag_block'][0]:
+                // raw data?
+                if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) {
+                    $this->moveCursor($match[0]);
+                    $this->lexRawData();
+                // {% line \d+ %}
+                } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) {
+                    $this->moveCursor($match[0]);
+                    $this->lineno = (int) $match[1];
+                } else {
+                    $this->pushToken(Twig_Token::BLOCK_START_TYPE);
+                    $this->pushState(self::STATE_BLOCK);
+                }
+                break;
+
+            case $this->options['tag_variable'][0]:
+                $this->pushToken(Twig_Token::VAR_START_TYPE);
+                $this->pushState(self::STATE_VAR);
+                break;
+        }
+    }
+
+    protected function lexBlock()
+    {
+        if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
+            $this->pushToken(Twig_Token::BLOCK_END_TYPE);
+            $this->moveCursor($match[0]);
+            $this->popState();
+        } else {
+            $this->lexExpression();
+        }
+    }
+
+    protected function lexVar()
+    {
+        if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
+            $this->pushToken(Twig_Token::VAR_END_TYPE);
+            $this->moveCursor($match[0]);
+            $this->popState();
+        } else {
+            $this->lexExpression();
+        }
+    }
+
+    protected function lexExpression()
+    {
+        // whitespace
+        if (preg_match('/\s+/A', $this->code, $match, null, $this->cursor)) {
+            $this->moveCursor($match[0]);
+
+            if ($this->cursor >= $this->end) {
+                throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->lineno, $this->filename);
+            }
+        }
+
+        // operators
+        if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) {
+            $this->pushToken(Twig_Token::OPERATOR_TYPE, $match[0]);
+            $this->moveCursor($match[0]);
+        }
+        // names
+        elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) {
+            $this->pushToken(Twig_Token::NAME_TYPE, $match[0]);
+            $this->moveCursor($match[0]);
+        }
+        // numbers
+        elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) {
+            $number = (float) $match[0];  // floats
+            if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
+                $number = (int) $match[0]; // integers lower than the maximum
+            }
+            $this->pushToken(Twig_Token::NUMBER_TYPE, $number);
+            $this->moveCursor($match[0]);
+        }
+        // punctuation
+        elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
+            // opening bracket
+            if (false !== strpos('([{', $this->code[$this->cursor])) {
+                $this->brackets[] = array($this->code[$this->cursor], $this->lineno);
+            }
+            // closing bracket
+            elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
+                if (empty($this->brackets)) {
+                    throw new Twig_Error_Syntax(sprintf('Unexpected "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
+                }
+
+                list($expect, $lineno) = array_pop($this->brackets);
+                if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
+                    throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+                }
+            }
+
+            $this->pushToken(Twig_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]);
+            ++$this->cursor;
+        }
+        // strings
+        elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
+            $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)));
+            $this->moveCursor($match[0]);
+        }
+        // opening double quoted string
+        elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
+            $this->brackets[] = array('"', $this->lineno);
+            $this->pushState(self::STATE_STRING);
+            $this->moveCursor($match[0]);
+        }
+        // unlexable
+        else {
+            throw new Twig_Error_Syntax(sprintf('Unexpected character "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
+        }
+    }
+
+    protected function lexRawData()
+    {
+        if (!preg_match($this->regexes['lex_raw_data'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
+            throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "block"'), $this->lineno, $this->filename);
+        }
+
+        $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
+        $this->moveCursor($text.$match[0][0]);
+
+        if (false !== strpos($match[1][0], $this->options['whitespace_trim'])) {
+            $text = rtrim($text);
+        }
+
+        $this->pushToken(Twig_Token::TEXT_TYPE, $text);
+    }
+
+    protected function lexComment()
+    {
+        if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
+            throw new Twig_Error_Syntax('Unclosed comment', $this->lineno, $this->filename);
+        }
+
+        $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
+    }
+
+    protected function lexString()
+    {
+        if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
+            $this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
+            $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
+            $this->moveCursor($match[0]);
+            $this->pushState(self::STATE_INTERPOLATION);
+
+        } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
+            $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
+            $this->moveCursor($match[0]);
+
+        } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
+
+            list($expect, $lineno) = array_pop($this->brackets);
+            if ($this->code[$this->cursor] != '"') {
+                throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+            }
+
+            $this->popState();
+            ++$this->cursor;
+        }
+    }
+
+    protected function lexInterpolation()
+    {
+        $bracket = end($this->brackets);
+        if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
+            array_pop($this->brackets);
+            $this->pushToken(Twig_Token::INTERPOLATION_END_TYPE);
+            $this->moveCursor($match[0]);
+            $this->popState();
+        } else {
+            $this->lexExpression();
+        }
+    }
+
+    protected function pushToken($type, $value = '')
+    {
+        // do not push empty text tokens
+        if (Twig_Token::TEXT_TYPE === $type && '' === $value) {
+            return;
+        }
+
+        $this->tokens[] = new Twig_Token($type, $value, $this->lineno);
+    }
+
+    protected function moveCursor($text)
+    {
+        $this->cursor += strlen($text);
+        $this->lineno += substr_count($text, "\n");
+    }
+
+    protected function getOperatorRegex()
+    {
+        $operators = array_merge(
+            array('='),
+            array_keys($this->env->getUnaryOperators()),
+            array_keys($this->env->getBinaryOperators())
+        );
+
+        $operators = array_combine($operators, array_map('strlen', $operators));
+        arsort($operators);
+
+        $regex = array();
+        foreach ($operators as $operator => $length) {
+            // an operator that ends with a character must be followed by
+            // a whitespace or a parenthesis
+            if (ctype_alpha($operator[$length - 1])) {
+                $regex[] = preg_quote($operator, '/').'(?=[\s()])';
+            } else {
+                $regex[] = preg_quote($operator, '/');
+            }
+        }
+
+        return '/'.implode('|', $regex).'/A';
+    }
+
+    protected function pushState($state)
+    {
+        $this->states[] = $this->state;
+        $this->state = $state;
+    }
+
+    protected function popState()
+    {
+        if (0 === count($this->states)) {
+            throw new Exception('Cannot pop state without a previous state');
+        }
+
+        $this->state = array_pop($this->states);
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LexerInterface.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LexerInterface.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LexerInterface.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LexerInterface.php Sun May 27 19:59:46 2012
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Interface implemented by lexer classes.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+interface Twig_LexerInterface
+{
+    /**
+     * Tokenizes a source code.
+     *
+     * @param  string $code     The source code
+     * @param  string $filename A unique identifier for the source code
+     *
+     * @return Twig_TokenStream A token stream instance
+     */
+    function tokenize($code, $filename = null);
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Array.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Array.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Array.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Array.php Sun May 27 19:59:46 2012
@@ -0,0 +1,102 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Loads a template from an array.
+ *
+ * When using this loader with a cache mechanism, you should know that a new cache
+ * key is generated each time a template content "changes" (the cache key being the
+ * source code of the template). If you don't want to see your cache grows out of
+ * control, you need to take care of clearing the old cache file by yourself.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Loader_Array implements Twig_LoaderInterface
+{
+    protected $templates;
+
+    /**
+     * Constructor.
+     *
+     * @param array $templates An array of templates (keys are the names, and values are the source code)
+     *
+     * @see Twig_Loader
+     */
+    public function __construct(array $templates)
+    {
+        $this->templates = array();
+        foreach ($templates as $name => $template) {
+            $this->templates[$name] = $template;
+        }
+    }
+
+    /**
+     * Adds or overrides a template.
+     *
+     * @param string $name     The template name
+     * @param string $template The template source
+     */
+    public function setTemplate($name, $template)
+    {
+        $this->templates[(string) $name] = $template;
+    }
+
+    /**
+     * Gets the source code of a template, given its name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The template source code
+     */
+    public function getSource($name)
+    {
+        $name = (string) $name;
+        if (!isset($this->templates[$name])) {
+            throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+        }
+
+        return $this->templates[$name];
+    }
+
+    /**
+     * Gets the cache key to use for the cache for a given template name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The cache key
+     */
+    public function getCacheKey($name)
+    {
+        $name = (string) $name;
+        if (!isset($this->templates[$name])) {
+            throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+        }
+
+        return $this->templates[$name];
+    }
+
+    /**
+     * Returns true if the template is still fresh.
+     *
+     * @param string    $name The template name
+     * @param timestamp $time The last modification time of the cached template
+     */
+    public function isFresh($name, $time)
+    {
+        $name = (string) $name;
+        if (!isset($this->templates[$name])) {
+            throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+        }
+
+        return true;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Chain.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Chain.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Chain.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Chain.php Sun May 27 19:59:46 2012
@@ -0,0 +1,100 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Loads templates from other loaders.
+ *
+ * @package twig
+ * @author  Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Loader_Chain implements Twig_LoaderInterface
+{
+    protected $loaders;
+
+    /**
+     * Constructor.
+     *
+     * @param Twig_LoaderInterface[] $loaders An array of loader instances
+     */
+    public function __construct(array $loaders = array())
+    {
+        $this->loaders = array();
+        foreach ($loaders as $loader) {
+            $this->addLoader($loader);
+        }
+    }
+
+    /**
+     * Adds a loader instance.
+     *
+     * @param Twig_LoaderInterface $loader A Loader instance
+     */
+    public function addLoader(Twig_LoaderInterface $loader)
+    {
+        $this->loaders[] = $loader;
+    }
+
+    /**
+     * Gets the source code of a template, given its name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The template source code
+     */
+    public function getSource($name)
+    {
+        foreach ($this->loaders as $loader) {
+            try {
+                return $loader->getSource($name);
+            } catch (Twig_Error_Loader $e) {
+            }
+        }
+
+        throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+    }
+
+    /**
+     * Gets the cache key to use for the cache for a given template name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The cache key
+     */
+    public function getCacheKey($name)
+    {
+        foreach ($this->loaders as $loader) {
+            try {
+                return $loader->getCacheKey($name);
+            } catch (Twig_Error_Loader $e) {
+            }
+        }
+
+        throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+    }
+
+    /**
+     * Returns true if the template is still fresh.
+     *
+     * @param string    $name The template name
+     * @param timestamp $time The last modification time of the cached template
+     */
+    public function isFresh($name, $time)
+    {
+        foreach ($this->loaders as $loader) {
+            try {
+                return $loader->isFresh($name, $time);
+            } catch (Twig_Error_Loader $e) {
+            }
+        }
+
+        throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Filesystem.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Filesystem.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Filesystem.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/Filesystem.php Sun May 27 19:59:46 2012
@@ -0,0 +1,152 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Loads template from the filesystem.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Loader_Filesystem implements Twig_LoaderInterface
+{
+    protected $paths;
+    protected $cache;
+
+    /**
+     * Constructor.
+     *
+     * @param string|array $paths A path or an array of paths where to look for templates
+     */
+    public function __construct($paths)
+    {
+        $this->setPaths($paths);
+    }
+
+    /**
+     * Returns the paths to the templates.
+     *
+     * @return array The array of paths where to look for templates
+     */
+    public function getPaths()
+    {
+        return $this->paths;
+    }
+
+    /**
+     * Sets the paths where templates are stored.
+     *
+     * @param string|array $paths A path or an array of paths where to look for templates
+     */
+    public function setPaths($paths)
+    {
+        if (!is_array($paths)) {
+            $paths = array($paths);
+        }
+
+        $this->paths = array();
+        foreach ($paths as $path) {
+            $this->addPath($path);
+        }
+    }
+
+    /**
+     * Adds a path where templates are stored.
+     *
+     * @param string $path A path where to look for templates
+     */
+    public function addPath($path)
+    {
+        // invalidate the cache
+        $this->cache = array();
+
+        if (!is_dir($path)) {
+            throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
+        }
+
+        $this->paths[] = $path;
+    }
+
+    /**
+     * Gets the source code of a template, given its name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The template source code
+     */
+    public function getSource($name)
+    {
+        return file_get_contents($this->findTemplate($name));
+    }
+
+    /**
+     * Gets the cache key to use for the cache for a given template name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The cache key
+     */
+    public function getCacheKey($name)
+    {
+        return $this->findTemplate($name);
+    }
+
+    /**
+     * Returns true if the template is still fresh.
+     *
+     * @param string    $name The template name
+     * @param timestamp $time The last modification time of the cached template
+     */
+    public function isFresh($name, $time)
+    {
+        return filemtime($this->findTemplate($name)) <= $time;
+    }
+
+    protected function findTemplate($name)
+    {
+        // normalize name
+        $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));
+
+        if (isset($this->cache[$name])) {
+            return $this->cache[$name];
+        }
+
+        $this->validateName($name);
+
+        foreach ($this->paths as $path) {
+            if (is_file($path.'/'.$name)) {
+                return $this->cache[$name] = $path.'/'.$name;
+            }
+        }
+
+        throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths)));
+    }
+
+    protected function validateName($name)
+    {
+        if (false !== strpos($name, "\0")) {
+            throw new Twig_Error_Loader('A template name cannot contain NUL bytes.');
+        }
+
+        $parts = explode('/', $name);
+        $level = 0;
+        foreach ($parts as $part) {
+            if ('..' === $part) {
+                --$level;
+            } elseif ('.' !== $part) {
+                ++$level;
+            }
+
+            if ($level < 0) {
+                throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
+            }
+        }
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/String.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/String.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/String.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Loader/String.php Sun May 27 19:59:46 2012
@@ -0,0 +1,59 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Loads a template from a string.
+ *
+ * When using this loader with a cache mechanism, you should know that a new cache
+ * key is generated each time a template content "changes" (the cache key being the
+ * source code of the template). If you don't want to see your cache grows out of
+ * control, you need to take care of clearing the old cache file by yourself.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Loader_String implements Twig_LoaderInterface
+{
+    /**
+     * Gets the source code of a template, given its name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The template source code
+     */
+    public function getSource($name)
+    {
+        return $name;
+    }
+
+    /**
+     * Gets the cache key to use for the cache for a given template name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The cache key
+     */
+    public function getCacheKey($name)
+    {
+        return $name;
+    }
+
+    /**
+     * Returns true if the template is still fresh.
+     *
+     * @param string    $name The template name
+     * @param timestamp $time The last modification time of the cached template
+     */
+    public function isFresh($name, $time)
+    {
+        return true;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LoaderInterface.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LoaderInterface.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LoaderInterface.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/LoaderInterface.php Sun May 27 19:59:46 2012
@@ -0,0 +1,53 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Interface all loaders must implement.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+interface Twig_LoaderInterface
+{
+    /**
+     * Gets the source code of a template, given its name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The template source code
+     *
+     * @throws Twig_Error_Loader When $name is not found
+     */
+    function getSource($name);
+
+    /**
+     * Gets the cache key to use for the cache for a given template name.
+     *
+     * @param  string $name The name of the template to load
+     *
+     * @return string The cache key
+     *
+     * @throws Twig_Error_Loader When $name is not found
+     */
+    function getCacheKey($name);
+
+    /**
+     * Returns true if the template is still fresh.
+     *
+     * @param string    $name The template name
+     * @param timestamp $time The last modification time of the cached template
+     *
+     * @return Boolean true if the template is fresh, false otherwise
+     *
+     * @throws Twig_Error_Loader When $name is not found
+     */
+    function isFresh($name, $time);
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Markup.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Markup.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Markup.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Markup.php Sun May 27 19:59:46 2012
@@ -0,0 +1,38 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Marks a content as safe.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Markup implements Countable
+{
+    protected $content;
+    protected $charset;
+
+    public function __construct($content, $charset)
+    {
+        $this->content = (string) $content;
+        $this->charset = $charset;
+    }
+
+    public function __toString()
+    {
+        return $this->content;
+    }
+
+    public function count()
+    {
+        return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node.php Sun May 27 19:59:46 2012
@@ -0,0 +1,227 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a node in the AST.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node implements Twig_NodeInterface
+{
+    protected $nodes;
+    protected $attributes;
+    protected $lineno;
+    protected $tag;
+
+    /**
+     * Constructor.
+     *
+     * The nodes are automatically made available as properties ($this->node).
+     * The attributes are automatically made available as array items ($this['name']).
+     *
+     * @param array   $nodes      An array of named nodes
+     * @param array   $attributes An array of attributes (should not be nodes)
+     * @param integer $lineno     The line number
+     * @param string  $tag        The tag name associated with the Node
+     */
+    public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
+    {
+        $this->nodes = $nodes;
+        $this->attributes = $attributes;
+        $this->lineno = $lineno;
+        $this->tag = $tag;
+    }
+
+    public function __toString()
+    {
+        $attributes = array();
+        foreach ($this->attributes as $name => $value) {
+            $attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
+        }
+
+        $repr = array(get_class($this).'('.implode(', ', $attributes));
+
+        if (count($this->nodes)) {
+            foreach ($this->nodes as $name => $node) {
+                $len = strlen($name) + 4;
+                $noderepr = array();
+                foreach (explode("\n", (string) $node) as $line) {
+                    $noderepr[] = str_repeat(' ', $len).$line;
+                }
+
+                $repr[] = sprintf('  %s: %s', $name, ltrim(implode("\n", $noderepr)));
+            }
+
+            $repr[] = ')';
+        } else {
+            $repr[0] .= ')';
+        }
+
+        return implode("\n", $repr);
+    }
+
+    public function toXml($asDom = false)
+    {
+        $dom = new DOMDocument('1.0', 'UTF-8');
+        $dom->formatOutput = true;
+        $dom->appendChild($xml = $dom->createElement('twig'));
+
+        $xml->appendChild($node = $dom->createElement('node'));
+        $node->setAttribute('class', get_class($this));
+
+        foreach ($this->attributes as $name => $value) {
+            $node->appendChild($attribute = $dom->createElement('attribute'));
+            $attribute->setAttribute('name', $name);
+            $attribute->appendChild($dom->createTextNode($value));
+        }
+
+        foreach ($this->nodes as $name => $n) {
+            if (null === $n) {
+                continue;
+            }
+
+            $child = $n->toXml(true)->getElementsByTagName('node')->item(0);
+            $child = $dom->importNode($child, true);
+            $child->setAttribute('name', $name);
+
+            $node->appendChild($child);
+        }
+
+        return $asDom ? $dom : $dom->saveXml();
+    }
+
+    public function compile(Twig_Compiler $compiler)
+    {
+        foreach ($this->nodes as $node) {
+            $node->compile($compiler);
+        }
+    }
+
+    public function getLine()
+    {
+        return $this->lineno;
+    }
+
+    public function getNodeTag()
+    {
+        return $this->tag;
+    }
+
+    /**
+     * Returns true if the attribute is defined.
+     *
+     * @param  string  The attribute name
+     *
+     * @return Boolean true if the attribute is defined, false otherwise
+     */
+    public function hasAttribute($name)
+    {
+        return array_key_exists($name, $this->attributes);
+    }
+
+    /**
+     * Gets an attribute.
+     *
+     * @param  string The attribute name
+     *
+     * @return mixed  The attribute value
+     */
+    public function getAttribute($name)
+    {
+        if (!array_key_exists($name, $this->attributes)) {
+            throw new Twig_Error_Runtime(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this)));
+        }
+
+        return $this->attributes[$name];
+    }
+
+    /**
+     * Sets an attribute.
+     *
+     * @param string The attribute name
+     * @param mixed  The attribute value
+     */
+    public function setAttribute($name, $value)
+    {
+        $this->attributes[$name] = $value;
+    }
+
+    /**
+     * Removes an attribute.
+     *
+     * @param string The attribute name
+     */
+    public function removeAttribute($name)
+    {
+        unset($this->attributes[$name]);
+    }
+
+    /**
+     * Returns true if the node with the given identifier exists.
+     *
+     * @param  string  The node name
+     *
+     * @return Boolean true if the node with the given name exists, false otherwise
+     */
+    public function hasNode($name)
+    {
+        return array_key_exists($name, $this->nodes);
+    }
+
+    /**
+     * Gets a node by name.
+     *
+     * @param  string The node name
+     *
+     * @return Twig_Node A Twig_Node instance
+     */
+    public function getNode($name)
+    {
+        if (!array_key_exists($name, $this->nodes)) {
+            throw new Twig_Error_Runtime(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
+        }
+
+        return $this->nodes[$name];
+    }
+
+    /**
+     * Sets a node.
+     *
+     * @param string    The node name
+     * @param Twig_Node A Twig_Node instance
+     */
+    public function setNode($name, $node = null)
+    {
+        $this->nodes[$name] = $node;
+    }
+
+    /**
+     * Removes a node by name.
+     *
+     * @param string The node name
+     */
+    public function removeNode($name)
+    {
+        unset($this->nodes[$name]);
+    }
+
+    public function count()
+    {
+        return count($this->nodes);
+    }
+
+    public function getIterator()
+    {
+        return new ArrayIterator($this->nodes);
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/AutoEscape.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/AutoEscape.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/AutoEscape.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/AutoEscape.php Sun May 27 19:59:46 2012
@@ -0,0 +1,40 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents an autoescape node.
+ *
+ * The value is the escaping strategy (can be html, js, ...)
+ *
+ * The true value is equivalent to html.
+ *
+ * If autoescaping is disabled, then the value is false.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_AutoEscape extends Twig_Node
+{
+    public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
+    {
+        parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->subcompile($this->getNode('body'));
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Block.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Block.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Block.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Block.php Sun May 27 19:59:46 2012
@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a block node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Block extends Twig_Node
+{
+    public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
+    {
+        parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->addDebugInfo($this)
+            ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
+            ->indent()
+        ;
+
+        $compiler
+            ->subcompile($this->getNode('body'))
+            ->outdent()
+            ->write("}\n\n")
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/BlockReference.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/BlockReference.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/BlockReference.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/BlockReference.php Sun May 27 19:59:46 2012
@@ -0,0 +1,38 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a block call node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface
+{
+    public function __construct($name, $lineno, $tag = null)
+    {
+        parent::__construct(array(), array('name' => $name), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->addDebugInfo($this)
+            ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Body.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Body.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Body.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Body.php Sun May 27 19:59:46 2012
@@ -0,0 +1,20 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a body node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Body extends Twig_Node
+{
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Do.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Do.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Do.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Do.php Sun May 27 19:59:46 2012
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a do node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Do extends Twig_Node
+{
+    public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
+    {
+        parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->addDebugInfo($this)
+            ->write('')
+            ->subcompile($this->getNode('expr'))
+            ->raw(";\n")
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Embed.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Embed.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Embed.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Embed.php Sun May 27 19:59:46 2012
@@ -0,0 +1,39 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2012 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents an embed node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Embed extends Twig_Node_Include
+{
+    // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
+    public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
+    {
+        parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
+
+        $this->setAttribute('filename', $filename);
+        $this->setAttribute('index', $index);
+    }
+
+    protected function addGetTemplate(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->write("\$this->env->loadTemplate(")
+            ->string($this->getAttribute('filename'))
+            ->raw(', ')
+            ->string($this->getAttribute('index'))
+            ->raw(")")
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression.php Sun May 27 19:59:46 2012
@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Abstract class for all nodes that represents an expression.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+abstract class Twig_Node_Expression extends Twig_Node
+{
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Array.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Array.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Array.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Array.php Sun May 27 19:59:46 2012
@@ -0,0 +1,86 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Array extends Twig_Node_Expression
+{
+    protected $index;
+
+    public function __construct(array $elements, $lineno)
+    {
+        parent::__construct($elements, array(), $lineno);
+
+        $this->index = -1;
+        foreach ($this->getKeyValuePairs() as $pair) {
+            if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) {
+                $this->index = $pair['key']->getAttribute('value');
+            }
+        }
+    }
+
+    public function getKeyValuePairs()
+    {
+        $pairs = array();
+
+        foreach (array_chunk($this->nodes, 2) as $pair) {
+            $pairs[] = array(
+                'key' => $pair[0],
+                'value' => $pair[1],
+            );
+        }
+
+        return $pairs;
+    }
+
+    public function hasElement(Twig_Node_Expression $key)
+    {
+        foreach ($this->getKeyValuePairs() as $pair) {
+            // we compare the string representation of the keys
+            // to avoid comparing the line numbers which are not relevant here.
+            if ((string) $key == (string) $pair['key']) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null)
+    {
+        if (null === $key) {
+            $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine());
+        }
+
+        array_push($this->nodes, $key, $value);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->raw('array(');
+        $first = true;
+        foreach ($this->getKeyValuePairs() as $pair) {
+            if (!$first) {
+                $compiler->raw(', ');
+            }
+            $first = false;
+
+            $compiler
+                ->subcompile($pair['key'])
+                ->raw(' => ')
+                ->subcompile($pair['value'])
+            ;
+        }
+        $compiler->raw(')');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/AssignName.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/AssignName.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/AssignName.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/AssignName.php Sun May 27 19:59:46 2012
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('$context[')
+            ->string($this->getAttribute('name'))
+            ->raw(']')
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary.php Sun May 27 19:59:46 2012
@@ -0,0 +1,40 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
+{
+    public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
+    {
+        parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('(')
+            ->subcompile($this->getNode('left'))
+            ->raw(' ')
+        ;
+        $this->operator($compiler);
+        $compiler
+            ->raw(' ')
+            ->subcompile($this->getNode('right'))
+            ->raw(')')
+        ;
+    }
+
+    abstract public function operator(Twig_Compiler $compiler);
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Add.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Add.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Add.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Add.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('+');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/And.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/And.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/And.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/And.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('&&');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('&');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('|');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('^');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Concat.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Concat.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Concat.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Concat.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('.');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Div.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Div.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Div.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Div.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('/');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Equal.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Equal.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Equal.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Equal.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('==');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/FloorDiv.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/FloorDiv.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/FloorDiv.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/FloorDiv.php Sun May 27 19:59:46 2012
@@ -0,0 +1,29 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->raw('intval(floor(');
+        parent::compile($compiler);
+        $compiler->raw('))');
+    }
+
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('/');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Greater.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Greater.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Greater.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Greater.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('>');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('>=');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/In.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/In.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/In.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/In.php Sun May 27 19:59:46 2012
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('twig_in_filter(')
+            ->subcompile($this->getNode('left'))
+            ->raw(', ')
+            ->subcompile($this->getNode('right'))
+            ->raw(')')
+        ;
+    }
+
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('in');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Less.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Less.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Less.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Less.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('<');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/LessEqual.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/LessEqual.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/LessEqual.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/LessEqual.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('<=');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mod.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mod.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mod.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mod.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('%');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mul.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mul.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mul.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Mul.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('*');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotEqual.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotEqual.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotEqual.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotEqual.php Sun May 27 19:59:46 2012
@@ -0,0 +1,17 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('!=');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotIn.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotIn.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotIn.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/NotIn.php Sun May 27 19:59:46 2012
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('!twig_in_filter(')
+            ->subcompile($this->getNode('left'))
+            ->raw(', ')
+            ->subcompile($this->getNode('right'))
+            ->raw(')')
+        ;
+    }
+
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('not in');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Or.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Or.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Or.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Or.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('||');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Power.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Power.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Power.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Power.php Sun May 27 19:59:46 2012
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('pow(')
+            ->subcompile($this->getNode('left'))
+            ->raw(', ')
+            ->subcompile($this->getNode('right'))
+            ->raw(')')
+        ;
+    }
+
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('**');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Range.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Range.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Range.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Range.php Sun May 27 19:59:46 2012
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
+{
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('range(')
+            ->subcompile($this->getNode('left'))
+            ->raw(', ')
+            ->subcompile($this->getNode('right'))
+            ->raw(')')
+        ;
+    }
+
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('..');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Sub.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Sub.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Sub.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Binary/Sub.php Sun May 27 19:59:46 2012
@@ -0,0 +1,18 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary
+{
+    public function operator(Twig_Compiler $compiler)
+    {
+        return $compiler->raw('-');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/BlockReference.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/BlockReference.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/BlockReference.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/BlockReference.php Sun May 27 19:59:46 2012
@@ -0,0 +1,52 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents a block call node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
+{
+    public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null)
+    {
+        parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        if ($this->getAttribute('as_string')) {
+            $compiler->raw('(string) ');
+        }
+
+        if ($this->getAttribute('output')) {
+            $compiler
+                ->addDebugInfo($this)
+                ->write("\$this->displayBlock(")
+                ->subcompile($this->getNode('name'))
+                ->raw(", \$context, \$blocks);\n")
+            ;
+        } else {
+            $compiler
+                ->raw("\$this->renderBlock(")
+                ->subcompile($this->getNode('name'))
+                ->raw(", \$context, \$blocks)")
+            ;
+        }
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Conditional.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Conditional.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Conditional.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Conditional.php Sun May 27 19:59:46 2012
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Conditional extends Twig_Node_Expression
+{
+    public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno)
+    {
+        parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
+    }
+
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler
+            ->raw('((')
+            ->subcompile($this->getNode('expr1'))
+            ->raw(') ? (')
+            ->subcompile($this->getNode('expr2'))
+            ->raw(') : (')
+            ->subcompile($this->getNode('expr3'))
+            ->raw('))')
+        ;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Constant.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Constant.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Constant.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Constant.php Sun May 27 19:59:46 2012
@@ -0,0 +1,23 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Constant extends Twig_Node_Expression
+{
+    public function __construct($value, $lineno)
+    {
+        parent::__construct(array(), array('value' => $value), $lineno);
+    }
+
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->repr($this->getAttribute('value'));
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/ExtensionReference.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/ExtensionReference.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/ExtensionReference.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/ExtensionReference.php Sun May 27 19:59:46 2012
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Represents an extension call node.
+ *
+ * @package    twig
+ * @author     Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
+{
+    public function __construct($name, $lineno, $tag = null)
+    {
+        parent::__construct(array(), array('name' => $name), $lineno, $tag);
+    }
+
+    /**
+     * Compiles the node to PHP.
+     *
+     * @param Twig_Compiler A Twig_Compiler instance
+     */
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter.php Sun May 27 19:59:46 2012
@@ -0,0 +1,61 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2009 Fabien Potencier
+ * (c) 2009 Armin Ronacher
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+class Twig_Node_Expression_Filter extends Twig_Node_Expression
+{
+    public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
+    {
+        parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
+    }
+
+    public function compile(Twig_Compiler $compiler)
+    {
+        $name = $this->getNode('filter')->getAttribute('value');
+
+        if (false === $filter = $compiler->getEnvironment()->getFilter($name)) {
+            $message = sprintf('The filter "%s" does not exist', $name);
+            if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFilters()))) {
+                $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
+            }
+
+            throw new Twig_Error_Syntax($message, $this->getLine());
+        }
+
+        $this->compileFilter($compiler, $filter);
+    }
+
+    protected function compileFilter(Twig_Compiler $compiler, Twig_FilterInterface $filter)
+    {
+        $compiler
+            ->raw($filter->compile().'(')
+            ->raw($filter->needsEnvironment() ? '$this->env, ' : '')
+            ->raw($filter->needsContext() ? '$context, ' : '')
+        ;
+
+        foreach ($filter->getArguments() as $argument) {
+            $compiler
+                ->string($argument)
+                ->raw(', ')
+            ;
+        }
+
+        $compiler->subcompile($this->getNode('node'));
+
+        foreach ($this->getNode('arguments') as $node) {
+            $compiler
+                ->raw(', ')
+                ->subcompile($node)
+            ;
+        }
+
+        $compiler->raw(')');
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter/Default.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter/Default.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter/Default.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/Node/Expression/Filter/Default.php Sun May 27 19:59:46 2012
@@ -0,0 +1,44 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2011 Fabien Potencier
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Returns the value or the default value when it is undefined or empty.
+ *
+ * <pre>
+ *  {{ var.foo|default('foo item on var is not defined') }}
+ * </pre>
+ *
+ * @package twig
+ * @author  Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter
+{
+    public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
+    {
+        $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('_default', $node->getLine()), $arguments, $node->getLine());
+
+        if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
+            $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine());
+            $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine());
+
+            $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine());
+        } else {
+            $node = $default;
+        }
+
+        parent::__construct($node, $filterName, $arguments, $lineno, $tag);
+    }
+
+    public function compile(Twig_Compiler $compiler)
+    {
+        $compiler->subcompile($this->getNode('node'));
+    }
+}



Mime
View raw message