show hex as icon in technical data

This commit is contained in:
mike-esokia
2018-05-18 17:36:19 +04:00
committed by Mike Ng
parent 1fa415a252
commit 12fc9344d4
2 changed files with 18 additions and 1 deletions

View File

@@ -127,6 +127,23 @@ 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, $value, $matches);
if ($matches && $matches[1] != null && $matches[2] != null) {
$colorCode = '#' . $matches[2][0];
$colorName = $matches[1][0];
$stringArr[$key] = '<span class="color-dot" style="margin-right: 4px; background-color: ' . $colorCode . '"></span>' . trim($colorName) . '<br />';
}
}
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

View File

@@ -128,7 +128,7 @@
<dl class="{% if limitedWidth %}{% else %}dl-horizontal{% endif %}">
{% for name, value in record.getCaption(caption_field_order(record, can_see_business)) %}
<dt>{{ caption_field_label(record, name) }}</dt>
<dd>{{ caption_field(record, name, value)|e|highlight }}</dd>
<dd>{{ caption_field(record, name, value)|e|highlight|parseColor }}</dd>
{% endfor %}
</dl>
{% if display_exif|default(true) and app.getAuthenticator().user is not none and user_setting('technical_display') == 'group' %}