2015-06-30 01:31:27 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Google Maps
|
|
|
|
* Description: Use Google Maps for displaying locations. After activation the post location just beneath your avatar in your posts will link to Google Maps.
|
|
|
|
* Version: 0.1
|
|
|
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
use Friendica\Core\Cache;
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
function googlemaps_install()
|
|
|
|
{
|
2015-06-30 01:31:27 -04:00
|
|
|
register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
|
|
|
|
|
|
|
logger("installed googlemaps");
|
|
|
|
}
|
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
function googlemaps_uninstall()
|
|
|
|
{
|
2015-06-30 01:31:27 -04:00
|
|
|
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
|
|
|
|
|
|
|
logger("removed googlemaps");
|
|
|
|
}
|
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
function googlemaps_location($a, &$item)
|
|
|
|
{
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
if(! (strlen($item['location']) || strlen($item['coord']))) {
|
2015-06-30 01:31:27 -04:00
|
|
|
return;
|
2017-11-09 11:08:32 -05:00
|
|
|
}
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
if ($item['coord'] != ""){
|
2015-06-30 01:31:27 -04:00
|
|
|
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
|
2017-11-09 11:08:32 -05:00
|
|
|
} else {
|
2015-06-30 01:31:27 -04:00
|
|
|
$target = "http://maps.google.com/?q=".urlencode($item['location']);
|
2017-11-09 11:08:32 -05:00
|
|
|
}
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
if ($item['location'] != "") {
|
2015-06-30 01:31:27 -04:00
|
|
|
$title = $item['location'];
|
2017-11-09 11:08:32 -05:00
|
|
|
} else {
|
2015-06-30 01:31:27 -04:00
|
|
|
$title = $item['coord'];
|
2017-11-09 11:08:32 -05:00
|
|
|
}
|
2015-06-30 01:31:27 -04:00
|
|
|
|
|
|
|
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
|
|
|
}
|