2015-06-30 05:31:27 +00: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>
|
|
|
|
*
|
|
|
|
*/
|
2018-01-17 00:51:12 +00:00
|
|
|
use Friendica\Core\Addon;
|
2017-11-09 16:08:32 +00:00
|
|
|
use Friendica\Core\Cache;
|
2015-06-30 05:31:27 +00:00
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
function googlemaps_install()
|
|
|
|
{
|
2018-01-17 00:51:12 +00:00
|
|
|
Addon::registerHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
2015-06-30 05:31:27 +00:00
|
|
|
|
|
|
|
logger("installed googlemaps");
|
|
|
|
}
|
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
function googlemaps_uninstall()
|
|
|
|
{
|
2018-01-17 00:51:12 +00:00
|
|
|
Addon::unregisterHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
2015-06-30 05:31:27 +00:00
|
|
|
|
|
|
|
logger("removed googlemaps");
|
|
|
|
}
|
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
function googlemaps_location($a, &$item)
|
|
|
|
{
|
2015-06-30 05:31:27 +00:00
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
if(! (strlen($item['location']) || strlen($item['coord']))) {
|
2015-06-30 05:31:27 +00:00
|
|
|
return;
|
2017-11-09 16:08:32 +00:00
|
|
|
}
|
2015-06-30 05:31:27 +00:00
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
if ($item['coord'] != ""){
|
2015-06-30 05:31:27 +00:00
|
|
|
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
|
2017-11-09 16:08:32 +00:00
|
|
|
} else {
|
2015-06-30 05:31:27 +00:00
|
|
|
$target = "http://maps.google.com/?q=".urlencode($item['location']);
|
2017-11-09 16:08:32 +00:00
|
|
|
}
|
2015-06-30 05:31:27 +00:00
|
|
|
|
2017-11-09 16:08:32 +00:00
|
|
|
if ($item['location'] != "") {
|
2015-06-30 05:31:27 +00:00
|
|
|
$title = $item['location'];
|
2017-11-09 16:08:32 +00:00
|
|
|
} else {
|
2015-06-30 05:31:27 +00:00
|
|
|
$title = $item['coord'];
|
2017-11-09 16:08:32 +00:00
|
|
|
}
|
2015-06-30 05:31:27 +00:00
|
|
|
|
|
|
|
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
|
|
|
}
|