<f:if condition="{configuration.insertAbove}">
    <f:render section="paginator" arguments="{pagination: pagination}"/>
</f:if>

<f:renderChildren arguments="{contentArguments}"/>

<f:if condition="{configuration.insertBelow}">
    <f:render section="paginator" arguments="{pagination: pagination}"/>
</f:if>

<f:section name="paginator">
    <f:if condition="{pagination.numberOfPages} > 1">
        <div class="page-navigation">
            <ul class="neos-fluid-widget-paginator">
                <f:if condition="{pagination.previousPage}">
                    <li class="previous">
                        <f:if condition="{pagination.previousPage} > 1">
                            <f:then>
                                <f:widget.link action="index" arguments="{currentPage: pagination.previousPage}">{f:translate(id: 'widget.paginate.previous', value: 'previous')}</f:widget.link>
                            </f:then>
                            <f:else>
                                <f:widget.link action="index">{f:translate(id: 'widget.paginate.previous', value: 'previous')}</f:widget.link>
                            </f:else>
                        </f:if>
                    </li>
                </f:if>
                <f:if condition="{pagination.displayRangeStart} > 1">
                    <li class="first">
                        <f:widget.link action="index">1</f:widget.link>
                    </li>
                </f:if>
                <f:if condition="{pagination.hasLessPages}">
                    <li>...</li>
                </f:if>
                <f:for each="{pagination.pages}" as="page">
                    <f:if condition="{page.isCurrent}">
                        <f:then>
                            <li class="current">
                                {page.number}
                            </li>
                        </f:then>
                        <f:else>
                            <li>
                                <f:if condition="{page.number} > 1">
                                    <f:then>
                                        <f:widget.link action="index" arguments="{currentPage: page.number}">{page.number}</f:widget.link>
                                    </f:then>
                                    <f:else>
                                        <f:widget.link action="index">{page.number}</f:widget.link>
                                    </f:else>
                                </f:if>
                            </li>
                        </f:else>
                    </f:if>
                </f:for>
                <f:if condition="{pagination.hasMorePages}">
                    <li>...</li>
                </f:if>
                <f:if condition="{pagination.displayRangeEnd} < {pagination.numberOfPages}">
                    <li class="last">
                        <f:widget.link action="index" arguments="{currentPage: pagination.numberOfPages}">{pagination.numberOfPages}</f:widget.link>
                    </li>
                </f:if>
                <f:if condition="{pagination.nextPage}">
                    <li class="next">
                        <f:widget.link action="index" arguments="{currentPage: pagination.nextPage}">{f:translate(id: 'widget.paginate.next', value: 'next')}</f:widget.link>
                    </li>
                </f:if>
            </ul>
        </div>
    </f:if>
</f:section>
