diff --git a/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php index 817a1ddc22..6733c89c8d 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php +++ b/lib/Alchemy/Phrasea/Model/Entities/ElasticsearchRecord.php @@ -11,9 +11,8 @@ namespace Alchemy\Phrasea\Model\Entities; -use Doctrine\Common\Collections\ArrayCollection; -use Alchemy\Phrasea\Model\RecordInterface; use Alchemy\Phrasea\Model\MutableRecordInterface; +use Alchemy\Phrasea\Model\RecordInterface; /** * Record entity from elastic search @@ -26,7 +25,7 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface private $baseId; private $collectionName; private $mimeType; - private $title; + private $title = []; private $originalName; private $updated; private $created; @@ -36,14 +35,11 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface private $type; private $status; private $isStory; - /** @var ArrayCollection */ - private $caption; - /** @var ArrayCollection */ - private $exif; - /** @var ArrayCollection */ - private $subdefs; - /** @var ArrayCollection */ - private $flags; + private $caption = []; + private $exif = []; + private $subdefs = []; + private $flags = []; + private $highlight = []; /** {@inheritdoc} */ public function getId() @@ -108,7 +104,7 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface /** {@inheritdoc} */ public function setIsStory($isStory) { - $this->isStory = (bool) $isStory; + $this->isStory = (bool)$isStory; } /** {@inheritdoc} */ @@ -185,12 +181,12 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface */ public function getTitle($locale = null) { - if ($locale && $this->title->containsKey($locale)) { - return $this->title->get($locale); + if ($locale && isset($this->title[$locale])) { + return $this->title[$locale]; } - if ($this->title->containsKey('default')) { - return $this->title->get('default'); + if (isset($this->title['default'])) { + return $this->title['default']; } return $this->getOriginalName(); @@ -199,9 +195,9 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface /** * Sets a collection of titles * - * @param ArrayCollection $titles + * @param string[] $titles */ - public function setTitles(ArrayCollection $titles) + public function setTitles(array $titles) { $this->title = $titles; } @@ -240,45 +236,41 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface $this->uuid = $uuid; } - /** @return ArrayCollection */ + /** @return array */ public function getCaption() { return $this->caption; } - public function setCaption(ArrayCollection $caption) + public function setCaption(array $caption) { $this->caption = $caption; } - /** @return ArrayCollection */ + /** @return array */ public function getExif() { return $this->exif; } - /** - * @param mixed $exif - */ - public function setExif(ArrayCollection $exif) + public function setExif(array $exif) { $this->exif = $exif; } - /** @return ArrayCollection */ + /** @return array */ public function getSubdefs() { return $this->subdefs; } - /** @return ArrayCollection */ - public function setSubdefs(ArrayCollection $subdefs) + public function setSubdefs(array $subdefs) { $this->subdefs = $subdefs; } /** - * @return ArrayCollection + * @return array */ public function getFlags() { @@ -286,9 +278,9 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface } /** - * @param ArrayCollection $flags + * @param array $flags */ - public function setFlags(ArrayCollection $flags) + public function setFlags(array $flags) { $this->flags = $flags; } @@ -319,4 +311,20 @@ class ElasticsearchRecord implements RecordInterface, MutableRecordInterface { $this->position = $position; } + + /** + * @return array + */ + public function getHighlight() + { + return $this->highlight; + } + + /** + * @param array $highlight + */ + public function setHighlight(array $highlight) + { + $this->highlight = $highlight; + } } diff --git a/lib/Alchemy/Phrasea/Model/RecordInterface.php b/lib/Alchemy/Phrasea/Model/RecordInterface.php index ddc4542632..c542b5afc3 100644 --- a/lib/Alchemy/Phrasea/Model/RecordInterface.php +++ b/lib/Alchemy/Phrasea/Model/RecordInterface.php @@ -58,6 +58,9 @@ interface RecordInterface /** @return integer */ public function getStatusBitField(); - /** @return ArrayCollection */ + /** @return array */ public function getExif(); + + /** @return array */ + public function getCaption(); } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php index 18b6c22b07..64abb667e7 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php @@ -268,6 +268,12 @@ class ElasticSearchEngine implements SearchEngineInterface $params['body']['from'] = $offset; $params['body']['size'] = $perPage; + $params['body']['highlight'] = [ + 'pre_tags' => ['[[em]]'], + 'post_tags' => ['[[/em]]'], + 'order' => 'score', + 'fields' => ['caption.*' => new \stdClass()] + ]; if ($aggs = $this->getAggregationQueryParams($options)) { $params['body']['aggs'] = $aggs; @@ -280,7 +286,7 @@ class ElasticSearchEngine implements SearchEngineInterface $n = 0; foreach ($res['hits']['hits'] as $hit) { - $results[] = ElasticsearchRecordHydrator::hydrate($hit['_source'], $n++); + $results[] = ElasticsearchRecordHydrator::hydrate($hit, $n++); } $facets = $this->facetsResponseFactory->__invoke($res); diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php index f3174e0672..33f1038b56 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticsearchRecordHydrator.php @@ -17,8 +17,11 @@ use igorw; class ElasticsearchRecordHydrator { - public static function hydrate(array $data, $position) + public static function hydrate(array $hit, $position) { + $data = $hit['_source']; + $highlight = isset($hit['highlight']) ? $hit['highlight'] : []; + $record = new ElasticsearchRecord(); $record->setPosition($position); @@ -38,11 +41,12 @@ class ElasticsearchRecordHydrator $record->setUpdated($updatedOn ? new \DateTime($updatedOn) : $updatedOn); $record->setUuid(igorw\get_in($data, ['uuid'], '')); $record->setStatusBitField(igorw\get_in($data, ['flags_bitfield'], 0)); - $record->setTitles(new ArrayCollection((array) igorw\get_in($data, ['title'], []))); - $record->setCaption(new ArrayCollection((array) igorw\get_in($data, ['caption'], []))); - $record->setExif(new ArrayCollection((array) igorw\get_in($data, ['exif'], []))); - $record->setSubdefs(new ArrayCollection((array) igorw\get_in($data, ['subdefs'], []))); - $record->setFlags(new ArrayCollection((array) igorw\get_in($data, ['flags'], []))); + $record->setTitles((array) igorw\get_in($data, ['title'], [])); + $record->setCaption((array) igorw\get_in($data, ['caption'], [])); + $record->setExif((array) igorw\get_in($data, ['exif'], [])); + $record->setSubdefs((array) igorw\get_in($data, ['subdefs'], [])); + $record->setFlags((array) igorw\get_in($data, ['flags'], [])); + $record->setHighlight((array) $highlight); return $record; } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php index 8d4d03a54b..4fd601810d 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Indexer/RecordIndexer.php @@ -232,6 +232,7 @@ class RecordIndexer } else { $m->addRawVersion(); $m->addAnalyzedVersion($this->locales); + $m->highlight(); } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php index d54905e979..c28a74b6e2 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/Mapping.php @@ -210,6 +210,15 @@ class Mapping return $this; } + public function highlight() + { + $field = &$this->currentField(); + + $field['term_vector'] = 'with_positions_offsets'; + + return $this; + } + public function has($name) { return isset($this->fields[$name]); diff --git a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php index 7634e4b720..f3f68d1f01 100644 --- a/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php +++ b/lib/Alchemy/Phrasea/Twig/PhraseanetExtension.php @@ -2,10 +2,10 @@ namespace Alchemy\Phrasea\Twig; +use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\ElasticsearchRecord; use Alchemy\Phrasea\Model\Entities\User; use Alchemy\Phrasea\Model\RecordInterface; -use Silex\Application; class PhraseanetExtension extends \Twig_Extension { @@ -40,13 +40,41 @@ class PhraseanetExtension extends \Twig_Extension )), new \Twig_SimpleFunction('record_flags', array($this, 'getRecordFlags')), new \Twig_SimpleFunction('border_checker_from_fqcn', array($this, 'getCheckerFromFQCN')), + new \Twig_SimpleFunction('caption_field', array($this, 'getCaptionField')), ); } + public function getCaptionField(RecordInterface $record, $field, $value) + { + if ($record instanceof ElasticsearchRecord) { + $highlightKey = sprintf('caption.%s', $field); + + $highlights = $record->getHighlight(); + if (false === isset($highlights[$highlightKey])) { + return implode('; ', (array) $value); + } + + $highlightValue = $highlights[$highlightKey]; + + // if field is multivalued, merge highlighted values with captions ones + if (is_array($value)) { + $highlightValue = array_merge($highlightValue, array_diff($value, array_map(function($value) { + return str_replace(array('[[em]]', '[[/em]]'), array('', ''), $value); + }, $highlightValue))); + } + + return implode('; ', (array) $highlightValue); + } + + return implode('; ', (array) $value); + } + public function getRecordFlags(RecordInterface $record) { $recordStatuses = []; - $databox = $this->app['phraseanet.appbox']->get_databox($record->getDataboxId()); + /** @var \appbox $appbox */ + $appbox = $this->app['phraseanet.appbox']; + $databox = $appbox->get_databox($record->getDataboxId()); $structure = $databox->getStatusStructure()->toArray(); @@ -182,8 +210,9 @@ class PhraseanetExtension extends \Twig_Extension public function getSubdefUrl(RecordInterface $record, $subdefName) { if ($record instanceof ElasticsearchRecord) { - if ($record->getSubdefs()->containsKey($subdefName)) { - $thumbnail = $record->getSubdefs()->get($subdefName); + $subdefs = $record->getSubdefs(); + if (isset($subdefs[$subdefName])) { + $thumbnail = $subdefs[$subdefName]; if (null !== $path = $thumbnail['path']) { if (is_string($path) && '' !== $path) { return $this->app['phraseanet.static-file']->getUrl($path); diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 537a803a81..054449bf1e 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -763,6 +763,22 @@ class record_adapter implements RecordInterface, cache_cacheableInterface return new caption_record($this->app, $this, $this->get_databox()); } + public function getCaption() + { + $collection = []; + + /** @var caption_field $field */ + foreach ($this->get_caption()->get_fields() as $field) { + $values = array_map(function(caption_Field_Value $fieldValue) { + return $fieldValue->getValue(); + }, $field->get_values()); + + $collection[$field->get_name()] = $values; + } + + return $collection; + } + /** * * @return string @@ -2020,7 +2036,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface /** {@inheritdoc} */ public function getExif() { - return new ArrayCollection($this->get_technical_infos()); + return $this->get_technical_infos(); } public function getStatusStructure() diff --git a/templates/web/common/caption.html.twig b/templates/web/common/caption.html.twig index 6905a32325..4e06972df6 100644 --- a/templates/web/common/caption.html.twig +++ b/templates/web/common/caption.html.twig @@ -1,20 +1,21 @@ {% import 'common/macros.html.twig' as macro %} -{% set business = false %} -{% if app['authentication'].getUser() is not none %} - {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %} -{% endif %} +{% set business = granted_on_collection(record.baseId, 'canmodifrecord') %} +{% set display_exif = true %} {% if view == 'answer' %} - {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, true) }} + {{ macro.caption(record, business, display_exif) }} {% elseif view == 'lazaret' %} - {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, true) }} + {{ macro.caption(record, business, display_exif) }} {% elseif view == 'preview' %} - {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }} + {% set display_exif = false %} + {{ macro.caption(record, business, display_exif) }} {% elseif view == 'basket' %} - {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }} + {% set display_exif = false %} + {{ macro.caption(record, business, display_exif) }} {% elseif view == 'overview' %} - {{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, false) }} + {% set display_exif = false %} + {{ macro.caption(record, business, display_exif) }} {% elseif view == 'publi' %} - {{ macro.format_caption(record, '', null, business, true, true) }} + {{ macro.caption(record, business, display_exif) }} {% endif %} diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig index 2f7eb55fd4..ee712955a1 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macros.html.twig @@ -116,19 +116,15 @@ {% endif %} {% endmacro %} -{% macro caption(record, business, technical) %} +{% macro caption(record, can_see_business, display_exif) %} {# @todo handle business fields #} {% for name, value in record.caption %} -
+
{{ name }} : - {% if value is iterable %} - {{ value | join(' ; ') }} - {% else %} - {{ value }} - {% endif %} + {{ caption_field(record, name, value)|e|highlight }}
{% endfor %} - {% if technical|default(true) and app['authentication'].user is not none and user_setting('technical_display') == 'group' %} + {% if display_exif|default(true) and app['authentication'].user is not none and user_setting('technical_display') == 'group' %}
{% include 'common/technical_datas.html.twig' %} {% endif %} diff --git a/templates/web/common/technical_datas.html.twig b/templates/web/common/technical_datas.html.twig index 64b9de9412..b01978ac16 100644 --- a/templates/web/common/technical_datas.html.twig +++ b/templates/web/common/technical_datas.html.twig @@ -19,52 +19,52 @@
{% block td_size %} - {% set width = record.exif.get(constant('media_subdef::TC_DATA_WIDTH')) %} - {% set height = record.exif.get(constant('media_subdef::TC_DATA_HEIGHT')) %} + {% set width = record.exif[constant('media_subdef::TC_DATA_WIDTH')]|default(null) %} + {% set height = record.exif[constant('media_subdef::TC_DATA_HEIGHT')]|default(null) %} {% if width is not none and height is not none %} {{ width ~ " x " ~ height }} {% endif %} {% endblock %}
{% block td_camera_model %} - {% if record.exif.get(constant('media_subdef::TC_DATA_CAMERAMODEL')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_CAMERAMODEL')] is defined %} {{ 'Camera Model' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_CAMERAMODEL')) }} + {{ record.exif[constant('media_subdef::TC_DATA_CAMERAMODEL')] }}
{% endif %} {% endblock %} {% block td_color_space %} - {% if record.exif.get(constant('media_subdef::TC_DATA_COLORSPACE')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_COLORSPACE')] is defined %} {{ 'Color space' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_COLORSPACE')) }} + {{ record.exif[constant('media_subdef::TC_DATA_COLORSPACE')] }}
{% endif %} {% endblock %} {% block td_channels %} - {% if record.exif.get(constant('media_subdef::TC_DATA_CHANNELS')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_CHANNELS')] is defined %} {{ 'Channels' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_CHANNELS')) }} + {{ record.exif[constant('media_subdef::TC_DATA_CHANNELS')] }}
{% endif %} {% endblock %} {% block td_color_depth %} - {% if record.exif.get(constant('media_subdef::TC_DATA_COLORDEPTH')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_COLORDEPTH')] is defined %} {{ 'Color Depth' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_COLORDEPTH')) }} bits + {{ record.exif[constant('media_subdef::TC_DATA_COLORDEPTH')] }} bits
{% endif %} {% endblock %} {% block td_iso_sensibility %} - {% if record.exif.get(constant('media_subdef::TC_DATA_ISO')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_ISO')] is defined %} {{ 'ISO sensibility' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_ISO')) }} + {{ record.exif[constant('media_subdef::TC_DATA_ISO')] }}
{% endif %} {% endblock %} {% block td_flash %} - {% if record.exif.get(constant('media_subdef::TC_DATA_FLASHFIRED')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_FLASHFIRED')] is defined %} {{ 'Flash' | trans }} : - {% if record.exif.get(constant('media_subdef::TC_DATA_FLASHFIRED')) %} + {% if record.exif[constant('media_subdef::TC_DATA_FLASHFIRED')] %} {{ 'yes' | trans }} {% else %} {{ 'no' | trans }} @@ -73,72 +73,72 @@ {% endif %} {% endblock %} {% block td_shutter_speed %} - {% if record.exif.get(constant('media_subdef::TC_DATA_SHUTTERSPEED')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_SHUTTERSPEED')] is defined %} {{ 'Shutter speed' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_SHUTTERSPEED')) }} s. + {{ record.exif[constant('media_subdef::TC_DATA_SHUTTERSPEED')] }} s.
{% endif %} {% endblock %} {% block td_apeture %} - {% if record.exif.get(constant('media_subdef::TC_DATA_APERTURE')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_APERTURE')] is defined %} {{ 'Aperture' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_APERTURE')) | round(2) }} + {{ record.exif[constant('media_subdef::TC_DATA_APERTURE')] | round(2) }}
{% endif %} {% endblock %} {% block td_focal_length %} - {% if record.exif.get(constant('media_subdef::TC_DATA_FOCALLENGTH')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_FOCALLENGTH')] is defined %} {{ 'Focal length' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_FOCALLENGTH')) }} mm + {{ record.exif[constant('media_subdef::TC_DATA_FOCALLENGTH')] }} mm
{% endif %} {% endblock %} {% block td_hyperfocal_distance %} - {% if record.exif.get(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')] is defined %} {{ 'Hyperfocal distance' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')) | round(2) }} mm + {{ record.exif[constant('media_subdef::TC_DATA_HYPERFOCALDISTANCE')] | round(2) }} mm
{% endif %} {% endblock %} {% block td_light_value %} - {% if record.exif.get(constant('media_subdef::TC_DATA_LIGHTVALUE')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_LIGHTVALUE')] is defined %} {{ 'Light Value' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_LIGHTVALUE')) | round(2) }} + {{ record.exif[constant('media_subdef::TC_DATA_LIGHTVALUE')] | round(2) }}
{% endif %} {% endblock %} {% block td_duration %} - {% if record.exif.get(constant('media_subdef::TC_DATA_DURATION')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_DURATION')] is defined %} {{ 'Duree' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_DURATION')) }} + {{ record.exif[constant('media_subdef::TC_DATA_DURATION')] }}
{% endif %} {% endblock %} {% block td_framerate %} - {% if record.exif.get(constant('media_subdef::TC_DATA_FRAMERATE')) is not none %} + {% if record.exif[constant('media_subdef::TC_DATA_FRAMERATE')] is defined %} {{ 'Images par secondes' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_FRAMERATE')) | round(2) }} ips + {{ record.exif[constant('media_subdef::TC_DATA_FRAMERATE')] | round(2) }} ips
{% endif %} {% endblock %} {% block td_codec_audio %} - {% if record.exif.get(constant('media_subdef::TC_DATA_AUDIOCODEC')) %} + {% if record.exif[constant('media_subdef::TC_DATA_AUDIOCODEC')] is defined %} {{ 'Codec Audio' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_AUDIOCODEC')) }} + {{ record.exif[constant('media_subdef::TC_DATA_AUDIOCODEC')] }}
{% endif %} {% endblock %} {% block td_codec_video %} - {% if record.exif.get(constant('media_subdef::TC_DATA_VIDEOCODEC')) %} + {% if record.exif[constant('media_subdef::TC_DATA_VIDEOCODEC')] is defined %} {{ 'Codec Video' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_VIDEOCODEC')) }} + {{ record.exif[constant('media_subdef::TC_DATA_VIDEOCODEC')] }}
{% endif %} {% endblock %} {% block td_audio_rate %} - {% if record.exif.get(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) %} + {% if record.exif[constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')] is defined %} {{ 'Frequence d\'echantillonage' | trans }} : - {{ record.exif.get(constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')) | round(2) }} kHz + {{ record.exif[constant('media_subdef::TC_DATA_AUDIOSAMPLERATE')] | round(2) }} kHz
{% endif %} {% endblock %} diff --git a/templates/web/lightbox/IE6/feed.html.twig b/templates/web/lightbox/IE6/feed.html.twig index 6e724c98dd..43a153a9d7 100644 --- a/templates/web/lightbox/IE6/feed.html.twig +++ b/templates/web/lightbox/IE6/feed.html.twig @@ -83,7 +83,7 @@
diff --git a/templates/web/lightbox/IE6/validate.html.twig b/templates/web/lightbox/IE6/validate.html.twig index 89f5e483fa..3b04b8ec3c 100644 --- a/templates/web/lightbox/IE6/validate.html.twig +++ b/templates/web/lightbox/IE6/validate.html.twig @@ -94,7 +94,7 @@ diff --git a/templates/web/lightbox/feed.html.twig b/templates/web/lightbox/feed.html.twig index 5f954cf888..d2f1600aed 100644 --- a/templates/web/lightbox/feed.html.twig +++ b/templates/web/lightbox/feed.html.twig @@ -81,7 +81,7 @@ diff --git a/templates/web/lightbox/validate.html.twig b/templates/web/lightbox/validate.html.twig index 7f0aa71d97..c35c5b03c1 100644 --- a/templates/web/lightbox/validate.html.twig +++ b/templates/web/lightbox/validate.html.twig @@ -95,7 +95,7 @@ diff --git a/templates/web/prod/preview/caption.html.twig b/templates/web/prod/preview/caption.html.twig index 48eb0a25b5..4406ed4bcd 100644 --- a/templates/web/prod/preview/caption.html.twig +++ b/templates/web/prod/preview/caption.html.twig @@ -1,8 +1,11 @@ {% import 'common/macros.html.twig' as macro %} - {% if app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id, 'canmodifrecord') %} + {% set can_edit = granted_on_collection(record.baseId, 'canmodifrecord') %} + {% set can_see_business = can_edit %} + + {% if can_edit %}
- + {{ 'action : editer' | trans }} @@ -13,9 +16,9 @@ {% endfor %}
- {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.get_base_id(), 'canmodifrecord') %} + {% if record.is_from_reg() %} - {{macro.format_caption(record, '', null, null, business, false, true)}} + {{macro.caption(record, can_see_business)}} {% else %} - {{macro.format_caption(record, null, null, business, false, true)}} + {{macro.caption(record, can_see_business)}} {% endif %} diff --git a/templates/web/prod/preview/result_train.html.twig b/templates/web/prod/preview/result_train.html.twig index afbb9ae8fa..f10584022a 100644 --- a/templates/web/prod/preview/result_train.html.twig +++ b/templates/web/prod/preview/result_train.html.twig @@ -5,7 +5,7 @@ {% set thumb_w = 70 %} {% set thumb_h = 70 %} - {% set thumbnail = record.subdefs.get('thumbnail') %} + {% set thumbnail = record.subdefs.thumbnail|default(null) %} {% if thumbnail is not none %} {% set thumb_w = thumbnail.width %} @@ -50,4 +50,3 @@
- \ No newline at end of file diff --git a/templates/web/prod/results/list.html.twig b/templates/web/prod/results/list.html.twig index 81525af7d0..7e24f19aaa 100644 --- a/templates/web/prod/results/list.html.twig +++ b/templates/web/prod/results/list.html.twig @@ -13,8 +13,8 @@
- {% set business = granted_on_collection(record.baseId, 'canmodifrecord') %} - {{ macro.caption(record, business) }} + {% set can_see_business = granted_on_collection(record.baseId, 'canmodifrecord') %} + {{ macro.caption(record, can_see_business) }}
diff --git a/templates/web/prod/results/macro.html.twig b/templates/web/prod/results/macro.html.twig index 63fa7cc7a0..06b8d619cf 100644 --- a/templates/web/prod/results/macro.html.twig +++ b/templates/web/prod/results/macro.html.twig @@ -4,7 +4,7 @@ {% set thumb_w = 256 %} {% set thumb_h = 256 %} - {% set thumbnail = record.subdefs.get('thumbnail') %} + {% set thumbnail = record.subdefs.thumbnail|default(null) %} {% if thumbnail is not none %} {% set thumb_w = thumbnail.width %} {% set thumb_h = thumbnail.height %} @@ -39,7 +39,7 @@ {% set thumb_w = 256 %} {% set thumb_h = 256 %} - {% set thumbnail = record.subdefs.get('thumbnailgif') %} + {% set thumbnail = record.subdefs.thumbnailgif|default(null) %} {% if thumbnail is not none %} {% set thumb_w = thumbnail.width %} {% set thumb_h = thumbnail.height %} @@ -66,4 +66,4 @@ -{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig index 5d2d6a31bf..e3a990a76c 100644 --- a/templates/web/prod/results/record.html.twig +++ b/templates/web/prod/results/record.html.twig @@ -1,4 +1,5 @@ {% import 'prod/results/macro.html.twig' as result_macro %} +{% import 'common/macros.html.twig' as macro %}
- {# @todo title should be localized #} -
- {{ record.title }} +
+ {{ record.title(app.locale)|highlight }}
{% for flag in record_flags(record) %} @@ -18,13 +18,12 @@
- {% if settings.rollover_thumbnail == 'caption' %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'answer', 'number' : record.position|default(0) }) %} - {% elseif settings.rollover_thumbnail == 'preview' %} - {% set tooltip = path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) %} - {% endif %} + {% set can_see_business = granted_on_collection(record.baseId, 'canmodifrecord') %} -
+
{% if settings.doctype_display == '1' %} {{ record_doctype_icon(record) }} @@ -35,7 +34,7 @@ {% endif %}
- {% set rollover = record.subdefs.containsKey('thumbnailgif') %} + {% set rollover = record.subdefs.thumbnailgif is defined %} {% set extraclass = '' %}
{% if rollover %} @@ -117,7 +116,7 @@ - {% if record.subdefs.containsKey('preview') and has_access_subdef(record, 'preview') %} + {% if record.subdefs.preview is defined and has_access_subdef(record, 'preview') %}
{% endif %} diff --git a/www/skins/prod/jquery.main-prod.js b/www/skins/prod/jquery.main-prod.js index e350d07df8..763d6e1ebd 100644 --- a/www/skins/prod/jquery.main-prod.js +++ b/www/skins/prod/jquery.main-prod.js @@ -3005,7 +3005,6 @@ function set_up_feed_box(data) { var $form = $('form.main_form', dialog.getDomElement()); $feeds_item.bind('click',function () { - console.log("clcik"); $feeds_item.removeClass('selected'); $(this).addClass('selected'); $('input[name="feed_id"]', $form).val($('input', this).val());