diff --git a/application/config/constants.php b/application/config/constants.php index 155841340..77633c2ef 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -53,6 +53,9 @@ define('QSO_PAGE_QSOS_COUNT_LIMIT', 20); define('USER_SLUG_LENGTH', 10); +define('QSO_WIDGET_DEFAULT_QSO_LIMIT', 15); +define('QSO_WIDGET_MAX_QSO_LIMIT', 50); + /* End of file constants.php */ /* Location: ./application/config/constants.php */ diff --git a/application/controllers/Widgets.php b/application/controllers/Widgets.php index 40d94275f..05192360a 100644 --- a/application/controllers/Widgets.php +++ b/application/controllers/Widgets.php @@ -14,14 +14,47 @@ class Widgets extends CI_Controller { } - // Can be used to embed last 11 QSOs in a iframe or javascript include. + // Can be used to embed last few QSOs public function qsos($logbook_slug = null) { if($logbook_slug == null) { show_error(__("Unknown Public Page, please make sure the public slug is correct.")); } - $this->load->model('logbook_model'); + // determine theme + $this->load->model('themes_model'); + $theme = $this->input->get('theme', TRUE); + if ($theme != null) { + if (($this->themes_model->get_theme_mode($theme) ?? '') != '') { + $data['theme'] = $theme; + } else { + $data['theme'] = $this->config->item('option_theme'); + } + } else { + $data['theme'] = "default"; + } + + // should we show time? + // TODO + $data['show_time'] = (($this->config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))); + $data['show_time'] = true; + + // determine text size + $text_size = $this->input->get('text_size', true) ?? 1; + $data['text_size_class'] = $this->prepare_text_size_css_class($text_size); + + // number of QSOs shown + $qso_count_param = $this->input->get('qso_count', TRUE); + if ($qso_count_param != null) { + $qso_count = min($qso_count_param, QSO_WIDGET_MAX_QSO_LIMIT); + } else { + $qso_count = QSO_WIDGET_DEFAULT_QSO_LIMIT; + } + + // date format + $data['date_format'] = $this->config->item('qso_date_format'); // date format from /config/wavelog.php + + $this->load->model('logbook_model'); $this->load->model('logbooks_model'); if($this->logbooks_model->public_slug_exists($logbook_slug)) { // Load the public view @@ -40,7 +73,7 @@ class Widgets extends CI_Controller { show_404(__("Unknown Public Page.")); } - $data['last_qsos_list'] = $this->logbook_model->get_last_qsos(15, $logbooks_locations_array); + $data['last_qsos_list'] = $this->logbook_model->get_last_qsos($qso_count, $logbooks_locations_array); $this->load->view('widgets/qsos', $data); } diff --git a/application/views/widgets/qsos.php b/application/views/widgets/qsos.php index 832b75a76..e95300471 100644 --- a/application/views/widgets/qsos.php +++ b/application/views/widgets/qsos.php @@ -1,64 +1,45 @@ - <?= __("QSOs"); ?> - + + + + + + + + <?= "QSOs"; ?> -config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { - $show_time = true; -} else { - $show_time = false; -} ?> - - - +
- - - - - - - - - + + + + + + session->userdata('user_date_format')) { - // If Logged in and session exists - $custom_date_format = $this->session->userdata('user_date_format'); - } else { - // Get Default date format from /config/wavelog.php - $custom_date_format = $this->config->item('qso_date_format'); - } - $i = 0; foreach ($last_qsos_list->result() as $row) { ?> '; ?> - - - - - - - - + + + + + COL_SAT_NAME != null) { ?> - + - +
COL_TIME_ON); echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); echo date('H:i', $timestamp); ?>COL_CALL)); ?>COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?>COL_RST_SENT; ?> COL_STX_STRING) { ?>(COL_STX_STRING;?>)COL_RST_RCVD; ?> COL_SRX_STRING) { ?>(COL_SRX_STRING;?>) + COL_TIME_ON); echo date($date_format, $timestamp); ?> + + COL_TIME_ON); echo date('H:i', $timestamp); ?> + + COL_CALL)); ?>COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?>COL_RST_SENT; ?> COL_STX_STRING) { ?>(COL_STX_STRING;?>)COL_RST_RCVD; ?> COL_SRX_STRING) { ?>(COL_SRX_STRING;?>) COL_SAT_NAME; ?>COL_SAT_NAME; ?> COL_BAND; ?>COL_BAND; ?>