logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1343084 [12/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/TokenParser/If.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/If.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/If.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/If.php Sun May 27 19:59:46
2012
@@ -0,0 +1,93 @@
+<?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.
+ */
+
+/**
+ * Tests a condition.
+ *
+ * <pre>
+ * {% if users %}
+ *  <ul>
+ *    {% for user in users %}
+ *      <li>{{ user.username|e }}</li>
+ *    {% endfor %}
+ *  </ul>
+ * {% endif %}
+ * </pre>
+ */
+class Twig_TokenParser_If extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $lineno = $token->getLine();
+        $expr = $this->parser->getExpressionParser()->parseExpression();
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+        $body = $this->parser->subparse(array($this, 'decideIfFork'));
+        $tests = array($expr, $body);
+        $else = null;
+
+        $end = false;
+        while (!$end) {
+            switch ($this->parser->getStream()->next()->getValue()) {
+                case 'else':
+                    $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+                    $else = $this->parser->subparse(array($this, 'decideIfEnd'));
+                    break;
+
+                case 'elseif':
+                    $expr = $this->parser->getExpressionParser()->parseExpression();
+                    $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+                    $body = $this->parser->subparse(array($this, 'decideIfFork'));
+                    $tests[] = $expr;
+                    $tests[] = $body;
+                    break;
+
+                case 'endif':
+                    $end = true;
+                    break;
+
+                default:
+                    throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig
was looking for the following tags "else", "elseif", or "endif" to close the "if" block started
at line %d)', $lineno), -1);
+            }
+        }
+
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+        return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag());
+    }
+
+    public function decideIfFork(Twig_Token $token)
+    {
+        return $token->test(array('elseif', 'else', 'endif'));
+    }
+
+    public function decideIfEnd(Twig_Token $token)
+    {
+        return $token->test(array('endif'));
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'if';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Import.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Import.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Import.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Import.php Sun May 27 19:59:46
2012
@@ -0,0 +1,47 @@
+<?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.
+ */
+
+/**
+ * Imports macros.
+ *
+ * <pre>
+ *   {% import 'forms.html' as forms %}
+ * </pre>
+ */
+class Twig_TokenParser_Import extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $macro = $this->parser->getExpressionParser()->parseExpression();
+        $this->parser->getStream()->expect('as');
+        $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(),
$token->getLine());
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+        return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'import';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Include.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Include.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Include.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Include.php Sun May 27
19:59:46 2012
@@ -0,0 +1,80 @@
+<?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.
+ */
+
+/**
+ * Includes a template.
+ *
+ * <pre>
+ *   {% include 'header.html' %}
+ *     Body
+ *   {% include 'footer.html' %}
+ * </pre>
+ */
+class Twig_TokenParser_Include extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $expr = $this->parser->getExpressionParser()->parseExpression();
+
+        list($variables, $only, $ignoreMissing) = $this->parseArguments();
+
+        return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(),
$this->getTag());
+    }
+
+    protected function parseArguments()
+    {
+        $stream = $this->parser->getStream();
+
+        $ignoreMissing = false;
+        if ($stream->test(Twig_Token::NAME_TYPE, 'ignore')) {
+            $stream->next();
+            $stream->expect(Twig_Token::NAME_TYPE, 'missing');
+
+            $ignoreMissing = true;
+        }
+
+        $variables = null;
+        if ($stream->test(Twig_Token::NAME_TYPE, 'with')) {
+            $stream->next();
+
+            $variables = $this->parser->getExpressionParser()->parseExpression();
+        }
+
+        $only = false;
+        if ($stream->test(Twig_Token::NAME_TYPE, 'only')) {
+            $stream->next();
+
+            $only = true;
+        }
+
+        $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+        return array($variables, $only, $ignoreMissing);
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'include';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Macro.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Macro.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Macro.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Macro.php Sun May 27 19:59:46
2012
@@ -0,0 +1,69 @@
+<?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.
+ */
+
+/**
+ * Defines a macro.
+ *
+ * <pre>
+ * {% macro input(name, value, type, size) %}
+ *    <input type="{{ type|default('text') }}" name="{{ name }}" value="{{ value|e }}"
size="{{ size|default(20) }}" />
+ * {% endmacro %}
+ * </pre>
+ */
+class Twig_TokenParser_Macro extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $lineno = $token->getLine();
+        $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue();
+
+        $arguments = $this->parser->getExpressionParser()->parseArguments();
+
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+        $this->parser->pushLocalScope();
+        $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+        if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) {
+            $value = $this->parser->getStream()->next()->getValue();
+
+            if ($value != $name) {
+                throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name'
(but %s given)", $value), $lineno);
+            }
+        }
+        $this->parser->popLocalScope();
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+        $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)),
$arguments, $lineno, $this->getTag()));
+
+        return null;
+    }
+
+    public function decideBlockEnd(Twig_Token $token)
+    {
+        return $token->test('endmacro');
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'macro';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Sandbox.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Sandbox.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Sandbox.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Sandbox.php Sun May 27
19:59:46 2012
@@ -0,0 +1,55 @@
+<?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 section of a template as untrusted code that must be evaluated in the sandbox
mode.
+ *
+ * <pre>
+ * {% sandbox %}
+ *     {% include 'user.html' %}
+ * {% endsandbox %}
+ * </pre>
+ *
+ * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details
+ */
+class Twig_TokenParser_Sandbox extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+        $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+        return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
+    }
+
+    public function decideBlockEnd(Twig_Token $token)
+    {
+        return $token->test('endsandbox');
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'sandbox';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Set.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Set.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Set.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Set.php Sun May 27 19:59:46
2012
@@ -0,0 +1,84 @@
+<?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.
+ */
+
+/**
+ * Defines a variable.
+ *
+ * <pre>
+ *  {% set foo = 'foo' %}
+ *
+ *  {% set foo = [1, 2] %}
+ *
+ *  {% set foo = {'foo': 'bar'} %}
+ *
+ *  {% set foo = 'foo' ~ 'bar' %}
+ *
+ *  {% set foo, bar = 'foo', 'bar' %}
+ *
+ *  {% set foo %}Some content{% endset %}
+ * </pre>
+ */
+class Twig_TokenParser_Set extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $lineno = $token->getLine();
+        $stream = $this->parser->getStream();
+        $names = $this->parser->getExpressionParser()->parseAssignmentExpression();
+
+        $capture = false;
+        if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) {
+            $stream->next();
+            $values = $this->parser->getExpressionParser()->parseMultitargetExpression();
+
+            $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+            if (count($names) !== count($values)) {
+                throw new Twig_Error_Syntax("When using set, you must have the same number
of variables and assignements.", $lineno);
+            }
+        } else {
+            $capture = true;
+
+            if (count($names) > 1) {
+                throw new Twig_Error_Syntax("When using set with a block, you cannot have
a multi-target.", $lineno);
+            }
+
+            $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+            $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+            $stream->expect(Twig_Token::BLOCK_END_TYPE);
+        }
+
+        return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag());
+    }
+
+    public function decideBlockEnd(Twig_Token $token)
+    {
+        return $token->test('endset');
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'set';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Spaceless.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Spaceless.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Spaceless.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Spaceless.php Sun May 27
19:59:46 2012
@@ -0,0 +1,59 @@
+<?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.
+ */
+
+/**
+ * Remove whitespaces between HTML tags.
+ *
+ * <pre>
+ * {% spaceless %}
+ *      <div>
+ *          <strong>foo</strong>
+ *      </div>
+ * {% endspaceless %}
+ *
+ * {# output will be <div><strong>foo</strong></div> #}
+ * </pre>
+ */
+class Twig_TokenParser_Spaceless extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $lineno = $token->getLine();
+
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+        $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
+        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+        return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
+    }
+
+    public function decideSpacelessEnd(Twig_Token $token)
+    {
+        return $token->test('endspaceless');
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'spaceless';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Use.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Use.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Use.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParser/Use.php Sun May 27 19:59:46
2012
@@ -0,0 +1,85 @@
+<?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.
+ */
+
+/**
+ * Imports blocks defined in another template into the current template.
+ *
+ * <pre>
+ * {% extends "base.html" %}
+ *
+ * {% use "blocks.html" %}
+ *
+ * {% block title %}{% endblock %}
+ * {% block content %}{% endblock %}
+ * </pre>
+ *
+ * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details.
+ */
+class Twig_TokenParser_Use extends Twig_TokenParser
+{
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    public function parse(Twig_Token $token)
+    {
+        $template = $this->parser->getExpressionParser()->parseExpression();
+
+        if (!$template instanceof Twig_Node_Expression_Constant) {
+            throw new Twig_Error_Syntax('The template references in a "use" statement must
be a string.', $token->getLine());
+        }
+
+        $stream = $this->parser->getStream();
+
+        $targets = array();
+        if ($stream->test('with')) {
+            $stream->next();
+
+            do {
+                $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+
+                $alias = $name;
+                if ($stream->test('as')) {
+                    $stream->next();
+
+                    $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+                }
+
+                $targets[$name] = new Twig_Node_Expression_Constant($alias, -1);
+
+                if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) {
+                    break;
+                }
+
+                $stream->next();
+            } while (true);
+        }
+
+        $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+        $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets'
=> new Twig_Node($targets))));
+
+        return null;
+    }
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    public function getTag()
+    {
+        return 'use';
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBroker.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBroker.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBroker.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBroker.php Sun May 27 19:59:46
2012
@@ -0,0 +1,113 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ * (c) 2010 Arnaud Le Blanc
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Default implementation of a token parser broker.
+ *
+ * @package twig
+ * @author  Arnaud Le Blanc <arnaud.lb@gmail.com>
+ */
+class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
+{
+    protected $parser;
+    protected $parsers = array();
+    protected $brokers = array();
+
+    /**
+     * Constructor.
+     *
+     * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
+     * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface
instances
+     */
+    public function __construct($parsers = array(), $brokers = array())
+    {
+        foreach ($parsers as $parser) {
+            if (!$parser instanceof Twig_TokenParserInterface) {
+                throw new Twig_Error('$parsers must a an array of Twig_TokenParserInterface');
+            }
+            $this->parsers[$parser->getTag()] = $parser;
+        }
+        foreach ($brokers as $broker) {
+            if (!$broker instanceof Twig_TokenParserBrokerInterface) {
+                throw new Twig_Error('$brokers must a an array of Twig_TokenParserBrokerInterface');
+            }
+            $this->brokers[] = $broker;
+        }
+    }
+
+    /**
+     * Adds a TokenParser.
+     *
+     * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
+     */
+    public function addTokenParser(Twig_TokenParserInterface $parser)
+    {
+        $this->parsers[$parser->getTag()] = $parser;
+    }
+
+    /**
+     * Adds a TokenParserBroker.
+     *
+     * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
+     */
+    public function addTokenParserBroker(Twig_TokenParserBroker $broker)
+    {
+        $this->brokers[] = $broker;
+    }
+
+    /**
+     * Gets a suitable TokenParser for a tag.
+     *
+     * First looks in parsers, then in brokers.
+     *
+     * @param string $tag A tag name
+     *
+     * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable
TokenParser was found
+     */
+    public function getTokenParser($tag)
+    {
+        if (isset($this->parsers[$tag])) {
+            return $this->parsers[$tag];
+        }
+        $broker = end($this->brokers);
+        while (false !== $broker) {
+            $parser = $broker->getTokenParser($tag);
+            if (null !== $parser) {
+                return $parser;
+            }
+            $broker = prev($this->brokers);
+        }
+
+        return null;
+    }
+
+    public function getParsers()
+    {
+        return $this->parsers;
+    }
+
+    public function getParser()
+    {
+        return $this->parser;
+    }
+
+    public function setParser(Twig_ParserInterface $parser)
+    {
+        $this->parser = $parser;
+        foreach ($this->parsers as $tokenParser) {
+            $tokenParser->setParser($parser);
+        }
+        foreach ($this->brokers as $broker) {
+            $broker->setParser($parser);
+        }
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBrokerInterface.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBrokerInterface.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBrokerInterface.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserBrokerInterface.php Sun
May 27 19:59:46 2012
@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of Twig.
+ *
+ * (c) 2010 Fabien Potencier
+ * (c) 2010 Arnaud Le Blanc
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Interface implemented by token parser brokers.
+ *
+ * Token parser brokers allows to implement custom logic in the process of resolving a token
parser for a given tag name.
+ *
+ * @package twig
+ * @author  Arnaud Le Blanc <arnaud.lb@gmail.com>
+ */
+interface Twig_TokenParserBrokerInterface
+{
+    /**
+     * Gets a TokenParser suitable for a tag.
+     *
+     * @param  string $tag A tag name
+     *
+     * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable
TokenParser was found
+     */
+    function getTokenParser($tag);
+
+    /**
+     * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows
of.
+     *
+     * @param Twig_ParserInterface $parser A Twig_ParserInterface interface
+     */
+    function setParser(Twig_ParserInterface $parser);
+
+    /**
+     * Gets the Twig_ParserInterface.
+     *
+     * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null
+     */
+    function getParser();
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserInterface.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserInterface.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserInterface.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenParserInterface.php Sun May 27
19:59:46 2012
@@ -0,0 +1,42 @@
+<?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.
+ */
+
+/**
+ * Interface implemented by token parsers.
+ *
+ * @package twig
+ * @author  Fabien Potencier <fabien@symfony.com>
+ */
+interface Twig_TokenParserInterface
+{
+    /**
+     * Sets the parser associated with this token parser
+     *
+     * @param $parser A Twig_Parser instance
+     */
+    function setParser(Twig_Parser $parser);
+
+    /**
+     * Parses a token and returns a node.
+     *
+     * @param Twig_Token $token A Twig_Token instance
+     *
+     * @return Twig_NodeInterface A Twig_NodeInterface instance
+     */
+    function parse(Twig_Token $token);
+
+    /**
+     * Gets the tag name associated with this token parser.
+     *
+     * @return string The tag name
+     */
+    function getTag();
+}

Added: logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenStream.php
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenStream.php?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenStream.php (added)
+++ logging/site/branches/cms/trunk/libs/Twig/lib/Twig/TokenStream.php Sun May 27 19:59:46
2012
@@ -0,0 +1,145 @@
+<?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 token stream.
+ *
+ * @package twig
+ * @author  Fabien Potencier <fabien@symfony.com>
+ */
+class Twig_TokenStream
+{
+    protected $tokens;
+    protected $current;
+    protected $filename;
+
+    /**
+     * Constructor.
+     *
+     * @param array  $tokens   An array of tokens
+     * @param string $filename The name of the filename which tokens are associated with
+     */
+    public function __construct(array $tokens, $filename = null)
+    {
+        $this->tokens     = $tokens;
+        $this->current    = 0;
+        $this->filename   = $filename;
+    }
+
+    /**
+     * Returns a string representation of the token stream.
+     *
+     * @return string
+     */
+    public function __toString()
+    {
+        return implode("\n", $this->tokens);
+    }
+
+    public function injectTokens(array $tokens)
+    {
+        $this->tokens = array_merge(array_slice($this->tokens, 0, $this->current),
$tokens, array_slice($this->tokens, $this->current));
+    }
+
+    /**
+     * Sets the pointer to the next token and returns the old one.
+     *
+     * @return Twig_Token
+     */
+    public function next()
+    {
+        if (!isset($this->tokens[++$this->current])) {
+            throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename);
+        }
+
+        return $this->tokens[$this->current - 1];
+    }
+
+    /**
+     * Tests a token and returns it or throws a syntax error.
+     *
+     * @return Twig_Token
+     */
+    public function expect($type, $value = null, $message = null)
+    {
+        $token = $this->tokens[$this->current];
+        if (!$token->test($type, $value)) {
+            $line = $token->getLine();
+            throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s"
expected%s)',
+                $message ? $message.'. ' : '',
+                Twig_Token::typeToEnglish($token->getType(), $line), $token->getValue(),
+                Twig_Token::typeToEnglish($type, $line), $value ? sprintf(' with value "%s"',
$value) : ''),
+                $line,
+                $this->filename
+            );
+        }
+        $this->next();
+
+        return $token;
+    }
+
+    /**
+     * Looks at the next token.
+     *
+     * @param integer $number
+     *
+     * @return Twig_Token
+     */
+    public function look($number = 1)
+    {
+        if (!isset($this->tokens[$this->current + $number])) {
+            throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename);
+        }
+
+        return $this->tokens[$this->current + $number];
+    }
+
+    /**
+     * Tests the current token
+     *
+     * @return bool
+     */
+    public function test($primary, $secondary = null)
+    {
+        return $this->tokens[$this->current]->test($primary, $secondary);
+    }
+
+    /**
+     * Checks if end of stream was reached
+     *
+     * @return bool
+     */
+    public function isEOF()
+    {
+        return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE;
+    }
+
+    /**
+     * Gets the current token
+     *
+     * @return Twig_Token
+     */
+    public function getCurrent()
+    {
+        return $this->tokens[$this->current];
+    }
+
+    /**
+     * Gets the filename associated with this stream
+     *
+     * @return string
+     */
+    public function getFilename()
+    {
+        return $this->filename;
+    }
+}

