diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..1cfcf0bc --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + "cSpell.words": [ + "callsign", + "cloudlog", + "hamradio", + "qslcard", + "sstv", + "sstvimages", + "sstvtable", + "SUBMODE", + "userdata" + ] +} diff --git a/application/controllers/Qsl.php b/application/controllers/Qsl.php index 89df8947..5037f72e 100644 --- a/application/controllers/Qsl.php +++ b/application/controllers/Qsl.php @@ -15,7 +15,7 @@ class Qsl extends CI_Controller { // Default view when loading controller. public function index() { - + $this->load->helper('storage'); // Load the storage helper $folder_name = "assets/qslcard"; $data['storage_used'] = sizeFormat(folderSize($folder_name)); @@ -181,48 +181,4 @@ class Qsl extends CI_Controller { $this->load->view('qslcard/qslcarousel', $data); } -} - -// Functions for storage, these need shifted to a libary to use across Cloudlog -function folderSize($dir){ - $count_size = 0; - $count = 0; - $dir_array = scandir($dir); - foreach($dir_array as $key=>$filename){ - if($filename!=".." && $filename!="."){ - if(is_dir($dir."/".$filename)){ - $new_foldersize = foldersize($dir."/".$filename); - $count_size = $count_size+ $new_foldersize; - }else if(is_file($dir."/".$filename)){ - $count_size = $count_size + filesize($dir."/".$filename); - $count++; - } - } - } - return $count_size; -} - -function sizeFormat($bytes){ - $kb = 1024; - $mb = $kb * 1024; - $gb = $mb * 1024; - $tb = $gb * 1024; - - if (($bytes >= 0) && ($bytes < $kb)) { - return $bytes . ' B'; - - } elseif (($bytes >= $kb) && ($bytes < $mb)) { - return ceil($bytes / $kb) . ' KB'; - - } elseif (($bytes >= $mb) && ($bytes < $gb)) { - return ceil($bytes / $mb) . ' MB'; - - } elseif (($bytes >= $gb) && ($bytes < $tb)) { - return ceil($bytes / $gb) . ' GB'; - - } elseif ($bytes >= $tb) { - return ceil($bytes / $tb) . ' TB'; - } else { - return $bytes . ' B'; - } -} +} \ No newline at end of file diff --git a/application/controllers/Sstv.php b/application/controllers/Sstv.php index c229a13a..935b77bb 100644 --- a/application/controllers/Sstv.php +++ b/application/controllers/Sstv.php @@ -8,11 +8,27 @@ class Sstv extends CI_Controller { function __construct() { parent::__construct(); - $this->lang->load('qslcard'); + $this->lang->load('sstv'); $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } + public function index() { + $this->load->helper('storage'); + $folder_name = "assets/sstvimages"; + $data['storage_used'] = sizeFormat(folderSize($folder_name)); + + // Render Page + $data['page_title'] = "SSTV Images"; + + $this->load->model('sstv_model'); + $data['sstvArray'] = $this->sstv_model->getQsoWithSstvImageList(); + + $this->load->view('interface_assets/header', $data); + $this->load->view('sstv/index'); + $this->load->view('interface_assets/footer'); + } + public function uploadSSTV() { $this->load->model('user_model'); if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } diff --git a/application/helpers/storage_helper.php b/application/helpers/storage_helper.php new file mode 100644 index 00000000..c84f44a9 --- /dev/null +++ b/application/helpers/storage_helper.php @@ -0,0 +1,44 @@ +$filename){ + if($filename!=".." && $filename!="."){ + if(is_dir($dir."/".$filename)){ + $new_foldersize = folderSize($dir."/".$filename); + $count_size = $count_size+ $new_foldersize; + }else if(is_file($dir."/".$filename)){ + $count_size = $count_size + filesize($dir."/".$filename); + $count++; + } + } + } + return $count_size; + } +} + +if (!function_exists('sizeFormat')) { + function sizeFormat($bytes){ + $kb = 1024; + $mb = $kb * 1024; + $gb = $mb * 1024; + $tb = $gb * 1024; + + if (($bytes >= 0) && ($bytes < $kb)) { + return $bytes . ' B'; + } elseif (($bytes >= $kb) && ($bytes < $mb)) { + return ceil($bytes / $kb) . ' KB'; + } elseif (($bytes >= $mb) && ($bytes < $gb)) { + return ceil($bytes / $mb) . ' MB'; + } elseif (($bytes >= $gb) && ($bytes < $tb)) { + return ceil($bytes / $gb) . ' GB'; + } elseif ($bytes >= $tb) { + return ceil($bytes / $tb) . ' TB'; + } else { + return $bytes . ' B'; + } + } +} diff --git a/application/language/bulgarian/menu_lang.php b/application/language/bulgarian/menu_lang.php index cdd86e6b..f72b17e4 100644 --- a/application/language/bulgarian/menu_lang.php +++ b/application/language/bulgarian/menu_lang.php @@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging'; $lang['menu_bandmap'] = 'Bandmap'; $lang['menu_view_qsl'] = 'View QSL Cards'; $lang['menu_view_eqsl'] = 'View eQSL Cards'; +$lang['menu_view_sstv'] = 'View SSTV Images'; $lang['menu_notes'] = 'Notes'; diff --git a/application/language/bulgarian/sstv_lang.php b/application/language/bulgarian/sstv_lang.php new file mode 100644 index 00000000..72c4c7d0 --- /dev/null +++ b/application/language/bulgarian/sstv_lang.php @@ -0,0 +1,5 @@ +db->get()->result(); } + function getQsoWithSstvImageList() + { + $CI = &get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (is_array($logbooks_locations_array) && !empty($logbooks_locations_array)) { + $this->db->select('*'); + $this->db->from($this->config->item('table_name')); + $this->db->join('sstv_images', 'sstv_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->order_by("id", "desc"); + + return $this->db->get(); + } else { + return false; + } + } + } diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index 1b021cad..f9859946 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -83,6 +83,8 @@ + + diff --git a/application/views/sstv/index.php b/application/views/sstv/index.php new file mode 100644 index 00000000..f71ce8bf --- /dev/null +++ b/application/views/sstv/index.php @@ -0,0 +1,71 @@ +
+
+

+ +

+ + + 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/cloudlog.php + $custom_date_format = $this->config->item('qso_date_format'); + } + + if ($sstvArray !== FALSE && is_array($sstvArray->result())) { + echo ' + + + + + + + + + + + + '; + + foreach ($sstvArray->result() as $sstvImage) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
' . lang('gen_hamradio_callsign') . '' . lang('gen_hamradio_mode') . '' . lang('general_word_date') . '' . lang('general_word_time') . '' . lang('gen_hamradio_band') . '
' . str_replace("0", "Ø", $sstvImage->COL_CALL) . ''; + echo $sstvImage->COL_SUBMODE == null ? $sstvImage->COL_MODE : $sstvImage->COL_SUBMODE; + echo ''; + $timestamp = strtotime($sstvImage->COL_TIME_ON); + echo date($custom_date_format, $timestamp); + echo ''; + $timestamp = strtotime($sstvImage->COL_TIME_ON); + echo date('H:i', $timestamp); + echo ''; + if ($sstvImage->COL_SAT_NAME != null) { + echo $sstvImage->COL_SAT_NAME; + } else { + echo strtolower($sstvImage->COL_BAND); + } + ; + echo '' . $sstvImage->filename . '
'; + } else { + echo ''; + } + ?> + +
\ No newline at end of file