From e9c6d1a56ea4b9aab7fc37072f6b5bbc1264c98b Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Tue, 2 Dec 2014 14:06:44 +0100 Subject: [PATCH] Fix mess in prod (record & feed) templates --- lib/Alchemy/Phrasea/Controller/Prod/Feed.php | 2 +- lib/Alchemy/Phrasea/Controller/Prod/Query.php | 17 +- templates/mobile/lightbox/feed.html.twig | 2 +- templates/web/common/doctype_icons.html.twig | 16 -- .../web/common/drop_down_options.html.twig | 49 ---- templates/web/common/macros.html.twig | 25 +- templates/web/common/thumbnail.html.twig | 111 ++++----- templates/web/prod/feeds/entry.html.twig | 2 - .../web/prod/feeds/entry_macro.html.twig | 67 ------ templates/web/prod/feeds/feeds.html.twig | 84 ------- .../web/prod/preview/basket_train.html.twig | 63 +++-- templates/web/prod/preview/caption.html.twig | 2 +- .../web/prod/preview/feed_train.html.twig | 61 +++-- .../web/prod/preview/reg_train.html.twig | 103 +++++---- .../web/prod/preview/result_train.html.twig | 51 ++-- .../web/prod/results/answerabstract.html.twig | 20 -- .../web/prod/results/answergrid.html.twig | 11 - .../web/prod/results/answerlist.html.twig | 27 --- templates/web/prod/results/entry.html.twig | 70 ++++++ templates/web/prod/results/feeds.html.twig | 97 ++++++++ templates/web/prod/results/grid.html.twig | 4 + templates/web/prod/results/help.html.twig | 134 +++++------ templates/web/prod/results/item.html.twig | 80 +++++++ templates/web/prod/results/list.html.twig | 24 ++ templates/web/prod/results/macro.html.twig | 69 ++++++ templates/web/prod/results/record.html.twig | 218 +++++++++--------- templates/web/prod/results/records.html.twig | 39 ++++ 27 files changed, 802 insertions(+), 646 deletions(-) delete mode 100644 templates/web/common/doctype_icons.html.twig delete mode 100644 templates/web/common/drop_down_options.html.twig delete mode 100644 templates/web/prod/feeds/entry.html.twig delete mode 100644 templates/web/prod/feeds/entry_macro.html.twig delete mode 100644 templates/web/prod/feeds/feeds.html.twig delete mode 100644 templates/web/prod/results/answerabstract.html.twig delete mode 100644 templates/web/prod/results/answergrid.html.twig delete mode 100644 templates/web/prod/results/answerlist.html.twig create mode 100644 templates/web/prod/results/entry.html.twig create mode 100644 templates/web/prod/results/feeds.html.twig create mode 100644 templates/web/prod/results/grid.html.twig create mode 100644 templates/web/prod/results/item.html.twig create mode 100644 templates/web/prod/results/list.html.twig create mode 100644 templates/web/prod/results/macro.html.twig create mode 100644 templates/web/prod/results/records.html.twig diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php index 9b1025c125..221e656f50 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Feed.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Feed.php @@ -207,7 +207,7 @@ class Feed implements ControllerProviderInterface $feeds = $app['repo.feeds']->getAllForUser($app['acl']->get($app['authentication']->getUser())); - $datas = $app['twig']->render('prod/feeds/feeds.html.twig', [ + $datas = $app['twig']->render('prod/results/feeds.html.twig', [ 'feeds' => $feeds, 'feed' => new Aggregate($app['EM'], $feeds), 'page' => $page diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Query.php b/lib/Alchemy/Phrasea/Controller/Prod/Query.php index 9c14a2851a..b4c51edad5 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Query.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Query.php @@ -52,8 +52,6 @@ class Query implements ControllerProviderInterface { $query = (string) $request->request->get('qry'); - $mod = $app['settings']->getUserSetting($app['authentication']->getUser(), 'view'); - $json = []; $options = SearchEngineOptions::fromRequest($app, $request); @@ -176,21 +174,10 @@ class Query implements ControllerProviderInterface if ($result->getTotal() === 0) { $template = 'prod/results/help.html.twig'; } else { - if ($mod == 'thumbs') { - $template = 'prod/results/answergrid.html.twig'; - } else { - $template = 'prod/results/answerlist.html.twig'; - } + $template = 'prod/results/records.html.twig'; } - $json['results'] = $app['twig']->render($template, [ - 'results' => $result, - 'highlight' => $result->getQuery(), - 'searchEngine' => $app['phraseanet.SE'], - 'searchOptions' => $options, - 'suggestions' => $prop - ] - ); + $json['results'] = $app['twig']->render($template, ['results'=> $result]); $json['query'] = $query; diff --git a/templates/mobile/lightbox/feed.html.twig b/templates/mobile/lightbox/feed.html.twig index 0aca4f732c..7c41cdf8ce 100644 --- a/templates/mobile/lightbox/feed.html.twig +++ b/templates/mobile/lightbox/feed.html.twig @@ -29,7 +29,7 @@ {% for item in feed_entry.getItems() %}
  • - {{thumbnail.format(item.getRecord(app).get_thumbnail(), 80, 80, '', true, false)}} + {{ thumbnail.format(item.getRecord(app).get_thumbnail(), 80, 80, '', true, false) }}
  • diff --git a/templates/web/common/doctype_icons.html.twig b/templates/web/common/doctype_icons.html.twig deleted file mode 100644 index dd5e9dc740..0000000000 --- a/templates/web/common/doctype_icons.html.twig +++ /dev/null @@ -1,16 +0,0 @@ -{% macro format(record)%} - {% set doctype = record.type %} - {% if record.story %} - - {% elseif doctype == 'image' %} - - {% elseif doctype == 'document' %} - - {% elseif doctype == 'flash' %} - - {% elseif doctype == 'video' %} - - {% elseif doctype == 'audio' %} - - {% endif %} -{% endmacro %} \ No newline at end of file diff --git a/templates/web/common/drop_down_options.html.twig b/templates/web/common/drop_down_options.html.twig deleted file mode 100644 index 7fb23045e5..0000000000 --- a/templates/web/common/drop_down_options.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{% macro prod(record, entry_id)%} - {% if not entry_id %} - - - - - - - - - {% endif %} -{% endmacro %} diff --git a/templates/web/common/macros.html.twig b/templates/web/common/macros.html.twig index 9663e3aa35..f9d8380c97 100644 --- a/templates/web/common/macros.html.twig +++ b/templates/web/common/macros.html.twig @@ -4,7 +4,7 @@ theme : 'custom', custom_theme_widget: 'recaptcha_widget', lang : '{{ app['locale'] }}' - }; + };
    @@ -46,7 +46,7 @@ -
    + @@ -54,9 +54,9 @@ {% set public_key = app["conf"].get(['registry', 'webservices', 'recaptcha-public-key']) %} {% endmacro %} @@ -103,14 +103,15 @@ {% endmacro %} {% macro format_caption(record, highlight, search_engine, include_business, bounceable, technical_data) %} - {# @todo business fields are always included ... #} - {% for name, value in record.getCaption() %} -
    - {{ name }} : {{ value is iterable ? value|join('; ') : value }} -
    + {% for field in record.get_caption().get_highlight_fields(highlight, null, search_engine, include_business) %} + {% set extra_classes = ['pair'] %} + {% if loop.index is odd %} + {% set extra_classes = ['impair'] %} + {% endif %} + {{ _self.caption_field(field, bounceable|default(true), extra_classes) }} {% endfor %} - {% if technical_data|default(true) and app['authentication'].user is not none and app['settings'].getUserSetting(app['authentication'].user, 'technical_display') == 'group' %} + {% if technical_data|default(true) and app['authentication'].getUser() is not none and app['settings'].getUserSetting(app['authentication'].getUser(), 'technical_display') == 'group' %}
    {% include 'common/technical_datas.html.twig' %} {% endif %} -{% endmacro %} +{% endmacro %} \ No newline at end of file diff --git a/templates/web/common/thumbnail.html.twig b/templates/web/common/thumbnail.html.twig index d2c6af2a3c..d5227bf4e7 100644 --- a/templates/web/common/thumbnail.html.twig +++ b/templates/web/common/thumbnail.html.twig @@ -1,63 +1,64 @@ -{% macro format(record, url, thumb_w, thumb_h, box_w, box_h, extra_class, wrap) %} - {% set record_type = record.type %} - {% set box_w = box_w|round %} - {% set box_h = box_h|default(box_w)|round %} +{% macro format(thumbnail, box_w, box_h, extra_class, wrap, lazyload) %} + {# @todo remove lazyload #} - {% if record_type == 'AUDIO' %} - {% set original_w = 320 %} - {% set original_h = 60 %} + {% set record_type = thumbnail.get_type() %} + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} - {% set fit_size = { - "width":original_w, - "height":original_h, - "top":0, - "left": 0 - } %} - {% elseif record_type == 'FLEXPAPER' %} - {% set original_w = 800 %} - {% set original_h = 600 %} + {% if record_type == 'AUDIO_MP3' %} + {% set original_w = 320 %} + {% set original_h = 60 %} - {% set fit_size = { - "width":800, - "height":600, - "top":0, - "left": 0 - } %} - {% else %} - {% set original_h = thumb_h > 0 ? thumb_h : 120 %} - {% set original_w = thumb_w > 0 ? thumb_w : 120 %} + {% set fit_size = { + "width":original_w, + "height":original_h, + "top":0, + "left": 0 + } %} + {% elseif record_type == 'FLEXPAPER' %} + {% set original_w = 800 %} + {% set original_h = 600 %} - {% set fit_size = fitIn( - {"width":original_w, "height":original_h}, - {"width":box_w, "height":box_h} - )%} - {% endif %} + {% set fit_size = { + "width":800, + "height":600, + "top":0, + "left": 0 + } %} + {% else %} + {% set original_h = thumbnail.get_height() > 0 ? thumbnail.get_height() : 120 %} + {% set original_w = thumbnail.get_width() > 0 ? thumbnail.get_width() : 120 %} - {% if wrap %} -
    - {% endif %} + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + )%} + {% endif %} - {% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} - {% import 'common/players/video.html.twig' as player %} - {{ player.video_player(thumbnail, url, original_w, original_h, fit_size) }} - {% elseif record_type == 'FLEXPAPER' %} - {% import 'common/players/pdf.html.twig' as player %} - {{ player.pdf_player(thumbnail, url, original_w, original_h, fit_size) }} - {% elseif record_type == 'AUDIO_MP3' %} - {% import 'common/players/audio.html.twig' as player %} - {{ player.audio_player(thumbnail, url, original_w, original_h, fit_size) }} - {% else %} - - - - {% endif %} + {% set url = app['authentication'].isAuthenticated() ? thumbnail.get_url() : thumbnail.get_permalink().get_url() %} - {% if wrap %} + {% if wrap %} +
    + {% endif %} + + {% if record_type == 'VIDEO_MP4' or record_type == 'VIDEO_FLV' %} + {% import 'common/players/video.html.twig' as player %} + {{ player.video_player(thumbnail, url, original_w, original_h, fit_size) }} + {% elseif record_type == 'FLEXPAPER' %} + {% import 'common/players/pdf.html.twig' as player %} + {{ player.pdf_player(thumbnail, url, original_w, original_h, fit_size) }} + {% elseif record_type == 'AUDIO_MP3' %} + {% import 'common/players/audio.html.twig' as player %} + {{ player.audio_player(thumbnail, url, original_w, original_h, fit_size) }} + {% else %} + + + + {% endif %} + + {% if wrap %}
    - {% endif %} -{% endmacro %} + {% endif %} +{% endmacro %} \ No newline at end of file diff --git a/templates/web/prod/feeds/entry.html.twig b/templates/web/prod/feeds/entry.html.twig deleted file mode 100644 index 699d111ebd..0000000000 --- a/templates/web/prod/feeds/entry.html.twig +++ /dev/null @@ -1,2 +0,0 @@ -{% import 'prod/feeds/entry_macro.html.twig' as _entry %} -{{ _entry.format(entry.getFeed(), entry) }} \ No newline at end of file diff --git a/templates/web/prod/feeds/entry_macro.html.twig b/templates/web/prod/feeds/entry_macro.html.twig deleted file mode 100644 index 2edf5ce097..0000000000 --- a/templates/web/prod/feeds/entry_macro.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{% macro format(feed, entry)%} - {% import 'prod/results/record.html.twig' as record_format %} - -
    - - - - - -
    -

    - {% if feed.isAggregated() %} - - {% endif %} - {{ entry.getTitle() }} - {% set author = entry.getAuthorName() %} - {% trans with {'%author%' : author} %}Par %author%{% endtrans %} -

    -
    - {% if entry.getFeed().isOwner(app['authentication'].getUser()) or entry.isPublisher(app['authentication'].getUser()) %} - - - - - - - {% endif %} -
    - -

    {{ entry.getSubtitle()|nl2br|raw }}

    -
    - {% for item in entry.getItems() %} - {% set record = item.getRecord(app) %} - {% set prefix = 'PUBLI_' ~ item.getId() %} - {{record_format.block(record, false, null, prefix, entry.getId())}} - {% endfor %} -
    -
    -{% endmacro %} diff --git a/templates/web/prod/feeds/feeds.html.twig b/templates/web/prod/feeds/feeds.html.twig deleted file mode 100644 index f192ce1c66..0000000000 --- a/templates/web/prod/feeds/feeds.html.twig +++ /dev/null @@ -1,84 +0,0 @@ -{% import 'prod/feeds/entry_macro.html.twig' as _entry %} -
    - {% if page == 1 %} -
    - - - - - -
    -

    - - {% if feed.isAggregated %} - {{ 'Toutes les publications' | trans }} - - - - {% else %} - {{ feed.getTitle() }} - - - - {% endif %} - {% if feed.isAggregated %} - - {% else %} - - {% endif %} -

    -
    - -
    -
    - {% endif %} - - {% set offset_start = ((page - 1) * 5 )%} - {% set entries = feed.getEntries(offset_start,5) %} - - {% for entry in entries %} - {{ _entry.format(feed, entry) }} - {% endfor %} - {% if entries|length == 0 %} -

    {{ 'Aucune entree pour le moment' | trans }}

    - {% endif %} - - {% if feed.getCountTotalEntries() > (page*5) %} - {% set next_page = page + 1 %} - - {% endif %} -
    diff --git a/templates/web/prod/preview/basket_train.html.twig b/templates/web/prod/preview/basket_train.html.twig index 0d9a3a46b0..3741fa220f 100644 --- a/templates/web/prod/preview/basket_train.html.twig +++ b/templates/web/prod/preview/basket_train.html.twig @@ -1,35 +1,48 @@
      - {% for child in record.get_container().getElements() %} + {% set basket = record.get_container %} + {% for element in basket.elements %} - {% set thumbnail = child.getRecord(app).get_thumbnail() %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% if thumbnail.get_width() > 0 and thumbnail.get_height() > 0 %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% else %} - {% set top = 65 %} + {% set record_item = element.record(app) %} + + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} + + {% set thumbnail = record_item.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} {% endif %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} - {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : child.getRecord(app).get_sbas_id(), 'record_id' : child.getRecord(app).get_record_id(), 'context' : 'basket' }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if record.get_number() == child.getOrd() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • + +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/caption.html.twig b/templates/web/prod/preview/caption.html.twig index 15933d9f2b..4cd602fc7c 100644 --- a/templates/web/prod/preview/caption.html.twig +++ b/templates/web/prod/preview/caption.html.twig @@ -15,5 +15,5 @@ {% if record.is_from_reg() %} {{macro.format_caption(record, '', null, null, business, false, true)}} {% else %} - {{macro.format_caption(record, highlight, searchEngine, business, false, true)}} + {{macro.format_caption(record, null, null, business, false, true)}} {% endif %} diff --git a/templates/web/prod/preview/feed_train.html.twig b/templates/web/prod/preview/feed_train.html.twig index d6535074e9..0aeb0c4624 100644 --- a/templates/web/prod/preview/feed_train.html.twig +++ b/templates/web/prod/preview/feed_train.html.twig @@ -1,35 +1,46 @@
      - {% for child in record.get_container() %} + {% set entry = record.get_container() %} + {% for item in entry.items %} + {% set record_item = item.record(app) %} - {% set thumbnail = child.getRecord(app).get_thumbnail() %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% if thumbnail.get_width() > 0 and thumbnail.get_height() > 0 %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% else %} - {% set top = 65 %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} + + {% set thumbnail = record_item.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} {% endif %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} - {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_preview', { 'sbas_id' : child.get_record().get_sbas_id(), 'record_id' : child.get_record().get_record_id() }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if record.get_number() == child.getOrd() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/reg_train.html.twig b/templates/web/prod/preview/reg_train.html.twig index 6dbb115d0a..7fb00de4b2 100644 --- a/templates/web/prod/preview/reg_train.html.twig +++ b/templates/web/prod/preview/reg_train.html.twig @@ -1,54 +1,79 @@ + {% set story = record.get_container %} - {% set regroupement = record.get_container() %} - {% set thumbnail = regroupement.get_thumbnail() %} + {% set thumb_w = 90 %} + {% set thumb_h = 90 %} - {% if thumbnail.get_height() > 0 %} - {% set ratio = thumbnail.get_width() / thumbnail.get_height() %} - {% else %} - {% set ratio = 1 %} - {% endif %} - {% if thumbnail.is_paysage %} - {% set style = 'width:80px;top:' %} - {% set top = (8 + (80 - (80 / ratio)) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:80px;top:8px;' %} - {% endif %} + {% set thumbnail = story.get_thumbnail %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} + {% endif %} + + {% set url = record_thumbnail_url(story) %} + + {% set box_w = 90 %} + {% set box_h = 96 %} + + {% set original_h = thumb_h > 0 ? thumb_h : 90 %} + {% set original_w = thumb_w > 0 ? thumb_w : 90 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %}
    - +
    + +
      + {% for record_item in record.get_train %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} - {% for contained in record.get_train %} - {% set thumbnail = contained.get_thumbnail() %} + {% set thumbnail = record_item.get_thumbnail %} - {% if thumbnail.is_paysage %} - {% set style = 'width:65px;top:' %} - {% set top = ((66 - (65 / (thumbnail.get_width() / thumbnail.get_height()))) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:8px;' %} - {% endif %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.get_width %} + {% set thumb_h = thumbnail.get_height %} + {% endif %} - {% set tooltip = '' %} - {% if app['conf'].get(['registry', 'classic', 'stories-preview']) %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : contained.get_sbas_id(), 'record_id' : contained.get_record_id(), 'context' : 'preview', 'number' : contained.get_number() }) %} - {% endif %} + {% set url = record_thumbnail_url(record_item) %} - {% set class = '' %} - {% if loop.index == record.get_number() %} - {% set class = ' selected' %} - {% endif %} + {% set box_w = 70 %} + {% set box_h = 80 %} -
    • -
    • + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %}
    diff --git a/templates/web/prod/preview/result_train.html.twig b/templates/web/prod/preview/result_train.html.twig index ecead5183c..fc2ad2c1bd 100644 --- a/templates/web/prod/preview/result_train.html.twig +++ b/templates/web/prod/preview/result_train.html.twig @@ -1,30 +1,41 @@
      - {% for rec in records %} + {% for record in records %} - {% set thumbnail = rec.get_thumbnail() %} - {% set w = thumbnail.get_width() %} - {% set h = thumbnail.get_height() %} + {% set thumb_w = 70 %} + {% set thumb_h = 70 %} - {% if thumbnail.is_paysage() %} - {% set style = 'width:65px;top:' %} - {% set top = ((66 - (65 / (w / h))) / 2)|round %} - {% set style = style ~ top %} - {% set style = style ~ 'px;' %} - {% else %} - {% set style = 'height:65px;top:0;' %} + {% set thumbnail = record.subdefs.get('thumbnail') %} + + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} {% endif %} - {% if selected == rec.get_number() %} - {% set class = ' selected ' %} - {% else %} - {% set class = '' %} - {% endif %} + {% set url = record_thumbnail_url(record) %} -
    • - - + {% set box_w = 70 %} + {% set box_h = 80 %} + + {% set original_h = thumb_h > 0 ? thumb_h : 70 %} + {% set original_w = thumb_w > 0 ? thumb_w : 70 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
    • +
    • {% endfor %} diff --git a/templates/web/prod/results/answerabstract.html.twig b/templates/web/prod/results/answerabstract.html.twig deleted file mode 100644 index b3b200f95e..0000000000 --- a/templates/web/prod/results/answerabstract.html.twig +++ /dev/null @@ -1,20 +0,0 @@ -{% import 'prod/results/record.html.twig' as record_format %} - -{% if results.getError() %} -
      {{results.getError()}}
      -{% else %} - {% if results.getWarning() %} -
      {{results.getWarning()}}
      - {% endif %} - - {% if suggestions %} - {% set suggestions = suggestions|e %} - {% set link = '' ~ suggestions ~ '' %} - {% trans with {'%link%' : link} %}Voulez-vous dire %link% ?{% endtrans %} -
      - {% endif %} - {% set th_size = app['settings'].getUserSetting(app['authentication'].getUser(), 'images_size')%} -
      - {% block content %}{% endblock %} -
      -{% endif %} diff --git a/templates/web/prod/results/answergrid.html.twig b/templates/web/prod/results/answergrid.html.twig deleted file mode 100644 index ec14ec78e0..0000000000 --- a/templates/web/prod/results/answergrid.html.twig +++ /dev/null @@ -1,11 +0,0 @@ - -{% extends "prod/results/answerabstract.html.twig" %} - -{% block content %} - - {% for record in results.getResults() %} - {{record_format.block(record, highlight, searchEngine, 'IMGT', false)}} - {% endfor %} - -{% endblock %} - diff --git a/templates/web/prod/results/answerlist.html.twig b/templates/web/prod/results/answerlist.html.twig deleted file mode 100644 index 18a9267e44..0000000000 --- a/templates/web/prod/results/answerlist.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "prod/results/answerabstract.html.twig" %} -{% block content %} - -{% import 'common/macros.html.twig' as macro %} - -{% for record in results.getResults() %} -
      - - - - - -
      - {{ record_format.block(record, highlight, searchEngine, 'IMGT', false) }} - -
      -
      - {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.baseId(), 'canmodifrecord') %} - {{ macro.format_caption(record, highlight, searchEngine, searchOptions, business, true, true) }} -
      -
      -
      -
      -{% endfor %} - -{% endblock %} - diff --git a/templates/web/prod/results/entry.html.twig b/templates/web/prod/results/entry.html.twig new file mode 100644 index 0000000000..c785c61655 --- /dev/null +++ b/templates/web/prod/results/entry.html.twig @@ -0,0 +1,70 @@ +{% import 'prod/results/macro.html.twig' as result_macro %} + +
      + + + + + +
      +

      + {% if feed.aggregated %} + + {% endif %} + {{ entry.title }} + {% set author = entry.authorName %} + + {% trans with {'%author%' : author} %}Par %author%{% endtrans %} + +

      +
      + {% if entry.feed.isOwner(app['authentication'].user) or entry.isPublisher(app['authentication'].user) %} + + + + + + + {% endif %} +
      + + +

      {{ entry.getSubtitle()|nl2br|raw }}

      + +
      + {% for item in entry.items %} + {% block item %} + {% include 'prod/results/item.html.twig' with { + 'item' : item, + 'entry': entry, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% endfor %} +
      +
      diff --git a/templates/web/prod/results/feeds.html.twig b/templates/web/prod/results/feeds.html.twig new file mode 100644 index 0000000000..fd03064ef6 --- /dev/null +++ b/templates/web/prod/results/feeds.html.twig @@ -0,0 +1,97 @@ +{% block result %} +
      + {# header for first page #} + {% if page == 1 %} +
      + + + + + +
      +

      + + {% if feed.isAggregated %} + {{ 'Toutes les publications' | trans }} + + + + + {% else %} + {{ feed.title }} + + + + + {% endif %} +

      +
      + +
      +
      + {% endif %} + + {% block content %} + {% set images_size = user_setting('images_size') %} + {% set technical_display = user_setting('technical_display') %} + {% set rollover_thumbnail = user_setting('rollover_thumbnail') %} + {% set doctype_display = user_setting('doctype_display') %} + + {% set offset_start = ((page - 1) * 5 )%} + {% set entries = feed.getEntries(offset_start,5) %} + + {% for entry in entries %} + {% block content_item %} + {% include 'prod/results/entry.html.twig' with { + 'feed': feed, + 'entry': entry, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% else %} +

      {{ 'Aucune entree pour le moment' | trans }}

      + {% endfor %} + + {# pagination #} + {% if feed.countTotalEntries > (page * 5) %} + {% set next_page = page + 1 %} + + {% endif %} + {% endblock %} +
      +{% endblock %} diff --git a/templates/web/prod/results/grid.html.twig b/templates/web/prod/results/grid.html.twig new file mode 100644 index 0000000000..6560728e99 --- /dev/null +++ b/templates/web/prod/results/grid.html.twig @@ -0,0 +1,4 @@ +{% include 'prod/results/record.html.twig' with { + 'record': item, + 'settings': settings +} %} diff --git a/templates/web/prod/results/help.html.twig b/templates/web/prod/results/help.html.twig index c6e8bcd4fe..0d996489ec 100644 --- a/templates/web/prod/results/help.html.twig +++ b/templates/web/prod/results/help.html.twig @@ -1,85 +1,73 @@ {% block content %} -{% if results.getError() %} -
      {{results.getError()}}
      -{% else %} - {% if results.getWarning() %} -
      {{results.getWarning()}}
      - {% endif %} -{% endif %} + {% if results.error %} +
      {{ results.error }}
      + {% elseif results.warning %} +
      {{ results.warning }}
      + {% endif %} -

      - {{ 'Votre recherche ne retourne aucun resultat' | trans }} -

      +

      + {{ 'Votre recherche ne retourne aucun resultat' | trans }} +

      -{% if suggestions %} - {% set link = '' ~ suggestions ~ '' %} - {% trans with {'%link%' : link} %}Voulez-vous dire %link% ?{% endtrans %} -
      -{% endif %} - -{% set th_size = app['settings'].getUserSetting(app['authentication'].getUser(), 'images_size')%} - -{% if app['locale'] == 'fr' %}
      -
      {{ 'La recherche s\'effectue grâce à la boîte de dialogue qui se trouve en haut à gauche de l\'écran.' | trans }} - {{ 'Sachez que vous pouvez utiliser les opérateurs ou caractères spéciaux suivants :' | trans }}
      -
      {{ '* , ? , ET , OU , SAUF , DANS , DERNIERS , TOUT (ou AND , OR , EXCEPT , LAST , ALL)' | trans }}
      +
      {{ 'La recherche s\'effectue grâce à la boîte de dialogue qui se trouve en haut à gauche de l\'écran.' | trans }} + {{ 'Sachez que vous pouvez utiliser les opérateurs ou caractères spéciaux suivants :' | trans }}
      +
      {{ '* , ? , ET , OU , SAUF , DANS , DERNIERS , TOUT (ou AND , OR , EXCEPT , LAST , ALL)' | trans }}
      -
      {{ 'Caractères de troncature' | trans }}
      +
      {{ 'Caractères de troncature' | trans }}
      - - - - - - - - - -
      {{ 'auto*' | trans }} {{ 'retourne "automobile", "automate", "autoroute", ...' | trans }}
      {{ 'dé?it' | trans }} {{ 'retourne "délit", "débit", ...' | trans }}
      + + + + + + + + + +
      {{ 'auto*' | trans }} {{ 'retourne "automobile", "automate", "autoroute", ...' | trans }}
      {{ 'dé?it' | trans }} {{ 'retourne "délit", "débit", ...' | trans }}
      -
      {{ 'Visualiser tous les enregistrements / les derniers enregistrements' | trans }}
      - - - - - - - - - -
      {{ 'TOUT' | trans }}{{ 'retourne tous les enregistrements des collections selectionnees' | trans }}
      {{ 'LAST 20' | trans }}{{ 'retourne les 20 derniers enregistrements archives dans les collections selectionnees' | trans }}
      +
      {{ 'Visualiser tous les enregistrements / les derniers enregistrements' | trans }}
      + + + + + + + + + +
      {{ 'TOUT' | trans }}{{ 'retourne tous les enregistrements des collections selectionnees' | trans }}
      {{ 'LAST 20' | trans }}{{ 'retourne les 20 derniers enregistrements archives dans les collections selectionnees' | trans }}
      -
      {{ 'Recherche multicritères' | trans }}
      - {{ 'Vous pouvez affiner votre recherche avec les opérateurs : ET, OU, SAUF ou DANS' | trans }}
      - - - - - - - - - - - - - - - - - -
      {{ 'sport' | trans }} ET {{ 'automobile' | trans }}{{ 'retourne les documents comprenant les deux mots.' | trans }}
      {{ 'journal OU jt' | trans }}{{ 'retourne les documents comprenant un mot et/ou l\'autre.' | trans }}
      {{ 'cannes SAUF festival' | trans }}{{ 'retourne les documents comprenant cannes sans le mot festival.' | trans }}
      {{ 'thalassa DANS titre' | trans }}{{ 'retourne les documents où le terme est au moins présent dans le titre, en évitant par exemple celles où le terme est uniquement cité dans la légende.' | trans }}
      +
      {{ 'Recherche multicritères' | trans }}
      + {{ 'Vous pouvez affiner votre recherche avec les opérateurs : ET, OU, SAUF ou DANS' | trans }}
      + + + + + + + + + + + + + + + + + +
      {{ 'sport' | trans }} ET {{ 'automobile' | trans }}{{ 'retourne les documents comprenant les deux mots.' | trans }}
      {{ 'journal OU jt' | trans }}{{ 'retourne les documents comprenant un mot et/ou l\'autre.' | trans }}
      {{ 'cannes SAUF festival' | trans }}{{ 'retourne les documents comprenant cannes sans le mot festival.' | trans }}
      {{ 'thalassa DANS titre' | trans }}{{ 'retourne les documents où le terme est au moins présent dans le titre, en évitant par exemple celles où le terme est uniquement cité dans la légende.' | trans }}
      -
      -

      {{ 'Attention' | trans }}

      -

      {{ 'pour chercher une phrase contenant un des mots-clé ci-dessus, utilisez les guillemets :' | trans }}

      - "{{ 'C dans l\'air' | trans }}" - , "{{ 'Et Dieu créa la femme' | trans }}" - , "{{ 'bijou en or' | trans }}" - , "{{ 'tout le sport' | trans }}" -
      +
      +

      {{ 'Attention' | trans }}

      +

      {{ 'pour chercher une phrase contenant un des mots-clé ci-dessus, utilisez les guillemets :' | trans }}

      + "{{ 'C dans l\'air' | trans }}" + , "{{ 'Et Dieu créa la femme' | trans }}" + , "{{ 'bijou en or' | trans }}" + , "{{ 'tout le sport' | trans }}" +
      -{% endif %} {% endblock %} diff --git a/templates/web/prod/results/item.html.twig b/templates/web/prod/results/item.html.twig new file mode 100644 index 0000000000..fc2eb5e5b9 --- /dev/null +++ b/templates/web/prod/results/item.html.twig @@ -0,0 +1,80 @@ +{% import 'common/thumbnail.html.twig' as thumbnail %} + +{% set record = item.record(app) %} + +
      +
      +
      +
      + {{ record.get_title }} +
      +
      + {{ record.get_status_icons|raw }} +
      +
      + + {% set rollover_gif = record.get_rollover_thumbnail %} + + {% if rollover_thumbnail == 'caption' %} + {% set tooltipsrc = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'publi' }) %} + {% elseif rollover_thumbnail == 'preview' %} + {% set tooltipsrc = path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) %} + {% endif %} + +
      +
      + {% if doctype_display %} + {{ record_doctype_icon(record) }} + {% endif %} + + {{ record.get_formated_duration }} + +
      +
      + {% set extraclass = rollover_gif ? 'rollover-gif-out' : '' %} + {{ thumbnail.format(record.get_thumbnail(), images_size, images_size, extraclass, true, false) }} + {% if rollover_gif %} + {{ thumbnail.format(rollover_gif, images_size, images_size, 'rollover-gif-hover', true, false) }} + {% endif %} +
      +
      + +
      + + + + {% set l_width = 30 %} + {% if rollover_thumbnail == 'preview' %} + {% set l_width = l_width + 20 %} + {% endif %} + {% if technical_display == '1' %} + {% set l_width = l_width + 20 %} + {% endif %} + + +
      + {{ record.get_collection_logo(app)|raw }} + + {% if record.has_preview and has_access_subdef(record, 'preview') %} +
      + {% endif %} + {% if rollover_thumbnail == 'preview' %} +
      + {% endif %} + {% if technical_display == '1' %} + + {% endif %} +
      +
      +
      +
      diff --git a/templates/web/prod/results/list.html.twig b/templates/web/prod/results/list.html.twig new file mode 100644 index 0000000000..4f15838002 --- /dev/null +++ b/templates/web/prod/results/list.html.twig @@ -0,0 +1,24 @@ +{% import 'common/macros.html.twig' as macro %} + +{% block content_item %} +
      + + + + + +
      + {% include 'prod/results/record.html.twig' with { + 'record': item, + 'settings': settings + }%} + +
      +
      + {% set business = app['acl'].get(app['authentication'].getUser()).has_right_on_base(record.baseId(), 'canmodifrecord') %} + {{ macro.format_caption(record, highlight, searchEngine, searchOptions, business, true, true) }} +
      +
      +
      +
      +{% endblock %} diff --git a/templates/web/prod/results/macro.html.twig b/templates/web/prod/results/macro.html.twig new file mode 100644 index 0000000000..63fa7cc7a0 --- /dev/null +++ b/templates/web/prod/results/macro.html.twig @@ -0,0 +1,69 @@ +{% macro thumbnail(record, box_w, box_h, extra_class) %} + {% set record_type = record.type %} + + {% set thumb_w = 256 %} + {% set thumb_h = 256 %} + + {% set thumbnail = record.subdefs.get('thumbnail') %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} + {% endif %} + + {% set url = record_thumbnail_url(record) %} + + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} + + {% set original_h = thumb_h > 0 ? thumb_h : 120 %} + {% set original_w = thumb_w > 0 ? thumb_w : 120 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
      + + + +
      +{% endmacro %} + +{% macro thumbnailgif(record, box_w, box_h, extra_class) %} + {% set record_type = record.type %} + + {% set thumb_w = 256 %} + {% set thumb_h = 256 %} + + {% set thumbnail = record.subdefs.get('thumbnailgif') %} + {% if thumbnail is not none %} + {% set thumb_w = thumbnail.width %} + {% set thumb_h = thumbnail.height %} + {% endif %} + + {% set url = record_thumbnailgif_url(record) %} + + {% set box_w = box_w|round %} + {% set box_h = box_h|default(box_w)|round %} + + {% set original_h = thumb_h > 0 ? thumb_h : 120 %} + {% set original_w = thumb_w > 0 ? thumb_w : 120 %} + + {% set fit_size = fitIn( + {"width":original_w, "height":original_h}, + {"width":box_w, "height":box_h} + ) + %} + +
      + + + +
      +{% endmacro %} \ No newline at end of file diff --git a/templates/web/prod/results/record.html.twig b/templates/web/prod/results/record.html.twig index c922e022ae..5bece1fabc 100644 --- a/templates/web/prod/results/record.html.twig +++ b/templates/web/prod/results/record.html.twig @@ -1,119 +1,131 @@ -{% macro block(record, highlight, searchEngine, prefix, entry_id)%} - {% import 'common/thumbnail.html.twig' as thumbnail_macro %} - {% import 'common/doctype_icons.html.twig' as doctype_icons %} - {% import 'common/drop_down_options.html.twig' as drop_down %} - {% set th_size = app['settings'].getUserSetting(app['authentication'].user, 'images_size')%} +{% import 'prod/results/macro.html.twig' as result_macro %} - {% if entry_id %} -
      - {% elseif record.story %} -
      - {% else %} -
      - {% endif %} -
      -
      - {# @todo title should be localized #} -
      - {{ record.title }} -
      -
      +
      +
      +
      + {# @todo title should be localized #} +
      + {{ record.title }} +
      +
      {# @todo find a proper way to map lifted flag to status icon img path #} {#{{record.get_status_icons|raw}}#} -
      - {% set thumbnail = record.subdefs.containsKey('thumbnail') ? record.subdefs.get('thumbnail') : null %} - {% set preview = record.subdefs.containsKey('preview') ? record.subdefs.get('preview') : null %} - {% set rollover_thumbnail = record.subdefs.containsKey('thumbnailgif') ? record.subdefs.get('thumbnailgif') : null %} +
      - {% set user_technical_display = app['settings'].getUserSetting(app['authentication'].user, 'technical_display') %} - {% set user_rollover_thumbnail = app['settings'].getUserSetting(app['authentication'].user, 'rollover_thumbnail') %} + {% 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 extraclass = '' %} - {% if user_rollover_thumbnail == 'caption' and searchEngine is not null %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'answer', 'number' : record.position }) %} - {% elseif user_rollover_thumbnail == 'caption' and searchEngine is null %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltip = path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'publi' }) %} - {% elseif user_rollover_thumbnail == 'preview' %} - {% set extraclass = extraclass ~ ' captionTips' %} - {% set tooltip = path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) %} - {% endif %} -
      -
      - {% if app['settings'].getUserSetting(app['authentication'].user, 'doctype_display') == '1' %} - {{doctype_icons.format(record)}} +
      +
      + {% 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 extraclass = '' %} - - {% if thumbnail is not none and thumbnail.path is defined and (thumbnail.path is not empty or thumbnail.path is not none) %} - {% set path = thumbnail.path %} - {% set width = thumbnail.width %} - {% set height = thumbnail.height %} - {% else %} - {% set path = app['root.path'] ~ '/www/skins/icons/substitution/' ~ record.mimeType|replace({'/': '_'}) ~ '.png' %} - {% set width = 256 %} - {% set height = 256 %} - {% endif %} - - {% set url = app['phraseanet.static-file'].getUrl(path) %} - - {{thumbnail_macro.format(record, url, width, height, th_size, th_size, extraclass, true, true)}} - - {% if rollover_thumbnail %} - {% set extraclass = 'rollover-gif-out' %} - {% if rollover_thumbnail.path is defined and (rollover_thumbnail.path is not empty or rollover_thumbnail.path is not none) %} - {% set url = app['phraseanet.static-file'].getUrl(rollover_thumbnail.path) %} - {{thumbnail_macro.format(record, url, rollover_thumbnail.width, rollover_thumbnail.height, th_size, th_size, 'rollover-gif-hover', true, true)}} - {% endif %} - {% endif %} -
      -
      - - - - {% set l_width = 30 %} - {% if user_rollover_thumbnail == 'preview' %} - {% set l_width = l_width + 20 %} - {% endif %} - {% if user_technical_display == '1' %} - {% set l_width = l_width + 20 %} - {% endif %} - - -
      - {{record.baseId | get_collection_logo(app, true)|raw}} - - {{drop_down.prod(record, entry_id)}} - {% if preview and app['acl'].get(app['authentication'].user).has_access_to_subdef(record, 'preview') %} -
      - {% endif %} - {% if user_rollover_thumbnail == 'preview' %} -
      - {% endif %} - {% if user_technical_display == '1' %} - - {% endif %} -
      + {% set rollover = record.subdefs.containsKey('thumbnailgif') %} + {% set extraclass = '' %} +
      + {% if rollover %} + {% set extraclass = 'rollover-gif-out' %} + {% endif %} + + {{ result_macro.thumbnail(record, settings.images_size, settings.images_size, extraclass) }} + + {% if rollover %} + {% set extraclass = 'rollover-gif-hover' %} + {{ result_macro.thumbnailgif(record, settings.images_size, settings.images_size, extraclass) }} + {% endif %}
      +
      + + + + + {% set l_width = 30 %} + + {% if settings.rollover_thumbnail == 'preview' %} + {% set l_width = l_width + 20 %} + {% elseif settings.technical_display == '1' %} + {% set l_width = l_width + 20 %} + {% endif %} + + {# drop down options #} + + +
      + {{ collection_logo(record.baseId) }} + + + + + + + + + + + {% if record.subdefs.containsKey('preview') and has_access_subdef(record, 'preview') %} +
      + {% endif %} + + {% if settings.rollover_thumbnail == 'preview' %} +
      + {% endif %} + + {% if settings.technical_display == '1' %} + + {% endif %} +
      +
      -{% endmacro %} +
      diff --git a/templates/web/prod/results/records.html.twig b/templates/web/prod/results/records.html.twig new file mode 100644 index 0000000000..225f7cdf40 --- /dev/null +++ b/templates/web/prod/results/records.html.twig @@ -0,0 +1,39 @@ +{% if results.error %} + {% block result_error %} +
      + {{ results.error }} +
      + {% endblock %} +{% else %} + {% if results.warning %} + {% block result_warning %} +
      + {{ results.warning }} +
      + {% endblock %} + {% endif %} + + {% block content %} + {% set images_size = user_setting('images_size') %} + {% set technical_display = user_setting('technical_display') %} + {% set rollover_thumbnail = user_setting('rollover_thumbnail') %} + {% set doctype_display = user_setting('doctype_display') %} + +
      + {% for item in results.results %} + {% block content_item %} + {% include (user_setting('view', 'thumbs') == 'thumbs') ? 'prod/results/grid.html.twig' : 'prod/results/list.html.twig' with { + 'record': item, + 'context': context, + 'settings': { + 'images_size': images_size, + 'technical_display': technical_display, + 'rollover_thumbnail': rollover_thumbnail, + 'doctype_display': doctype_display + } + } %} + {% endblock %} + {% endfor %} +
      + {% endblock %} +{% endif %}