diff options
Diffstat (limited to 'phpBB/phpbb/template/twig/extension.php')
-rw-r--r-- | phpBB/phpbb/template/twig/extension.php | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/phpBB/phpbb/template/twig/extension.php b/phpBB/phpbb/template/twig/extension.php index d5b14129b5..f6f8e03ca2 100644 --- a/phpBB/phpbb/template/twig/extension.php +++ b/phpBB/phpbb/template/twig/extension.php @@ -18,20 +18,20 @@ class extension extends \Twig_Extension /** @var \phpbb\template\context */ protected $context; - /** @var \phpbb\user */ - protected $user; + /** @var \phpbb\language\language */ + protected $language; /** * Constructor * * @param \phpbb\template\context $context - * @param \phpbb\user $user + * @param \phpbb\language\language $language * @return \phpbb\template\twig\extension */ - public function __construct(\phpbb\template\context $context, $user) + public function __construct(\phpbb\template\context $context, $language) { $this->context = $context; - $this->user = $user; + $this->language = $language; } /** @@ -71,6 +71,7 @@ class extension extends \Twig_Extension { return array( new \Twig_SimpleFilter('subset', array($this, 'loop_subset'), array('needs_environment' => true)), + // @deprecated 3.2.0 Uses twig's JS escape method instead of addslashes new \Twig_SimpleFilter('addslashes', 'addslashes'), ); } @@ -145,7 +146,7 @@ class extension extends \Twig_Extension // of items to grab (length) // Start must always be the actual starting number for this calculation (not negative) - $start = ($start < 0) ? sizeof($item) + $start : $start; + $start = ($start < 0) ? count($item) + $start : $start; $end = $end - $start; } @@ -171,14 +172,14 @@ class extension extends \Twig_Extension $context_vars = $this->context->get_root_ref(); - if (isset($context_vars['L_' . $key])) + if (is_string($key) && isset($context_vars['L_' . $key])) { return $context_vars['L_' . $key]; } - // LA_ is transformed into lang(\'$1\')|addslashes, so we should not + // LA_ is transformed into lang(\'$1\')|escape('js'), so we should not // need to check for it - return call_user_func_array(array($this->user, 'lang'), $args); + return call_user_func_array(array($this->language, 'lang'), $args); } } |