Skip to content

Commit

Permalink
Bump to 6.x alpha and add stub for GeoJson NS
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Jul 27, 2018
1 parent f23b59d commit 124318f
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 81 deletions.
2 changes: 1 addition & 1 deletion Maps.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static function addToAdminLinks( ALTree &$admin_links_tree ) {

$smw_docu_row = $displaying_data_section->getRow( 'smw' );

$maps_docu_label = wfMessage( 'adminlinks_documentation', 'Maps' )->text();
$maps_docu_label = wfMessage( 'adminlinks_documentation', 'Maps.class' )->text();
$smw_docu_row->addItem(
AlItem::newFromExternalLink( 'https://www.semantic-mediawiki.org/wiki/Extension:Maps', $maps_docu_label )
);
Expand Down
56 changes: 1 addition & 55 deletions Maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,4 @@
* @author Jeroen De Dauw < [email protected] >
*/

use Maps\MapsSetup;

if ( defined( 'Maps_COORDS_FLOAT' ) ) {
// Do not initialize more than once.
return 1;
}

// The different coordinate notations.
define( 'Maps_COORDS_FLOAT', 'float' );
define( 'Maps_COORDS_DMS', 'dms' );
define( 'Maps_COORDS_DM', 'dm' );
define( 'Maps_COORDS_DD', 'dd' );

require_once __DIR__ . '/Maps_Settings.php';

// Include the composer autoloader if it is present.
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once( __DIR__ . '/vendor/autoload.php' );
}

// Internationalization
$GLOBALS['wgMessagesDirs']['Maps'] = __DIR__ . '/i18n';
$GLOBALS['wgExtensionMessagesFiles']['MapsMagic'] = __DIR__ . '/Maps.i18n.magic.php';
$GLOBALS['wgExtensionMessagesFiles']['MapsAlias'] = __DIR__ . '/Maps.i18n.alias.php';

$GLOBALS['wgExtensionFunctions'][] = function() {
if ( $GLOBALS['egMapsDisableExtension'] ) {
return true;
}

if ( defined( 'Maps_VERSION' ) ) {
// Do not initialize more than once.
return true;
}

// Only initialize the extension when all dependencies are present.
if ( !defined( 'Validator_VERSION' ) ) {
throw new Exception( 'You need to have Validator installed in order to use Maps' );
}

if ( version_compare( $GLOBALS['wgVersion'], '1.27c', '<' ) ) {
throw new Exception(
'This version of Maps requires MediaWiki 1.27 or above; use Maps 4.2.x for older versions.'
. ' More information at https://github.com/JeroenDeDauw/Maps/blob/master/INSTALL.md'
);
}

define( 'Maps_VERSION', '5.7 alpha' );
define( 'SM_VERSION', Maps_VERSION );

( new MapsSetup( $GLOBALS ) )->setup();

return true;
};

wfLoadExtension( 'Maps' );
59 changes: 59 additions & 0 deletions MapsRegistration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use Maps\MapsSetup;

class MapsRegistration {

public static function onRegistration() {
if ( defined( 'Maps_COORDS_FLOAT' ) ) {
// Do not initialize more than once.
return true;
}

// The different coordinate notations.
define( 'Maps_COORDS_FLOAT', 'float' );
define( 'Maps_COORDS_DMS', 'dms' );
define( 'Maps_COORDS_DM', 'dm' );
define( 'Maps_COORDS_DD', 'dd' );

require_once __DIR__ . '/Maps_Settings.php';

// Internationalization
$GLOBALS['wgMessagesDirs']['Maps.class'] = __DIR__ . '/i18n';
$GLOBALS['wgExtensionMessagesFiles']['MapsMagic'] = __DIR__ . '/Maps.i18n.magic.php';
$GLOBALS['wgExtensionMessagesFiles']['MapsAlias'] = __DIR__ . '/Maps.i18n.alias.php';

$GLOBALS['wgExtensionFunctions'][] = function() {
if ( $GLOBALS['egMapsDisableExtension'] ) {
return true;
}

if ( defined( 'Maps_VERSION' ) ) {
// Do not initialize more than once.
return true;
}

// Only initialize the extension when all dependencies are present.
if ( !defined( 'Validator_VERSION' ) ) {
throw new Exception( 'You need to have Validator installed in order to use Maps' );
}

if ( version_compare( $GLOBALS['wgVersion'], '1.27c', '<' ) ) {
throw new Exception(
'This version of Maps requires MediaWiki 1.27 or above; use Maps 4.2.x for older versions.'
. ' More information at https://github.com/JeroenDeDauw/Maps/blob/master/INSTALL.md'
);
}

( new MapsSetup( $GLOBALS ) )->setup();

return true;
};

return true;
}

}



3 changes: 0 additions & 3 deletions Maps_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@
// When true, debugging messages will be logged using mw.log(). Do not use on production wikis.
$GLOBALS['egMapsDebugJS'] = false;

// Namespace index start of the mapping namespaces.
$GLOBALS['egMapsNamespaceIndex'] = 420;


// Mapping service specific configuration

