From 5a50a38395033caf5fceda4627679e3923213189 Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Tue, 23 Jul 2024 14:13:56 +0200 Subject: [PATCH] adjustments --- application/controllers/Widgets.php | 40 ++++++++----------- application/libraries/OptionsLib.php | 6 ++- .../oqrs_widget.php => widgets/oqrs.php} | 20 ++++------ 3 files changed, 27 insertions(+), 39 deletions(-) rename application/views/{oqrs/oqrs_widget.php => widgets/oqrs.php} (85%) diff --git a/application/controllers/Widgets.php b/application/controllers/Widgets.php index c8ec87163..47b5637ea 100644 --- a/application/controllers/Widgets.php +++ b/application/controllers/Widgets.php @@ -46,26 +46,7 @@ class Widgets extends CI_Controller { } } - public function oqrs($logbook_slug = null) { - if ($logbook_slug == null || !$this->logbooks_model->public_slug_exists($logbook_slug)) { - show_404(__("Unknown Public Page, please make sure the public slug is correct.")); - return; - } - - $logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug); - if ($logbook_id == false) { - show_404(__("Unknown Public Page, please make sure the public slug is correct.")); - return; - } - $this->load->model('user_model'); - $this->load->model('stationsetup_model'); - $user_callsign = $this->user_model->get_by_id($this->stationsetup_model->public_slug_exists_userid($logbook_slug))->row()->user_callsign; - if ($user_callsign == false) { - log_message('error', 'No user_id or user_callsign for public slug: '. $logbook_slug); - show_404(__("Can't find any users for this public slug.")); - return; - } - + public function oqrs($user_callsign) { $this->load->model('oqrs_model'); $stations = $this->oqrs_model->get_oqrs_stations(); @@ -73,11 +54,22 @@ class Widgets extends CI_Controller { show_404(__("No stations found that are using Wavelog OQRS.")); return; } + + $slug = $this->security->xss_clean($this->input->get('slug')); + if ($slug != null) { + $data['logo_url'] = site_url() . '/visitor/' . $slug; + } else { + $data['logo_url'] = 'https://github.com/wavelog/wavelog'; + } + + $theme = $this->security->xss_clean($this->input->get('theme')); + if ($theme != null) { + $data['theme'] = $theme; + } else { + $data['theme'] = $this->config->item('option_theme'); + } - $data['slug'] = $logbook_slug; $data['user_callsign'] = $user_callsign; - $data['groupedSearch'] = $this->optionslib->get_option('groupedSearch'); - - $this->load->view('oqrs/oqrs_widget', $data); + $this->load->view('widgets/oqrs', $data); } } \ No newline at end of file diff --git a/application/libraries/OptionsLib.php b/application/libraries/OptionsLib.php index 81716aa0b..ded8483c3 100644 --- a/application/libraries/OptionsLib.php +++ b/application/libraries/OptionsLib.php @@ -119,12 +119,14 @@ class OptionsLib { } - function get_logo($logo_location) { + function get_logo($logo_location, $theme = null) { $CI =& get_instance(); // get the theme with the get_theme() function above - $theme = $this->get_theme(); + if ($theme == null) { + $theme = $this->get_theme(); + } // load the themes model and fetch the logo name from it $CI->load->model('Themes_model'); diff --git a/application/views/oqrs/oqrs_widget.php b/application/views/widgets/oqrs.php similarity index 85% rename from application/views/oqrs/oqrs_widget.php rename to application/views/widgets/oqrs.php index 2d4ee76e1..bfe106ec1 100644 --- a/application/views/oqrs/oqrs_widget.php +++ b/application/views/widgets/oqrs.php @@ -14,20 +14,14 @@ To use this widget insert this Element: - - + + <?= __("Wavelog OQRS"); ?>