aboutsummaryrefslogtreecommitdiff
path: root/www/list.php
blob: 7c60ceb5b2ff63e50a2e282a6a6f94a1ca16e3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
/**
 * List a repository
 */
namespace phorkie;
$reqWritePermissions = false;
require_once 'www-header.php';
$rs = new Repositories();

$page = $GLOBALS['phorkie']['cfg']['defaultListPage'];
if (isset($_GET['page'])) {
    if (!is_numeric($_GET['page'])) {
        throw new Exception_Input('List page is not numeric');
    }
    $page = (int)$_GET['page'] - 1;
}

$perPage = $GLOBALS['phorkie']['cfg']['perPage'];
list($repos, $repoCount, $page) = $rs->getList($page, $perPage);

$pager = new Html_Pager(
    $repoCount, $perPage, $page + 1, 'list/%d'
);

$db = new Database();
render(
    'list',
    array(
        'repos'   => $repos,
        'pager'   => $pager,
        'recents' => $db->getSearch()->listAll(0, 5, 'modate', 'desc'),
        'dh'      => new \Date_HumanDiff(),
    )
);
?>