]> git.mxchange.org Git - friendica-addons.git/blob - googlemaps/googlemaps.php
audon/C/messages.po hinzugefĆ¼gt
[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
10 use Friendica\App;
11 use Friendica\Core\Hook;
12 use Friendica\Core\Logger;
13
14 function googlemaps_install()
15 {
16         Hook::register('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
17
18         Logger::notice('installed googlemaps');
19 }
20
21 function googlemaps_location(&$item)
22 {
23         if (!(strlen($item['location']) || strlen($item['coord']))) {
24                 return;
25         }
26
27         if ($item['coord'] != '') {
28                 $target = 'http://maps.google.com/?q=' . urlencode($item['coord']);
29         } else {
30                 $target = 'http://maps.google.com/?q=' . urlencode($item['location']);
31         }
32
33         if ($item['location'] != '') {
34                 $title = $item['location'];
35         } else {
36                 $title = $item['coord'];
37         }
38
39         $item['html'] = '<a target="map" title="' . $title . '" href= "' . $target . '">' . $title . '</a>';
40 }