Project builds pagination improvements

This commit is contained in:
Dmitry Khomutov 2014-06-09 00:08:46 +07:00
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());