Esempio n. 1
0
function bookPage()
{
    $books = new Books();
    $id = (int) $_GET['book'] + 0;
    if (!isset($books[$id])) {
        notFound();
    }
    $book = $books[$id];
    global $tpl;
    $tpl->assign('page_title', $book['title']);
    $tpl->assign('menu_links', Path::menu('book'));
    $tpl->assign('menu_links_admin', Path::menuAdmin('book'));
    $tpl->assign('book', $book);
    $tpl->assign('id', $book['id']);
    $tpl->assign('displayStatus', displayStatus($book['status']));
    $tpl->assign('displayAuthors', displayAuthors($book['author']));
    $tpl->assign('displayNote', displayNote($book['note']));
    $tpl->assign('country', $book['country']);
    $tpl->assign('displayGenres', displayGenres($book['genre']));
    $tpl->assign('token', getToken());
    $tpl->assign('books_count', $books->count());
    $tpl->assign('book_next', $books->nextBook($book['id']));
    $tpl->assign('book_previous', $books->previousBook($book['id']));
    $social_url = str_replace('./', BASE_URL, Path::book($book['id']));
    $tpl->assign('social', ['title' => $book['title'], 'description' => ($book['status'] == Book::SEEN ? displaySimpleNote($book['note']) . ' — ' : '') . str_replace('<br />', '', displaySummary($book['summary'], 250)), 'image' => Books::CompleteImageURI($book), 'twitter' => urlencode(($book['status'] == Book::SEEN ? 'I’ve rated ' . $book['note'] . ' ' . String::pluralize('star', $book['note']) : 'I want to read') . ' “' . $book['title'] . '” from ' . $book['author'] . ' ' . $social_url), 'url' => $social_url]);
    $tpl->draw('book');
    exit;
}