mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
pkg_comments: Only display 10 comments by default.
Add a mechanism to view all comments. Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
parent
94da2bf1dc
commit
5b8b0757f4
2 changed files with 36 additions and 5 deletions
|
@ -194,9 +194,25 @@ function create_dummy($pname="", $sid="") {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# grab package comments
|
# Return the number of comments for a specified package
|
||||||
#
|
function package_comments_count($pkgid = 0) {
|
||||||
function package_comments($pkgid=0) {
|
if ($pkgid) {
|
||||||
|
$dbh = db_connect();
|
||||||
|
$q = "SELECT COUNT(*) FROM PackageComments ";
|
||||||
|
$q.= "WHERE PackageID = " . mysql_real_escape_string($pkgid);
|
||||||
|
$q.= " AND DelUsersID = 0";
|
||||||
|
}
|
||||||
|
$result = db_query($q, $dbh);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mysql_result($result, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Return an array of package comments
|
||||||
|
function package_comments($pkgid = 0) {
|
||||||
$comments = array();
|
$comments = array();
|
||||||
if ($pkgid) {
|
if ($pkgid) {
|
||||||
$dbh = db_connect();
|
$dbh = db_connect();
|
||||||
|
@ -206,6 +222,11 @@ function package_comments($pkgid=0) {
|
||||||
$q.= " AND PackageID = ".mysql_real_escape_string($pkgid);
|
$q.= " AND PackageID = ".mysql_real_escape_string($pkgid);
|
||||||
$q.= " AND DelUsersID = 0"; # only display non-deleted comments
|
$q.= " AND DelUsersID = 0"; # only display non-deleted comments
|
||||||
$q.= " ORDER BY CommentTS DESC";
|
$q.= " ORDER BY CommentTS DESC";
|
||||||
|
|
||||||
|
if (!isset($_GET['comments'])) {
|
||||||
|
$q.= " LIMIT 10";
|
||||||
|
}
|
||||||
|
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
|
|
@ -24,5 +24,15 @@ while (list($indx, $carr) = each($comments)) { ?>
|
||||||
</div>
|
</div>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<?php
|
<?php
|
||||||
} ?>
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$count = package_comments_count($_GET['ID']);
|
||||||
|
if ($count > 10 && !isset($_GET['comments'])) {
|
||||||
|
echo '<div class="pgbox">';
|
||||||
|
echo '<a href="'. $_SERVER['PHP_SELF'] . '?ID=' . $_REQUEST['ID'] . '&comments=all">'. __('Show all %s comments', $count) . '</a>';
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue