]> git.mxchange.org Git - friendica-addons.git/blob - googlemaps/googlemaps.php
Merge pull request #539 from MrPetovan/bug/4555-remove-active-users-feature
[friendica-addons.git] / googlemaps / googlemaps.php
1 <?php
2 /**
3  * Name: Google Maps
4  * Description: Use Google Maps for displaying locations. After activation the post location just beneath your avatar in your posts will link to Google Maps.
5  * Version: 0.1
6  * Author: Michael Vogel <https://pirati.ca/profile/heluecht>
7  *
8  */
9 use Friendica\Core\Addon;
10 use Friendica\Core\Cache;
11
12 function googlemaps_install()
13 {
14         Addon::registerHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
15
16         logger("installed googlemaps");
17 }
18
19 function googlemaps_uninstall()
20 {
21         Addon::unregisterHook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
22
23         logger("removed googlemaps");
24 }
25
26 function googlemaps_location($a, &$item)
27 {
28
29         if(! (strlen($item['location']) || strlen($item['coord']))) {
30                 return;
31         }
32
33         if ($item['coord'] != ""){ 
34                 $target = "http://maps.google.com/?q=".urlencode($item['coord']);
35         } else {
36                 $target = "http://maps.google.com/?q=".urlencode($item['location']);
37         }
38
39         if ($item['location'] != "") {
40                 $title = $item['location'];
41         } else {
42                 $title = $item['coord'];
43         }
44
45         $item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
46 }