Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue 756 geoJson namespace error #757

28 changes: 22 additions & 6 deletions src/GeoJsonPages/GeoJsonContentHandler.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @reviewer thomas-topway-it for KM-A
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not add author or reviewer tags in this repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


declare( strict_types = 1 );

namespace Maps\GeoJsonPages;
Expand Down Expand Up @@ -34,19 +38,31 @@ protected function fillParserOutput(
ParserOutput &$parserOutput
) {
'@phan-var GeoJsonContent $content';

// @see JsonContentHandler -> fillParserOutput
if ( $cpoParams->getGenerateHtml() ) {
if ( $content->isValid() ) {
$text = $content->getData()->getValue();
$parserOutput->setText( $content->rootValueTable( $content->getData()->getValue() ) );

} else {
$error = wfMessage( 'invalid-json-data' )->parse();
$parserOutput->setText( $error );
}
JeroenDeDauw marked this conversation as resolved.
Show resolved Hide resolved

if ( !$cpoParams->getGenerateHtml() || !$content->isValid() ) {
$parserOutput->setText( '' );
return;
$parserOutput->addModuleStyles( [ 'mediawiki.content.json' ] );
} else {
$parserOutput->setText( null );
}

GeoJsonMapPageUi::forExistingPage( $content->beautifyJSON() )
->addToOutput( OutputFacade::newFromParserOutput( $parserOutput ) );
// @FIXME alternatively decode $this->mText in GeoJsonLegacyContent
// to avoid decoding it again in SubObjectBuilder -> getSubObjectsFromGeoJson
$text = json_encode( $content->getData()->getValue() );
JeroenDeDauw marked this conversation as resolved.
Show resolved Hide resolved

if ( MapsFactory::globalInstance()->smwIntegrationIsEnabled() && $parserOutput->hasText() ) {
MapsFactory::globalInstance()
->newSemanticGeoJsonStore( $parserOutput, $cpoParams->getPage() )
->storeGeoJson( $parserOutput->getRawText() );
->storeGeoJson( $text );
}
}
}