{#
/**
* @file
* Twitter Bootstrap v4-beta.2 Sliding pagination control implementation.
*
* View that can be used with the pagination module
* from the Twitter Bootstrap CSS Toolkit
* https://getbootstrap.com/docs/4.0/components/pagination/
*
*/
#}
{% macro _pagination_path(route, query, pageParameterName, page_number) %}
{% if page_number == 1 %}
{% set _route = route %}
{% set _query = query|filter((v, k) => k != pageParameterName) %}
{% else %}
{% set _route = route~'._pagination' %}
{% set _query = query|merge({(pageParameterName): page_number}) %}
{% endif %}
{{ path(_route, _query)|lower }}
{% endmacro %}
{% from _self import _pagination_path %}
{% if pageCount > 1 %}
<nav class="pagination">
{% set classAlign = (align is not defined) ? '' : align=='center' ? ' justify-content-center' : (align=='right' ? ' justify-content-end' : '') %}
{% set classSize = (size is not defined) ? '' : size=='large' ? ' pagination-lg' : (size=='small' ? ' pagination-sm' : '') %}
<ul class="d-flex">
{% if previous is defined %}
<li class="pagination__item">
<a class="pagination__link" rel="prev" href="{{ _pagination_path(route, query, pageParameterName, previous) }}">{#« {{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}#}
<svg class="icon">
<use xlink:href="#icon-arrow-left"></use>
</svg>
</a>
</li>
{% else %}
<li class="pagination__item disabled">
<span class="pagination__link d-flex">
{#« {{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}#}
<svg class="icon">
<use xlink:href="#icon-arrow-left"></use>
</svg>
</span>
</li>
{% endif %}
{% if startPage > 1 %}
<li class="pagination__item">
<a class="pagination__link" href="{{ _pagination_path(route, query, pageParameterName, 1) }}">1</a>
</li>
{% if startPage == 3 %}
<li class="pagination__item">
<a class="pagination__link" href="{{ _pagination_path(route, query, pageParameterName, 2) }}">2</a>
</li>
{% elseif startPage != 2 %}
<li class="pagination__item pagination__item_spacer">
<div class="pagination__link d-flex">...</div>
</li>
{% endif %}
{% endif %}
{% for page in pagesInRange %}
{% if page != current %}
<li class="pagination__item">
<a class="pagination__link" href="{{ _pagination_path(route, query, pageParameterName, page) }}">{{ page }}</a>
</li>
{% else %}
<li class="pagination__item pagination__item_first pagination__item_active">
<a href="#" class="pagination__link">{{ page }}</a>
</li>
{% endif %}
{% endfor %}
{% if pageCount > endPage %}
{% if pageCount > (endPage + 1) %}
{% if pageCount > (endPage + 2) %}
<li class="pagination__item pagination__item_spacer">
<div class="pagination__link">...</div>
</li>
{% else %}
<li class="pagination__item">
<a class="pagination__link" href="{{ _pagination_path(route, query, pageParameterName, (pageCount - 1)) }}">{{ pageCount -1 }}</a>
</li>
{% endif %}
{% endif %}
<li class="pagination__item">
<a class="pagination__link" href="{{ _pagination_path(route, query, pageParameterName, pageCount) }}">{{ pageCount }}</a>
</li>
{% endif %}
{% if next is defined %}
<li class="pagination__item">
<a class="pagination__link" rel="next" href="{{ _pagination_path(route, query, pageParameterName, next) }}">
{#{{ 'label_next'|trans({}, 'KnpPaginatorBundle') }} »#}
<svg class="icon">
<use xlink:href="#icon-arrow-right"></use>
</svg>
</a>
</li>
{% else %}
<li class="pagination__item disabled">
<span class="pagination__link">{#{{ 'label_next'|trans({}, 'KnpPaginatorBundle') }} »#}
<svg class="icon">
<use xlink:href="#icon-arrow-right"></use>
</svg>
</span>
</li>
{% endif %}
</ul>
</nav>
{% endif %}