diff --git a/src/GeoJsonPages/GeoJsonContentHandler.php b/src/GeoJsonPages/GeoJsonContentHandler.php index 75a23865..70b6a147 100644 --- a/src/GeoJsonPages/GeoJsonContentHandler.php +++ b/src/GeoJsonPages/GeoJsonContentHandler.php @@ -5,6 +5,7 @@ namespace Maps\GeoJsonPages; use Content; +use FormatJson; use Maps\MapsFactory; use Maps\Presentation\OutputFacade; use MediaWiki\Content\Renderer\ContentParseParams; @@ -24,6 +25,11 @@ public function makeEmptyContent(): GeoJsonContent { $class = $this->getContentClass(); return new $class( $class::newEmptyContentString() ); } + + public static function newEmptyContentString(): string { + $text = '{"type": "FeatureCollection", "features": []}'; + return FormatJson::encode( FormatJson::parse( $text )->getValue(), true, FormatJson::UTF8_OK ); + } /** * @inheritdoc @@ -34,13 +40,14 @@ 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() ) { + && MapsFactory::globalInstance()->smwIntegrationIsEnabled() ) { + + ( GeoJsonMapPageUi::forExistingPage( GeoJsonContent::formatJson( $content->getData()->getValue() ) ) ) + ->addToOutput( OutputFacade::newFromParserOutput( $parserOutput ) ); // @FIXME alternatively decode $this->mText in GeoJsonLegacyContent // to avoid decoding it again in SubObjectBuilder -> getSubObjectsFromGeoJson @@ -49,6 +56,9 @@ protected function fillParserOutput( MapsFactory::globalInstance() ->newSemanticGeoJsonStore( $parserOutput, $cpoParams->getPage() ) ->storeGeoJson( $text ); + + } else { + parent::fillParserOutput( $content, $cpoParams, $parserOutput ); } } }