{% if pageCount > 0 %}
{% set defaultPageQuantityAround = 2 %}
{% set minimumPageQuantityAround = min(currentPage - 1, pageCount - currentPage) %}
{% set conditionBefore = currentPage != 1 and minimumPageQuantityAround <= currentPage - 1 %}
{% set conditionAfter = currentPage != pageCount and minimumPageQuantityAround <= pageCount - currentPage %}
{% set PageQuantityAroundBefore = conditionBefore ? defaultPageQuantityAround : minimumPageQuantityAround %}
{% set PageQuantityAroundAfter = conditionAfter ? defaultPageQuantityAround : minimumPageQuantityAround %}
<nav aria-label="pagination" id="pagination" class="mt-40px mb-40px toggleable visible jcc">
<ul class="dflex jcc prelative cblue w100 fwwrap">
{% if pageCount > 1 %}
<li class="previous pabsolute{% if currentPage == 1 %} not-link{% else %} active{% endif %}">
{% if currentPage - 1 != 0 %}
<a href="?page={{ currentPage - 1 }}" data-page="{{ currentPage - 1 }}" class="dblock nodeco fs14{% if currentPage != 1 %} cblue{% else %} cgrey{% endif %}">
{{ source("svg/left-arrow-icon.html.twig") }}
{% if dontShowText is not defined %}
<span>Précédent</span>
{% endif %}
</a>
{% else %}
<div class="cgrey fs14">
{{ source("svg/left-arrow-icon.html.twig") }}
{% if dontShowText is not defined %}
<span>Précédent</span>
{% endif %}
</div>
{% endif %}
</li>
{% endif %}
{% for i in 1..pageCount %}
{% set url = "?page=" ~ i %}
{% if app.request.get('elems') is not empty %}
{% set url = url ~ "&elems=" ~ app.request.get('elems') %}
{% endif %}
{% if currentPage == i %}
<li class="current not-link cblue nodeco dblock prelative">{{ i }}</li>
{% elseif (i < currentPage and 1 != i) and (i == currentPage - PageQuantityAroundBefore - 1) %}
<li class="not-link">...</li>
{% elseif (i > currentPage and pageCount != i) and (i == currentPage + PageQuantityAroundAfter + 1) %}
<li class="not-link">...</li>
{% elseif (i == 2) or (i == 3) %}
{% include "blocks/sub-blocks/pagination-li.html.twig" %}
{% elseif (1 != i) and (i < currentPage - PageQuantityAroundBefore - 1) %}
{% include "blocks/sub-blocks/pagination-li.html.twig" with { nodisplay: true } %}
{% elseif (i == pageCount - 1) or (i == pageCount - 2) %}
{% include "blocks/sub-blocks/pagination-li.html.twig" %}
{% elseif (pageCount != i) and (i > currentPage + PageQuantityAroundAfter + 1) %}
{% include "blocks/sub-blocks/pagination-li.html.twig" with { nodisplay: true } %}
{% elseif i == 1 or i == pageCount %}
{% include "blocks/sub-blocks/pagination-li.html.twig" %}
{% else %}
{% include "blocks/sub-blocks/pagination-li.html.twig" %}
{% endif %}
{% endfor %}
{% if pageCount > 1 %}
<li class="next pabsolute{% if currentPage == pageCount %} not-link{% else %} active{% endif %}">
{% if currentPage + 1 <= pageCount %}
<a href="?page={{ currentPage + 1 }}" data-page="{{ currentPage + 1 }}" class="dblock nodeco fs14{% if currentPage != pageCount %} cblue{% else %} cgrey{% endif %}">
{% if dontShowText is not defined %}
<span>Suivant</span>
{% endif %}
{{ source("svg/right-arrow-icon.html.twig") }}
</a>
{% else %}
<div class="cgrey fs14">
{% if dontShowText is not defined %}
<span>Suivant</span>
{% endif %}
{{ source("svg/right-arrow-icon.html.twig") }}
</div>
{% endif %}
</li>
{% endif %}
</ul>
</nav>
{% else %}
<div>Aucun résultat ne correspond à ces critères.</div>
{% endif %}