2012-02-10 03:10:12 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Open Street Map
|
|
|
|
* Description: Use openstreetmap.org for displaying locations.
|
|
|
|
* Version: 1.0
|
|
|
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
2012-02-10 04:53:56 +01:00
|
|
|
if(! (strlen($item['location']) || strlen($item['coord'])))
|
|
|
|
return;
|
|
|
|
|
2012-02-10 03:10:12 +01:00
|
|
|
$location = '';
|
|
|
|
$coord = '';
|
|
|
|
|
|
|
|
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://www.openstreetmap.org/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
|
|
|
|
|
|
|
|
if($item['coord']) {
|
|
|
|
$coords = explode(' ', $item['coord']);
|
|
|
|
if(count($coords) > 1) {
|
2012-02-10 04:53:56 +01:00
|
|
|
$coord = '<a target="map" title="' . $item['coord'] . '" href="http://www.openstreetmap.org/?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom=18">' . $item['coord'] . '</a>' ;
|
2012-02-10 03:10:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(strlen($coord)) {
|
|
|
|
if($location)
|
|
|
|
$location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
|
|
|
|
else
|
|
|
|
$location = '<span class="smalltext">' . $coord . '</span>';
|
|
|
|
}
|
|
|
|
$item['html'] = $location;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|