mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15538] Fixes unrelated to the error
PHPBB3-15538
This commit is contained in:
parent
971b905569
commit
23fae74bf2
6 changed files with 34 additions and 48 deletions
|
@ -63,11 +63,15 @@ services:
|
||||||
|
|
||||||
template.twig.extensions.implode:
|
template.twig.extensions.implode:
|
||||||
class: phpbb\template\twig\extension\implode
|
class: phpbb\template\twig\extension\implode
|
||||||
|
tags:
|
||||||
|
- { name: twig.extension }
|
||||||
|
|
||||||
template.twig.extensions.macro:
|
template.twig.extensions.macro:
|
||||||
class: phpbb\template\twig\extension\macro
|
class: phpbb\template\twig\extension\macro
|
||||||
arguments:
|
arguments:
|
||||||
- '@template.twig.environment'
|
- '@template.twig.environment'
|
||||||
|
tags:
|
||||||
|
- { name: twig.extension }
|
||||||
|
|
||||||
template.twig.extensions.routing:
|
template.twig.extensions.routing:
|
||||||
class: phpbb\template\twig\extension\routing
|
class: phpbb\template\twig\extension\routing
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\extension;
|
||||||
|
|
||||||
use phpbb\template\twig\environment;
|
use phpbb\template\twig\environment;
|
||||||
|
|
||||||
abstract class icon extends \Twig\Extension\AbstractExtension
|
class icon extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
/** @var \phpbb\user */
|
/** @var \phpbb\user */
|
||||||
protected $user;
|
protected $user;
|
||||||
|
@ -48,7 +48,7 @@ abstract class icon extends \Twig\Extension\AbstractExtension
|
||||||
public function getFilters()
|
public function getFilters()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new \Twig\TwigFilter('Png_path', [$this, 'png_path'], ['needs_environment' => true]),
|
new \Twig\TwigFilter('png_path', [$this, 'png_path'], ['needs_environment' => true]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ abstract class icon extends \Twig\Extension\AbstractExtension
|
||||||
* @param string $icon The icon name
|
* @param string $icon The icon name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function png_path(environment $environment, $icon)
|
public function png_path(environment $environment, $icon)
|
||||||
{
|
{
|
||||||
$board_url = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH;
|
$board_url = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH;
|
||||||
$web_path = $board_url ? generate_board_url() . '/' : $environment->get_web_root_path();
|
$web_path = $board_url ? generate_board_url() . '/' : $environment->get_web_root_path();
|
||||||
|
@ -87,7 +87,7 @@ abstract class icon extends \Twig\Extension\AbstractExtension
|
||||||
* @param string $icon The icon name
|
* @param string $icon The icon name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function svg_clean(environment $environment, $icon)
|
public function svg_clean(environment $environment, $icon)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -110,8 +110,10 @@ abstract class icon extends \Twig\Extension\AbstractExtension
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($doc->childNodes as $child) {
|
foreach ($doc->childNodes as $child)
|
||||||
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
|
{
|
||||||
|
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE)
|
||||||
|
{
|
||||||
$child->parentNode->removeChild($child);
|
$child->parentNode->removeChild($child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace phpbb\template\twig\extension;
|
namespace phpbb\template\twig\extension;
|
||||||
|
|
||||||
abstract class implode extends \Twig\Extension\AbstractExtension
|
class implode extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the name of this extension.
|
* Returns the name of this extension.
|
||||||
|
@ -50,7 +50,7 @@ abstract class implode extends \Twig\Extension\AbstractExtension
|
||||||
* @param mixed $arguments
|
* @param mixed $arguments
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function implode_attributes(...$arguments)
|
public function implode_attributes(...$arguments)
|
||||||
{
|
{
|
||||||
$string = '';
|
$string = '';
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
@ -71,13 +71,17 @@ abstract class implode extends \Twig\Extension\AbstractExtension
|
||||||
}
|
}
|
||||||
else if (is_array($value))
|
else if (is_array($value))
|
||||||
{
|
{
|
||||||
if (is_integer($key) && is_string($value))
|
foreach ($value as $k => $v)
|
||||||
{
|
{
|
||||||
$attributes[] = $value;
|
if (is_integer($k) && is_string($v))
|
||||||
|
{
|
||||||
|
$attributes[] = $v;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$attributes[$key] = $value;
|
|
||||||
|
$attributes[$k] = $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -92,11 +96,13 @@ abstract class implode extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
if (is_string($attribute))
|
if (is_string($attribute))
|
||||||
{
|
{
|
||||||
|
$value = is_bool($value) ? ($value ? 'true' : 'false') : $value;
|
||||||
|
|
||||||
$string .= ' ' . $attribute . '="' . $value . '"';
|
$string .= ' ' . $attribute . '="' . $value . '"';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$string .= ' ' . $attribute;
|
$string .= ' ' . $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +135,7 @@ abstract class implode extends \Twig\Extension\AbstractExtension
|
||||||
* @param mixed $arguments
|
* @param mixed $arguments
|
||||||
* @return string The classes string prepended with a space
|
* @return string The classes string prepended with a space
|
||||||
*/
|
*/
|
||||||
protected function implode_classes(...$arguments)
|
public function implode_classes(...$arguments)
|
||||||
{
|
{
|
||||||
$classes = [];
|
$classes = [];
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace phpbb\template\twig\extension;
|
||||||
|
|
||||||
use phpbb\template\twig\environment;
|
use phpbb\template\twig\environment;
|
||||||
|
|
||||||
abstract class macro extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface
|
class macro extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface
|
||||||
{
|
{
|
||||||
/** @var environment */
|
/** @var environment */
|
||||||
protected $twig;
|
protected $twig;
|
||||||
|
@ -37,7 +37,7 @@ abstract class macro extends \Twig\Extension\AbstractExtension implements \Twig\
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'macro';
|
return 'macros';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,33 +1,5 @@
|
||||||
{# Wrapper function #}
|
{# Wrapper function #}
|
||||||
{% macro Icon(type, icon, classes = '', title = '', hidden = false, attributes = {}) %}
|
{% macro Icon(type, icon, classes = '', title = '', hidden = false, attributes = {}) %}
|
||||||
{% set type = type|capitalize %}
|
{% set type = type|capitalize %}
|
||||||
|
Hello
|
||||||
{% if type in ['Fa', 'Png', 'Svg'] %}
|
|
||||||
{{ attribute(_self, type, [icon, classes, title, hidden, attributes]) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endmacro Icon %}
|
{% endmacro Icon %}
|
||||||
|
|
||||||
{# FA icons #}
|
|
||||||
{% macro Fa(icon, classes = '', title = '', hidden = false, attributes = {}) %}
|
|
||||||
<i class="o-icon font fa-{{ icon ~ Implode_classes(classes) }}"{% if hidden %}{% if title %} title="{{ lang(title) }}"{% endif %} aria-hidden="true"{% endif %}{{ Implode_attributes(attributes) }}></i>
|
|
||||||
{% if title %}<span{% if hidden %} class="sr-only"{% endif %}>{{ lang(title) }}</span>{% endif %}
|
|
||||||
{% endmacro Fa %}
|
|
||||||
|
|
||||||
{# PNG icons #}
|
|
||||||
{% macro Png(icon, classes = '', title = '', hidden = false, attributes = {}) %}
|
|
||||||
<img class="o-icon png png-{{ icon ~ Implode_classes(classes) }}" src="{{ icon|png_path }}" alt="{{ lang(title) }}"{{ _self.attributes(attributes) }}
|
|
||||||
{% endmacro Png %}
|
|
||||||
|
|
||||||
{# SVG icons #}
|
|
||||||
{% macro Svg(icon, classes = '', title = '', hidden = false, attributes = {}) %}
|
|
||||||
{% set title_id = title ? title|lower|replace({' ': '_'}) ~ '-' ~ random() %}
|
|
||||||
|
|
||||||
<svg class="o-icon svg svg-{{ icon ~ Implode_classes(classes) }}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"{% if title %}{% if hidden %} aria-hidden="true"{% endif %} aria-labelledby="{{ title_id }}"{% endif %} role="img"{{ Implode_attributes(attributes) }}>
|
|
||||||
{% if title %}
|
|
||||||
<title id="{{ title_id }}">{{ lang(title) }}</title>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{{ svg_clean(icon) }}
|
|
||||||
</svg>
|
|
||||||
{% endmacro Svg %}
|
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
<!-- EVENT index_body_markforums_after -->
|
<!-- EVENT index_body_markforums_after -->
|
||||||
|
|
||||||
|
Test: {{ macros.Icon('fa', 'phone') }}
|
||||||
|
|
||||||
<!-- INCLUDE forumlist_body.html -->
|
<!-- INCLUDE forumlist_body.html -->
|
||||||
|
|
||||||
<!-- EVENT index_body_forumlist_body_after -->
|
<!-- EVENT index_body_forumlist_body_after -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue