[PATCH v3 2/2] Allow paginating package comments

Johannes Löthberg johannes at kyriasis.com
Sun Jul 22 15:54:36 UTC 2018


Signed-off-by: Johannes Löthberg <johannes at kyriasis.com>
---
 web/lib/pkgbasefuncs.inc.php | 5 +++--
 web/lib/pkgfuncs.inc.php     | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 953a581..eb22c38 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -291,9 +291,10 @@ function pkgbase_display_details($base_id, $row, $SID="") {
 		unset($pinned);
 
 
-		$limit = isset($_GET['comments']) ? 0 : 10;
-		$comments = pkgbase_comments($base_id, $limit, $include_deleted);
+		$total_comment_count = pkgbase_comments_count($base_id, $include_deleted);
+		[$pagination_templs, $per_page, $offset] = calculate_pagination($total_comment_count);
 
+		$comments = pkgbase_comments($base_id, $per_page, $include_deleted, false, $offset);
 		if (!empty($comments)) {
 			$comment_section = "package";
 			include('pkg_comments.php');
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 140b8fc..c9aef36 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -630,9 +630,10 @@ function pkg_display_details($id=0, $row, $SID="") {
 		unset($pinned);
 
 
-		$limit = isset($_GET['comments']) ? 0 : 10;
-		$comments = pkgbase_comments($base_id, $limit, $include_deleted);
+		$total_comment_count = pkgbase_comments_count($base_id, $include_deleted);
+		[$pagination_templs, $per_page, $offset] = calculate_pagination($total_comment_count);
 
+		$comments = pkgbase_comments($base_id, $per_page, $include_deleted, false, $offset);
 		if (!empty($comments)) {
 			$comment_section = "package";
 			include('pkg_comments.php');
-- 
2.18.0


More information about the aur-dev mailing list