{#
/**
 * @file
 * Foundation 5 Sliding pagination control implementation.
 *
 * View that can be used with the pagination module
 * from the Foundation 5 CSS Toolkit
 * https://get.foundation/sites/docs-v5/components/pagination.html
 *
 * @author Vincent Loy <vincent.loy1@gmail.com>
 *
 * This view have been ported from twitter bootstrap v3 pagination control implementation
 * from:
 * @author Pablo Díez <pablodip@gmail.com>
 * @author Jan Sorgalla <jsorgalla@gmail.com>
 * @author Artem Ponomarenko <imenem@inbox.ru>
 * @author Artem Zabelin <artjomzabelin@gmail.com>
 */
#}
{% if pageCount > 1 %}
    <ul class="pagination">
        {% if previous is defined %}
                 <li class="arrow">
                     <a rel="prev" href="{{ path(route, knp_pagination_query(query, previous, options)) }}">&laquo; {{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}</a>
                 </li>
        {% else %}
            <li class="arrow unavailable">
                <a>
                    &laquo; {{ 'label_previous'|trans({}, 'KnpPaginatorBundle') }}
                </a>
            </li>
        {% endif %}

        {% if startPage > 1 %}
            <li>
                <a href="{{ path(route, knp_pagination_query(query, 1, options)) }}">1</a>
            </li>
            {% if startPage == 3 %}
                <li>
                    <a href="{{ path(route, knp_pagination_query(query, 2, options)) }}">2</a>
                </li>
            {% elseif startPage != 2 %}
                <li class="unavailable">
                    <a>&hellip;</a>
                </li>
            {% endif %}
        {% endif %}

        {% for page in pagesInRange %}
            {% if page != current %}
                <li>
                    <a href="{{ path(route, knp_pagination_query(query, page, options)) }}">
                        {{ page }}
                    </a>
                </li>
            {% else %}
                <li class="current">
                    <a>{{ page }}</a>
                </li>
            {% endif %}

        {% endfor %}

        {% if pageCount > endPage %}
            {% if pageCount > (endPage + 1) %}
                {% if pageCount > (endPage + 2) %}
                    <li class="unavailable">
                        <a>&hellip;</a>
                    </li>
                {% else %}
                    <li>
                        <a href="{{ path(route, knp_pagination_query(query, (pageCount - 1), options)) }}">
                            {{ pageCount - 1 }}
                        </a>
                    </li>
                {% endif %}
            {% endif %}
            <li>
                <a href="{{ path(route, knp_pagination_query(query, pageCount, options)) }}">{{ pageCount }}</a>
            </li>
        {% endif %}

        {% if next is defined %}
            <li class="arrow">
                <a rel="next" href="{{ path(route, knp_pagination_query(query, next, options)) }}">
                    {{ 'label_next'|trans({}, 'KnpPaginatorBundle') }} &nbsp;&raquo;
                </a>
            </li>
        {% else %}
            <li class="arrow unavailable">
                <a>
                    {{ 'label_next'|trans({}, 'KnpPaginatorBundle') }} &nbsp;&raquo;
                </a>
            </li>
        {% endif %}
    </ul>
{% endif %}
