aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template/twig
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/template/twig')
-rw-r--r--phpBB/includes/template/twig/extension.php1
-rw-r--r--phpBB/includes/template/twig/lexer.php17
-rw-r--r--phpBB/includes/template/twig/tokenparser/event.php25
3 files changed, 41 insertions, 2 deletions
diff --git a/phpBB/includes/template/twig/extension.php b/phpBB/includes/template/twig/extension.php
index bf4b0e8c54..a607bac150 100644
--- a/phpBB/includes/template/twig/extension.php
+++ b/phpBB/includes/template/twig/extension.php
@@ -39,6 +39,7 @@ class phpbb_template_twig_extension extends Twig_Extension
array(),
array(
'eq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ //'and' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
'!==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
),
);
diff --git a/phpBB/includes/template/twig/lexer.php b/phpBB/includes/template/twig/lexer.php
index f60c58249c..21d8fb770e 100644
--- a/phpBB/includes/template/twig/lexer.php
+++ b/phpBB/includes/template/twig/lexer.php
@@ -19,11 +19,12 @@ class phpbb_template_twig_lexer extends Twig_Lexer
{
protected function lexExpression()
{
+ var_dump(substr($this->code, $this->cursor, 40), $this->states);
parent::lexExpression();
// Last element parsed
$last_element = end($this->tokens);
-
+
/**
* Check for old fashioned INCLUDE statements without enclosed quotes
*/
@@ -42,7 +43,7 @@ class phpbb_template_twig_lexer extends Twig_Lexer
*/
if ($last_element->getValue() === 'IF')
{
- if (preg_match('#^\s*\.([a-zA-Z0-9_\.]+)#', substr($this->code, $this->cursor), $match))
+ if (preg_match('#^\s*(not\s)?\.([a-zA-Z0-9_\.]+)#', substr($this->code, $this->cursor), $match))
{
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
$this->moveCursor($match[0]);
@@ -61,5 +62,17 @@ class phpbb_template_twig_lexer extends Twig_Lexer
$this->moveCursor($match[1]);
}
}
+
+ /**
+ * Check for old fashioned INCLUDE statements without enclosed quotes
+ */
+ if ($last_element->getValue() === 'INCLUDE')
+ {
+ if (preg_match('#^\s*([a-zA-Z0-9_]+\.[a-zA-Z0-9]+)#', substr($this->code, $this->cursor), $match))
+ {
+ $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[1]));
+ $this->moveCursor($match[0]);
+ }
+ }
}
}
diff --git a/phpBB/includes/template/twig/tokenparser/event.php b/phpBB/includes/template/twig/tokenparser/event.php
index cd211098d6..27a8350af1 100644
--- a/phpBB/includes/template/twig/tokenparser/event.php
+++ b/phpBB/includes/template/twig/tokenparser/event.php
@@ -21,6 +21,31 @@
*/
class phpbb_template_twig_tokenparser_event extends Twig_TokenParser_Include
{
+ protected function parseArguments()
+ {
+ $stream = $this->parser->getStream();
+
+ $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.
*