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 .= '
'; + if($_GET['page'] > 1) + $previous .= ''; + $previous .= 'Previous'; + $previous .= ''; + // Next Button + $next = ''; + if($_GET['page'] < $max_pages) + $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'])) { 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 .= '
'; - if($_GET['page'] > 1) - $previous .= ''; - $previous .= 'Previous'; - $previous .= ''; - // Next Button - $next = ''; - if($_GET['page'] < $max_pages) - $next .= ''; - $next .= ' Next'; - $next .= ''; - // Comments Amount - $comment_amount = ''; - $comment_amount .= ' ' .$comment_count.' Comments
'; - // Call the data - echo $previous; - echo $next; - echo $comment_amount; + // Previous Button + $previous = ''; + $previous .= '
'; + if($_GET['page'] > 1) + $previous .= ''; + $previous .= 'Previous'; + $previous .= ''; + // Next Button + $next = ''; + if($_GET['page'] < $max_pages) + if($_GET['page'] == 0) //the page=1 url doesn't show up at first so need to count from 2 at the beginning + $next .= ''; + else + $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'])) { 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 .= ''; $next .= ' Next'; $next .= ''; + // Page Amount + $page_amount = ''; + $page_amount .= ' ' .$max_pages.' Pages'; // Call the data echo $previous; echo $next; + echo $page_amount; // now display the comments if (isset($data['comments'])) { From 04352ee4aa8009d73b4f2d5430c412b1a2bbf2c6 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Mon, 3 Dec 2018 02:12:41 +0100 Subject: [PATCH 10/16] I think this finally fixed the php 7.2 count error. had to insert it directly instead of a variable. --- action.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.php b/action.php index 568b91b..02a17bc 100644 --- a/action.php +++ b/action.php @@ -475,12 +475,16 @@ protected function _show($reply = null, $edit = null) { $next .= ''; $next .= ' Next'; $next .= ''; + // Comment Amount + $comment_amount = ''; + $comment_amount .= ' ' .count($data['comments']).' Comments'; // Page Amount $page_amount = ''; $page_amount .= ' ' .$max_pages.' Pages'; // Call the data echo $previous; echo $next; + echo $comment_amount; echo $page_amount; // now display the comments From 631772a37994f4d32789be7b4b16d742f3c743a0 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Mon, 3 Dec 2018 02:22:34 +0100 Subject: [PATCH 11/16] Update action.php --- action.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/action.php b/action.php index 02a17bc..568b91b 100644 --- a/action.php +++ b/action.php @@ -475,16 +475,12 @@ protected function _show($reply = null, $edit = null) { $next .= ''; $next .= ' Next'; $next .= ''; - // Comment Amount - $comment_amount = ''; - $comment_amount .= ' ' .count($data['comments']).' Comments'; // Page Amount $page_amount = ''; $page_amount .= ' ' .$max_pages.' Pages'; // Call the data echo $previous; echo $next; - echo $comment_amount; echo $page_amount; // now display the comments From ec095311fbe212580fb47c0e857b2023c58434d0 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Mon, 3 Dec 2018 02:34:17 +0100 Subject: [PATCH 12/16] Removed comment_count variable Whoops count was already defined. this should also fix the php 7.2 count bug for good this time... I hope --- action.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.php b/action.php index 568b91b..ed3b03c 100644 --- a/action.php +++ b/action.php @@ -435,9 +435,8 @@ 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']); // How many pages will there be - $max_pages = ceil($comment_count / $nItemsPerPage); + $max_pages = ceil($cnt / $nItemsPerPage); // What page are we currently on? $page = min($max_pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( @@ -475,12 +474,16 @@ protected function _show($reply = null, $edit = null) { $next .= ''; $next .= ' Next'; $next .= ''; + // Comment Amount + $comment_amount = ''; + $comment_amount .= ' ' .$cnt.' Comments'; // Page Amount $page_amount = ''; $page_amount .= ' ' .$max_pages.' Pages'; // Call the data echo $previous; echo $next; + echo $comment_amount; echo $page_amount; // now display the comments From 2cd6c430f233f8c93de75bb53d46208a95772eb9 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Tue, 4 Dec 2018 00:09:27 +0100 Subject: [PATCH 13/16] forgot to remove a comment --- action.php | 1 - 1 file changed, 1 deletion(-) diff --git a/action.php b/action.php index ed3b03c..f7f6091 100644 --- a/action.php +++ b/action.php @@ -434,7 +434,6 @@ protected function _show($reply = null, $edit = null) { // How many items to list per page $nItemsPerPage = 50; - // amount of comments made // How many pages will there be $max_pages = ceil($cnt / $nItemsPerPage); // What page are we currently on? From 34d58620c001ebf70685160dec3fb41f232470ec Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Sat, 15 Dec 2018 14:49:20 +0100 Subject: [PATCH 14/16] updates code a little bit. --- action.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/action.php b/action.php index f7f6091..8f5a2f0 100644 --- a/action.php +++ b/action.php @@ -459,31 +459,30 @@ protected function _show($reply = null, $edit = null) { } // Previous Button $previous = ''; - $previous .= '
'; - if($_GET['page'] > 1) + if($_GET['page'] > 1){ $previous .= ''; $previous .= 'Previous'; $previous .= ''; + } // Next Button $next = ''; - if($_GET['page'] < $max_pages) - if($_GET['page'] == 0) //the page=1 url doesn't show up at first so need to count from 2 at the beginning + if($_GET['page'] < $max_pages){ + if($_GET['page'] == 0){ //the page=1 url doesn't show up at first so need to count from 2 at the beginning $next .= ''; - else + }else{ $next .= ''; + } $next .= ' Next'; $next .= ''; + } // Comment Amount $comment_amount = ''; $comment_amount .= ' ' .$cnt.' Comments'; // Page Amount $page_amount = ''; - $page_amount .= ' ' .$max_pages.' Pages
'; + $page_amount .= ' ' .$max_pages.' Pages'; // Call the data - echo $previous; - echo $next; - echo $comment_amount; - echo $page_amount; + echo '
'.$previous, $next, $page_amount.'
'.NL; // now display the comments if (isset($data['comments'])) { From b15e08755bd723b380475c9660da69600f7b6b91 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Sat, 15 Dec 2018 14:54:55 +0100 Subject: [PATCH 15/16] Update action.php --- action.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/action.php b/action.php index 8f5a2f0..81f0e8c 100644 --- a/action.php +++ b/action.php @@ -459,22 +459,19 @@ protected function _show($reply = null, $edit = null) { } // Previous Button $previous = ''; - if($_GET['page'] > 1){ + if($_GET['page'] > 1) $previous .= ''; $previous .= 'Previous'; $previous .= ''; - } // Next Button $next = ''; - if($_GET['page'] < $max_pages){ + if($_GET['page'] < $max_pages) if($_GET['page'] == 0){ //the page=1 url doesn't show up at first so need to count from 2 at the beginning $next .= ''; - }else{ + else $next .= ''; - } $next .= ' Next'; $next .= ''; - } // Comment Amount $comment_amount = ''; $comment_amount .= ' ' .$cnt.' Comments'; From d20da5adf18ff6fc2aa4157f091bc314f1f79841 Mon Sep 17 00:00:00 2001 From: 3P1 <43551242+H1K1CH4N@users.noreply.github.com> Date: Sat, 15 Dec 2018 14:56:44 +0100 Subject: [PATCH 16/16] Update action.php --- action.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.php b/action.php index 81f0e8c..c13139f 100644 --- a/action.php +++ b/action.php @@ -466,7 +466,7 @@ protected function _show($reply = null, $edit = null) { // Next Button $next = ''; if($_GET['page'] < $max_pages) - if($_GET['page'] == 0){ //the page=1 url doesn't show up at first so need to count from 2 at the beginning + if($_GET['page'] == 0)//the page=1 url doesn't show up at first so need to count from 2 at the beginning $next .= ''; else $next .= '';