From: Michael Date: Wed, 13 Dec 2017 21:37:34 +0000 (+0000) Subject: Map is moved to the new place X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ea10a7c00250ee1a3ce0600d3a19885889ad8895;p=friendica.git Map is moved to the new place --- diff --git a/include/bbcode.php b/include/bbcode.php index 749a7c5946..be59c18072 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -6,10 +6,10 @@ use Friendica\Core\Cache; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Model\Contact; +use Friendica\Util\Map; require_once 'include/oembed.php'; require_once 'include/event.php'; -require_once 'include/map.php'; require_once 'mod/proxy.php'; require_once 'include/plaintext.php'; @@ -33,11 +33,11 @@ function bb_PictureCache($matches) { function bb_map_coords($match) { // the extra space in the following line is intentional - return str_replace($match[0], '
' . generate_map(str_replace('/', ' ', $match[1])) . '
', $match[0]); + return str_replace($match[0], '
' . Map::byCoordinates(str_replace('/', ' ', $match[1])) . '
', $match[0]); } function bb_map_location($match) { // the extra space in the following line is intentional - return str_replace($match[0], '
' . generate_named_map($match[1]) . '
', $match[0]); + return str_replace($match[0], '
' . Map::byLocation($match[1]) . '
', $match[0]); } function bb_attachment($Text, $simplehtml = false, $tryoembed = true) { diff --git a/include/event.php b/include/event.php index 4795867b12..bc9467dc80 100644 --- a/include/event.php +++ b/include/event.php @@ -9,9 +9,9 @@ use Friendica\Content\Feature; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Util\Map; require_once 'include/bbcode.php'; -require_once 'include/map.php'; require_once 'include/datetime.php'; require_once "include/conversation.php"; @@ -75,7 +75,7 @@ function format_event_html($ev, $simple = false) { // Include a map of the location if the [map] BBCode is used. if (strpos($ev['location'], "[map") !== false) { - $map = generate_named_map($ev['location']); + $map = Map::byLocation($ev['location']); if ($map !== $ev['location']) { $o.= $map; } @@ -967,9 +967,9 @@ function format_event_item($item) { } // Construct the map HTML. if (isset($evloc['address'])) { - $location['map'] = '
' . generate_named_map($evloc['address']) . '
'; + $location['map'] = '
' . Map::byLocation($evloc['address']) . '
'; } elseif (isset($evloc['coordinates'])) { - $location['map'] = '
' . generate_map(str_replace('/', ' ', $evloc['coordinates'])) . '
'; + $location['map'] = '
' . Map::byCoordinates(str_replace('/', ' ', $evloc['coordinates'])) . '
'; } // Construct the profile link (magic-auth). diff --git a/include/map.php b/include/map.php deleted file mode 100644 index e2398b2fd1..0000000000 --- a/include/map.php +++ /dev/null @@ -1,18 +0,0 @@ - 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); -} diff --git a/include/text.php b/include/text.php index b246623a3a..5cc573697d 100644 --- a/include/text.php +++ b/include/text.php @@ -9,9 +9,9 @@ use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; +use Friendica\Util\Map; require_once "include/friendica_smarty.php"; -require_once "include/map.php"; require_once "mod/proxy.php"; require_once "include/conversation.php"; @@ -1372,7 +1372,7 @@ function prepare_body(&$item, $attach = false, $preview = false) { // Map. if (strpos($s, '
') !== false && x($item, 'coord')) { - $x = generate_map(trim($item['coord'])); + $x = Map::byCoordinates(trim($item['coord'])); if ($x) { $s = preg_replace('/\
/', '$0' . $x, $s); } diff --git a/mod/photos.php b/mod/photos.php index cc3ec71a65..412f2aafff 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1488,7 +1488,7 @@ function photos_content(App $a) { } if ($link_item['coord']) { - $map = generate_map($link_item['coord']); + $map = Map::byCoordinates($link_item['coord']); } } diff --git a/src/Util/Map.php b/src/Util/Map.php new file mode 100644 index 0000000000..e2398b2fd1 --- /dev/null +++ b/src/Util/Map.php @@ -0,0 +1,18 @@ + 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); +}