mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
show hex as icon in technical data
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user