user-manager-macros.html.twig 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. {% macro pagination(pagination, url, ps, appendUrl) %}
  2. {% if pagination.count > 1 %}
  3. <div class="admin-addon-user-manager-pagination">
  4. <ul class="admin-addon-user-manager-pagination__pages">
  5. {% if pagination.current > 1 %}
  6. <li><a href="{{ url ~ '/page' ~ ps ~ '1' ~ appendUrl }}"><<</a></li>
  7. {% endif %}
  8. {% if pagination.current > 2 %}
  9. <li><a href="{{ url ~ '/page' ~ ps ~ (pagination.current - 1) ~ appendUrl }}"><</a></li>
  10. {% endif %}
  11. {% set fromPage = (pagination.current - 2 < 1) ? 1 : pagination.current - 2 %}
  12. {% set toPage = (pagination.current + 2 > pagination.count) ? pagination.count : pagination.current + 2 %}
  13. {% for i in fromPage..toPage %}
  14. {% if pagination.current == i %}
  15. <li class="current">{{ i }}</li>
  16. {% else %}
  17. <li><a href="{{ url ~ '/page' ~ ps ~ i ~ appendUrl }}">{{ i }}</a></li>
  18. {% endif %}
  19. {% endfor %}
  20. {% if pagination.current < pagination.count - 1 %}
  21. <li><a href="{{ url ~ '/page' ~ ps ~ (pagination.current + 1) ~ appendUrl }}">></a></li>
  22. {% endif %}
  23. {% if pagination.current < pagination.count %}
  24. <li><a href="{{ url ~ '/page' ~ ps ~ pagination.count ~ appendUrl }}">>></a></li>
  25. {% endif %}
  26. </ul>
  27. <div class="admin-addon-user-manager-pagination__text">{{ "PLUGIN_ADMIN_ADDON_USER_MANAGER.PAGINATION_SUMMARY"|t(pagination.startOffset + 1, pagination.endOffset, pagination.total) }}</div>
  28. </div>
  29. {% endif %}
  30. {% endmacro %}