* 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');
$zoom = get_config('openstreetmap','zoom');
$location = '';
$coord = '';
$location = (($item['location']) ? '' . $item['location'] . '' : '');
if($item['coord']) {
$coords = explode(' ', $item['coord']);
if(count($coords) > 1) {
$coord = '' . $item['coord'] . '' ;
}
}
if(strlen($coord)) {
if($location)
$location .= '
(' . $coord . ')';
else
$location = '' . $coord . '';
}
$item['html'] = $location;
return;
}
function openstreetmap_plugin_admin (&$a, &$o) {
$t = file_get_contents( dirname(__file__)."/admin.tpl");
$o = replace_macros( $t, array(
'$submit' => t('Submit'),
'$tmsserver' => array('tmsserver', t('Tile Server URL'), get_config('openstreetmap','tmsserver' ), t('A list of public tile servers')),
'$zoom' => array('zoom', t('Default zoom'), get_config('openstreetmap','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);
}