Expand Down
14 changes: 14 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ different releases and which versions of PHP and MediaWiki they support, see the
[platform compatibility tables](INSTALL.md#platform-compatibility-and-release-status).


## Maps 6.0.0

Under development

* Dropped support for MediaWiki older than 1.31
* Added `extension.json`

### Breaking changes

* Maps is no longer automatically loaded when it is installed with Composer. You now need to call `wfLoadExtension( 'Maps' )`
(preferred) or include the entry point (`require_once __DIR__ . '/extensions/Maps/Maps.php';`) in `LocalSettings.php`
* Removed `Maps_VERSION` and `SM_VERSION` constants
* Removed `egMapsNamespaceIndex` setting

## Maps 5.7.0

Under development
Expand Down
6 changes: 2 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,14 @@
"data-values/common": "~0.4.1"
},
"autoload": {
"files" : [
"Maps.php"
],
"psr-4": {
"Maps\\": "src/",
"Maps\\Tests\\TestDoubles\\": "tests/TestDoubles/"
},
"classmap": [
"includes/",
"MapsRegistration.php",
"Maps.hooks.php",
"includes/",
"SemanticMaps/src/",
"SemanticMaps/SemanticMaps.hooks.php",
"tests/Unit/Elements/",
Expand Down
42 changes: 42 additions & 0 deletions extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "Maps",
"version": "6.0 alpha",

"author": [
"[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]",
"..."
],
"url": "https://github.com/JeroenDeDauw/Maps/blob/master/README.md#maps",
"descriptionmsg": "maps-desc",
"license-name": "GPL-2.0-or-later",
"type": "parserhook",

"requires": {
"MediaWiki": ">= 1.31.0"
},

"callback": "MapsRegistration::onRegistration",
"ContentHandlers": {
"GeoJson": "Maps\\GeoJson\\GeoJsonContentHandler"
},
"namespaces": [
{
"id": 420,
"constant": "NS_GEO_JSON",
"name": "GeoJson",
"subpages": false,
"content": true,
"defaultcontentmodel": "GeoJson"
},
{
"id": 556,
"constant": "NS_GEO_JSON_TALK",
"name": "GeoJson_talk",
"subpages": true,
"content": false,
"defaultcontentmodel": "wikitext"
}
],

"manifest_version": 2
}
2 changes: 1 addition & 1 deletion includes/specials/SpecialMapEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ protected function getAttribs() {
}

protected function getGroupName() {
return 'maps';
return 'Maps.class';
}
}
13 changes: 13 additions & 0 deletions src/GeoJson/GeoJsonContent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Maps\GeoJson;

class GeoJsonContent extends \JsonContent {

/* public */ const CONTENT_MODEL_ID = 'GeoJSON';

public function __construct( $text, $modelId = self::CONTENT_MODEL_ID ) {
parent::__construct( $text, $modelId );
}

}
15 changes: 15 additions & 0 deletions src/GeoJson/GeoJsonContentHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Maps\GeoJson;

class GeoJsonContentHandler extends \JsonContentHandler {

public function __construct( $modelId = GeoJsonContent::CONTENT_MODEL_ID ) {
parent::__construct( $modelId );
}

protected function getContentClass() {
return GeoJsonContent::class;
}

}
22 changes: 5 additions & 17 deletions src/MapsSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class MapsSetup {

private $mwGlobals;

public static function foo( ) {
return true;
}

public function __construct( array &$mwGlobals ) {
$this->mwGlobals = $mwGlobals;
}
Expand All @@ -42,7 +46,6 @@ public function setup() {
}

private function registerAllTheThings() {
$this->registerCredits();
$this->registerWebResources();
$this->registerApiModules();
$this->registerParserHooks();
Expand All @@ -59,29 +62,14 @@ private function defaultSettings() {

if ( in_array( 'googlemaps3', $this->mwGlobals['egMapsAvailableServices'] ) ) {
$this->mwGlobals['wgSpecialPages']['MapEditor'] = 'SpecialMapEditor';
$this->mwGlobals['wgSpecialPageGroups']['MapEditor'] = 'maps';
$this->mwGlobals['wgSpecialPageGroups']['MapEditor'] = 'Maps.class';
}

if ( $this->mwGlobals['egMapsGMaps3ApiKey'] === '' && array_key_exists( 'egGoogleJsApiKey', $this->mwGlobals ) ) {
$this->mwGlobals['egMapsGMaps3ApiKey'] = $this->mwGlobals['egGoogleJsApiKey'];
}
}

private function registerCredits() {
$this->mwGlobals['wgExtensionCredits']['parserhook'][] = [
'path' => __FILE__,
'name' => 'Maps',
'version' => Maps_VERSION,
'author' => [
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]',
'...'
],
'url' => 'https://github.com/JeroenDeDauw/Maps/blob/master/README.md#maps',
'descriptionmsg' => 'maps-desc',
'license-name' => 'GPL-2.0-or-later'
];
}

private function registerWebResources() {
$this->mwGlobals['wgResourceModules'] = array_merge(
$this->mwGlobals['wgResourceModules'],
Expand Down

0 comments on commit 124318f

Please sign in to comment.