Skip to content

Commit

Permalink
Issue 763 - show editor in Geojson namespace (#767)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
thomas-topway-it and krabina authored Mar 26, 2024
1 parent 7175b47 commit 04f3f89
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
6 changes: 5 additions & 1 deletion src/GeoJsonPages/GeoJsonContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
29 changes: 17 additions & 12 deletions src/GeoJsonPages/GeoJsonContentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
}

0 comments on commit 04f3f89

Please sign in to comment.