diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index ca4a05dd..22ec12e3 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -111,6 +111,18 @@ final class Wall extends VKAPIRequestHandler ]; } + $geo = []; + + if($post->getGeolocation()) { + $geoarray = $post->getGeolocationByArray(); + + $geo = [ + "coordinates" => $geoarray[0] . " " . $geoarray[1], + "showmap" => 1, + "type" => "point" + ]; + } + $items[] = (object)[ "id" => $post->getVirtualId(), "from_id" => $from_id, @@ -128,6 +140,7 @@ final class Wall extends VKAPIRequestHandler "is_explicit" => $post->isExplicit(), "attachments" => $attachments, "post_source" => $post_source, + "geo" => $geo, "comments" => (object)[ "count" => $post->getCommentsCount(), "can_post" => 1 diff --git a/Web/Models/Entities/Post.php b/Web/Models/Entities/Post.php index e84a8107..03210144 100644 --- a/Web/Models/Entities/Post.php +++ b/Web/Models/Entities/Post.php @@ -181,6 +181,18 @@ class Post extends Postable return $this->getRecord()->geolocation; } + function getGeolocationAsArray(): ?array { + $location = $this->getRecord()->geolocation; + if(is_null($location)) return null; + + preg_match('/^((\-?|\+?)?\d+(\.\d+)?),\s*((\-?|\+?)?\d+(\.\d+)?)$/', $location, $location_array); + + $latitude = floatval($location_array[1]); + $longitude = floatval($location_array[4]); + + return array($latitude, $longitude); + } + function getMapEmbed(): ?string { $location = $this->getRecord()->geolocation; if(is_null($location)) return null; diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 2c9fbd10..8c08d282 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -268,7 +268,7 @@ async function openMapDialog(id) { let iframe = await API.Wall.getMapIframe(id) - let frame = MessageBox("Геолокация", iframe, [tr("close")], [Function.noop]); + let frame = MessageBox(tr("geolocation"), iframe, [tr("close")], [Function.noop]); document.querySelector(".ovk-diag-body").style.padding = "10px" } diff --git a/locales/en.strings b/locales/en.strings index 4aaa4483..28ea12f9 100644 --- a/locales/en.strings +++ b/locales/en.strings @@ -214,6 +214,8 @@ "reply" = "Reply"; +"geolocation" = "Geolocation"; + /* Friends */ "friends" = "Friends"; diff --git a/locales/ru.strings b/locales/ru.strings index 6faa5e2e..3a6c2120 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -191,6 +191,7 @@ "version_incompatibility" = "Не удалось отобразить это вложение. Возможно, база данных несовместима с текущей версией OpenVK."; "graffiti" = "Граффити"; "reply" = "Ответить"; +"geolocation" = "Геолокация"; /* Friends */