pagination.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @var \App\View\AppView $this
  4. * @var bool $addArrows
  5. * @var array $options
  6. * @var bool $reverse
  7. */
  8. if (!isset($separator)) {
  9. if (defined('PAGINATOR_SEPARATOR')) {
  10. $separator = PAGINATOR_SEPARATOR;
  11. } else {
  12. $separator = '';
  13. }
  14. }
  15. if (empty($first)) {
  16. $first = __d('tools', 'first');
  17. }
  18. if (empty($last)) {
  19. $last = __d('tools', 'last');
  20. }
  21. if (empty($prev)) {
  22. $prev = __d('tools', 'previous');
  23. }
  24. if (empty($next)) {
  25. $next = __d('tools', 'next');
  26. }
  27. if (!isset($format)) {
  28. $format = __d('tools', 'Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total');
  29. }
  30. if (!empty($reverse)) {
  31. $tmp = $first;
  32. $first = $last;
  33. $last = $tmp;
  34. $tmp = $prev;
  35. $prev = $next;
  36. $next = $tmp;
  37. }
  38. if (!empty($addArrows)) {
  39. $prev = '« ' . $prev;
  40. $next .= ' »';
  41. }
  42. $escape = isset($escape) ? $escape : true;
  43. ?>
  44. <div class="paginator paging row">
  45. <div class="col-lg-6">
  46. <ul class="pagination">
  47. <?php echo $this->Paginator->first($first, ['escape' => $escape]);?>
  48. <?php echo $separator; ?>
  49. <?php echo $this->Paginator->prev($prev, ['escape' => $escape, 'disabledTitle' => false]);?>
  50. <?php echo $separator; ?>
  51. <?php echo $this->Paginator->numbers(['escape' => $escape, 'separator' => $separator]);?>
  52. <?php echo $separator; ?>
  53. <?php echo $this->Paginator->next($next, ['escape' => $escape, 'disabledTitle' => false]);?>
  54. <?php echo $separator; ?>
  55. <?php echo $this->Paginator->last($last, ['escape' => $escape]);?>
  56. </ul>
  57. </div>
  58. <div class="col-lg-6">
  59. <p class="paging-description">
  60. <?php echo $this->Paginator->counter($format); ?>
  61. </p>
  62. </div>
  63. </div>
  64. <?php if (!empty($options['ajaxPagination'])) {
  65. $ajaxContainer = !empty($options['paginationContainer']) ? $options['paginationContainer'] : '.page';
  66. $script = "$(document).ready(function() {
  67. $('div.pagination a').live('click', function () {
  68. $('$ajaxContainer').fadeTo(300, 0);
  69. var thisHref = $(this).attr('href');
  70. $('$ajaxContainer').load(thisHref, function() {
  71. $(this).fadeTo(200, 1);
  72. $('html, body').animate({
  73. scrollTop: $('$ajaxContainer').offset().top
  74. }, 200);
  75. });
  76. return false;
  77. });
  78. });";
  79. if (isset($this->Js)) {
  80. $this->Js->buffer($script);
  81. }
  82. } ?>