Make QSO widget better looking and more configurable

This commit is contained in:
Filip Melík
2025-02-27 21:22:29 +01:00
parent cd386cb92c
commit 3ba53828bb
3 changed files with 66 additions and 49 deletions

View File

@@ -53,6 +53,9 @@ define('QSO_PAGE_QSOS_COUNT_LIMIT', 20);
define('USER_SLUG_LENGTH', 10); define('USER_SLUG_LENGTH', 10);
define('QSO_WIDGET_DEFAULT_QSO_LIMIT', 15);
define('QSO_WIDGET_MAX_QSO_LIMIT', 50);
/* End of file constants.php */ /* End of file constants.php */
/* Location: ./application/config/constants.php */ /* Location: ./application/config/constants.php */

View File

@@ -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) { public function qsos($logbook_slug = null) {
if($logbook_slug == null) { if($logbook_slug == null) {
show_error(__("Unknown Public Page, please make sure the public slug is correct.")); 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'); $this->load->model('logbooks_model');
if($this->logbooks_model->public_slug_exists($logbook_slug)) { if($this->logbooks_model->public_slug_exists($logbook_slug)) {
// Load the public view // Load the public view
@@ -40,7 +73,7 @@ class Widgets extends CI_Controller {
show_404(__("Unknown Public Page.")); 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); $this->load->view('widgets/qsos', $data);
} }

View File

@@ -1,64 +1,45 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head> <head>
<title><?= __("QSOs"); ?></title> <meta charset="UTF-8">
<style type="text/css" media="screen"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
body {
font-family: Arial, "MS Trebuchet", sans-serif; <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/<?php echo $theme; ?>/bootstrap.min.css">
} <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/<?php echo $theme; ?>/overrides.css">
.titles th { <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/general.css">
font-weight: bold;
text-align: left; <title><?= "QSOs"; ?></title>
}
</style>
</head> </head>
<?php if (($this->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;
} ?>
<body> <body>
<table width="100%" class="zebra-striped"> <table width="100%" class="table table-striped">
<tr class="titles"> <tr class="titles">
<th><?= __("Date"); ?></th> <th class="<?= $text_size_class ?>"><?= __("Date"); ?></th>
<?php if ($show_time) { ?> <th class="<?= $text_size_class ?>"><?= __("Call"); ?></th>
<th><?= __("Time"); ?></th> <th class="<?= $text_size_class ?>"><?= __("Mode"); ?></th>
<?php } ?> <th class="<?= $text_size_class ?>"><?= __("Sent"); ?></th>
<th><?= __("Call"); ?></th> <th class="<?= $text_size_class ?>"><?= __("Rcvd"); ?></th>
<th><?= __("Mode"); ?></th> <th class="<?= $text_size_class ?>"><?= __("Band"); ?></th>
<th><?= __("Sent"); ?></th>
<th><?= __("Rcvd"); ?></th>
<th><?= __("Band"); ?></th>
</tr> </tr>
<?php <?php
// Get Date format
if($this->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; $i = 0;
foreach ($last_qsos_list->result() as $row) { ?> foreach ($last_qsos_list->result() as $row) { ?>
<?php echo '<tr class="tr'.($i & 1).'">'; ?> <?php echo '<tr class="tr'.($i & 1).'">'; ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date($custom_date_format, $timestamp); ?></td> <td class="<?= $text_size_class ?>">
<?php if ($show_time) { ?> <?php $timestamp = strtotime($row->COL_TIME_ON); echo date($date_format, $timestamp); ?>
<td><?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?></td> <?php if ($show_time) { ?>
<?php } ?> <?php $timestamp = strtotime($row->COL_TIME_ON); echo date('H:i', $timestamp); ?>
<td><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></td> <?php } ?>
<td><?php echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?></td> </td>
<td><?php echo $row->COL_RST_SENT; ?> <?php if ($row->COL_STX_STRING) { ?>(<?php echo $row->COL_STX_STRING;?>)<?php } ?></td> <td class="<?= $text_size_class ?>"><?php echo str_replace("0","&Oslash;",strtoupper($row->COL_CALL)); ?></td>
<td><?php echo $row->COL_RST_RCVD; ?> <?php if ($row->COL_SRX_STRING) { ?>(<?php echo $row->COL_SRX_STRING;?>)<?php } ?></td> <td class="<?= $text_size_class ?>"><?php echo $row->COL_SUBMODE==null?$row->COL_MODE:$row->COL_SUBMODE; ?></td>
<td class="<?= $text_size_class ?>"><?php echo $row->COL_RST_SENT; ?> <?php if ($row->COL_STX_STRING) { ?>(<?php echo $row->COL_STX_STRING;?>)<?php } ?></td>
<td class="<?= $text_size_class ?>"><?php echo $row->COL_RST_RCVD; ?> <?php if ($row->COL_SRX_STRING) { ?>(<?php echo $row->COL_SRX_STRING;?>)<?php } ?></td>
<?php if($row->COL_SAT_NAME != null) { ?> <?php if($row->COL_SAT_NAME != null) { ?>
<td><?php echo $row->COL_SAT_NAME; ?></td> <td class="<?= $text_size_class ?>"><?php echo $row->COL_SAT_NAME; ?></td>
<?php } else { ?> <?php } else { ?>
<td><?php echo $row->COL_BAND; ?></td> <td class="<?= $text_size_class ?>"><?php echo $row->COL_BAND; ?></td>
<?php } ?> <?php } ?>
</tr> </tr>
<?php $i++; } ?> <?php $i++; } ?>