X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=openstreetmap%2Fopenstreetmap.php;h=fda29905d411821fb145ce80aae1c01767731ced;hb=84c8c4f0029032f31becd6ec8d9032da4be88462;hp=d76414c440c98539caf1289a0e584ee085047266;hpb=bb5588b5eb8d6c292c78ce276774c75dac2386fc;p=friendica-addons.git diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php index d76414c4..fda29905 100755 --- a/openstreetmap/openstreetmap.php +++ b/openstreetmap/openstreetmap.php @@ -1,42 +1,49 @@ - * + * Author: Klaus Weidenbach * */ - function openstreetmap_install() { - register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); logger("installed openstreetmap"); } - function openstreetmap_uninstall() { - unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); logger("removed openstreetmap"); } - function openstreetmap_location($a, &$item) { + if(! (strlen($item['location']) || strlen($item['coord']))) + return; + + /* + * Get the configuration variables from the .htconfig file. + */ + $tmsserver = get_config('openstreetmap','tmsserver'); + if(! $tmsserver) + $tmsserver = 'http://openstreetmap.org'; + $zoom = get_config('openstreetmap','zoom'); + if(! $zoom) + $zoom = 17; $location = ''; $coord = ''; - $location = (($item['location']) ? '' . $item['location'] . '' : ''); + $location = (($item['location']) ? '' . $item['location'] . '' : ''); if($item['coord']) { $coords = explode(' ', $item['coord']); if(count($coords) > 1) { - $coord = '' . $item['coord'] . '' ; + $coord = '' . $item['coord'] . '' ; } } if(strlen($coord)) { @@ -49,3 +56,26 @@ function openstreetmap_location($a, &$item) { return; } + +function openstreetmap_plugin_admin (&$a, &$o) { + $t = file_get_contents( dirname(__file__)."/admin.tpl"); + $tmsserver = get_config('openstreetmap','tmsserver'); + if(! $tmsserver) + $tmsserver = 'http://openstreetmap.org'; + $zoom = get_config('openstreetmap','zoom'); + if(! $zoom) + $zoom = 17; + + $o = replace_macros( $t, array( + '$submit' => t('Submit'), + '$tmsserver' => array('tmsserver', t('Tile Server URL'), $tmsserver, t('A list of public tile servers')), + '$zoom' => array('zoom', t('Default zoom'), $zoom, t('The default zoom level. (1:world, 18:highest)')), + )); +} +function openstreetmap_plugin_admin_post (&$a) { + $url = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : ''); + $zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '17'); + set_config('openstreetmap', 'tmsserver', $url); + set_config('openstreetmap', 'zoom', $zoom); + info( t('Settings updated.'). EOL); +}