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