Jeroen De Dauw has uploaded a new change for review.
https://gerrit.wikimedia.org/r/80031
Change subject: Infrastructure improvements
......................................................................
Infrastructure improvements
Change-Id: I3e017cc4105ccfb7af19ad1debdf16151a3822f0
---
M Maps.php
M Maps_Settings.php
M README.md
A composer.json
M includes/services/GoogleMaps3/GoogleMaps3.php
M includes/services/Leaflet/Leaflet.php
M includes/services/OpenLayers/OpenLayers.php
A phpunit.xml.dist
A tests/bootstrap.php
A tests/evilMediaWikiBootstrap.php
10 files changed, 499 insertions(+), 296 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Maps
refs/changes/31/80031/1
diff --git a/Maps.php b/Maps.php
index 69c2196..3a7005b 100644
--- a/Maps.php
+++ b/Maps.php
@@ -27,196 +27,210 @@
die( 'Not an entry point.' );
}
-if ( version_compare( $wgVersion , '1.18c' , '<' ) ) {
- die( '<b>Error:</b> This version of Maps requires MediaWiki 1.18 or
above; use Maps 1.0.x for MediaWiki 1.17 and Maps 0.7.x for older versions.' );
-}
-
-// Include the Validator extension if that hasn't been done yet, since it's
required for Maps to work.
-if ( !defined( 'Validator_VERSION' ) ) {
- @include_once( __DIR__ . '/../Validator/Validator.php' );
-}
-
-// Only initialize the extension when all dependencies are present.
-if ( !defined( 'ParamProcessor_VERSION' ) ) {
- die( '<b>Error:</b> You need to have <a
href="http://www.mediawiki.org/wiki/Extension:Validator">Validator
(ParamProcessor)</a> 1.0 or later installed in order to use <a
href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.<br />' );
+if ( defined( 'Maps_VERSION' ) ) {
+ // Do not initialize more then once.
+ return;
}
define( 'Maps_VERSION' , '3.0 alpha' );
-$wgExtensionCredits['parserhook'][] = array(
- 'path' => __FILE__ ,
- 'name' => 'Maps' ,
- 'version' => Maps_VERSION ,
- 'author' => array(
- '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De
Dauw]'
- ) ,
- 'url' => 'https://www.mediawiki.org/wiki/Extension:Maps' ,
- 'descriptionmsg' => 'maps-desc'
-);
-
-// The different coordinate notations.
-define( 'Maps_COORDS_FLOAT' , 'float' );
-define( 'Maps_COORDS_DMS' , 'dms' );
-define( 'Maps_COORDS_DM' , 'dm' );
-define( 'Maps_COORDS_DD' , 'dd' );
-
-$egMapsScriptPath = ( $wgExtensionAssetsPath === false ? $wgScriptPath .
'/extensions' : $wgExtensionAssetsPath ) . '/Maps';
-$egMapsDir = __DIR__ . '/';
-
-$egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION;
-
-$wgExtensionMessagesFiles['Maps'] = __DIR__ .
'/Maps.i18n.php';
-$wgExtensionMessagesFiles['MapsMagic'] = __DIR__ .
'/Maps.i18n.magic.php';
-$wgExtensionMessagesFiles['MapsNamespaces'] = __DIR__ .
'/Maps.i18n.namespaces.php';
-$wgExtensionMessagesFiles['MapsAlias'] = __DIR__ .
'/Maps.i18n.alias.php';
-
-$wgAutoloadClasses = array_merge( $wgAutoloadClasses, include
'Maps.classes.php' );
-
-$wgResourceModules = array_merge( $wgResourceModules, include
'Maps.resources.php' );
-
-$wgAPIModules['geocode'] = 'Maps\Api\Geocode';
-
-// Register the initialization function of Maps.
-$wgExtensionFunctions[] = function () {
- wfRunHooks( 'MappingServiceLoad' );
- wfRunHooks( 'MappingFeatureLoad' );
-
- if ( in_array( 'googlemaps3', $GLOBALS['egMapsAvailableServices'] ) ) {
- global $wgSpecialPages, $wgSpecialPageGroups;
-
- $wgSpecialPages['MapEditor'] = 'SpecialMapEditor';
- $wgSpecialPageGroups['MapEditor'] = 'maps';
- }
-
- return true;
-};
-
-// Since 0.2
-$wgHooks['AdminLinks'][] = 'MapsHooks::addToAdminLinks';
-
-// Since 0.6.5
-$wgHooks['UnitTestsList'][] = 'MapsHooks::registerUnitTests';
-
-// Since 0.7.1
-$wgHooks['ArticleFromTitle'][] = 'MapsHooks::onArticleFromTitle';
-
-// Since 1.0
-$wgHooks['MakeGlobalVariablesScript'][] =
'MapsHooks::onMakeGlobalVariablesScript';
-
-// Since ??
-$wgHooks['CanonicalNamespaces'][] = 'MapsHooks::onCanonicalNamespaces';
-
-// Parser hooks
-
-// Required for #coordinates.
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsCoordinates();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsDisplayMap();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsDistance();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsFinddestination();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsGeocode();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsGeodistance();
- return $instance->init( $parser );
-};
-
-$wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
- $instance = new MapsMapsDoc();
- return $instance->init( $parser );
-};
-
-// Geocoders
-
-// Registration of the GeoNames service geocoder.
-$wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register';
-
-// Registration of the Google Geocoding (v2) service geocoder.
-$wgHooks['GeocoderFirstCallInit'][] = 'MapsGoogleGeocoder::register';
-
-// Layers
-
-// Registration of the image layer type.
-$wgHooks['MappingLayersInitialization'][] = 'MapsImageLayer::register';
-
-// Registration of the KML layer type.
-$wgHooks['MappingLayersInitialization'][] = 'MapsKMLLayer::register';
-
-// Mapping services
-
-// Include the mapping services that should be loaded into Maps.
-// Commenting or removing a mapping service will make Maps completely ignore
it, and so improve performance.
-
-// Google Maps API v3
-// TODO: improve loading mechanism
-include_once $egMapsDir . 'includes/services/GoogleMaps3/GoogleMaps3.php';
-
-// OpenLayers API
-// TODO: improve loading mechanism
-include_once $egMapsDir . 'includes/services/OpenLayers/OpenLayers.php';
-
-// Leaflet API
-// TODO: improve loading mechanism
-include_once $egMapsDir . 'includes/services/Leaflet/Leaflet.php';
-
-
-$egMapsSettings = array();
-
-// Include the settings file.
-require_once $egMapsDir . 'Maps_Settings.php';
-
-define( 'Maps_NS_LAYER' , $egMapsNamespaceIndex + 0 );
-define( 'Maps_NS_LAYER_TALK' , $egMapsNamespaceIndex + 1 );
-
-$wgAvailableRights[] = 'geocode';
-
-// Users that can geocode. By default the same as those that can edit.
-foreach ( $wgGroupPermissions as $group => $rights ) {
- if ( array_key_exists( 'edit' , $rights ) ) {
- $wgGroupPermissions[$group]['geocode'] =
$wgGroupPermissions[$group]['edit'];
- }
+// Include the composer autoloader if it is present.
+if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
+ include_once( __DIR__ . '/vendor/autoload.php' );
}
-$egMapsGlobalJSVars = array();
+// Attempt to include the ParamProcessor lib if that has not been loaded yet.
+if ( !defined( 'ParamProcessor_VERSION' ) && file_exists( __DIR__ .
'/../Validator/Validator.php' ) ) {
+ include_once( __DIR__ . '/../Validator/Validator.php' );
+}
-$wgParamDefinitions['mappingservice'] = array(
- 'definition'=> 'Maps\ServiceParam',
-);
+// Attempt to include the DataValues lib if that has not been loaded yet.
+if ( !defined( 'DataValues_VERSION' ) && file_exists( __DIR__ .
'/../DataValues/DataValues.php' ) ) {
+ include_once( __DIR__ . '/../DataValues/DataValues.php' );
+}
-$wgParamDefinitions['mapslocation'] = array(
- 'string-parser' => 'Maps\LocationParser',
-);
+// Only initialize the extension when all dependencies are present.
+if ( !defined( 'ParamProcessor_VERSION' ) ) {
+ throw new Exception( 'You need to have ParamProcessor (Validator) 1.0
or later installed in order to use Maps' );
+}
-$wgParamDefinitions['mapsline'] = array(
- 'string-parser' => 'Maps\LineParser',
-);
+// Only initialize the extension when all dependencies are present.
+if ( !defined( 'DataValues_VERSION' ) ) {
+ throw new Exception( 'You need to have DataValues installed in order to
use Maps' );
+}
-$wgParamDefinitions['mapspolygon'] = array(
- 'string-parser' => 'Maps\PolygonParser',
-);
+if ( version_compare( $GLOBALS['wgVersion'], '1.18c' , '<' ) ) {
+ throw new Exception( 'This version of Maps requires MediaWiki 1.18 or
above; use Maps 1.0.x for MediaWiki 1.17 and Maps 0.7.x for older versions.' );
+}
-$wgParamDefinitions['distance'] = array(
- 'string-parser' => 'Maps\DistanceParser',
-);
+call_user_func( function() {
+ global $wgExtensionCredits, $wgExtensionAssetsPath, $wgScriptPath,
$wgAutoloadClasses;
+ global $wgResourceModules, $wgGroupPermissions, $egMapsNamespaceIndex,
$wgStyleVersion;
+ global $egMapsScriptPath, $egMapsStyleVersion, $wgHooks,
$wgExtensionMessagesFiles;
-$wgParamDefinitions['wmsoverlay'] = array(
- 'string-parser' => 'Maps\WmsOverlayParser',
-);
+ $wgExtensionCredits['parserhook'][] = array(
+ 'path' => __FILE__ ,
+ 'name' => 'Maps' ,
+ 'version' => Maps_VERSION ,
+ 'author' => array(
+ '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw
Jeroen De Dauw]'
+ ) ,
+ 'url' => 'https://www.mediawiki.org/wiki/Extension:Maps' ,
+ 'descriptionmsg' => 'maps-desc'
+ );
+
+ // The different coordinate notations.
+ define( 'Maps_COORDS_FLOAT' , 'float' );
+ define( 'Maps_COORDS_DMS' , 'dms' );
+ define( 'Maps_COORDS_DM' , 'dm' );
+ define( 'Maps_COORDS_DD' , 'dd' );
+
+ $egMapsScriptPath = ( $wgExtensionAssetsPath === false ? $wgScriptPath
. '/extensions' : $wgExtensionAssetsPath ) . '/Maps';
+ $egMapsDir = __DIR__ . '/';
+
+ $egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION;
+
+ $wgExtensionMessagesFiles['Maps'] =
__DIR__ . '/Maps.i18n.php';
+ $wgExtensionMessagesFiles['MapsMagic'] = __DIR__ .
'/Maps.i18n.magic.php';
+ $wgExtensionMessagesFiles['MapsNamespaces'] = __DIR__ .
'/Maps.i18n.namespaces.php';
+ $wgExtensionMessagesFiles['MapsAlias'] = __DIR__ .
'/Maps.i18n.alias.php';
+
+ $wgAutoloadClasses = array_merge( $wgAutoloadClasses, include
'Maps.classes.php' );
+
+ $wgResourceModules = array_merge( $wgResourceModules, include
'Maps.resources.php' );
+
+ $wgAPIModules['geocode'] = 'Maps\Api\Geocode';
+
+ // Register the initialization function of Maps.
+ $GLOBALS['wgExtensionFunctions'][] = function () {
+ wfRunHooks( 'MappingServiceLoad' );
+ wfRunHooks( 'MappingFeatureLoad' );
+
+ if ( in_array( 'googlemaps3',
$GLOBALS['egMapsAvailableServices'] ) ) {
+ global $wgSpecialPages, $wgSpecialPageGroups;
+
+ $wgSpecialPages['MapEditor'] = 'SpecialMapEditor';
+ $wgSpecialPageGroups['MapEditor'] = 'maps';
+ }
+
+ return true;
+ };
+
+ $wgHooks['AdminLinks'][] = 'MapsHooks::addToAdminLinks';
+ $wgHooks['UnitTestsList'][] = 'MapsHooks::registerUnitTests';
+ $wgHooks['ArticleFromTitle'][] = 'MapsHooks::onArticleFromTitle';
+ $wgHooks['MakeGlobalVariablesScript'][] =
'MapsHooks::onMakeGlobalVariablesScript';
+ $wgHooks['CanonicalNamespaces'][] = 'MapsHooks::onCanonicalNamespaces';
+
+ // Parser hooks
+
+ // Required for #coordinates.
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsCoordinates();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsDisplayMap();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsDistance();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsFinddestination();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsGeocode();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsGeodistance();
+ return $instance->init( $parser );
+ };
+
+ $wgHooks['ParserFirstCallInit'][] = function( Parser &$parser ) {
+ $instance = new MapsMapsDoc();
+ return $instance->init( $parser );
+ };
+
+ // Geocoders
+
+ // Registration of the GeoNames service geocoder.
+ $wgHooks['GeocoderFirstCallInit'][] = 'MapsGeonamesGeocoder::register';
+
+ // Registration of the Google Geocoding (v2) service geocoder.
+ $wgHooks['GeocoderFirstCallInit'][] = 'MapsGoogleGeocoder::register';
+
+ // Layers
+
+ // Registration of the image layer type.
+ $wgHooks['MappingLayersInitialization'][] = 'MapsImageLayer::register';
+
+ // Registration of the KML layer type.
+ $wgHooks['MappingLayersInitialization'][] = 'MapsKMLLayer::register';
+
+ // Mapping services
+
+ // Include the mapping services that should be loaded into Maps.
+ // Commenting or removing a mapping service will make Maps completely
ignore it, and so improve performance.
+
+ // Google Maps API v3
+ // TODO: improve loading mechanism
+ include_once $egMapsDir .
'includes/services/GoogleMaps3/GoogleMaps3.php';
+
+ // OpenLayers API
+ // TODO: improve loading mechanism
+ include_once $egMapsDir . 'includes/services/OpenLayers/OpenLayers.php';
+
+ // Leaflet API
+ // TODO: improve loading mechanism
+ include_once $egMapsDir . 'includes/services/Leaflet/Leaflet.php';
+
+
+ require_once __DIR__ . '/Maps_Settings.php';
+
+ define( 'Maps_NS_LAYER' , $egMapsNamespaceIndex + 0 );
+ define( 'Maps_NS_LAYER_TALK' , $egMapsNamespaceIndex + 1 );
+
+ $wgAvailableRights[] = 'geocode';
+
+ // Users that can geocode. By default the same as those that can edit.
+ foreach ( $wgGroupPermissions as $group => $rights ) {
+ if ( array_key_exists( 'edit' , $rights ) ) {
+ $wgGroupPermissions[$group]['geocode'] =
$wgGroupPermissions[$group]['edit'];
+ }
+ }
+
+ global $wgParamDefinitions;
+
+ $wgParamDefinitions['mappingservice'] = array(
+ 'definition'=> 'Maps\ServiceParam',
+ );
+
+ $wgParamDefinitions['mapslocation'] = array(
+ 'string-parser' => 'Maps\LocationParser',
+ );
+
+ $wgParamDefinitions['mapsline'] = array(
+ 'string-parser' => 'Maps\LineParser',
+ );
+
+ $wgParamDefinitions['mapspolygon'] = array(
+ 'string-parser' => 'Maps\PolygonParser',
+ );
+
+ $wgParamDefinitions['distance'] = array(
+ 'string-parser' => 'Maps\DistanceParser',
+ );
+
+ $wgParamDefinitions['wmsoverlay'] = array(
+ 'string-parser' => 'Maps\WmsOverlayParser',
+ );
+} );
diff --git a/Maps_Settings.php b/Maps_Settings.php
index 44f21a5..3543ff8 100644
--- a/Maps_Settings.php
+++ b/Maps_Settings.php
@@ -19,7 +19,7 @@
die( 'Not an entry point.' );
}
-
+global $egMapsAvailableServices, $egMapsDefaultService, $egMapsDefaultServices;
// Mapping services configuration
@@ -27,8 +27,7 @@
$egMapsAvailableServices = array(
'googlemaps3',
'openlayers',
- 'leaflet',
- //'osm'
+ 'leaflet',
);
// String. The default mapping service, which will be used when no
default
@@ -49,6 +48,9 @@
// Geocoding
+
+global $egMapsAvailableGeoServices, $egMapsDefaultGeoService,
$egMapsUserGeoOverrides;
+global $egMapsAllowCoordsGeocoding, $egMapsEnableGeoCache, $egMapsGeoNamesUser;
// Array of String. Array containing all the geocoding services that
will be
// made available to the user. Currently Maps provides the following
services:
@@ -86,6 +88,9 @@
// Coordinate configuration
+global $egMapsAvailableCoordNotations, $egMapsCoordinateNotation,
$egMapsCoordinateDirectional;
+global $egMapsInternatDirectionLabels;
+
// The coordinate notations that should be available.
$egMapsAvailableCoordNotations = array(
Maps_COORDS_FLOAT,
@@ -108,7 +113,9 @@
// Distance configuration
-
+
+global $egMapsDistanceUnits, $egMapsDistanceUnit, $egMapsDistanceDecimals;
+
// Array. A list of units (keys) and how many meters they represent
(value).
// No spaces! If the unit consists out of multiple words, just write
them together.
$egMapsDistanceUnits = array(
@@ -135,6 +142,9 @@
// General map configuration
+
+global $egMapsMapWidth, $egMapsMapHeight, $egMapsSizeRestrictions,
$egMapsDefaultMapCentre;
+global $egMapsDefaultTitle, $egMapsDefaultLabel, $egMapsResizableByDefault,
$egMapsRezoomForKML;
// Integer or string. The default width and height of a map. These
values will
// only be used when the user does not provide them.
@@ -165,7 +175,9 @@
// Other general configuration
-
+
+global $egMapsDebugJS, $egMapsNamespaceIndex, $egMapsAllowExternalImages;
+
// When true, debugging messages will be logged using mw.log(). Do not
use on production wikis.
$egMapsDebugJS = false;
@@ -180,7 +192,11 @@
// Specific mapping service configuration
// Google Maps v3
-
+
+global $egMapsGMaps3Zoom, $egMapsGMaps3Types, $egMapsGMaps3Type,
$egMapsGMaps3Controls;
+global $egMapsGMaps3DefTypeStyle, $egMapsGMaps3DefZoomStyle,
$egMapsGMaps3AutoInfoWindows;
+global $egMapsGMaps3Layers, $egMapsGMaps3DefaultTilt, $egGoogleJsApiKey,
$egMapsShowPOI;
+
// Integer. The default zoom of a map. This value will only be
used when the
// user does not provide one.
$egMapsGMaps3Zoom = 14;
@@ -237,7 +253,10 @@
// OpenLayers
-
+
+global $egMapsOpenLayersZoom, $egMapsOLControls, $egMapsOLLayers,
$egMapsOLAvailableLayers;
+global $egMapsOLLayerGroups, $egMapsOLLayerDependencies;
+
// Integer. The default zoom of a map. This value will only be
used when the
// user does not provide one.
$egMapsOpenLayersZoom = 13;
@@ -289,7 +308,9 @@
'bing' => array( 'bing-normal', 'bing-satellite',
'bing-hybrid' ),
'osm' => array( 'osmarender', 'osm-mapnik',
'osm-cyclemap' ),
);
-
+
+ global $wgJsMimeType;
+
// Layer dependencies
$egMapsOLLayerDependencies = array(
'yahoo' => "<style type='text/css'> #controls {width:
512px;}</style><script
src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>",
@@ -299,6 +320,12 @@
// Leaflet
+global $egMapsLeafletZoom;
+
// Integer. The default zoom of a map. This value will only be
used when the
// user does not provide one.
- $egMapsLeafletZoom = 14;
\ No newline at end of file
+ $egMapsLeafletZoom = 14;
+
+
+global $egMapsGlobalJSVars;
+$egMapsGlobalJSVars = array();
\ No newline at end of file
diff --git a/README.md b/README.md
index ca36611..f3c1ca3 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,5 @@
# Maps
-[](http://travis-ci.org/wikimedia/mediawiki-extensions-Maps)
-
Maps is the MediaWiki extension that provides the ability to visualize
geographic data
with dynamic, JavaScript based, mapping API's such as Google Maps and
OpenLayers in your
wiki pages. It has build in support for geocoding, displaying maps, displaying
markers,
@@ -13,17 +11,23 @@
and OpenStreetMap. These also allow you to display maps with Google Earth,
OpenStreetMaps,
Bing maps and others.
+[](http://travis-ci.org/wikimedia/mediawiki-extensions-Maps)
+[](https://coveralls.io/r/wikimedia/mediawiki-extensions-Maps?branch=master)
+[](https://www.versioneye.com/php/mediawiki:maps/dev-master)
+
+On [Packagist](https://packagist.org/packages/mediawiki/maps):
+[](https://packagist.org/packages/mediawiki/maps)
+[](https://packagist.org/packages/mediawiki/maps)
+
Notes on installing Maps are found in the file INSTALL.
## Contributing
-If you have bug reports or requests, please add them to the Talk page [0]. You
can also
-send them to Jeroen De Dauw, jeroendedauw -at- gmail.com, and Yaron Koren, at
yaron57 -at-
-gmail.com.
+If you have bug reports or requests, please add them to
+[the Talk page](https://www.mediawiki.org/wiki/Extension_talk:Maps).
+You can also send them to Jeroen De Dauw, jeroendedauw -at- gmail.com,
+and Yaron Koren, at yaron57 -at- gmail.com.
-[0] http://www.mediawiki.org/w/index.php?title=Extension_talk:Maps
-
-For more info, see http://mapping.referata.com/wiki/Mapping_on_MediaWiki
## Credits to other projects
@@ -63,4 +67,5 @@
* [Maps on Ohloh](https://www.ohloh.net/p/maps)
* [Maps on MediaWiki.org](https://www.mediawiki.org/wiki/Extension:Maps)
-* [TravisCI build
status](https://travis-ci.org/wikimedia/mediawiki-extensions-Maps)
\ No newline at end of file
+* [TravisCI build
status](https://travis-ci.org/wikimedia/mediawiki-extensions-Maps)
+* [Semantic Maps on
MediaWiki.org](https://www.mediawiki.org/wiki/Extension:Semantic_Maps)
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..c5d95cd
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,29 @@
+{
+ "name": "mediawiki/maps",
+ "description": "Adds various mapping features to MediaWiki",
+ "keywords": ["MediaWiki", "Semantic MediaWiki", "Maps", "Google Maps",
"OpenLayers", "OSM", "OpenStreetMap"],
+ "homepage": "https://www.mediawiki.org/wiki/Extension:Maps",
+ "license": "GPL-2.0+",
+ "authors": [
+ {
+ "name": "Jeroen De Dauw",
+ "email": "[email protected]",
+ "homepage": "http://jeroendedauw.com",
+ "role": "Creator and lead developer"
+ }
+ ],
+ "support": {
+ "email": "[email protected]",
+ "issues": "https://bugzilla.wikimedia.org/",
+ "irc": "irc://irc.freenode.net/mediawiki",
+ "forum": "https://www.mediawiki.org/wiki/Extension_talk:Maps",
+ "wiki": "https://www.mediawiki.org/wiki/Extension:Maps",
+ "source":
"https://github.com/wikimedia/mediawiki-extensions-Maps"
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "param-processor/param-processor": "dev-master",
+ "data-values/data-values": "dev-master"
+ },
+ "minimum-stability" : "dev"
+}
diff --git a/includes/services/GoogleMaps3/GoogleMaps3.php
b/includes/services/GoogleMaps3/GoogleMaps3.php
index 8f74e34..cf02f05 100644
--- a/includes/services/GoogleMaps3/GoogleMaps3.php
+++ b/includes/services/GoogleMaps3/GoogleMaps3.php
@@ -21,63 +21,67 @@
die( 'Not an entry point.' );
}
-$wgResourceModules['ext.maps.googlemaps3'] = array(
- 'dependencies' => array( 'ext.maps.common' ),
- 'localBasePath' => __DIR__,
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'jquery.googlemap.js',
- 'ext.maps.googlemaps3.js'
- ),
- 'messages' => array(
- 'maps-googlemaps3-incompatbrowser',
- 'maps-copycoords-prompt',
- 'maps-searchmarkers-text',
- )
-);
+call_user_func( function() {
+ global $wgResourceModules, $egMapsScriptPath, $wgHooks;
-$wgResourceModules['ext.maps.gm3.markercluster'] = array(
- 'localBasePath' => __DIR__ . '/gm3-util-library',
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'markerclusterer.js',
- ),
-);
+ $wgResourceModules['ext.maps.googlemaps3'] = array(
+ 'dependencies' => array( 'ext.maps.common' ),
+ 'localBasePath' => __DIR__,
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'jquery.googlemap.js',
+ 'ext.maps.googlemaps3.js'
+ ),
+ 'messages' => array(
+ 'maps-googlemaps3-incompatbrowser',
+ 'maps-copycoords-prompt',
+ 'maps-searchmarkers-text',
+ )
+ );
-$wgResourceModules['ext.maps.gm3.markerwithlabel'] = array(
- 'localBasePath' => __DIR__ . '/gm3-util-library',
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'markerwithlabel.js',
- ),
- 'styles' => array(
- 'markerwithlabel.css',
- ),
-);
+ $wgResourceModules['ext.maps.gm3.markercluster'] = array(
+ 'localBasePath' => __DIR__ . '/gm3-util-library',
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'markerclusterer.js',
+ ),
+ );
-$wgResourceModules['ext.maps.gm3.geoxml'] = array(
- 'localBasePath' => __DIR__ . '/geoxml3',
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/geoxml3',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'geoxml3.js',
- 'ZipFile.complete.js', //kmz handling
- ),
-);
+ $wgResourceModules['ext.maps.gm3.markerwithlabel'] = array(
+ 'localBasePath' => __DIR__ . '/gm3-util-library',
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'markerwithlabel.js',
+ ),
+ 'styles' => array(
+ 'markerwithlabel.css',
+ ),
+ );
-$wgResourceModules['ext.maps.gm3.earth'] = array(
- 'localBasePath' => __DIR__ . '/gm3-util-library',
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'googleearth-compiled.js',
- ),
-);
+ $wgResourceModules['ext.maps.gm3.geoxml'] = array(
+ 'localBasePath' => __DIR__ . '/geoxml3',
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/geoxml3',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'geoxml3.js',
+ 'ZipFile.complete.js', //kmz handling
+ ),
+ );
-$wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps3';
+ $wgResourceModules['ext.maps.gm3.earth'] = array(
+ 'localBasePath' => __DIR__ . '/gm3-util-library',
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/GoogleMaps3/gm3-util-library',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'googleearth-compiled.js',
+ ),
+ );
+
+ $wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps3';
+} );
/**
* Initialization function for the Google Maps v3 service.
@@ -90,7 +94,7 @@
function efMapsInitGoogleMaps3() {
global $wgAutoloadClasses;
- $wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ .
'/Maps_GoogleMaps3.php';
+ $wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ .
'/Maps_GoogleMaps3.php';
MapsMappingServices::registerService( 'googlemaps3', 'MapsGoogleMaps3'
);
diff --git a/includes/services/Leaflet/Leaflet.php
b/includes/services/Leaflet/Leaflet.php
index ae5dcbd..24f803b 100644
--- a/includes/services/Leaflet/Leaflet.php
+++ b/includes/services/Leaflet/Leaflet.php
@@ -22,30 +22,34 @@
die( 'This file is an extension to MediaWiki and thus not a valid entry
point.' );
}
-// Specify the function that will initialize the parser function.
-$wgHooks['MappingServiceLoad'][] = 'efMapsInitLeaflet';
+call_user_func( function() {
+ global $wgHooks, $wgResourceModules, $egMapsScriptPath;
-$wgResourceModules['ext.maps.leaflet'] = array(
- 'dependencies' => array( 'ext.maps.common' ),
- 'localBasePath' => __DIR__,
- 'remoteBasePath' => $egMapsScriptPath . '/includes/services/Leaflet',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'leaflet/leaflet.js',
- 'jquery.leaflet.js',
- 'ext.maps.leaflet.js',
+ // Specify the function that will initialize the parser function.
+ $wgHooks['MappingServiceLoad'][] = 'efMapsInitLeaflet';
+
+ $wgResourceModules['ext.maps.leaflet'] = array(
+ 'dependencies' => array( 'ext.maps.common' ),
+ 'localBasePath' => __DIR__,
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/Leaflet',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'leaflet/leaflet.js',
+ 'jquery.leaflet.js',
+ 'ext.maps.leaflet.js',
),
- 'styles' => array(
- 'leaflet/leaflet.css',
- 'leaflet/leaflet.ie.css',
- ),
- 'messages' => array(
- 'maps-markers',
- 'maps-copycoords-prompt',
- 'maps-searchmarkers-text',
- ),
-);
-
+ 'styles' => array(
+ 'leaflet/leaflet.css',
+ 'leaflet/leaflet.ie.css',
+ ),
+ 'messages' => array(
+ 'maps-markers',
+ 'maps-copycoords-prompt',
+ 'maps-searchmarkers-text',
+ ),
+ );
+} );
+
/**
* Initialization function for the Leaflet service.
*
diff --git a/includes/services/OpenLayers/OpenLayers.php
b/includes/services/OpenLayers/OpenLayers.php
index 43f2336..5c6114b 100644
--- a/includes/services/OpenLayers/OpenLayers.php
+++ b/includes/services/OpenLayers/OpenLayers.php
@@ -21,30 +21,35 @@
die( 'Not an entry point.' );
}
-$wgResourceModules['ext.maps.openlayers'] = array(
- 'dependencies' => array( 'ext.maps.common' ),
- 'localBasePath' => __DIR__,
- 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/OpenLayers',
- 'group' => 'ext.maps',
- 'scripts' => array(
- 'OpenLayers/OpenLayers.js',
- 'OSM/OpenStreetMap.js',
- 'jquery.openlayers.js',
- 'ext.maps.openlayers.js'
- ),
- 'styles' => array(
- 'OpenLayers/theme/default/style.css'
- ),
- 'messages' => array(
- 'maps-markers',
- 'maps-copycoords-prompt',
- 'maps-searchmarkers-text',
- )
-);
+call_user_func( function() {
+ global $wgHooks, $wgResourceModules, $egMapsScriptPath,
$wgAutoloadClasses;
-$wgAutoloadClasses['MapsOpenLayers'] = __DIR__ . '/Maps_OpenLayers.php';
+ $wgResourceModules['ext.maps.openlayers'] = array(
+ 'dependencies' => array( 'ext.maps.common' ),
+ 'localBasePath' => __DIR__,
+ 'remoteBasePath' => $egMapsScriptPath .
'/includes/services/OpenLayers',
+ 'group' => 'ext.maps',
+ 'scripts' => array(
+ 'OpenLayers/OpenLayers.js',
+ 'OSM/OpenStreetMap.js',
+ 'jquery.openlayers.js',
+ 'ext.maps.openlayers.js'
+ ),
+ 'styles' => array(
+ 'OpenLayers/theme/default/style.css'
+ ),
+ 'messages' => array(
+ 'maps-markers',
+ 'maps-copycoords-prompt',
+ 'maps-searchmarkers-text',
+ )
+ );
-$wgHooks['MappingServiceLoad'][] = 'efMapsInitOpenLayers';
+ $wgAutoloadClasses['MapsOpenLayers'] = __DIR__ . '/Maps_OpenLayers.php';
+
+ $wgHooks['MappingServiceLoad'][] = 'efMapsInitOpenLayers';
+} );
+
function efMapsInitOpenLayers() {
MapsMappingServices::registerService(
'openlayers',
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 0000000..f002e6f
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,20 @@
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ bootstrap="tests/bootstrap.php"
+ cacheTokens="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false"
+ strict="true"
+ verbose="true">
+ <testsuites>
+ <testsuite name="Maps">
+ <directory>tests/phpunit</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
new file mode 100644
index 0000000..748f304
--- /dev/null
+++ b/tests/bootstrap.php
@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * PHPUnit test bootstrap file for the Maps extension.
+ *
+ * @since 3.0
+ *
+ * @file
+ * @ingroup Maps
+ *
+ * @licence GNU GPL v2+
+ * @author Jeroen De Dauw < [email protected] >
+ */
+
+require_once( __DIR__ . '/evilMediaWikiBootstrap.php' );
+
+require_once( __DIR__ . '/../Maps.php' );
+
+//require_once( __DIR__ . '/testLoader.php' );
diff --git a/tests/evilMediaWikiBootstrap.php b/tests/evilMediaWikiBootstrap.php
new file mode 100644
index 0000000..add7f9a
--- /dev/null
+++ b/tests/evilMediaWikiBootstrap.php
@@ -0,0 +1,76 @@
+<?php
+
+define( 'MEDIAWIKI', true );
+
+global $IP;
+$IP = getenv( 'MW_INSTALL_PATH' );
+
+if ( $IP === false ) {
+ $IP = dirname( __FILE__ ) . '/../../..';
+}
+
+$self = 'foobar';
+
+// Detect compiled mode
+# Get the MWInit class
+require_once "$IP/includes/Init.php";
+require_once "$IP/includes/AutoLoader.php";
+# Stub the profiler
+require_once "$IP/includes/profiler/Profiler.php";
+
+# Start the profiler
+$wgProfiler = array();
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+ require "$IP/StartProfiler.php";
+}
+
+// Some other requires
+require_once "$IP/includes/Defines.php";
+
+require_once MWInit::compiledPath( 'includes/DefaultSettings.php' );
+
+foreach ( get_defined_vars() as $key => $var ) {
+ if ( !array_key_exists( $key, $GLOBALS ) ) {
+ $GLOBALS[$key] = $var;
+ }
+}
+
+if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
+ # Use a callback function to configure MediaWiki
+ MWFunction::call( MW_CONFIG_CALLBACK );
+} else {
+ // Require the configuration (probably LocalSettings.php)
+ require loadSettings();
+}
+
+// Some last includes
+require_once MWInit::compiledPath( 'includes/Setup.php' );
+
+// Much much faster startup than creating a title object
+$wgTitle = null;
+
+global $wgAutoloadClasses;
+
+if ( is_null( $wgAutoloadClasses ) ) {
+ $wgAutoloadClasses = array();
+}
+
+require_once $IP . '/tests/TestsAutoLoader.php';
+
+function loadSettings() {
+ global $wgCommandLineMode, $IP;
+
+ $settingsFile = "$IP/LocalSettings.php";
+
+ if ( !is_readable( $settingsFile ) ) {
+ $this->error( "A copy of your installation's
LocalSettings.php\n" .
+ "must exist and be readable in the source directory.\n"
.
+ "Use --conf to specify it.", true );
+ }
+ $wgCommandLineMode = true;
+ return $settingsFile;
+}
+
+foreach ( $GLOBALS['wgExtensionFunctions'] as $extensionFunction ) {
+ call_user_func( $extensionFunction );
+}
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/80031
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e017cc4105ccfb7af19ad1debdf16151a3822f0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Maps
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits