Add IDs to comments
[aur.git] / web / template / pkg_comments.php
blob26fddfd5863a87199882fb47d134af6954760093
1 <?php
2 if (isset($row['BaseID'])) {
3 /* On a package details page. */
4 $base_id = $row['BaseID'];
5 } else {
6 /* On a package base details page. */
7 $base_id = $row['ID'];
9 $include_deleted = has_credential(CRED_COMMENT_VIEW_DELETED);
10 $count = pkgbase_comments_count($base_id, $include_deleted);
12 <div id="news">
13 <h3>
14 <a href="<?= htmlentities(get_pkgbase_uri($pkgbase_name), ENT_QUOTES) . '?' . mkurl('comments=all') ?>" title="<?= __('View all comments' , $count) ?> (<?= $count ?>)"><?= __('Latest Comments') ?></a>
15 <span class="arrow"></span>
16 </h3>
18 <?php while (list($indx, $row) = each($comments)): ?>
19 <?php
20 $date_fmtd = gmdate('Y-m-d H:i', $row['CommentTS']);
21 if ($row['UserName']) {
22 $user_fmtd = html_format_username($row['UserName']);
23 $heading = __('%s commented on %s', $user_fmtd, $date_fmtd);
24 } else {
25 $heading = __('Anonymous comment on %s', $date_fmtd);
28 if ($row['EditedTS']) {
29 $date_fmtd = gmdate('Y-m-d H:i', $row['EditedTS']);
30 $heading .= ' <span class="edited">(';
31 if ($row['DelUsersID']) {
32 $user_fmtd = html_format_username($row['DelUserName']);
33 $heading .= __('deleted on %s by %s', $date_fmtd, $user_fmtd);
34 } else {
35 $user_fmtd = html_format_username($row['EditUserName']);
36 $heading .= __('last edited on %s by %s', $date_fmtd, $user_fmtd);
38 $heading .= ')</span>';
41 $row['DelUserName'] = html_format_username($row['DelUserName']);
42 $row['EditUserName'] = html_format_username($row['EditUserName']);
44 <h4 id="comment-<?= $row['ID'] ?>"<?php if ($row['DelUsersID']): ?> class="comment-deleted"<?php endif; ?>>
45 <?= $heading ?>
46 <?php if (!$row['DelUsersID'] && can_delete_comment_array($row)): ?>
47 <form class="delete-comment-form" method="post" action="<?= htmlspecialchars(get_pkgbase_uri($pkgbase_name), ENT_QUOTES); ?>">
48 <fieldset style="display:inline;">
49 <input type="hidden" name="action" value="do_DeleteComment" />
50 <input type="hidden" name="comment_id" value="<?= $row['ID'] ?>" />
51 <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
52 <input type="image" class="delete-comment" src="/images/x.min.svg" width="11" height="11" alt="<?= __('Delete comment') ?>" title="<?= __('Delete comment') ?>" name="submit" value="1" />
53 </fieldset>
54 </form>
55 <?php endif; ?>
56 <?php if (!$row['DelUsersID'] && can_edit_comment_array($row)): ?>
57 <a href="<?= htmlspecialchars(get_pkgbase_uri($pkgbase_name) . 'edit-comment/?comment_id=' . $row['ID'], ENT_QUOTES) ?>" class="edit-comment" title="<?= __('Edit comment') ?>"><img src="/images/pencil.min.svg" alt="<?= __('Edit comment') ?>" width="11" height="11"></a>
58 <?php endif; ?>
59 </h4>
60 <div class="article-content<?php if ($row['DelUsersID']): ?> comment-deleted<?php endif; ?>">
61 <p>
62 <?= parse_comment($row['Comments']) ?>
63 </p>
64 </div>
65 <?php endwhile; ?>
66 </div>
68 <?php if ($count > 10 && !isset($_GET['comments'])): ?>
69 <div id="news">
70 <h3>
71 <a href="<?= htmlentities(get_pkgbase_uri($pkgbase_name), ENT_QUOTES) . '?' . mkurl('comments=all') ?>" title="<?= __('View all comments') ?> (<?= $count ?>)"><?= __('All comments', $count) ?></a>
72 </h3>
73 </div>
74 <?php endif; ?>