phpBB

Code Changes

File: phpbb/template/twig/extension.php

  Unmodified   Added   Modified   Removed
Line 13Line 13

namespace phpbb\template\twig;



namespace phpbb\template\twig;


class extension extends \Twig_Extension

class extension extends \Twig\Extension\AbstractExtension

{
/** @var \phpbb\template\context */
protected $context;

{
/** @var \phpbb\template\context */
protected $context;

Line 51Line 51
	/**
* Returns the token parser instance to add to the existing list.
*

	/**
* Returns the token parser instance to add to the existing list.
*

	* @return array An array of Twig_TokenParser instances

	* @return array An array of \Twig\TokenParser\AbstractTokenParser instances

	*/
public function getTokenParsers()
{

	*/
public function getTokenParsers()
{

Line 74Line 74
	public function getFilters()
{
return array(

	public function getFilters()
{
return array(

			new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),

			new \Twig\TwigFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)),

			// @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes

			// @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes

			new \Twig_SimpleFilter('addslashes', 'addslashes'),

			new \Twig\TwigFilter('addslashes', 'addslashes'),

		);
}


		);
}


Line 88Line 88
	public function getFunctions()
{
return array(

	public function getFunctions()
{
return array(

			new \Twig_SimpleFunction('lang', array($this, 'lang')),
new \Twig_SimpleFunction('lang_defined', array($this, 'lang_defined')),
new \Twig_SimpleFunction('get_class', 'get_class'),

			new \Twig\TwigFunction('lang', array($this, 'lang')),
new \Twig\TwigFunction('lang_defined', array($this, 'lang_defined')),
new \Twig\TwigFunction('get_class', 'get_class'),

		);
}


		);
}


Line 103Line 103
	{
return array(
array(

	{
return array(
array(

				'!' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),

				'!' => array('precedence' => 50, 'class' => '\Twig\Node\Expression\Unary\NotUnary'),

			),
array(
// precedence settings are copied from similar operators in Twig core extension

			),
array(
// precedence settings are copied from similar operators in Twig core extension

				'||' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'&&' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'||' => array('precedence' => 10, 'class' => '\Twig\Node\Expression\Binary\OrBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'&&' => array('precedence' => 15, 'class' => '\Twig\Node\Expression\Binary\AndBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),





				'eq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'eq' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\EqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),





				'ne' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'neq' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'<>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'ne' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\NotEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'neq' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\NotEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'<>' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\NotEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),





				'===' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\equalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'!==' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\notequalequal', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'===' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\equalequal', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'!==' => array('precedence' => 20, 'class' => '\phpbb\template\twig\node\expression\binary\notequalequal', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),





				'gt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'gte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'ge' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'lt' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'lte' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),
'le' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'gt' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\GreaterBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'gte' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\GreaterEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'ge' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\GreaterEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'lt' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\LessBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'lte' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\LessEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),
'le' => array('precedence' => 20, 'class' => '\Twig\Node\Expression\Binary\LessEqualBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),





				'mod' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => \Twig_ExpressionParser::OPERATOR_LEFT),

				'mod' => array('precedence' => 60, 'class' => '\Twig\Node\Expression\Binary\ModBinary', 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT),

			),
);
}

			),
);
}

Line 134Line 134
	/**
* Grabs a subset of a loop
*

	/**
* Grabs a subset of a loop
*

	* @param \Twig_Environment $env          A Twig_Environment instance

	* @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 mixed            $item         A variable
* @param integer $start Start of the subset
* @param integer $end End of the subset

Line 142Line 142
	*
* @return mixed The sliced variable
*/

	*
* @return mixed The sliced variable
*/

	public function loop_subset(\Twig_Environment $env, $item, $start, $end = null, $preserveKeys = false)

	public 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
if ($end >= 1)

	{
// We do almost the same thing as Twig's slice (array_slice), except when $end is positive
if ($end >= 1)