From b08b3a5fd8469053b3ec931fd2f4650f586f0cb3 Mon Sep 17 00:00:00 2001 From: Mike Ng Date: Mon, 19 Feb 2018 11:04:47 +0400 Subject: [PATCH] PORT PHRAS-854 to 4.1 --- .../Core/Provider/TwigServiceProvider.php | 19 +++++++++++++++++++ .../Elastic/ElasticsearchRecordHydrator.php | 2 +- .../web/common/technical_datas.html.twig | 2 +- templates/web/prod/results/item.html.twig | 6 +++--- templates/web/prod/results/record.html.twig | 10 +++++----- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php index 6fa067a84c..6b9ceae618 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TwigServiceProvider.php @@ -143,6 +143,25 @@ class TwigServiceProvider implements ServiceProviderInterface $twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) { return str_replace('"', '\"', $value); })); + + $twig->addFilter(new \Twig_SimpleFilter('formatDuration', + function ($secondsInDecimals) { + $time = []; + $hours = floor($secondsInDecimals / 3600); + $secondsInDecimals -= $hours * 3600; + $minutes = floor($secondsInDecimals / 60); + $secondsInDecimals -= $minutes * 60; + $seconds = intVal($secondsInDecimals % 60, 10); + if ($hours > 0) { + array_push($time, (strlen($hours) < 2) ? "0{$hours}" : $hours); + } + array_push($time, (strlen($minutes) < 2) ? "0{$minutes}" : $minutes); + array_push($time, (strlen($seconds) < 2) ? "0{$seconds}" : $seconds); + $formattedTime = implode(':', $time); + + return $formattedTime; + } + )); } /** diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php index 3c6003b6fe..5a49303b9f 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php @@ -62,7 +62,7 @@ class ElasticsearchRecordHydrator $record->setTitles((array) igorw\get_in($data, ['title'], [])); $record->setCaption((array) igorw\get_in($data, ['caption'], [])); $record->setPrivateCaption((array) igorw\get_in($data, ['private_caption'], [])); - $record->setExif((array) igorw\get_in($data, ['exif'], [])); + $record->setExif((array)igorw\get_in($data, ['metadata_tags'], [])); $record->setSubdefs((array) igorw\get_in($data, ['subdefs'], [])); $record->setFlags((array) igorw\get_in($data, ['flags'], [])); $record->setHighlight((array) $highlight); diff --git a/templates/web/common/technical_datas.html.twig b/templates/web/common/technical_datas.html.twig index b9c8156cbe..905c597099 100644 --- a/templates/web/common/technical_datas.html.twig +++ b/templates/web/common/technical_datas.html.twig @@ -126,7 +126,7 @@ {% block td_duration %} {% if record.exif[constant('media_subdef::TC_DATA_DURATION')] is defined %}
{{ 'Duree' | trans }} : -
{{ record.exif[constant('media_subdef::TC_DATA_DURATION')] }}
+
{{ record.exif[constant('media_subdef::TC_DATA_DURATION')]|formatDuration }}
{% endif %} {% endblock %} {% block td_framerate %} diff --git a/templates/web/prod/results/item.html.twig b/templates/web/prod/results/item.html.twig index 45bfc33d7d..5afafc3650 100644 --- a/templates/web/prod/results/item.html.twig +++ b/templates/web/prod/results/item.html.twig @@ -33,12 +33,12 @@
- {% if doctype_display %} - {{ record_doctype_icon(record) }} - {% endif %} {{ record.get_formated_duration }} + {% if doctype_display %} + {{ record_doctype_icon(record) }} + {% endif %}
{% set extraclass = rollover_gif ? 'rollover-gif-out' : '' %} diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig index 1c5765f233..bccf31775e 100644 --- a/templates/web/prod/results/record.html.twig +++ b/templates/web/prod/results/record.html.twig @@ -28,14 +28,14 @@ {% if settings.rollover_thumbnail == 'preview' %}tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) }}"{% endif %} style="height:{{ settings.images_size }}px; z-index:90;">
+ + {% if record.type == 'video' and attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION')) is defined %} + {{ attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION'))|formatDuration }} + {% endif %} + {% if settings.doctype_display == '1' %} {{ record_doctype_icon(record) }} {% endif %} - - {% if record.type == 'video' and attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION')) is defined %} - {{ attribute(record.exif, constant('\\media_subdef::TC_DATA_DURATION')) }} - {% endif %} -
{% set rollover = record.subdefs.thumbnailgif is defined %} {% set extraclass = '' %}