From c23f38740d82f05987793664c07305120e9b9dd4 Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Sun, 2 Dec 2018 23:44:59 +0100
Subject: [PATCH 01/16] Ads Pagination to the comments section
default starts with 20 comments.
Needs some refinements.
---
action.php | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
diff --git a/action.php b/action.php
index 3756317..84c3430 100644
--- a/action.php
+++ b/action.php
@@ -431,7 +431,54 @@ protected function _show($reply = null, $edit = null) {
ptln('', 2);
ptln('
', 2);
}
-
+
+ // How many items to list per page
+ $nItemsPerPage = 20;
+ // amount of comments made
+ $comment_count = $data['comments'] && count($data['comments']);
+ // How many pages will there be
+ $max_pages = ceil($comment_count / $nItemsPerPage);
+ // What page are we currently on?
+ $page = min($max_pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
+ 'options' => array(
+ 'default' => 1,
+ 'min_range' => 1,
+ ),
+ )));
+ // now display the comments
+ if (isset($data['comments'])) {
+ if (!$this->getConf('usethreading')) {
+ $data['comments'] = $this->_flattenThreads($data['comments']);
+ uasort($data['comments'], '_sortCallback');
+ }
+ if($this->getConf('newestfirst')) {
+ $data['comments'] = array_reverse($data['comments']);
+ }
+ foreach (array_slice ($data['comments'], $nItemsPerPage*($page-1), $nItemsPerPage) as $key => $value) {
+ if ($key == $edit) $this->_form($value['raw'], 'save', $edit); // edit form
+ else $this->_print($key, $data, '', $reply);
+ }
+ }
+ // Previous Button
+ $previous = '';
+ $previous .= '
';
+ // Call the data
+ echo $previous;
+ echo $next;
+ echo $comment_amount;
// now display the comments
if (isset($data['comments'])) {
if (!$this->getConf('usethreading')) {
From 1cf237f5ea8d853eafbe38d41bd72fa708296bed Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 00:02:36 +0100
Subject: [PATCH 02/16] Update action.php
---
action.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/action.php b/action.php
index 84c3430..95cba29 100644
--- a/action.php
+++ b/action.php
@@ -435,7 +435,7 @@ protected function _show($reply = null, $edit = null) {
// How many items to list per page
$nItemsPerPage = 20;
// amount of comments made
- $comment_count = $data['comments'] && count($data['comments']);
+ $comment_count = count($data['comments']); //gives an error in php 7.2
// How many pages will there be
$max_pages = ceil($comment_count / $nItemsPerPage);
// What page are we currently on?
From 5296aba6c05ec3e4f52a94e6a9f3164799e0311e Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 00:22:14 +0100
Subject: [PATCH 03/16] fixed pag=1 error and improved the layout
---
action.php | 62 +++++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 29 deletions(-)
diff --git a/action.php b/action.php
index 95cba29..e92da17 100644
--- a/action.php
+++ b/action.php
@@ -433,16 +433,16 @@ protected function _show($reply = null, $edit = null) {
}
// How many items to list per page
- $nItemsPerPage = 20;
+ $nItemsPerPage = 50;
// amount of comments made
- $comment_count = count($data['comments']); //gives an error in php 7.2
- // How many pages will there be
- $max_pages = ceil($comment_count / $nItemsPerPage);
- // What page are we currently on?
- $page = min($max_pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
- 'options' => array(
- 'default' => 1,
- 'min_range' => 1,
+ $comment_count = count($data['comments']);
+ // How many pages will there be
+ $max_pages = ceil($comment_count / $nItemsPerPage);
+ // What page are we currently on?
+ $page = min($max_pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
+ 'options' => array(
+ 'default' => 1,
+ 'min_range' => 1,
),
)));
// now display the comments
@@ -459,26 +459,30 @@ protected function _show($reply = null, $edit = null) {
else $this->_print($key, $data, '', $reply);
}
}
- // Previous Button
- $previous = '';
- $previous .= '
';
- // Call the data
- echo $previous;
- echo $next;
- echo $comment_amount;
+ // Previous Button
+ $previous = '';
+ $previous .= '
';
+ // Call the data
+ echo $previous;
+ echo $next;
+ echo $comment_amount;
+
// now display the comments
if (isset($data['comments'])) {
if (!$this->getConf('usethreading')) {
From de9e755ab27cf4dc2fba152a4df6862eca90b5fb Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 00:23:57 +0100
Subject: [PATCH 04/16] Update action.php
---
action.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/action.php b/action.php
index e92da17..a7aa3d8 100644
--- a/action.php
+++ b/action.php
@@ -454,7 +454,7 @@ protected function _show($reply = null, $edit = null) {
if($this->getConf('newestfirst')) {
$data['comments'] = array_reverse($data['comments']);
}
- foreach (array_slice ($data['comments'], $nItemsPerPage*($page-1), $nItemsPerPage) as $key => $value) {
+ foreach (array_slice ($data['comments'], $nItemsPerPage*($page-1), $nItemsPerPage) as $key => $value) {
if ($key == $edit) $this->_form($value['raw'], 'save', $edit); // edit form
else $this->_print($key, $data, '', $reply);
}
From e1ad50afd5ec64f64cb5974bc721a4f61d2c7a29 Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 01:04:28 +0100
Subject: [PATCH 05/16] This fixes the php 7.2 php count error when there is no
content
---
action.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/action.php b/action.php
index a7aa3d8..c64ad0c 100644
--- a/action.php
+++ b/action.php
@@ -435,7 +435,7 @@ protected function _show($reply = null, $edit = null) {
// How many items to list per page
$nItemsPerPage = 50;
// amount of comments made
- $comment_count = count($data['comments']);
+ $comment_count = is_array($data['comments']) ? count($data['comments']) : 1;
// How many pages will there be
$max_pages = ceil($comment_count / $nItemsPerPage);
// What page are we currently on?
@@ -443,8 +443,8 @@ protected function _show($reply = null, $edit = null) {
'options' => array(
'default' => 1,
'min_range' => 1,
- ),
- )));
+ ),
+ )));
// now display the comments
if (isset($data['comments'])) {
if (!$this->getConf('usethreading')) {
From b88629f7ce58bbf8983e1c3ac97997a57085c1e1 Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 01:42:26 +0100
Subject: [PATCH 06/16] Update action.php
---
action.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/action.php b/action.php
index c64ad0c..218733f 100644
--- a/action.php
+++ b/action.php
@@ -435,7 +435,7 @@ protected function _show($reply = null, $edit = null) {
// How many items to list per page
$nItemsPerPage = 50;
// amount of comments made
- $comment_count = is_array($data['comments']) ? count($data['comments']) : 1;
+ $comment_count = count($data['comments']);
// How many pages will there be
$max_pages = ceil($comment_count / $nItemsPerPage);
// What page are we currently on?
From bfe5a69a838f95388da8fd0bde4a8d62271c8240 Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 01:47:31 +0100
Subject: [PATCH 07/16] Update action.php
---
action.php | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/action.php b/action.php
index 218733f..1573dca 100644
--- a/action.php
+++ b/action.php
@@ -435,7 +435,7 @@ protected function _show($reply = null, $edit = null) {
// How many items to list per page
$nItemsPerPage = 50;
// amount of comments made
- $comment_count = count($data['comments']);
+ $comment_count = count($data);
// How many pages will there be
$max_pages = ceil($comment_count / $nItemsPerPage);
// What page are we currently on?
@@ -475,13 +475,9 @@ protected function _show($reply = null, $edit = null) {
$next .= '
';
$next .= ' Next';
$next .= '';
- // Comments Amount
- $comment_amount = '';
- $comment_amount .= '
'.$comment_count.' Comments ';
// Call the data
echo $previous;
echo $next;
- echo $comment_amount;
// now display the comments
if (isset($data['comments'])) {
From 7ee682588bc511c862b104defc6023d8efd7228f Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 01:48:34 +0100
Subject: [PATCH 08/16] Update action.php
---
action.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/action.php b/action.php
index 1573dca..ade1089 100644
--- a/action.php
+++ b/action.php
@@ -435,7 +435,7 @@ protected function _show($reply = null, $edit = null) {
// How many items to list per page
$nItemsPerPage = 50;
// amount of comments made
- $comment_count = count($data);
+ $comment_count = count($data['comments']);
// How many pages will there be
$max_pages = ceil($comment_count / $nItemsPerPage);
// What page are we currently on?
From 1571aab6af1d34d5ad945747ebed1cc96557baab Mon Sep 17 00:00:00 2001
From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com>
Date: Mon, 3 Dec 2018 01:51:12 +0100
Subject: [PATCH 09/16] Removed content count because of php 7.2 bug add
page_amount
---
action.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/action.php b/action.php
index ade1089..568b91b 100644
--- a/action.php
+++ b/action.php
@@ -475,9 +475,13 @@ protected function _show($reply = null, $edit = null) {
$next .= '