From b577aaebfd4283648169f8ba9f3e7fd58150fcf8 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Sun, 8 Jun 2014 23:46:42 +0700 Subject: [PATCH 1/2] Project builds pagination improvements --- PHPCI/View/Project/view.phtml | 12 +++++++++--- public/assets/css/phpci.css | 16 +++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index bc89e9d8..08781dd3 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -89,9 +89,15 @@ print '
  • « Prev
  • '; } - for($i = 1; $i <= $pages; $i++) - { - print '
  • ' . $i . '
  • '; + if ($pages > 1) { + for($i = 1; $i <= $pages; $i++) + { + if ($i == $page) { + print '
  • ' . $i . '
  • '; + } else { + print '
  • ' . $i . '
  • '; + } + } } if ($page < $pages) { diff --git a/public/assets/css/phpci.css b/public/assets/css/phpci.css index 7113ad1c..a4fa440a 100644 --- a/public/assets/css/phpci.css +++ b/public/assets/css/phpci.css @@ -84,4 +84,18 @@ h1 { .word-wrap { word-wrap: break-word; -} \ No newline at end of file +} + +ul.pagination { + +} + + ul.pagination > li > span { + color: #333; + } + + ul.pagination > li > span:hover, + ul.pagination > li > span:focus { + color: #333; + background-color: #fff; + } \ No newline at end of file From c8288bf7e18fa75648a078e5263625c7ff5dd158 Mon Sep 17 00:00:00 2001 From: Dmitry Khomutov Date: Mon, 9 Jun 2014 00:08:46 +0700 Subject: [PATCH 2/2] Project builds pagination improvements --- PHPCI/Controller/ProjectController.php | 17 ++++++++++++----- PHPCI/View/Project/view.phtml | 2 -- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index 76f794c7..6de6af1a 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -56,13 +56,20 @@ class ProjectController extends \PHPCI\Controller throw new NotFoundException('Project with id: ' . $projectId . ' not found'); } - $page = $this->getParam('p', 1); - $builds = $this->getLatestBuildsHtml($projectId, (($page - 1) * 10)); + $per_page = 10; + $page = $this->getParam('p', 1); + $builds = $this->getLatestBuildsHtml($projectId, (($page - 1) * $per_page)); + $pages = ceil($builds[1] / $per_page); - $this->view->builds = $builds[0]; - $this->view->total = $builds[1]; + if ($page > $pages) { + throw new NotFoundException('Page with number: ' . $page . ' not found'); + } + + $this->view->builds = $builds[0]; + $this->view->total = $builds[1]; $this->view->project = $project; - $this->view->page = $page; + $this->view->page = $page; + $this->view->pages = $pages; $this->config->set('page_title', $project->getTitle()); diff --git a/PHPCI/View/Project/view.phtml b/PHPCI/View/Project/view.phtml index 08781dd3..30fd24aa 100644 --- a/PHPCI/View/Project/view.phtml +++ b/PHPCI/View/Project/view.phtml @@ -82,8 +82,6 @@