From 598ee706aedef40fd4fac9c3e9305471df5ab200 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Wed, 3 Dec 2014 13:51:06 +0000 Subject: [PATCH] Cleaning up pagination. --- PHPCI/View/Project/view.phtml | 33 ++++++++++++++++++++++++++++++--- PHPCI/View/layout.phtml | 6 ++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index 741ea0cb..38cfcc4c 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -108,20 +108,47 @@ if ($page > 1) { } if ($pages > 1) { - for($i = 1; $i <= $pages; $i++) + + $start = $page - 3; + + if ($start <= 0) { + $start = 1; + } + + $end = $page + 3; + + if ($end > $pages) { + $end = $pages; + } + + if ($start > 1) { + print '
  • 1...
  • '; + } + + for($i = $start; $i <= $end; $i++) { + if ($pages > $end && $i == $pages) continue; + if ($i == $page) { - print '
  • ' . $i . '
  • '; + print '
  • ' . $i . '
  • '; } else { print '
  • ' . $i . '
  • '; } } + + if ($pages > $end) { + print '
  • ...'.$pages.'
  • '; + } } -if ($page < $pages) { + + +if ($page < $pages - 1) { print '
  • Next »
  • '; } + + print ''; ?> \ No newline at end of file diff --git a/PHPCI/View/layout.phtml b/PHPCI/View/layout.phtml index c6171a07..dac44274 100644 --- a/PHPCI/View/layout.phtml +++ b/PHPCI/View/layout.phtml @@ -71,6 +71,12 @@ color: #fff; } + .pagination>li>span { + font-weight: bold; + background: #337ab7; + color: #fff; + } +