{% macro grid(item) %}
    {% import "features/macro-elements.twig" as macroElements %}
    {{ macroElements.html_figure(item, 'file', 'img-responsive', true, 'fa-link') }}
    {{ macroElements.html_figure(item, 'thumb') }}
    {{ macroElements.html_video(item) }}
    {{ macroElements.html_listOptions(item) }}
    {{ macroElements.html_amount(item) }}
    {{ macroElements.html_titleh2(item) }}
    {% if item.text %}
    {{ macroElements.html_text(item, 'text') }}
    {% endif %}
    {% if item.call %}
    {{ macroElements.html_text(item, 'call') }}
    {% endif %}
{% endmacro %}

{% macro list(item) %}
{% import "features/macro-elements.twig" as macroElements %}
{{ macroElements.html_titleh2(item) }}
{{ macroElements.html_figure(item, 'thumb') }}
{{ macroElements.html_listOptions(item) }}
{{ macroElements.html_text(item, 'text') }}
<div class="clearfix"></div>
{% endmacro %}

{% macro asideBlock(actions) %}
{% import _self as toolsArchives %}
{% if actions.search %}
    {{ toolsArchives.widgetSearch(actions.search) }}
{% endif %}

{% if actions %}
    {% for key, item in actions %}
        {% if key != 'search' and item.list %}
        <div class="widget-sidebar widget-sidebar-{{ key }}">
            {{ toolsArchives.widgetFilterList(item) }}
        </div>
        {% endif %}
    {% endfor %}
{% endif %}
{% endmacro %}

{% macro asideList(actions) %}
{% import _self as toolsArchives %}
{% if actions %}
<div class="row asideList">
    <div class="col col-sm-6 col-md-6 col-lg-6">
        {% if actions.search %}
        {{ toolsArchives.widgetSearch(actions.search) }}
        {% endif %}
    </div>

    {% for key, item in actions %}
    {% if key != 'search' %}
    <div class="col col-sm-6 col-md-3 col-lg-3">
        {{ toolsArchives.widgetFilterList(item) }}
    </div>
    {% endif %}
    {% endfor %}
</div>
{% endif %}
{% endmacro %}

{% macro pagination(data, length = 1, class = null) %}
{% if data.pages|length > length %}
<div class="container-pagination{% if class %} {{ class }}{% endif %}">
    <ul class="pagination">
        {% set prev = data.prev %}
        <li class="{{ prev.class }}"><a href="{{ prev.link }}" title="{{ prev.title|striptags|raw }}"><i class="fa fa-angle-double-left"></i></a></li>
        {% for item in data.pages %}
        <li class="{{ item.class }}"><a href="{{ item.link }}" title="{{ item.label|striptags|raw }}">{{ item.title|raw }}</a></li>
        {% endfor %}
        {% set next = data.next %}
        <li class="{{ next.class }}"><a href="{{ next.link }}" title="{{ next.title|striptags|raw }}"><i class="fa fa-angle-double-right"></i></a></li>
    </ul>
</div>
{% endif %}
{% endmacro %}

{% macro widgetSearch(data) %}
{% import "features/macro-forms.twig" as macroForms %}
{% if data %}
<div class="widget-sidebar widget-sidebar-search">
    <form id="searchInternalForm" class="form-searchInternal" name="searchInternalForm" method="post" action="{{ data.action }}">
        {{ macroForms.public_key() }}

        <div class="input-group">
            <input type="text" id="stringSearch_internal" name="stringSearch_internal" class="form-control" required placeholder="{{ data.placeholder|striptags|raw }}" />

            <span class="input-group-btn">
                <button id="submitSearch_internal" type="submit" name="submitSearch_internal" class="btn btn-primary" value="submitSearch_internal" title="{{ data.label|striptags|raw }}"><i class="fa fa-search"></i></button>
            </span>
        </div>
    </form>
</div>
{% endif %}
{% endmacro %}

{% macro widgetFilterList(data, class = null) %}
{% if data.list %}
<div class="side-nav{% if class %} {{ class }}{% endif %}">
    {% if not data.info.notitle %}
    <div class="side-nav-head">
        <button class="fa fa-fw fa-bars"></button>
        <h3 class="heading-macro"><a href="{{ data.info.url }}" title="{{ data.info.title|striptags|raw }}">{{ data.info.title|raw }}</a></h3>
    </div>
    {% endif %}

    {% if data.info.type == 'list' %}
    <ul class="list-unstyled list-group">
    {% for item in data.list %}
        <li class="list-group-item {% if item.active == true %}active{% endif %} item-{{ item.id }}">
            <a href="{{ item.url }}" title="{{ item.title|striptags|raw }}">{% if item.total %}<span class="cont pull-right">({{ item.total }})</span> {% endif %}{{ item.title|raw }}</a>
        </li>
    {% endfor %}
    </ul>
    {% elseif data.info.type == 'select' %}
    <div class="clearfix input-select-container">
    <select name="selectLink" class="form-control filter-link">
        <option value="{{ data.info.url }}" selected>{{ data.info.label|raw }}</option>
    {% for item in data.list %}
        <option value="{{ item.url }}"{% if item.active == true %} selected{% endif %}>{{ item.title|raw }}</option>
    {% endfor %}
    </select>
    </div>
    {% endif %}
</div>
{% endif %}
{% endmacro %}

{% macro widgetFilterListSelect(data, class = null) %}
{% if data.list %}
<div class="clearfix input-select-container">
    <select name="selectLink" class="form-control filter-link">
        <option value="{{ data.info.url }}" selected>{{ data.info.label|raw }}</option>
        {% for item in data.list %}
        <option value="{{ item.url }}"{% if item.active == true %} selected{% endif %}>{{ item.title|raw }}</option>
        {% endfor %}
    </select>
</div>
{% endif %}
{% endmacro %}

{% macro noneitens(text) %}
<div class="alert alert-info nomargin">
    <b>{{ text|raw }}</b>
</div>
{% endmacro %}

{% macro readmore(label, link, classLink = 'btn btn-lg btn-primary', class = 'margintop-40') %}
{% if label and link %}
<div class="text-center{% if class %} {{ class }}{% endif %}">
    <a href="{{ link }}" class="{{ classLink }}" title="{{ label|striptags|raw }}">{{ label|raw }}</a>
</div>
{% endif %}
{% endmacro %}
