feat[maptile_options]: Add a button "reset defaults"

This commit is contained in:
HB9HIL
2024-12-06 16:08:02 +01:00
parent 03e1b7b01f
commit 7d50998f0c
2 changed files with 43 additions and 34 deletions

View File

@@ -438,10 +438,17 @@ class Options extends CI_Controller {
$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');
if ($this->input->post('reset_defaults') == '1') {
$map_tile_server_copyright = 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a>';
$saved = $this->optionslib->update('map_tile_server', 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'yes');
$saved = $this->optionslib->update('map_tile_server_dark', 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', 'yes');
$saved = $this->optionslib->update('map_tile_subdomains', 'abc', 'yes');
} else {
$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

View File

@@ -43,37 +43,39 @@
<?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>
<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"); ?>" />
<div class="d-flex justify-content-between">
<input class="btn btn-primary" type="submit" value="<?= __("Save"); ?>" />
<button class="btn btn-secondary" type="submit" name="reset_defaults" value="1"><?= __("Reset to Defaults"); ?></button>
</div>
</form>
</div>
</div>