diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-11-27 14:55:05 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-11-27 14:55:24 +0100 |
commit | 33f4d267ef9a3b65a1fbda82afa13ecc486b5c80 (patch) | |
tree | 2e19c6d0b72144d50197c01dcc2ad000913553ef /phpBB/phpbb/template/twig/extension.php | |
parent | 0d4bf3ff45a76dcb763c76502944aa7bf78b690b (diff) | |
parent | 125e76f9aa83141534387a965e8373c9b9cd5c4d (diff) | |
download | forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.gz forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.bz2 forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.xz forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.zip |
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/11842
Conflicts:
phpBB/includes/acp/acp_groups.php
Diffstat (limited to 'phpBB/phpbb/template/twig/extension.php')
-rw-r--r-- | phpBB/phpbb/template/twig/extension.php | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index 1ddb97369e..6847dbd9f8 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -9,14 +9,6 @@ namespace phpbb\template\twig; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - class extension extends \Twig_Extension { /** @var \phpbb\template\context */ @@ -48,11 +40,11 @@ class extension extends \Twig_Extension return 'phpbb'; } - /** - * Returns the token parser instance to add to the existing list. - * - * @return array An array of Twig_TokenParser instances - */ + /** + * Returns the token parser instance to add to the existing list. + * + * @return array An array of Twig_TokenParser instances + */ public function getTokenParsers() { return array( @@ -66,36 +58,36 @@ class extension extends \Twig_Extension ); } - /** - * Returns a list of filters to add to the existing list. - * - * @return array An array of filters - */ - public function getFilters() - { + /** + * Returns a list of filters to add to the existing list. + * + * @return array An array of filters + */ + public function getFilters() + { return array( new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), new \Twig_SimpleFilter('addslashes', 'addslashes'), ); - } - - /** - * Returns a list of global functions to add to the existing list. - * - * @return array An array of global functions - */ - public function getFunctions() - { + } + + /** + * Returns a list of global functions to add to the existing list. + * + * @return array An array of global functions + */ + public function getFunctions() + { return array( new \Twig_SimpleFunction('lang', array($this, 'lang')), ); } - /** - * Returns a list of operators to add to the existing list. - * - * @return array An array of operators - */ + /** + * Returns a list of operators to add to the existing list. + * + * @return array An array of operators + */ public function getOperators() { return array( @@ -126,19 +118,19 @@ class extension extends \Twig_Extension 'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT), ), ); - } + } /** - * Grabs a subset of a loop - * - * @param Twig_Environment $env A Twig_Environment instance - * @param mixed $item A variable - * @param integer $start Start of the subset - * @param integer $end End of the subset - * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array) - * - * @return mixed The sliced variable - */ + * Grabs a subset of a loop + * + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $item A variable + * @param integer $start Start of the subset + * @param integer $end End of the subset + * @param Boolean $preserveKeys Whether to preserve key or not (when the input is an array) + * + * @return mixed The sliced variable + */ function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false) { // We do almost the same thing as Twig's slice (array_slice), except when $end is positive |