Project builds pagination improvements

This commit is contained in:
Dmitry Khomutov 2014-06-09 00:08:46 +07:00
parent b577aaebfd
commit c8288bf7e1
2 changed files with 12 additions and 7 deletions

View file

@ -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());

View file

@ -82,8 +82,6 @@
<?php
print '<div><ul class="pagination">';
$pages = ceil($total / 10);
$pages = $pages == 0 ? 1 : $pages;
if ($page > 1) {
print '<li><a href="' . PHPCI_URL . 'project/view/'.$project->getId().'?p='.($page == 1 ? '1' : $page - 1).'">&laquo; Prev</a></li>';