From ea785efb30ced6ab399b290df6f202cb97315f80 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 25 Jun 2013 14:22:40 -0500 Subject: [feature/twig] PHP token support PHPBB3-11598 --- phpBB/includes/template/twig/node/php.php | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 phpBB/includes/template/twig/node/php.php (limited to 'phpBB/includes/template/twig/node/php.php') diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php new file mode 100644 index 0000000000..cf60ef33fc --- /dev/null +++ b/phpBB/includes/template/twig/node/php.php @@ -0,0 +1,40 @@ +environment = $environment; + + parent::__construct(array('text' => $text), array(), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); + + $config = $this->environment->get_phpbb_config(); + + if ($config['tpl_allow_php']) + { + $compiler + ->raw($this->getNode('text')->getAttribute('data')) + ; + } + } +} -- cgit v1.2.1 From 99b776a4e56a9144bddc153ea993a96588b1c73b Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 25 Jun 2013 14:59:41 -0500 Subject: [feature/twig] Add a comment to tpl output if PHP used, but disabled PHPBB3-11598 --- phpBB/includes/template/twig/node/php.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/template/twig/node/php.php') diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index cf60ef33fc..83481b1d69 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -28,13 +28,17 @@ class phpbb_template_twig_node_php extends Twig_Node { $compiler->addDebugInfo($this); - $config = $this->environment->get_phpbb_config(); - - if ($config['tpl_allow_php']) + if (!$config['tpl_allow_php']) { $compiler - ->raw($this->getNode('text')->getAttribute('data')) + ->write("// PHP Disabled\n") ; + + return; } + + $compiler + ->raw($this->getNode('text')->getAttribute('data')) + ; } } -- cgit v1.2.1 From 040186418aa15d1de4a99b81cf05ee74ef94e042 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Tue, 25 Jun 2013 20:52:04 -0500 Subject: [feature/twig] Forgot to set up $config in node/php.php PHPBB3-11598 --- phpBB/includes/template/twig/node/php.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'phpBB/includes/template/twig/node/php.php') diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index 83481b1d69..953cd184a7 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -28,6 +28,8 @@ class phpbb_template_twig_node_php extends Twig_Node { $compiler->addDebugInfo($this); + $config = $this->environment->get_phpbb_config(); + if (!$config['tpl_allow_php']) { $compiler -- 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 --- phpBB/includes/template/twig/node/php.php | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'phpBB/includes/template/twig/node/php.php') diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index 953cd184a7..ebf4947e48 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -12,21 +12,21 @@ class phpbb_template_twig_node_php extends Twig_Node /** @var Twig_Environment */ protected $environment; - public function __construct(Twig_Node_Text $text, phpbb_template_twig_environment $environment, $lineno, $tag = null) - { - $this->environment = $environment; - - parent::__construct(array('text' => $text), array(), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); + public function __construct(Twig_Node_Text $text, phpbb_template_twig_environment $environment, $lineno, $tag = null) + { + $this->environment = $environment; + + parent::__construct(array('text' => $text), array(), $lineno, $tag); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + public function compile(Twig_Compiler $compiler) + { + $compiler->addDebugInfo($this); $config = $this->environment->get_phpbb_config(); @@ -42,5 +42,5 @@ class phpbb_template_twig_node_php extends Twig_Node $compiler ->raw($this->getNode('text')->getAttribute('data')) ; - } + } } -- 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/node/php.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'phpBB/includes/template/twig/node/php.php') diff --git a/phpBB/includes/template/twig/node/php.php b/phpBB/includes/template/twig/node/php.php index ebf4947e48..c11539ea7f 100644 --- a/phpBB/includes/template/twig/node/php.php +++ b/phpBB/includes/template/twig/node/php.php @@ -7,6 +7,15 @@ * */ +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + + class phpbb_template_twig_node_php extends Twig_Node { /** @var Twig_Environment */ -- cgit v1.2.1