friendica-addons/googlemaps/googlemaps.php

42 lines
1.1 KiB
PHP
Raw Normal View History

<?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-02-12 00:00:01 +00:00
require_once('include/cache.php');
2018-02-12 00:00:01 +00:00
function googlemaps_install() {
register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
logger("installed googlemaps");
}
2018-02-12 00:00:01 +00:00
function googlemaps_uninstall() {
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
logger("removed googlemaps");
}
2018-02-12 00:00:01 +00:00
function googlemaps_location($a, &$item) {
2018-02-12 00:00:01 +00:00
if(! (strlen($item['location']) || strlen($item['coord'])))
return;
2018-02-12 00:00:01 +00:00
if ($item['coord'] != "")
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
2018-02-12 00:00:01 +00:00
else
$target = "http://maps.google.com/?q=".urlencode($item['location']);
2018-02-12 00:00:01 +00:00
if ($item['location'] != "")
$title = $item['location'];
2018-02-12 00:00:01 +00:00
else
$title = $item['coord'];
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
}