Replace deprecated Addon::callHooks with Hook::callAll
[friendica.git/.git] / src / Util / Map.php
1 <?php
2 /**
3  * @file src/Util/Map.php
4  */
5 namespace Friendica\Util;
6
7 use Friendica\Core\Hook;
8
9 /**
10  * Leaflet Map related functions
11  */
12 class Map {
13         public static function byCoordinates($coord, $html_mode = 0) {
14                 $coord = trim($coord);
15                 $coord = str_replace([',','/','  '],[' ',' ',' '],$coord);
16                 $arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => ''];
17                 Hook::callAll('generate_map',$arr);
18                 return ($arr['html']) ? $arr['html'] : $coord;
19         }
20
21         public static function byLocation($location, $html_mode = 0) {
22                 $arr = ['location' => $location, 'mode' => $html_mode, 'html' => ''];
23                 Hook::callAll('generate_named_map',$arr);
24                 return ($arr['html']) ? $arr['html'] : $location;
25         }
26
27         public static function getCoordinates($location) {
28                 $arr = ['location' => $location, 'lat' => false, 'lon' => false];
29                 Hook::callAll('Map::getCoordinates', $arr);
30                 return $arr;
31         }
32 }