From 6330d5df77f7e5804e0afed53ae057504d27f2ef Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Tue, 2 Apr 2024 09:51:10 -0500 Subject: [PATCH 1/5] added pagination to visitor page only if the public search option is enabled --- application/controllers/Visitor.php | 39 +++++++++++++++++++++++++++-- application/views/visitor/index.php | 11 +++++--- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 92fe41d3..82a278ac 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -75,6 +75,38 @@ class Visitor extends CI_Controller { $this->load->model('logbook_model'); + // Only load, config, and init pagination if public search is enabled + if ($this ->public_search_enabled($public_slug)) { + $this->load->library('pagination'); + + //Pagination config + $config['base_url'] = base_url().'index.php/visitor/'. $public_slug . '/index'; + $config['total_rows'] = $this->logbook_model->total_qsos($logbooks_locations_array); + $config['per_page'] = '25'; + $config['num_links'] = $this->logbook_model->total_qsos($logbooks_locations_array) / 25; + $config['full_tag_open'] = ''; + $config['attributes'] = ['class' => 'page-link']; + $config['first_link'] = false; + $config['last_link'] = false; + $config['first_tag_open'] = '
  • '; + $config['first_tag_close'] = '
  • '; + $config['prev_link'] = '«'; + $config['prev_tag_open'] = '
  • '; + $config['prev_tag_close'] = '
  • '; + $config['next_link'] = '»'; + $config['next_tag_open'] = '
  • '; + $config['next_tag_close'] = '
  • '; + $config['last_tag_open'] = '
  • '; + $config['last_tag_close'] = '
  • '; + $config['cur_tag_open'] = '
  • '; + $config['cur_tag_close'] = '(current)
  • '; + $config['num_tag_open'] = '
  • '; + $config['num_tag_close'] = '
  • '; + + $this->pagination->initialize($config); + } + // Public visitor so no QRA to setup $data['qra'] = "none"; @@ -107,8 +139,11 @@ class Visitor extends CI_Controller { $data['total_lotw_sent'] = $QSLStatsBreakdownArray['LoTW_Sent']; $data['total_lotw_rcvd'] = $QSLStatsBreakdownArray['LoTW_Received']; - - $data['last_five_qsos'] = $this->logbook_model->get_last_qsos('18', $logbooks_locations_array); + + // If public search is enabled, show paginated results, otherwise show last 18 qsos + $data['results'] = $this->public_search_enabled($public_slug) + ? $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(4), $logbooks_locations_array) + : $this->logbook_model->get_last_qsos('18', $logbooks_locations_array); $data['page_title'] = "Dashboard"; $data['slug'] = $public_slug; diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 898e9fcd..6a191cce 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -79,13 +79,13 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { 0) { - foreach ($last_five_qsos->result() as $row) { ?> + if(!empty($results) > 0) { + foreach ($results->result() as $row) { ?> '; ?> session->userdata('user_date_format')) { // If Logged in and session exists @@ -114,6 +114,11 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { + CI->public_search_enabled($slug)) { ?> + + From c2c2b0f395492c8c04c7a15f8e746a9ca0ecf527 Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Tue, 2 Apr 2024 10:14:01 -0500 Subject: [PATCH 2/5] self reivew, simplify logic on checking if results is empty --- application/views/visitor/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 6a191cce..b063a249 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -81,7 +81,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { 0) { + if(!empty($results)) { foreach ($results->result() as $row) { ?> '; ?> From eab8af806802996247172e29dedf478eed3e2074 Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Tue, 2 Apr 2024 10:15:25 -0500 Subject: [PATCH 3/5] remove errant empty line addition --- application/views/visitor/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index b063a249..011f3e81 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -79,7 +79,6 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { result() as $row) { ?> From b0a7eef25e8cae3e5d9da6699945bc2288f59c8c Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Thu, 4 Apr 2024 07:39:00 -0500 Subject: [PATCH 4/5] remove search_enabled config requirement --- application/controllers/Visitor.php | 63 ++++++++++++++--------------- application/views/visitor/index.php | 8 ++-- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 82a278ac..571ce2c7 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -75,37 +75,36 @@ class Visitor extends CI_Controller { $this->load->model('logbook_model'); - // Only load, config, and init pagination if public search is enabled - if ($this ->public_search_enabled($public_slug)) { - $this->load->library('pagination'); - - //Pagination config - $config['base_url'] = base_url().'index.php/visitor/'. $public_slug . '/index'; - $config['total_rows'] = $this->logbook_model->total_qsos($logbooks_locations_array); - $config['per_page'] = '25'; - $config['num_links'] = $this->logbook_model->total_qsos($logbooks_locations_array) / 25; - $config['full_tag_open'] = '
      '; - $config['full_tag_close'] = '
    '; - $config['attributes'] = ['class' => 'page-link']; - $config['first_link'] = false; - $config['last_link'] = false; - $config['first_tag_open'] = '
  • '; - $config['first_tag_close'] = '
  • '; - $config['prev_link'] = '«'; - $config['prev_tag_open'] = '
  • '; - $config['prev_tag_close'] = '
  • '; - $config['next_link'] = '»'; - $config['next_tag_open'] = '
  • '; - $config['next_tag_close'] = '
  • '; - $config['last_tag_open'] = '
  • '; - $config['last_tag_close'] = '
  • '; - $config['cur_tag_open'] = '
  • '; - $config['cur_tag_close'] = '(current)
  • '; - $config['num_tag_open'] = '
  • '; - $config['num_tag_close'] = '
  • '; + // load config and init pagination + $this->load->library('pagination'); + + //Pagination config + $config['base_url'] = base_url().'index.php/visitor/'. $public_slug . '/index'; + $config['total_rows'] = $this->logbook_model->total_qsos($logbooks_locations_array); + $config['per_page'] = '25'; + $config['num_links'] = $this->logbook_model->total_qsos($logbooks_locations_array) / 25; + $config['full_tag_open'] = '
      '; + $config['full_tag_close'] = '
    '; + $config['attributes'] = ['class' => 'page-link']; + $config['first_link'] = false; + $config['last_link'] = false; + $config['first_tag_open'] = '
  • '; + $config['first_tag_close'] = '
  • '; + $config['prev_link'] = '«'; + $config['prev_tag_open'] = '
  • '; + $config['prev_tag_close'] = '
  • '; + $config['next_link'] = '»'; + $config['next_tag_open'] = '
  • '; + $config['next_tag_close'] = '
  • '; + $config['last_tag_open'] = '
  • '; + $config['last_tag_close'] = '
  • '; + $config['cur_tag_open'] = '
  • '; + $config['cur_tag_close'] = '(current)
  • '; + $config['num_tag_open'] = '
  • '; + $config['num_tag_close'] = '
  • '; + + $this->pagination->initialize($config); - $this->pagination->initialize($config); - } // Public visitor so no QRA to setup $data['qra'] = "none"; @@ -141,9 +140,7 @@ class Visitor extends CI_Controller { $data['total_lotw_rcvd'] = $QSLStatsBreakdownArray['LoTW_Received']; // If public search is enabled, show paginated results, otherwise show last 18 qsos - $data['results'] = $this->public_search_enabled($public_slug) - ? $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(4), $logbooks_locations_array) - : $this->logbook_model->get_last_qsos('18', $logbooks_locations_array); + $data['results'] = $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(4), $logbooks_locations_array); $data['page_title'] = "Dashboard"; $data['slug'] = $public_slug; diff --git a/application/views/visitor/index.php b/application/views/visitor/index.php index 011f3e81..9edffdc1 100644 --- a/application/views/visitor/index.php +++ b/application/views/visitor/index.php @@ -113,11 +113,9 @@ function echoQrbCalcLink($mygrid, $grid, $vucc) { - CI->public_search_enabled($slug)) { ?> - - + From 83ad320e0207acfd02770b416799d491178b3e08 Mon Sep 17 00:00:00 2001 From: Patrick Burns Date: Thu, 4 Apr 2024 07:40:27 -0500 Subject: [PATCH 5/5] fix comment --- application/controllers/Visitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Visitor.php b/application/controllers/Visitor.php index 571ce2c7..815db34d 100644 --- a/application/controllers/Visitor.php +++ b/application/controllers/Visitor.php @@ -139,7 +139,7 @@ class Visitor extends CI_Controller { $data['total_lotw_sent'] = $QSLStatsBreakdownArray['LoTW_Sent']; $data['total_lotw_rcvd'] = $QSLStatsBreakdownArray['LoTW_Received']; - // If public search is enabled, show paginated results, otherwise show last 18 qsos + // Show paginated results $data['results'] = $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(4), $logbooks_locations_array); $data['page_title'] = "Dashboard";