Use central function to generate ADIF-Header

This commit is contained in:
int2001
2025-12-05 08:01:12 +00:00
parent ad11abe84b
commit 5e02b514ae
4 changed files with 14 additions and 24 deletions

View File

@@ -103,11 +103,7 @@ class adif extends CI_Controller {
header('Content-Disposition: attachment; filename="'.$filename.'"');
// Output ADIF header // No chance to use exportall-view any longer, because of chunking logic
echo "Wavelog ADIF export\n";
echo "<ADIF_VER:5>3.1.6\n";
echo "<PROGRAMID:".strlen($this->config->item('app_name')).">".$this->config->item('app_name')."\r\n";
echo "<PROGRAMVERSION:".strlen($this->optionslib->get_option('version')).">".$this->optionslib->get_option('version')."\r\n";
echo "<EOH>\n\n";
echo $this->adifhelper->getAdifHeader($this->config->item('app_name'),$this->optionslib->get_option('version'));
// Stream QSOs in 5K chunks
$offset = 0;
@@ -204,12 +200,7 @@ class adif extends CI_Controller {
header('Content-Type: text/plain; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$filename.'"');
// Output ADIF header // No chance to use exportall-view any longer, because of chunking logic
echo "Wavelog ADIF export\n";
echo "<ADIF_VER:5>3.1.6\n";
echo "<PROGRAMID:".strlen($this->config->item('app_name')).">".$this->config->item('app_name')."\r\n";
echo "<PROGRAMVERSION:".strlen($this->optionslib->get_option('version')).">".$this->optionslib->get_option('version')."\r\n";
echo "<EOH>\n\n";
echo $this->adifhelper->getAdifHeader($this->config->item('app_name'),$this->optionslib->get_option('version'));
// Collect QSO IDs for LoTW marking (since we can't access all at once)
$qso_ids_for_lotw = [];

View File

@@ -453,11 +453,7 @@ class API extends CI_Controller {
$offset = 0;
// Start building ADIF content
$adif_content = "Wavelog ADIF export\n";
$adif_content .= "<ADIF_VER:5>3.1.6\n";
$adif_content .= "<PROGRAMID:".strlen($this->config->item('app_name')).">".$this->config->item('app_name')."\r\n";
$adif_content .= "<PROGRAMVERSION:".strlen($this->optionslib->get_option('version')).">".$this->optionslib->get_option('version')."\r\n";
$adif_content .= "<EOH>\n\n";
$adif_content = $this->adifhelper->getAdifHeader($this->config->item('app_name'),$this->optionslib->get_option('version'));
do {
// Calculate chunk size for this iteration

View File

@@ -262,6 +262,15 @@ class AdifHelper {
return $line;
}
function getAdifHeader($app_name,$version) {
$adif_header = "Wavelog ADIF export\n";
$adif_header .= "<ADIF_VER:5>3.1.6\n";
$adif_header .= "<PROGRAMID:".strlen($app_name).">".$app_name."\r\n";
$adif_header .= "<PROGRAMVERSION:".strlen($version).">".$version."\r\n";
$adif_header .= "<EOH>\n\n";
return $adif_header;
}
function getAdifFieldLine($adifcolumn, $dbvalue) {
if ($dbvalue !== "" && $dbvalue !== null && $dbvalue !== 0) {
return "<" . $adifcolumn . ":" . mb_strlen($dbvalue, "UTF-8") . ">" . $dbvalue . "\r\n";

View File

@@ -5,19 +5,13 @@
header('Content-Type: text/plain; charset=utf-8');
header('Content-Disposition: attachment; filename="'.$this->session->userdata('user_callsign').'-'.date('Ymd-Hi').'.adi"');
}
?>
Wavelog ADIF export
<ADIF_VER:5>3.1.6
<PROGRAMID:<?php echo strlen($this->config->item('app_name')); ?>><?php echo $this->config->item('app_name')."\r\n"; ?>
<PROGRAMVERSION:<?php echo strlen($this->optionslib->get_option('version')); ?>><?php echo $this->optionslib->get_option('version')."\r\n"; ?>
<EOH>
<?php
$CI =& get_instance();
if (!$CI->load->is_loaded('AdifHelper')) {
$CI->load->library('AdifHelper');
}
echo $this->adifhelper->getAdifHeader($CI->config->item('app_name'),$CI->optionslib->get_option('version'));
foreach ($qsos->result() as $qso) {
echo $CI->adifhelper->getAdifLine($qso);
}