X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FMap.php;h=4fa1d1ca3e08fc0f41c0ec4143718dc03323504d;hb=204e52ea307b182175ae0c64d6eb69c71a104658;hp=e2398b2fd187ed8a5e9d2f890e0a149191db973d;hpb=ea10a7c00250ee1a3ce0600d3a19885889ad8895;p=friendica.git diff --git a/src/Util/Map.php b/src/Util/Map.php index e2398b2fd1..4fa1d1ca3e 100644 --- a/src/Util/Map.php +++ b/src/Util/Map.php @@ -1,18 +1,49 @@ . + * + */ + +namespace Friendica\Util; + +use Friendica\Core\Hook; /** * Leaflet Map related functions */ - - function generate_map($coord) { - $coord = trim($coord); - $coord = str_replace(array(',','/',' '),array(' ',' ',' '),$coord); - $arr = array('lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'html' => ''); - call_hooks('generate_map',$arr); - return (($arr['html']) ? $arr['html'] : $coord); -} -function generate_named_map($location) { - $arr = array('location' => $location, 'html' => ''); - call_hooks('generate_named_map',$arr); - return (($arr['html']) ? $arr['html'] : $location); +class Map { + public static function byCoordinates($coord, $html_mode = 0) { + $coord = trim($coord); + $coord = str_replace([',','/',' '],[' ',' ',' '],$coord); + $arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'mode' => $html_mode, 'html' => '']; + Hook::callAll('generate_map',$arr); + return ($arr['html']) ? $arr['html'] : $coord; + } + + public static function byLocation($location, $html_mode = 0) { + $arr = ['location' => $location, 'mode' => $html_mode, 'html' => '']; + Hook::callAll('generate_named_map',$arr); + return ($arr['html']) ? $arr['html'] : $location; + } + + public static function getCoordinates($location) { + $arr = ['location' => $location, 'lat' => false, 'lon' => false]; + Hook::callAll('Map::getCoordinates', $arr); + return $arr; + } }