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>
|
|
|
|
*
|
|
|
|
*/
|
2022-06-23 01:16:22 -04:00
|
|
|
|
|
|
|
use Friendica\App;
|
2018-12-26 02:28:16 -05:00
|
|
|
use Friendica\Core\Hook;
|
2018-10-30 13:18:47 -04:00
|
|
|
use Friendica\Core\Logger;
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2017-11-09 11:08:32 -05:00
|
|
|
function googlemaps_install()
|
|
|
|
{
|
2018-12-26 02:28:16 -05:00
|
|
|
Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
2015-06-30 01:31:27 -04:00
|
|
|
|
2022-06-23 01:16:22 -04:00
|
|
|
Logger::notice('installed googlemaps');
|
2015-06-30 01:31:27 -04:00
|
|
|
}
|
|
|
|
|
2023-01-13 21:16:09 -05:00
|
|
|
function googlemaps_location(&$item)
|
2017-11-09 11:08:32 -05:00
|
|
|
{
|
2022-06-23 01:16:22 -04: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
|
|
|
|
2022-06-23 01:16:22 -04:00
|
|
|
if ($item['coord'] != '') {
|
|
|
|
$target = 'http://maps.google.com/?q=' . urlencode($item['coord']);
|
2017-11-09 11:08:32 -05:00
|
|
|
} else {
|
2022-06-23 01:16:22 -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
|
|
|
|
2022-06-23 01:16:22 -04: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
|
|
|
|
2022-06-23 01:16:22 -04:00
|
|
|
$item['html'] = '<a target="map" title="' . $title . '" href= "' . $target . '">' . $title . '</a>';
|
2015-06-30 01:31:27 -04:00
|
|
|
}
|