{% import 'prod/results/macro.html.twig' as result_macro %}
{% import 'common/macros.html.twig' as macro %}

<div style="width:{{ settings.images_size + 30}}px;"
     sbas="{{ record.databoxId }}"
     id="{{ prefix|default('IMGT') }}_{{ record.id }}"
     class="IMGT diapo {% if record.story %}grouping{% endif %} type-{{ record.type }}"
     {% if settings.handle_dblclick %}onDblClick="openPreview(this, '{{ record.story ? 'REG' : 'RESULT' }}', '{{ record.position|default(0) }}', '{{ record.id }}');"{% endif %}>
    <div style="padding: 4px;">
        <div style="height:40px; position: relative; z-index: 95;margin-bottom:0;border-bottom:none;">
            <div class="title" style="max-height:100%" title="{{ record.getTitle(app.locale) }}">
                {{ record.getTitle(app.locale)|highlight }}
            </div>
            <div class="status">
                {% for flag in record_flags(record) %}
                    <img src="{{ flag.path }}" title="{{ attribute(flag.labels, app.locale) }}" />
                {% endfor %}
            </div>
        </div>

        {% set can_see_business = granted_on_collection(record.baseId, [constant('\\ACL::CANMODIFRECORD')]) %}

        <div class="thumb captionTips"
             {% if settings.rollover_thumbnail == 'caption' %}tooltipsrc="{{ path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'answer', 'number' : record.position|default(0) }) }}"{% endif %}
             {% 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;">
            <div class="doc_infos">
                <span class="duration">
                    {% 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 %}
                </span>
                {% if settings.doctype_display == '1' %}
                    {{ record_doctype_icon(record) }}
                {% endif %}
            </div>
            {% set rollover = record.subdefs.thumbnailgif is defined %}
            {% set extraclass = '' %}
            <div class="{% if rollover %}rollovable{% endif %}">
                {% 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 %}
            </div>
        </div>
        <div style="height: 25px; position:relative; text-align:left;">
            <table class="bottom actions" style="width:100%; table-layout:fixed;">
                <tr>
                    <td style="text-align:left;text-overflow:ellipsis;overflow:hidden;">
                        {% set collectionLogo = collection_logo(record.baseId) %}
                        {% if collectionLogo is empty %}
                        {{ record.collectionName }}
                        {% else %}
                        {{ collectionLogo|raw }}
                        {% endif %}
                    </td>

                    {% set l_width = 30 %}

                    {% if settings.rollover_thumbnail == 'preview' or settings.rollover_thumbnail == 'caption' %}
                        {% set l_width = l_width + 50 %}
                    {% elseif settings.technical_display == '1' %}
                        {% set l_width = l_width + 50 %}
                    {% endif %}

                    {# drop down options #}
                    <td style="text-align:right;width:{{l_width}}px;" valign="bottom">

                        {% if settings.rollover_thumbnail == 'caption' %}
                            {% if record_subdef_url(record, 'preview') is not null and has_access_subdef(record, 'preview') %}
                                <span class="icon-stack previewTips" tooltipsrc="{{ path('prod_tooltip_preview', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) }}">
                                  <i class="icon-circle icon-stack-base"></i>
                                  <i class="icon-search icon-light"></i>
                                </span>
                            {% endif %}
                        {% endif %}
                        {% if settings.rollover_thumbnail == 'preview' %}
                            <span class="icon-stack captionRolloverTips"
                                  tooltipsrc="{{ path('prod_tooltip_caption', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId, 'context' : 'answer', 'number' : record.position|default(0) }) }}">
                              <i class="icon-circle icon-stack-base"></i>
                              <i class="icon-list icon-light"></i>
                            </span>
                        {% endif %}

                        {% if settings.technical_display == '1' %}
                            <span class="icon-stack infoTips" tooltipsrc="{{ path('prod_tooltip_technical_data', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) }}">
                              <i class="icon-circle icon-stack-base"></i>
                              <i class="icon-info icon-light"></i>
                            </span>
                        {% endif %}

                        {%  if settings.show_context_menu %}
                        <span class="icon-stack contextMenuTrigger"  id="contextTrigger_{{record.id}}"
                              tooltipsrc="{{ path('prod_tooltip_technical_data', { 'sbas_id' : record.databoxId, 'record_id' : record.recordId }) }}">
                              <i class="icon-circle icon-stack-base"></i>
                              <i class="icon-ellipsis-horizontal icon-light"></i>
                        </span>
                        <table cellspacing="0" cellpadding="0" style="display:none;" id="answerContext_{{record.id}}" class="contextMenu answercontextmenu">
                            <tbody>
                            <tr>
                                <td>
                                    <div class="context-menu context-menu-theme-vista">
                                        {% if granted_on_collection(record.baseId, [constant('\\ACL::CANPUTINALBUM')]) and not record.story %}
                                            <div title="" class="context-menu-item">
                                                <div class="context-menu-item-inner"
                                                     onclick="evt_add_in_chutier('{{record.databoxId}}','{{record.recordId}}',false,this);return(false);">
                                                    {{ 'action : ajouter au panier' | trans }}
                                                </div>
                                            </div>
                                        {% endif %}
                                        {% if granted_on_collection(record.baseId, [constant('\\ACL::CANDWNLDPREVIEW')]) or granted_on_collection(record.baseId, [constant('\\ACL::CANDWNLDHD')]) %}
                                            <div title="" class="context-menu-item">
                                                <div class="context-menu-item-inner"
                                                     onclick="evt_dwnl('{{record.id}}',false,this);return(false);">
                                                    {{ 'action : exporter' | trans }}
                                                </div>
                                            </div>
                                        {% endif %}
                                        <div title="" class="context-menu-item">
                                            <div class="context-menu-item-inner"
                                                 onclick="evt_print('{{record.id}}');return(false);">
                                                {{ 'action : print' | trans }}
                                            </div>
                                        </div>
                                        {% if app['conf'].get(['registry', 'actions', 'social-tools']) == 'all'
                                        or (app['conf'].get(['registry', 'actions', 'social-tools']) == 'publishers'
                                        and granted_on_databox(record.databoxId, constant('\\ACL::BAS_CHUPUB'))) %}
                                            {% if record.story is empty %}
                                                <div title="" class="context-menu-item">
                                                    <div class="context-menu-item-inner"
                                                         onclick="shareThis('{{record.baseId}}','{{record.recordId}}');">
                                                        {{ 'reponses:: partager' | trans }}
                                                    </div>
                                                </div>
                                            {% endif %}
                                        {% endif %}
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
