diff --git a/application/controllers/Options.php b/application/controllers/Options.php index 29d9f6619..443f60d7b 100644 --- a/application/controllers/Options.php +++ b/application/controllers/Options.php @@ -389,102 +389,6 @@ class Options extends CI_Controller { redirect('/options/email'); } - // function used to display the /maptiles url in global options - function maptiles() { - $data['page_title'] = __("Wavelog Options"); - $data['sub_heading'] = __("Maptiles Server"); - - $data['maptile_server_url'] = $this->optionslib->get_option('map_tile_server') ?? 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; - $data['maptile_server_url_dark'] = $this->optionslib->get_option('map_tile_server_dark') ?? 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'; - $data['subdomain_system'] = $this->optionslib->get_option('map_tile_subdomains') ?? 'abc'; - $map_tile_server_copyright = $this->optionslib->get_option('map_tile_server_copyright') ?? 'Map data © OpenStreetMap'; - preg_match('/([^<]+)<\/a>/', $map_tile_server_copyright, $matches); - $data['copyright_url'] = $matches[1]; - $data['copyright_text'] = $matches[2]; - - $this->load->view('interface_assets/header', $data); - $this->load->view('options/maptiles'); - $this->load->view('interface_assets/footer'); - } - - // Handles saving the Maptiles options to the options system. - function maptiles_save() { - - $data['page_title'] = __("Wavelog Options"); - $data['sub_heading'] = __("Maptiles Server"); - - $this->load->helper(array('form', 'url')); - - $this->load->library('form_validation'); - - $this->form_validation->set_rules('maptile_server_url', 'URL of Maptile Server', 'required'); - $this->form_validation->set_rules('maptile_server_url_dark', 'URL of Dark Maptile Server', 'required'); - $this->form_validation->set_rules('subdomain_system', 'Subdomains for Loadbalancing', 'required'); - $this->form_validation->set_rules('copyright_url', 'URL for Copyright', 'required'); - $this->form_validation->set_rules('copyright_text', 'Text for Copyright', 'required'); - - if ($this->form_validation->run() == FALSE) { - - $data['maptile_server_url'] = $this->optionslib->get_option('maptile_server_url') ?? 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; - $data['maptile_server_url_dark'] = $this->optionslib->get_option('map_tile_server_dark') ?? 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'; - $data['subdomain_system'] = $this->optionslib->get_option('map_tile_subdomains') ?? 'abc'; - $map_tile_server_copyright = $this->optionslib->get_option('map_tile_server_copyright') ?? 'Map data © OpenStreetMap'; - preg_match('/([^<]+)<\/a>/', $map_tile_server_copyright, $matches); - $data['copyright_url'] = $matches[1]; - $data['copyright_text'] = $matches[2]; - - $this->load->view('interface_assets/header', $data); - $this->load->view('options/maptiles'); - $this->load->view('interface_assets/footer'); - } else { - $saved = false; - $map_tile_server_copyright = 'Map data © ' . $this->input->post('copyright_text', true) . ''; - $saved = $this->optionslib->update('map_tile_server', $this->input->post('maptile_server_url', true), 'yes'); - $saved = $this->optionslib->update('map_tile_server_dark', $this->input->post('maptile_server_url_dark', true), 'yes'); - $saved = $this->optionslib->update('map_tile_subdomains', $this->input->post('subdomain_system', true), 'yes'); - $saved = $this->optionslib->update('map_tile_server_copyright', $map_tile_server_copyright, 'yes'); - - // Also clean up static map images - if (!$this->load->is_loaded('staticmap_model')) { - $this->load->model('staticmap_model'); - } - if (!$this->load->is_loaded('stations')) { - $this->load->model('stations'); - } - $station_ids = explode(',',$this->stations->all_station_ids_of_user()); - foreach ($station_ids as $station_id) { - $this->staticmap_model->remove_static_map_image($station_id); - log_message('debug', 'Removed static map image for station ID ' . $station_id); - } - // also remove the tilecache - $cachepath = $this->config->item('cache_path') == '' ? APPPATH . 'cache/' : $this->config->item('cache_path'); - $cacheDir = $cachepath . "tilecache/"; - $tilecache_warning = false; - if (function_usable('exec')) { - try { - if (is_dir($cacheDir)) { - exec('rm -rf ' . $cacheDir); - } - } catch (\Throwable $th) { - $tilecache_warning = true; - } - } else { - $tilecache_warning = true; - } - if ($tilecache_warning) { - $this->session->set_flashdata('warning', sprintf(__("Maptile cache could not be removed. Delete the folder manually. Path: %s"), str_replace(FCPATH, '', $cacheDir))); - log_message('debug', 'Maptile cache could not be removed. Delete the folder manually. Path: ' . str_replace(FCPATH, '', $cacheDir)); - } - if($saved == true) { - $this->session->set_flashdata('success', __("Maptile Options saved!")); - } else { - $this->session->set_flashdata('error', __("Maptile Options could not be saved!")); - log_message('error', 'Maptile Options could not be saved!'); - } - redirect('/options/maptiles'); - } - } - // function used to display the /version_dialog url function version_dialog() { diff --git a/application/models/Staticmap_model.php b/application/models/Staticmap_model.php index a4c82e859..e95736885 100644 --- a/application/models/Staticmap_model.php +++ b/application/models/Staticmap_model.php @@ -163,21 +163,20 @@ class Staticmap_model extends CI_Model { // Set the tile layer if ($thememode != null) { $attribution = $this->optionslib->get_option('option_map_tile_server_copyright') ?? 'Map data © OpenStreetMap'; - $subdomains = $this->optionslib->get_option('option_map_tile_subdomains') ?? 'abc'; if ($thememode == 'light') { $server_url = $this->optionslib->get_option('option_map_tile_server') ?? ''; if ($server_url == '') { $server_url = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; $this->optionslib->update('map_tile_server', $server_url, 'yes'); } - $tileLayer = new \Wavelog\StaticMapImage\TileLayer($server_url, $attribution, $thememode, $subdomains); + $tileLayer = new \Wavelog\StaticMapImage\TileLayer($server_url, $attribution, $thememode); } elseif ($thememode == 'dark') { $server_url = $this->optionslib->get_option('option_map_tile_server_dark') ?? ''; if ($server_url == '') { $server_url = 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'; $this->optionslib->update('map_tile_server_dark', $server_url, 'yes'); } - $tileLayer = new \Wavelog\StaticMapImage\TileLayer($server_url, $attribution, $thememode, $subdomains); + $tileLayer = new \Wavelog\StaticMapImage\TileLayer($server_url, $attribution, $thememode); } else { $tileLayer = \Wavelog\StaticMapImage\TileLayer::defaultTileLayer(); } diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index d5fc30779..c3a7fb153 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -4,7 +4,6 @@ */ var option_map_tile_server = 'optionslib->get_option('option_map_tile_server');?>'; var option_map_tile_server_copyright = 'optionslib->get_option('option_map_tile_server_copyright');?>'; - var option_map_tile_subdomains = 'optionslib->get_option('option_map_tile_subdomains');?>'; var base_url = ""; // Base URL var site_url = ""; // Site URL diff --git a/application/views/options/maptiles.php b/application/views/options/maptiles.php deleted file mode 100644 index 092517f8a..000000000 --- a/application/views/options/maptiles.php +++ /dev/null @@ -1,83 +0,0 @@ -
- = __("This modifies the map source in various locations within Wavelog. Do not change any values here unless you are confident in what you are doing."); ?> -
-