summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLoui Chang <louipc.ist@gmail.com>2010-04-15 16:52:55 -0400
committerLoui Chang <louipc.ist@gmail.com>2010-04-15 16:52:55 -0400
commit5b8b0757f4f938f86bed86ae56fa3511704e006f (patch)
tree5e9576e04a93309c1e931afc7836d844af26cd89 /web
parent94da2bf1dceeff037933755912dd333302ca5ec9 (diff)
downloadaurweb-5b8b0757f4f938f86bed86ae56fa3511704e006f.tar.xz
pkg_comments: Only display 10 comments by default.
Add a mechanism to view all comments. Signed-off-by: Loui Chang <louipc.ist@gmail.com>
Diffstat (limited to 'web')
-rw-r--r--web/lib/pkgfuncs.inc29
-rw-r--r--web/template/pkg_comments.php12
2 files changed, 36 insertions, 5 deletions
diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc
index 0b65170..49bedc3 100644
--- a/web/lib/pkgfuncs.inc
+++ b/web/lib/pkgfuncs.inc
@@ -194,9 +194,25 @@ function create_dummy($pname="", $sid="") {
}
-# grab package comments
-#
-function package_comments($pkgid=0) {
+# Return the number of comments for a specified package
+function package_comments_count($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();
if ($pkgid) {
$dbh = db_connect();
@@ -206,6 +222,11 @@ function package_comments($pkgid=0) {
$q.= " AND PackageID = ".mysql_real_escape_string($pkgid);
$q.= " AND DelUsersID = 0"; # only display non-deleted comments
$q.= " ORDER BY CommentTS DESC";
+
+ if (!isset($_GET['comments'])) {
+ $q.= " LIMIT 10";
+ }
+
$result = db_query($q, $dbh);
if (!$result) {
@@ -328,7 +349,7 @@ function package_details($id=0, $SID="") {
include('actions_form.php');
include('pkg_comment_form.php');
}
-
+
# Print Comments
$comments = package_comments($id);
if (!empty($comments)) {
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php
index 7c42ac1..02171a0 100644
--- a/web/template/pkg_comments.php
+++ b/web/template/pkg_comments.php
@@ -24,5 +24,15 @@ while (list($indx, $carr) = each($comments)) { ?>
</div>
</blockquote>
<?php
-} ?>
+}
+?>
</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>';
+}
+?>