diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-03-27 07:50:58 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-03-27 07:50:58 +0200 |
| commit | 4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10 (patch) | |
| tree | 0da5e9ace9d5b5eb359308dfaa81d7fbf5a147b0 /www/list.php | |
| parent | c12906d4181a185db6de00e4a1dc11897a1d4718 (diff) | |
| download | phorkie-4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10.tar.gz phorkie-4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10.zip | |
listing all pastes works
Diffstat (limited to 'www/list.php')
| -rw-r--r-- | www/list.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/www/list.php b/www/list.php new file mode 100644 index 0000000..a212322 --- /dev/null +++ b/www/list.php @@ -0,0 +1,38 @@ +<?php +/** + * Fork a repository + */ +namespace Phorkie; +require_once 'www-header.php'; +$rs = new Repositories(); + +$page = 0; +if (isset($_GET['page'])) { + if (!is_numeric($_GET['page'])) { + throw new Exception_Input('List page is not numeric'); + } + $page = (int)$_GET['page']; +} + +$perPage = 10; +$repos = $rs->getList($page, $perPage); + +$links = array('prev' => null, 'next' => null); +if ($page > 0) { + $links['prev'] = '/list/' . ($page - 1); + if ($page - 1 == 0) { + $links['prev'] = '/list'; + } +} +if (count($repos) && count($repos) == $perPage) { + $links['next'] = '/list/' . ($page + 1); +} + +render( + 'list', + array( + 'repos' => $repos, + 'links' => $links, + ) +); +?> |
