pagination.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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">Previous</span>
  26. </a>
  27. </li>
  28. <li class="page-item"><a class="page-link" href="#" data-toggle="modal" data-target="#modal-page-jump">Page <?=number_format($page)?> of <?=number_format($page_count)?></a></li>
  29. <li class="page-item <?=$next_disabled?>">
  30. <a class="page-link" href="<?=htmlspecialchars($next_url)?>">
  31. <span aria-hidden="true">&raquo;</span>
  32. <span class="sr-only">Next</span>
  33. </a>
  34. </li>
  35. </ul>
  36. </nav>
  37. </div>
  38. </div>