]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #4060 from annando/system-unavailable
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 13 Dec 2017 22:01:47 +0000 (17:01 -0500)
committerGitHub <noreply@github.com>
Wed, 13 Dec 2017 22:01:47 +0000 (17:01 -0500)
"system_unavailable.php" is unavailable now

include/bbcode.php
include/event.php
include/map.php [deleted file]
include/text.php
mod/photos.php
src/Util/Map.php [new file with mode: 0644]

index 749a7c5946729ddb5828ea9d723c5da71ebe9a0c..be59c180726860a0292f2e10ef0b9e574afbd56f 100644 (file)
@@ -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], '<div class="map"  >' . generate_map(str_replace('/', ' ', $match[1])) . '</div>', $match[0]);
+       return str_replace($match[0], '<div class="map"  >' . Map::byCoordinates(str_replace('/', ' ', $match[1])) . '</div>', $match[0]);
 }
 function bb_map_location($match) {
        // the extra space in the following line is intentional
-       return str_replace($match[0], '<div class="map"  >' . generate_named_map($match[1]) . '</div>', $match[0]);
+       return str_replace($match[0], '<div class="map"  >' . Map::byLocation($match[1]) . '</div>', $match[0]);
 }
 
 function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
index 4795867b129dde88fde5a377f34a7ff000cc113b..bc9467dc80217a1c352277ebaf94ef91c4fe6c3d 100644 (file)
@@ -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'] = '<div class="map">' . generate_named_map($evloc['address']) . '</div>';
+               $location['map'] = '<div class="map">' . Map::byLocation($evloc['address']) . '</div>';
        } elseif (isset($evloc['coordinates'])) {
-               $location['map'] = '<div class="map">' . generate_map(str_replace('/', ' ', $evloc['coordinates'])) . '</div>';
+               $location['map'] = '<div class="map">' . Map::byCoordinates(str_replace('/', ' ', $evloc['coordinates'])) . '</div>';
        }
 
        // Construct the profile link (magic-auth).
diff --git a/include/map.php b/include/map.php
deleted file mode 100644 (file)
index e2398b2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * 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);
-}
index b246623a3a984d84c8c63736d6de2709fbdfb3d7..5cc573697dac656f1c97df0e211815dc4a44a24e 100644 (file)
@@ -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, '<div class="map">') !== false && x($item, 'coord')) {
-               $x = generate_map(trim($item['coord']));
+               $x = Map::byCoordinates(trim($item['coord']));
                if ($x) {
                        $s = preg_replace('/\<div class\=\"map\"\>/', '$0' . $x, $s);
                }
index cc3ec71a658a940127b31b8264bc105b4dce43d6..412f2aafff54416a300670daa3f7a1883d91096a 100644 (file)
@@ -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 (file)
index 0000000..6ca0b1b
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * @file src/Util/Map.php
+ */
+namespace Friendica\Util;
+
+/**
+ * Leaflet Map related functions
+ */
+class Map {
+       public static function byCoordinates($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;
+       }
+
+       public static function byLocation($location) {
+               $arr = array('location' => $location, 'html' => '');
+               call_hooks('generate_named_map',$arr);
+               return ($arr['html']) ? $arr['html'] : $location;
+       }
+}