-function openstreetmap_plugin_admin(&$a, &$o) {
- $t = get_markup_template("admin.tpl", "addon/openstreetmap/");
- $tmsserver = get_config('openstreetmap', 'tmsserver');
- if(! $tmsserver)
- $tmsserver = 'http://www.openstreetmap.org';
- $nomserver = get_config('openstreetmap', 'nomserver');
- if(! $nomserver)
- $nomserver = 'http://nominatim.openstreetmap.org/search.php';
- $zoom = get_config('openstreetmap', 'zoom');
- if(! $zoom)
- $zoom = 16;
- $marker = get_config('openstreetmap', 'marker');
- if(! $marker)
- $marker = 0;
-
- $o = replace_macros($t, array(
- '$submit' => t('Submit'),
- '$tmsserver' => array('tmsserver', t('Tile Server URL'), $tmsserver, t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank">public tile servers</a>')),
- '$nomserver' => array('nomserver', t('Nominatim (reverse geocoding) Server URL'), $nomserver, t('A list of <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank">Nominatim servers</a>')),
- '$zoom' => array('zoom', t('Default zoom'), $zoom, t('The default zoom level. (1:world, 18:highest, also depends on tile server)')),
- '$marker' => array('marker', t('Include marker on map'), $marker, t('Include a marker on the map.')),
- ));
-}
-function openstreetmap_plugin_admin_post(&$a) {
- $urltms = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
- $urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
- $zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
- $marker = ((x($_POST, 'marker')) ? intval(trim($_POST['marker'])) : '0');
- set_config('openstreetmap', 'tmsserver', $urltms);
- set_config('openstreetmap', 'nomserver', $urlnom);
- set_config('openstreetmap', 'zoom', $zoom);
- set_config('openstreetmap', 'marker', $marker);
- info( t('Settings updated.') . EOL);
+function openstreetmap_addon_admin(&$a, &$o)
+{
+ $t = Renderer::getMarkupTemplate("admin.tpl", "addon/openstreetmap/");
+ $tmsserver = DI::config()->get('openstreetmap', 'tmsserver', OSM_TMS);
+ $nomserver = DI::config()->get('openstreetmap', 'nomserver', OSM_NOM);
+ $zoom = DI::config()->get('openstreetmap', 'zoom', OSM_ZOOM);
+ $marker = DI::config()->get('openstreetmap', 'marker', OSM_MARKER);
+
+ // This is needed since we stored an empty string in the config in previous versions
+ if (empty($nomserver)) {
+ $nomserver = OSM_NOM;
+ }
+
+ $o = Renderer::replaceMacros($t, [
+ '$submit' => DI::l10n()->t('Submit'),
+ '$tmsserver' => ['tmsserver', DI::l10n()->t('Tile Server URL'), $tmsserver, DI::l10n()->t('A list of <a href="http://wiki.openstreetmap.org/wiki/TMS" target="_blank" rel="noopener noreferrer">public tile servers</a>')],
+ '$nomserver' => ['nomserver', DI::l10n()->t('Nominatim (reverse geocoding) Server URL'), $nomserver, DI::l10n()->t('A list of <a href="http://wiki.openstreetmap.org/wiki/Nominatim" target="_blank" rel="noopener noreferrer">Nominatim servers</a>')],
+ '$zoom' => ['zoom', DI::l10n()->t('Default zoom'), $zoom, DI::l10n()->t('The default zoom level. (1:world, 18:highest, also depends on tile server)')],
+ '$marker' => ['marker', DI::l10n()->t('Include marker on map'), $marker, DI::l10n()->t('Include a marker on the map.')],
+ ]);