Nice(r) view for the update results page

This commit is contained in:
phl0
2025-03-21 12:10:32 +01:00
parent 822329833b
commit e3a163865f
3 changed files with 9 additions and 7 deletions

View File

@@ -491,7 +491,7 @@ class Update extends CI_Controller {
public function update_hamsofnote() {
$this->load->model('Update_model');
$bodyData['satupdates'] = $this->Update_model->update_hams_of_note();
$bodyData['hamsofnote'] = $this->Update_model->update_hams_of_note();
$data['page_title'] = __("Update of Hams of Note");
$this->load->view('interface_assets/header', $data);
$this->load->view('update/hamsofnote', $bodyData);

View File

@@ -488,6 +488,7 @@ class Update_model extends CI_Model {
$this->db->empty_table("hams_of_note");
$this->db->query("ALTER TABLE hams_of_note AUTO_INCREMENT 1");
$file = 'https://www.ham2k.com/data/hams-of-note.txt';
$result = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $file);
curl_setopt($ch, CURLOPT_HEADER, false);
@@ -504,12 +505,13 @@ class Update_model extends CI_Model {
$index = strpos($line, ' ');
$call = substr($line, 0, $index);
$name = substr($line, strpos($line, ' '));
$linkname = $link = '';
$linkname = $link = null;
if (strpos($name, '[')) {
$linkname = substr($name, strpos($name, '[')+1, (strpos($name, ']') - strpos($name, '[')-1));
$link= substr($name, strpos($name, '(')+1, (strpos($name, ')') - strpos($name, '(')-1));
$name = substr($name, 0, strpos($name, '['));
}
array_push($result, array('callsign' => $call, 'name' => $name, 'linkname' => $linkname, 'link' => $link));
$hon[$i]['callsign'] = $call;
$hon[$i]['description'] = $name;
$hon[$i]['linkname'] = $linkname;
@@ -522,7 +524,7 @@ class Update_model extends CI_Model {
}
}
$this->db->insert_batch('hams_of_note', $hon);
return;
return $result;
}
}

View File

@@ -2,11 +2,11 @@
<h2><?php echo $page_title; ?></h2>
<?php
if ($satupdates) {
if ($hamsofnote) {
echo '<table class="table table-striped table-hover">';
echo '<tr><th>'.__('Name').'</th><th>'.__('Display Name').'</th><th>'.__('Start Date').'</th><th>'.__('End Date').'</th><th>'.__('Status').'</th></tr>';
foreach ($satupdates as $sat) {
echo('<tr><td>'.$sat['name'].'</td><td>'.$sat['displayname'].'</td><td>'.$sat['startDate'].'</td><td>'.$sat['endDate'].'</td><td>'.$sat['status'].'</td></tr>');
echo '<tr><th>'.__('Callsign').'</th><th>'.__('Name / Description').'</th></tr>';
foreach ($hamsofnote as $hamofnote) {
echo('<tr><td>'.$hamofnote['callsign'].'</td><td>'.$hamofnote['name'].' <a target="_blank" href="'.$hamofnote['link'].'">'.$hamofnote['linkname'].'</a></td></tr>');
}
echo '</table>';
} else {