From 04f3f89950c0aeb593281aa529cdd07796752712 Mon Sep 17 00:00:00 2001 From: thomas-topway-it Date: Tue, 26 Mar 2024 18:59:57 +0400 Subject: [PATCH] Issue 763 - show editor in Geojson namespace (#767) * Update Basemap.at URLs according to https://cdn.basemap.at/basemap.at_URL_Umstellung_2023.pdf * Update leaflet-providers.js * Update leaflet-providers.js * add static function * fixes show editor MW > 1.37 * removed unused method * fix variable * fix condition * fix space --------- Co-authored-by: Bernhard Krabina --- src/GeoJsonPages/GeoJsonContent.php | 6 ++++- src/GeoJsonPages/GeoJsonContentHandler.php | 29 +++++++++++++--------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/GeoJsonPages/GeoJsonContent.php b/src/GeoJsonPages/GeoJsonContent.php index 89145499..f5841e84 100644 --- a/src/GeoJsonPages/GeoJsonContent.php +++ b/src/GeoJsonPages/GeoJsonContent.php @@ -13,7 +13,11 @@ class GeoJsonContent extends \JsonContent { public static function newEmptyContentString(): string { $text = '{"type": "FeatureCollection", "features": []}'; - return FormatJson::encode( FormatJson::parse( $text )->getValue(), true, FormatJson::UTF8_OK ); + return self::formatJson( FormatJson::parse( $text )->getValue() ); + } + + public static function formatJson( $value ): string { + return FormatJson::encode( $value, true, FormatJson::UTF8_OK ); } public function __construct( string $text, string $modelId = self::CONTENT_MODEL_ID ) { diff --git a/src/GeoJsonPages/GeoJsonContentHandler.php b/src/GeoJsonPages/GeoJsonContentHandler.php index 75a23865..732f7721 100644 --- a/src/GeoJsonPages/GeoJsonContentHandler.php +++ b/src/GeoJsonPages/GeoJsonContentHandler.php @@ -34,21 +34,26 @@ protected function fillParserOutput( ParserOutput &$parserOutput ) { '@phan-var GeoJsonContent $content'; + // this method won't be called below MW_VERSION 1.38 - parent::fillParserOutput( $content, $cpoParams, $parserOutput ); - - if ( $cpoParams->getGenerateHtml() - && $content->isValid() - && MapsFactory::globalInstance()->smwIntegrationIsEnabled() - && $parserOutput->hasText() ) { + if ( $cpoParams->getGenerateHtml() && $content->isValid() ) { - // @FIXME alternatively decode $this->mText in GeoJsonLegacyContent - // to avoid decoding it again in SubObjectBuilder -> getSubObjectsFromGeoJson - $text = json_encode( $content->getData()->getValue() ); + // display map + ( GeoJsonMapPageUi::forExistingPage( GeoJsonContent::formatJson( $content->getData()->getValue() ) ) ) + ->addToOutput( OutputFacade::newFromParserOutput( $parserOutput ) ); - MapsFactory::globalInstance() - ->newSemanticGeoJsonStore( $parserOutput, $cpoParams->getPage() ) - ->storeGeoJson( $text ); + if ( MapsFactory::globalInstance()->smwIntegrationIsEnabled() ) { + // @FIXME alternatively decode $this->mText in GeoJsonLegacyContent + // to avoid decoding it again in SubObjectBuilder -> getSubObjectsFromGeoJson + $text = json_encode( $content->getData()->getValue() ); + + MapsFactory::globalInstance() + ->newSemanticGeoJsonStore( $parserOutput, $cpoParams->getPage() ) + ->storeGeoJson( $text ); + } + + } else { + parent::fillParserOutput( $content, $cpoParams, $parserOutput ); } } }