Пример #1
0
// all books asked [need to be after other page they need pagination!]
// HOME PAGE
if (empty($_GET) || isset($_GET['page'])) {
    $books = new Books();
    $page = isset($_GET['page']) ? (int) $_GET['page'] : -1;
    if ($page == 0 || $page == 1) {
        header('Location: ./');
    } else {
        if ($page == -1) {
            $page = 0;
        }
    }
    // check if pagination is asked
    if (!empty($_GET['page'])) {
        checkPagination($page, $books->count());
        $tpl->assign('book', $books->lastBooks(($page - 1) * PAGINATION));
    } else {
        $tpl->assign('book', $books->lastBooks());
    }
    $tpl->assign('pagination', displayPagination($page, $books->count()));
    $tpl->assign('page_title', !empty($page) ? 'Page ' . $page : '');
    $tpl->assign('menu_links', Path::menu('home'));
    $tpl->assign('menu_links_admin', Path::menuAdmin('home'));
    $tpl->assign('token', getToken());
    $tpl->draw('list');
    exit;
}
// book asked
if (!empty($_GET['book'])) {
    bookPage();
}