1
0

pagination.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. if(!isset($pagination_object)) return;
  3. $page = $pagination_object->page;
  4. $page_count = $pagination_object->pageCount;
  5. $uri = $_SERVER["REQUEST_URI"];
  6. $parts = explode("?", $uri);
  7. $path = $parts[0];
  8. $query_string = $parts[1] ?? "";
  9. parse_str($query_string, $nvp);
  10. $previous_disabled = ($page <= 1) ? "disabled" : "";
  11. $next_disabled = ($page >= $page_count) ? "disabled" : "";
  12. $previous_url = $path . "?" . http_build_query(array_merge($nvp, ["page" => $page - 1]));
  13. $next_url = $path . "?" . http_build_query(array_merge($nvp, ["page" => $page + 1]));
  14. ?>
  15. <div class="row">
  16. <div class="col-sm align-self-center mb-3 mb-sm-0 text-center text-sm-left">
  17. <?=htmlspecialchars($pagination_object->rangeText)?>
  18. </div>
  19. <div class="col-sm-auto">
  20. <nav aria-label="Page navigation">
  21. <ul class="pagination mb-0 justify-content-center">
  22. <li class="page-item <?=$previous_disabled?>">
  23. <a class="page-link" href="<?=htmlspecialchars($previous_url)?>">
  24. <span aria-hidden="true">&laquo;</span>
  25. <span class="sr-only"><?=htmlspecialchars(__("Previous"))?></span>
  26. </a>
  27. </li>
  28. <li class="page-item">
  29. <a class="page-link" href="#" data-toggle="modal" data-target="#modal-page-jump">
  30. <?=sprintf(__("Page %s of %s"), number_format($page), number_format($page_count))?>
  31. </a>
  32. </li>
  33. <li class="page-item <?=$next_disabled?>">
  34. <a class="page-link" href="<?=htmlspecialchars($next_url)?>">
  35. <span aria-hidden="true">&raquo;</span>
  36. <span class="sr-only"><?=htmlspecialchars(__("Next"))?></span>
  37. </a>
  38. </li>
  39. </ul>
  40. </nav>
  41. </div>
  42. </div>