[v3,2/2] Allow paginating package comments

Message ID 20180722155436.22293-2-johannes@kyriasis.com
State Superseded, archived
Headers show
Series [v3,1/2] Allow listing all comments from a user | expand

Commit Message

Johannes Löthberg July 22, 2018, 3:54 p.m. UTC
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
---
 web/lib/pkgbasefuncs.inc.php | 5 +++--
 web/lib/pkgfuncs.inc.php     | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Lukas Fleischer Aug. 5, 2018, 4:32 p.m. UTC | #1
On Sun, 22 Jul 2018 at 17:54:36, Johannes Löthberg wrote:
> Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
> ---
>  web/lib/pkgbasefuncs.inc.php | 5 +++--
>  web/lib/pkgfuncs.inc.php     | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> [...]

Great! Does this also mean we actually get paginated package comments or
does this only make pagination possible by manually adding GET
parameters to the URL?

Best regards,
Lukas
Johannes Löthberg Aug. 5, 2018, 11:58 p.m. UTC | #2
Quoting Lukas Fleischer (2018-08-05 18:32:56)
> On Sun, 22 Jul 2018 at 17:54:36, Johannes Löthberg wrote:
> > Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
> > ---
> >  web/lib/pkgbasefuncs.inc.php | 5 +++--
> >  web/lib/pkgfuncs.inc.php     | 5 +++--
> >  2 files changed, 6 insertions(+), 4 deletions(-)
> > [...]
> 
> Great! Does this also mean we actually get paginated package comments or
> does this only make pagination possible by manually adding GET
> parameters to the URL?
> 

Proper pagination for everything.

Patch

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');