diff options
author | Yaco <franco@reevo.org> | 2021-10-19 20:24:11 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2021-10-19 20:24:11 -0300 |
commit | e3880a1c86acaa3bbd05786ad2f5c586e6511a58 (patch) | |
tree | ec77bfc5b69f259a159c95188797bd0dade92357 /www/wiki/extensions/Maps/src/MapsSetup.php | |
parent | 20ca0685509f8010580d3b45036a64ab48616af1 (diff) |
updates Maps to 7.13.0
Diffstat (limited to 'www/wiki/extensions/Maps/src/MapsSetup.php')
-rw-r--r-- | www/wiki/extensions/Maps/src/MapsSetup.php | 87 |
1 files changed, 66 insertions, 21 deletions
diff --git a/www/wiki/extensions/Maps/src/MapsSetup.php b/www/wiki/extensions/Maps/src/MapsSetup.php index 245d3915..d682339b 100644 --- a/www/wiki/extensions/Maps/src/MapsSetup.php +++ b/www/wiki/extensions/Maps/src/MapsSetup.php @@ -5,7 +5,7 @@ declare( strict_types = 1 ); namespace Maps; use DataValues\Geo\Parsers\LatLongParser; -use Maps\DataAccess\JsonFileParser; +use Maps\DataAccess\GeoJsonFetcher; use Maps\MediaWiki\Content\GeoJsonContent; use Maps\MediaWiki\Content\GeoJsonContentHandler; use Maps\MediaWiki\ParserHooks\CoordinatesFunction; @@ -47,15 +47,6 @@ class MapsSetup { } } - private function registerAllTheThings() { - $this->registerParserHooks(); - $this->registerPermissions(); - $this->registerParameterTypes(); - $this->registerHooks(); - - $this->mwGlobals['wgContentHandlers'][GeoJsonContent::CONTENT_MODEL_ID] = GeoJsonContentHandler::class; - } - private function defaultSettings() { if ( $this->mwGlobals['egMapsGMaps3Language'] === '' ) { $this->mwGlobals['egMapsGMaps3Language'] = $this->mwGlobals['wgLang']; @@ -74,6 +65,15 @@ class MapsSetup { } } + private function registerAllTheThings() { + $this->registerParserHooks(); + $this->registerPermissions(); + $this->registerParameterTypes(); + $this->registerHooks(); + $this->registerGeoJsonContentModel(); + $this->registerEditApiModuleFallbacks(); + } + private function registerParserHooks() { if ( $this->mwGlobals['egMapsEnableCoordinateFunction'] ) { $this->mwGlobals['wgHooks']['ParserFirstCallInit'][] = function ( Parser &$parser ) { @@ -109,13 +109,7 @@ class MapsSetup { $hookName, function ( $text, array $arguments, Parser $parser ) { if ( $text !== null ) { - $defaultParameters = DisplayMapFunction::getHookDefinition( "\n" )->getDefaultParameters(); - $defaultParam = array_shift( $defaultParameters ); - - // If there is a first default parameter, set the tag contents as its value. - if ( $defaultParam !== null ) { - $arguments[$defaultParam] = $text; - } + $arguments[DisplayMapFunction::getDefaultParameters()[0]] = $text; } return MapsFactory::newDefault()->getDisplayMapFunction()->getMapHtmlForParameterList( $parser, $arguments ); @@ -192,15 +186,66 @@ class MapsSetup { $this->mwGlobals['wgParamDefinitions']['mapsimageoverlay'] = [ 'string-parser' => ImageOverlayParser::class, ]; - - $this->mwGlobals['wgParamDefinitions']['jsonfile'] = [ - 'string-parser' => JsonFileParser::class, - ]; } private function registerHooks() { $this->mwGlobals['wgHooks']['AdminLinks'][] = 'Maps\MediaWiki\MapsHooks::addToAdminLinks'; $this->mwGlobals['wgHooks']['MakeGlobalVariablesScript'][] = 'Maps\MediaWiki\MapsHooks::onMakeGlobalVariablesScript'; + $this->mwGlobals['wgHooks']['SkinTemplateNavigation'][] = 'Maps\MediaWiki\MapsHooks::onSkinTemplateNavigation'; + $this->mwGlobals['wgHooks']['BeforeDisplayNoArticleText'][] = 'Maps\MediaWiki\MapsHooks::onBeforeDisplayNoArticleText'; + $this->mwGlobals['wgHooks']['ShowMissingArticle'][] = 'Maps\MediaWiki\MapsHooks::onShowMissingArticle'; + $this->mwGlobals['wgHooks']['ListDefinedTags'][] = 'Maps\MediaWiki\MapsHooks::onRegisterTags'; + $this->mwGlobals['wgHooks']['ChangeTagsListActive'][] = 'Maps\MediaWiki\MapsHooks::onRegisterTags'; + $this->mwGlobals['wgHooks']['ChangeTagsAllowedAdd'][] = 'Maps\MediaWiki\MapsHooks::onChangeTagsAllowedAdd'; + $this->mwGlobals['wgHooks']['ResourceLoaderTestModules'][] = 'Maps\MediaWiki\MapsHooks::onResourceLoaderTestModules'; + } + + private function registerGeoJsonContentModel() { + $this->mwGlobals['wgContentHandlers'][GeoJsonContent::CONTENT_MODEL_ID] = GeoJsonContentHandler::class; + } + + private function registerEditApiModuleFallbacks() { + // mediawiki.api.edit is present in 1.31 but not 1.32 + // Once Maps requires MW 1.32+, this can be removed after replacing usage of mediawiki.api.edit + if ( version_compare( $this->mwGlobals['wgVersion'], '1.32', '>=' ) ) { + $this->mwGlobals['wgResourceModules']['mediawiki.api.edit'] = [ + 'dependencies' => [ + 'mediawiki.api' + ], + 'targets' => [ 'desktop', 'mobile' ] + ]; + } + + // 1.35 combines the jquery.ui modules into one + if ( version_compare( $this->mwGlobals['wgVersion'], '1.35', '>=' ) ) { + $this->mwGlobals['wgResourceModules']['jquery.ui.resizable'] = [ + 'dependencies' => [ + 'jquery.ui' + ], + 'targets' => [ 'desktop', 'mobile' ] + ]; + + $this->mwGlobals['wgResourceModules']['jquery.ui.autocomplete'] = [ + 'dependencies' => [ + 'jquery.ui' + ], + 'targets' => [ 'desktop', 'mobile' ] + ]; + + $this->mwGlobals['wgResourceModules']['jquery.ui.slider'] = [ + 'dependencies' => [ + 'jquery.ui' + ], + 'targets' => [ 'desktop', 'mobile' ] + ]; + + $this->mwGlobals['wgResourceModules']['jquery.ui.dialog'] = [ + 'dependencies' => [ + 'jquery.ui' + ], + 'targets' => [ 'desktop', 'mobile' ] + ]; + } } } |