diff --git a/phpBB/phpbb/template/twig/extension/icon.php b/phpBB/phpbb/template/twig/extension/icon.php index 1a6adc48f3..6c077385f3 100644 --- a/phpBB/phpbb/template/twig/extension/icon.php +++ b/phpBB/phpbb/template/twig/extension/icon.php @@ -23,7 +23,7 @@ class icon extends \Twig\Extension\AbstractExtension /** * Constructor. * - * @param \phpbb\user $user User object + * @param \phpbb\user $user User object */ public function __construct(\phpbb\user $user) { @@ -33,7 +33,7 @@ class icon extends \Twig\Extension\AbstractExtension /** * Returns the name of this extension. * - * @return string The extension name + * @return string The extension name */ public function getName() { @@ -43,7 +43,7 @@ class icon extends \Twig\Extension\AbstractExtension /** * Returns a list of filters to add to the existing list. * - * @return \Twig\TwigFilter[] + * @return \Twig\TwigFilter[] Array of twig filters */ public function getFilters() { @@ -55,7 +55,7 @@ class icon extends \Twig\Extension\AbstractExtension /** * Returns a list of functions to add to the existing list. * - * @return \Twig\TwigFunction[] + * @return \Twig\TwigFunction[] Array of twig functions */ public function getFunctions() { @@ -77,7 +77,7 @@ class icon extends \Twig\Extension\AbstractExtension $web_path = $board_url ? generate_board_url() . '/' : $environment->get_web_root_path(); $style_path = $this->user->style['style_path']; - return "{$web_path}styles/{$style_path}/template/icons/png/{$icon}.png"; + return "{$web_path}styles/{$style_path}/theme/icons/png/{$icon}.png"; } /** diff --git a/phpBB/phpbb/template/twig/extension/implode.php b/phpBB/phpbb/template/twig/extension/implode.php index 5c6d313a4d..93c6fe48ae 100644 --- a/phpBB/phpbb/template/twig/extension/implode.php +++ b/phpBB/phpbb/template/twig/extension/implode.php @@ -18,7 +18,7 @@ class implode extends \Twig\Extension\AbstractExtension /** * Returns the name of this extension. * - * @return string The extension name + * @return string The extension name */ public function getName() { @@ -28,7 +28,7 @@ class implode extends \Twig\Extension\AbstractExtension /** * Returns a list of functions to add to the existing list. * - * @return \Twig\TwigFunction[] + * @return \Twig\TwigFunction[] Array of twig functions */ public function getFunctions() { @@ -47,8 +47,8 @@ class implode extends \Twig\Extension\AbstractExtension * Implode_attributes('checked', {'data-ajax': 'true'}) * Implode_attributes(['checked', {'data-ajax': 'true'}]) * - * @param mixed $arguments - * @return string + * @param mixed $arguments Attributes to implode + * @return string The attributes string */ public function implode_attributes(...$arguments) { @@ -132,8 +132,8 @@ class implode extends \Twig\Extension\AbstractExtension * 'hidden-class': S_POST_HIDDEN, * }]) * - * @param mixed $arguments - * @return string The classes string prepended with a space + * @param mixed $arguments The classes to implode + * @return string The classes string prepended with a space */ public function implode_classes(...$arguments) { diff --git a/phpBB/phpbb/template/twig/extension/macro.php b/phpBB/phpbb/template/twig/extension/macro.php index f786a15de1..f8fd4f303b 100644 --- a/phpBB/phpbb/template/twig/extension/macro.php +++ b/phpBB/phpbb/template/twig/extension/macro.php @@ -23,7 +23,7 @@ class macro extends \Twig\Extension\AbstractExtension implements \Twig\Extension /** * Constructor. * - * @param environment $twig Twig environment object + * @param environment $twig Twig environment object */ public function __construct(environment $twig) { @@ -33,7 +33,7 @@ class macro extends \Twig\Extension\AbstractExtension implements \Twig\Extension /** * Returns the name of this extension. * - * @return string The extension name + * @return string The extension name */ public function getName() { @@ -43,22 +43,13 @@ class macro extends \Twig\Extension\AbstractExtension implements \Twig\Extension /** * Returns a list of global variables to add to the existing list. * - * @return array An array of global variables + * @throws \Twig\Error\Error + * @return array An array of global variables */ public function getGlobals() { - $macros = null; - - try - { - $macros = $this->twig->loadTemplate('macros.html'); - } - catch (\Twig\Error\Error $e) - { - } - return [ - 'macros' => $macros, + 'macros' => $this->twig->loadTemplate('macros/macros.twig'), ]; } } diff --git a/phpBB/styles/all/template/macros.html b/phpBB/styles/all/template/macros.html deleted file mode 100644 index 637140c6dc..0000000000 --- a/phpBB/styles/all/template/macros.html +++ /dev/null @@ -1,5 +0,0 @@ -{# Wrapper function #} -{% macro Icon(type, icon, classes = '', title = '', hidden = false, attributes = {}) %} - {% set type = type|capitalize %} -Hello -{% endmacro Icon %} diff --git a/phpBB/styles/all/template/macros/macros.twig b/phpBB/styles/all/template/macros/macros.twig new file mode 100644 index 0000000000..649d3ee889 --- /dev/null +++ b/phpBB/styles/all/template/macros/macros.twig @@ -0,0 +1,34 @@ +{# Wrapper function #} +{% macro Icon(type, icon, classes = '', title = '', hidden = false, attributes = {}) %} + {% set type = type|capitalize %} + + {% if type in ['Fa', 'Png', 'Svg'] %} + {{ attribute(_self, type, [icon, classes, title, hidden, attributes]) }} + {% endif %} +{% endmacro Icon %} + +{# FA icons #} +{% macro Fa(icon, classes = '', title = '', hidden = false, attributes = {}) %} + + {% if title %}