pagination.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. $modulus = isset($modulus) ? $modulus : 8;
  44. ?>
  45. <div class="paginator paging row">
  46. <div class="col-lg-6">
  47. <ul class="pagination">
  48. <?php echo $this->Paginator->first($first, ['escape' => $escape]);?>
  49. <?php echo $separator; ?>
  50. <?php echo $this->Paginator->prev($prev, ['escape' => $escape, 'disabledTitle' => false]);?>
  51. <?php echo $separator; ?>
  52. <?php echo $this->Paginator->numbers(['escape' => $escape, 'separator' => $separator, 'modulus' => $modulus]);?>
  53. <?php echo $separator; ?>
  54. <?php echo $this->Paginator->next($next, ['escape' => $escape, 'disabledTitle' => false]);?>
  55. <?php echo $separator; ?>
  56. <?php echo $this->Paginator->last($last, ['escape' => $escape]);?>
  57. </ul>
  58. </div>
  59. <div class="col-lg-6">
  60. <p class="paging-description">
  61. <?php echo $this->Paginator->counter($format); ?>
  62. </p>
  63. </div>
  64. </div>
  65. <?php if (!empty($options['ajaxPagination'])) {
  66. $ajaxContainer = !empty($options['paginationContainer']) ? $options['paginationContainer'] : '.page';
  67. $script = "$(document).ready(function() {
  68. $('div.pagination a').live('click', function () {
  69. $('$ajaxContainer').fadeTo(300, 0);
  70. var thisHref = $(this).attr('href');
  71. $('$ajaxContainer').load(thisHref, function() {
  72. $(this).fadeTo(200, 1);
  73. $('html, body').animate({
  74. scrollTop: $('$ajaxContainer').offset().top
  75. }, 200);
  76. });
  77. return false;
  78. });
  79. });";
  80. if (isset($this->Js)) {
  81. $this->Js->buffer($script);
  82. }
  83. } ?>