123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- require_once __DIR__ . '/../include/utils.php';
- require_once __DIR__ . '/../include/comments.php';
- if (!isset($_GET['id']) || !ctype_digit($_GET['id'])) {
- die_with_message(400, get_string('illegal-id'));
- }
- $is_replies = (isset($_GET['type']) && $_GET['type'] == 'replies');
- $id = $_GET['id'];
- $current_page = (isset($_GET['p']) && ctype_digit($_GET['p']) && $_GET['p'] > 0) ? $_GET['p'] : 1;
- list($comments, $error) = $is_replies
- ? get_artwork_comment_replies($id, $current_page)
- : get_artwork_comments($id, COMMENTS_PER_PAGE * ($current_page - 1), COMMENTS_PER_PAGE);
- if ($error) {
- die_with_message(500, get_string($error));
- }
- $comments = $comments->body;
- $title = sprintf(get_string($is_replies ? 'artwork.replies-popup' : 'artwork.comments-popup'), $id);
- render_page_header($title);
- ?>
- <div class="container container-card">
- <div class="comments">
- <h1><?= $title ?></h1>
- <?php render_comment_list($comments->comments) ?>
-
- <p class="paginator"><?php
- $query_prefix = $is_replies ? "?type=replies&id=$id&p=" : "?id=$id&p=";
- if ($current_page != 1) { ?>
- <a href="<?= $query_prefix . ($current_page - 1) ?>">◂</a><?php
- } ?>
- <a class="selected"><?= $current_page ?></a><?php
- if ($comments->hasNext) { ?>
- <a href="<?= $query_prefix . ($current_page + 1) ?>">▸</a><?php
- } ?>
- </p>
- </div>
- </div>
- <?php
- render_page_footer();
|