Added: logging/site/branches/cms/trunk/libs/Twig/package.xml.tpl
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/package.xml.tpl?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/package.xml.tpl (added)
+++ logging/site/branches/cms/trunk/libs/Twig/package.xml.tpl Sun May 27 19:59:46 2012
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package packagerversion="1.8.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0"
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
+    http://pear.php.net/dtd/tasks-1.0.xsd
+    http://pear.php.net/dtd/package-2.0
+    http://pear.php.net/dtd/package-2.0.xsd">
+ <name>Twig</name>
+ <channel>pear.twig-project.org</channel>
+ <summary>Twig is a PHP template engine.</summary>
+ <description>
+   Twig is a template language for PHP, released under the new BSD license
+   (code and documentation).
+
+   Twig uses a syntax similar to the Django and Jinja template languages which
+   inspired the Twig runtime environment.
+ </description>
+ <lead>
+  <name>Fabien Potencier</name>
+  <user>fabpot</user>
+  <email>fabien.potencier@symfony-project.org</email>
+  <active>yes</active>
+ </lead>
+ <lead>
+  <name>Armin Ronacher</name>
+  <user>armin</user>
+  <email>armin.ronacher@active-4.com</email>
+  <active>no</active>
+ </lead>
+ <date>{{ date }}</date>
+ <time>{{ time }}</time>
+ <version>
+  <release>{{ version }}</release>
+  <api>{{ api_version }}</api>
+ </version>
+ <stability>
+  <release>{{ stability }}</release>
+  <api>{{ stability }}</api>
+ </stability>
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
+ <notes>-</notes>
+ <contents>
+   <dir name="/">
+     <file name="AUTHORS" role="doc" />
+     <file name="CHANGELOG" role="doc" />
+     <file name="LICENSE" role="doc" />
+     <file name="README.markdown" role="doc" />
+     <dir name="lib">
+      <dir name="Twig">
+{{ files }}
+      </dir>
+     </dir>
+   </dir>
+ </contents>
+ <dependencies>
+  <required>
+   <php>
+    <min>5.2.4</min>
+   </php>
+   <pearinstaller>
+    <min>1.4.0</min>
+   </pearinstaller>
+  </required>
+ </dependencies>
+ <phprelease />
+</package>

