diff --git a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php index 6b9ceae618..4dddd878ad 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php @@ -127,6 +127,22 @@ class TwigServiceProvider implements ServiceProviderInterface ); }, ['needs_environment' => true, 'is_safe' => ['html']])); + $twig->addFilter(new \Twig_SimpleFilter('parseColor', function (\Twig_Environment $twig, $string) use ($app) { + $re = '/^(.*)\[#([0-9a-fA-F]{6})]$/m'; + $stringArr = explode(';', $string); + foreach ($stringArr as $key => $value) { + preg_match_all($re, trim($value), $matches); + if ($matches && $matches[1] != null && $matches[2] != null) { + $colorCode = '#' . $matches[2][0]; + $colorName = $matches[1][0]; + + $stringArr[$key] = '' . $colorName . '
'; + } + } + + return implode('', $stringArr); + }, ['needs_environment' => true, 'is_safe' => ['html']])); + $twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) { // bounce value if it is present in thesaurus as well diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig index 50091a8af3..1683aa98c3 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macros.html.twig @@ -128,8 +128,8 @@
{% for field in record.get_caption().get_highlight_fields(null, can_see_business) %}
{{ field.label_name }}
-
{{ _self.caption_value(field, bounceable|default(true))|highlight|linkify }}
- {% endfor %} +
{{ _self.caption_value(field, bounceable|default(true))|highlight|linkify|parseColor }}
+ {% endfor %}
{% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %}