Revert "feat[global options]: Add the ability to change the Maptile Settings in Global Options"

This reverts commit ac5892cdcb.
This commit is contained in:
HB9HIL
2024-12-06 14:19:08 +01:00
parent 71bea930b8
commit bc1b23e913
9 changed files with 35 additions and 221 deletions

View File

@@ -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 &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>';
preg_match('/<a href="([^"]+)">([^<]+)<\/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 &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>';
preg_match('/<a href="([^"]+)">([^<]+)<\/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 &copy; <a href="' . $this->input->post('copyright_url', true) . '">' . $this->input->post('copyright_text', true) . '</a>';
$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() {

View File

@@ -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 &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>';
$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();
}

View File

@@ -4,7 +4,6 @@
*/
var option_map_tile_server = '<?php echo $this->optionslib->get_option('option_map_tile_server');?>';
var option_map_tile_server_copyright = '<?php echo $this->optionslib->get_option('option_map_tile_server_copyright');?>';
var option_map_tile_subdomains = '<?php echo $this->optionslib->get_option('option_map_tile_subdomains');?>';
var base_url = "<?php echo base_url(); ?>"; // Base URL
var site_url = "<?php echo site_url(); ?>"; // Site URL

View File

@@ -1,83 +0,0 @@
<div class="container settings">
<div class="row">
<!-- Nav Start -->
<?php $this->load->view('options/sidebar') ?>
<!-- Nav End -->
<!-- Content -->
<div class="col-md-9">
<div class="card">
<div class="card-header">
<h2><?php echo $page_title; ?> - <?php echo $sub_heading; ?></h2>
</div>
<div class="card-body">
<?php if ($this->session->flashdata('success')) { ?>
<!-- Display Success Message -->
<div class="alert alert-success">
<?php echo $this->session->flashdata('success'); ?>
</div>
<?php } ?>
<?php if ($this->session->flashdata('warning')) { ?>
<!-- Display warning Message -->
<div class="alert alert-warning">
<?php echo $this->session->flashdata('warning'); ?>
</div>
<?php } ?>
<?php if ($this->session->flashdata('message')) { ?>
<!-- Display Message -->
<div class="alert-message error">
<?php echo $this->session->flashdata('message'); ?>
</div>
<?php } ?>
<?php if (validation_errors()) { ?>
<div class="alert alert-danger">
<a class="btn-close" data-bs-dismiss="alert"></a>
<?php echo validation_errors(); ?>
</div>
<?php } ?>
<?php echo form_open('options/maptiles_save'); ?>
<p class="alert alert-info">
<?= __("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."); ?>
</p>
<div class="mb-3">
<label for="maptile_server_url"><?= __("Maptiles Server URL"); ?></label>
<input type="text" name="maptile_server_url" class="form-control" id="maptile_server_url" aria-describedby="maptile_server_urlHelp" value="<?php echo $maptile_server_url; ?>">
<small id="maptile_server_urlHelp" class="form-text text-muted"><?= __("URL of the map server which serves the maptiles."); ?> <?= sprintf(__("For the %sStatic Map API%s this URL is only used when theme is set to %s. Default: %s"), '<a href="https://github.com/wavelog/wavelog/wiki/Static-Map-Images">', '</a>', "'light'", "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"); ?></small>
</div>
<div class="mb-3">
<label for="maptile_server_url_dark"><?= __("Maptiles Server URL for Dark Tiles - ONLY Static Map API"); ?></label>
<input type="text" name="maptile_server_url_dark" class="form-control" id="maptile_server_url_dark" aria-describedby="maptile_server_url_darkHelp" value="<?php echo $maptile_server_url_dark; ?>">
<small id="maptile_server_url_darkHelp" class="form-text text-muted"><?= sprintf(__("URL of the map server which serves the dark maptiles. Only used for Static Map API. Default: %s"),"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png"); ?></small>
</div>
<div class="mb-3">
<label for="subdomain_system"><?= __("Subdomain System of Maptile Server"); ?></label>
<input type="text" name="subdomain_system" class="form-control" id="subdomain_system" aria-describedby="subdomain_systemHelp" value="<?php echo $subdomain_system; ?>">
<small id="subdomain_systemHelp" class="form-text text-muted"><?= sprintf(__("System of the subdomains at this server ({s}). They are used for loadbalancing. Default: %s"), "abc"); ?></small>
</div>
<div class="mb-3">
<label for="copyright_url"><?= __("URL of the Copyright Source"); ?></label>
<input type="text" name="copyright_url" class="form-control" id="copyright_url" aria-describedby="copyright_urlHelp" value="<?php echo $copyright_url; ?>">
<small id="copyright_urlHelp" class="form-text text-muted"><?= sprintf(__("Source URL for the copyright tag. Default: %s"), "https://www.openstreetmap.org/"); ?></small>
</div>
<div class="mb-3">
<label for="copyright_text"><?= __("Name of the Copyright Source"); ?></label>
<input type="text" name="copyright_text" class="form-control" id="copyright_text" aria-describedby="copyright_textHelp" value="<?php echo $copyright_text; ?>">
<small id="copyright_textHelp" class="form-text text-muted"><?= sprintf(__("Text for the copyright tag. Default: %s"), "OpenStreetMap"); ?></small>
</div>
<!-- Save the Form -->
<input class="btn btn-primary" type="submit" value="<?= __("Save"); ?>" />
</form>
</div>
</div>
</div>
</div>
</div>

View File

@@ -8,7 +8,6 @@
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/oqrs'); ?>"><?= __("OQRS Options"); ?></a></li>
<?php } ?>
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/dxcluster'); ?>"><?= __("DXCluster"); ?></a></li>
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/maptiles'); ?>"><?= __("Maptiles Server"); ?></a></li>
<li class="list-group-item"><a class="nav-link" href="<?php echo site_url('options/version_dialog'); ?>"><?= __("Version Info"); ?></a></li>
</ul>
</div>

View File

@@ -1,7 +1,6 @@
<script>
var slug = '<?php echo $slug; ?>';
var tileUrl="<?php echo $this->optionslib->get_option('option_map_tile_server');?>"
var option_map_tile_subdomains = '<?php echo $this->optionslib->get_option('option_map_tile_subdomains');?>';
let user_map_custom = JSON.parse('<?php echo $user_map_custom; ?>');
</script>
<style>

View File

@@ -1,25 +1,23 @@
<script type="text/javascript">
/*
*
* Define global javascript variables
*
*/
var base_url = "<?php echo base_url(); ?>"; // Base URL
var site_url = "<?php echo site_url(); ?>"; // Site URL
var icon_dot_url = "<?php echo base_url();?>assets/images/dot.png";
var option_map_tile_server_copyright = '<?php echo $this->optionslib->get_option('option_map_tile_server_copyright');?>';
var option_map_tile_subdomains = '<?php echo $this->optionslib->get_option('option_map_tile_subdomains');?>';
</script>
<!-- General JS Files used across Wavelog -->
<script src="<?php echo base_url(); ?>assets/js/jquery-3.3.1.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.bundle.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/leaflet.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/L.Maidenhead.qrb.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/leaflet.geodesic.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/darkmodehelpers.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/easyprint.js"></script>
<!-- General JS Files used across Wavelog -->
<script src="<?php echo base_url(); ?>assets/js/jquery-3.3.1.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.bundle.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/leaflet.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/L.Maidenhead.qrb.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/leaflet/leaflet.geodesic.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/darkmodehelpers.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/easyprint.js"></script>
<script type="text/javascript">
/*
*
* Define global javascript variables
*
*/
var base_url = "<?php echo base_url(); ?>"; // Base URL
var site_url = "<?php echo site_url(); ?>"; // Site URL
var icon_dot_url = "<?php echo base_url();?>assets/images/dot.png";
var option_map_tile_server_copyright = '<?php echo $this->optionslib->get_option('option_map_tile_server_copyright');?>';
</script>
<script id="leafembed" type="text/javascript" src="<?php echo base_url();?>assets/js/leaflet/leafembed.js" tileUrl="<?php echo $this->optionslib->get_option('map_tile_server');?>"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/sections/exportmap.js"></script>
<script type="text/javascript" src="<?php echo base_url();?>assets/js/sections/cqmap_geojson.js"></script>

View File

@@ -1,17 +1,3 @@
<script type="text/javascript">
/*
*
* Define global javascript variables
*
*/
var base_url = "<?php echo base_url(); ?>"; // Base URL
var site_url = "<?php echo site_url(); ?>"; // Site URL
var icon_dot_url = "<?php echo base_url();?>assets/images/dot.png";
var option_map_tile_server_copyright = '<?php echo $this->optionslib->get_option('option_map_tile_server_copyright');?>';
var option_map_tile_subdomains = '<?php echo $this->optionslib->get_option('option_map_tile_subdomains');?>';
var lang_general_gridsquares = "<?= __("Gridsquares"); ?>";
</script>
<!-- General JS Files used across Wavelog -->
<script src="<?php echo base_url(); ?>assets/js/jquery-3.3.1.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/jquery.fancybox.min.js"></script>
@@ -23,6 +9,19 @@
<script src="<?php echo base_url(); ?>assets/js/bootstrapdialog/js/bootstrap-dialog.min.js"></script>
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/easyprint.js"></script>
<script type="text/javascript">
/*
*
* Define global javascript variables
*
*/
var base_url = "<?php echo base_url(); ?>"; // Base URL
var site_url = "<?php echo site_url(); ?>"; // Site URL
var icon_dot_url = "<?php echo base_url();?>assets/images/dot.png";
var option_map_tile_server_copyright = '<?php echo $this->optionslib->get_option('option_map_tile_server_copyright');?>';
var lang_general_gridsquares = "<?= __("Gridsquares"); ?>";
</script>
<!-- DATATABLES LANGUAGE -->
<?php
$local_code = $language['locale'];

File diff suppressed because one or more lines are too long