Added: logging/site/branches/cms/trunk/libs/Twig/phpunit.xml.dist
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/Twig/phpunit.xml.dist?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/Twig/phpunit.xml.dist (added)
+++ logging/site/branches/cms/trunk/libs/Twig/phpunit.xml.dist Sun May 27 19:59:46 2012
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+         backupStaticAttributes="false"
+         colors="true"
+         convertErrorsToExceptions="true"
+         convertNoticesToExceptions="true"
+         convertWarningsToExceptions="true"
+         processIsolation="false"
+         stopOnFailure="false"
+         syntaxCheck="false"
+         bootstrap="test/bootstrap.php"
+>
+  <testsuites>
+    <testsuite name="Twig Test Suite">
+      <directory>./test/Twig/</directory>
+    </testsuite>
+  </testsuites>
+
+  <filter>
+    <whitelist>
+      <directory suffix=".php">./lib/Twig/</directory>
+    </whitelist>
+  </filter>
+</phpunit>

Added: logging/site/branches/cms/trunk/libs/textile/README
URL: http://svn.apache.org/viewvc/logging/site/branches/cms/trunk/libs/textile/README?rev=1343084&view=auto
==============================================================================
--- logging/site/branches/cms/trunk/libs/textile/README (added)
+++ logging/site/branches/cms/trunk/libs/textile/README Sun May 27 19:59:46 2012
@@ -0,0 +1,2 @@
+Textile downloaded from:
+http://textpattern.googlecode.com/svn/development/4.x/textpattern/lib/classTextile.php



Mime
View raw message