From 15114067e6c88e4ec8fa9d1ff66fd0de28b1144f Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 10 Jun 2013 11:17:11 -0500 Subject: [feature/twig] Replace phpBB template code with Twig syntax, then parse w/Twig Fixing begin token/node, adding includejs token/node PHPBB3-11598 --- .../template/twig/tokenparser/includejs.php | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 phpBB/includes/template/twig/tokenparser/includejs.php (limited to 'phpBB/includes/template/twig/tokenparser/includejs.php') diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php new file mode 100644 index 0000000000..36a1fcb585 --- /dev/null +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -0,0 +1,49 @@ + + * {% include 'header.html' %} + * Body + * {% include 'footer.html' %} + * + */ +class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser_Include +{ + /** + * 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 phpbb_template_twig_node_includejs($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDEJS'; + } +} -- cgit v1.2.1 From 95884edf08d962d0f8cf764f4870f910d4d65009 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Wed, 12 Jun 2013 12:32:56 -0500 Subject: [feature/twig] Correcting output of INCLUDEJS PHPBB3-11598 --- .../template/twig/tokenparser/includejs.php | 33 ++++++++-------------- 1 file changed, 11 insertions(+), 22 deletions(-) (limited to 'phpBB/includes/template/twig/tokenparser/includejs.php') diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index 36a1fcb585..efa8692f4b 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -1,25 +1,13 @@ - * {% include 'header.html' %} - * Body - * {% include 'footer.html' %} - * - */ -class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser_Include +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser { /** * Parses a token and returns a node. @@ -32,9 +20,10 @@ class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser_Include { $expr = $this->parser->getExpressionParser()->parseExpression(); - list($variables, $only, $ignoreMissing) = $this->parseArguments(); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_includejs($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + return new phpbb_template_twig_node_includejs($expr, $token->getLine(), $this->getTag()); } /** -- cgit v1.2.1 From 3ca99f8122c149a66f59dbf3c9884c095db7ad3c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Mon, 24 Jun 2013 22:37:58 -0500 Subject: [feature/twig] Append assets_version to includejs tag Some fixes for main template parser PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/includejs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/template/twig/tokenparser/includejs.php') diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index efa8692f4b..0b46f315d2 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -23,7 +23,7 @@ class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser $stream = $this->parser->getStream(); $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_includejs($expr, $token->getLine(), $this->getTag()); + return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); } /** -- cgit v1.2.1 From 57c2d99e65ce107208db10721cff5b815ee3403c Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 2 Jul 2013 12:34:16 -0500 Subject: [feature/twig] Fix indentation PHPBB3-11598 --- .../template/twig/tokenparser/includejs.php | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'phpBB/includes/template/twig/tokenparser/includejs.php') diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index 0b46f315d2..962d01ac45 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -9,30 +9,30 @@ class phpbb_template_twig_tokenparser_includejs 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(); + /** + * 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(); - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); + $stream = $this->parser->getStream(); + $stream->expect(Twig_Token::BLOCK_END_TYPE); - return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_includejs($expr, $this->parser->getEnvironment(), $token->getLine(), $this->getTag()); + } - /** - * Gets the tag name associated with this token parser. - * - * @return string The tag name - */ - public function getTag() - { - return 'INCLUDEJS'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDEJS'; + } } -- cgit v1.2.1 From c5c34ff831faf96368d34012dc65bdb9451227aa Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Fri, 5 Jul 2013 13:10:35 -0500 Subject: [feature/twig] Add check for defined IN_PHPBB in all new Twig related files PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/includejs.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/template/twig/tokenparser/includejs.php') diff --git a/phpBB/includes/template/twig/tokenparser/includejs.php b/phpBB/includes/template/twig/tokenparser/includejs.php index 962d01ac45..b02b2f89ba 100644 --- a/phpBB/includes/template/twig/tokenparser/includejs.php +++ b/phpBB/includes/template/twig/tokenparser/includejs.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_includejs extends Twig_TokenParser { /** -- cgit v1.2.1