From 1da4be04b021af62e24f91bf0f82849c78bd04b9 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Sun, 9 Jun 2013 22:09:00 -0500 Subject: [feature/twig] WIP extension/lexer/some tokenparsers/nodes PHPBB3-11598 --- .../includes/template/twig/tokenparser/include.php | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 phpBB/includes/template/twig/tokenparser/include.php (limited to 'phpBB/includes/template/twig/tokenparser/include.php') diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php new file mode 100644 index 0000000000..d9421095d1 --- /dev/null +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -0,0 +1,33 @@ + + * {% include 'header.html' %} + * Body + * {% include 'footer.html' %} + * + */ +class phpbb_template_twig_tokenparser_include extends Twig_TokenParser_Include +{ + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDE'; + } +} -- cgit v1.2.1 From c958155fb63667e1d54d6d31489bf17c0a180dab Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 24 Jun 2013 12:39:28 -0500 Subject: [feature/twig] Able to set chain of namespaces to search for loadTemplate() This is done so that when event template files are included, if they include files themselves, that namespace is checked first, then __main__ is checked to include the correct template file. Also, when template files are included from a particular namespace, this is done so that the files from that namespace are included first, then the main namespace is checked. We may want to change this behavior in the future to allow choosing which locations have priority, but for now, this is what I am doing to make sure the behavior is simple and always the same. PHPBB3-11598 --- phpBB/includes/template/twig/tokenparser/include.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'phpBB/includes/template/twig/tokenparser/include.php') diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index d9421095d1..32e1cd331d 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -21,6 +21,22 @@ */ class phpbb_template_twig_tokenparser_include 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_include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); + } + /** * Gets the tag name associated with this token parser. * -- cgit v1.2.1 From 309ed5e5c32cb334986b53ca855e26dd483c2919 Mon Sep 17 00:00:00 2001 From: Nathan Guse Date: Mon, 24 Jun 2013 13:37:22 -0500 Subject: [feature/twig] Fixing file header copyrights PHPBB3-11598 --- .../includes/template/twig/tokenparser/include.php | 26 ++++++---------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'phpBB/includes/template/twig/tokenparser/include.php') diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index 32e1cd331d..0f7e4faf8f 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -1,24 +1,12 @@ - * {% include 'header.html' %} - * Body - * {% include 'footer.html' %} - * - */ +* +* @package phpBB3 +* @copyright (c) 2013 phpBB Group, sections (c) 2009 Fabien Potencier +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + class phpbb_template_twig_tokenparser_include extends Twig_TokenParser_Include { /** -- 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 --- .../includes/template/twig/tokenparser/include.php | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'phpBB/includes/template/twig/tokenparser/include.php') diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index 0f7e4faf8f..5b5105d23e 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -9,29 +9,29 @@ class phpbb_template_twig_tokenparser_include 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(); + /** + * 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(); + list($variables, $only, $ignoreMissing) = $this->parseArguments(); - return new phpbb_template_twig_node_include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); - } + return new phpbb_template_twig_node_include($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 'INCLUDE'; - } + /** + * Gets the tag name associated with this token parser. + * + * @return string The tag name + */ + public function getTag() + { + return 'INCLUDE'; + } } -- 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/include.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/template/twig/tokenparser/include.php') diff --git a/phpBB/includes/template/twig/tokenparser/include.php b/phpBB/includes/template/twig/tokenparser/include.php index 5b5105d23e..520f9fd1a0 100644 --- a/phpBB/includes/template/twig/tokenparser/include.php +++ b/phpBB/includes/template/twig/tokenparser/include.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_tokenparser_include extends Twig_TokenParser_Include { /** -- cgit v1.2.1