diff --git a/.gitignore b/.gitignore index f078e9121..18089b7cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ -.* *~ *.kate-swp !.* +.idea/ + +vendor/ +extensions/ composer.phar composer.lock \ No newline at end of file diff --git a/Maps.php b/Maps.php index 6d5de5a2c..7ad725bcd 100644 --- a/Maps.php +++ b/Maps.php @@ -17,79 +17,22 @@ return 1; } -define( 'Maps_VERSION' , '3.0 alpha' ); +define( 'Maps_VERSION' , '3.0 beta' ); // Include the composer autoloader if it is present. if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) { include_once( __DIR__ . '/vendor/autoload.php' ); } -// 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' ); -} - -// Attempt to include the DataValues lib if that has not been loaded yet. -if ( !defined( 'DATAVALUES_VERSION' ) && is_readable( __DIR__ . '/../DataValues/DataValues.php' ) ) { - include_once( __DIR__ . '/../DataValues/DataValues.php' ); -} - -// Include the DataValuesInterfaces library if that hasn't been done yet. -if ( !defined( 'DATAVALUES_INTERFACES_VERSION' ) ) { - @include_once( __DIR__ . '/../DataValuesInterfaces/DataValuesInterfaces.php' ); -} - -// Include the DataValuesCommon library if that hasn't been done yet. -if ( !defined( 'DATAVALUES_COMMON_VERSION' ) ) { - @include_once( __DIR__ . '/../DataValuesCommon/DataValuesCommon.php' ); -} - -// 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' ); -} - -// Only initialize the extension when all dependencies are present. -if ( !defined( 'DATAVALUES_VERSION' ) ) { - throw new Exception( 'You need to have DataValues loaded in order to use Maps' ); -} - -// Only initialize the extension when all dependencies are present. -if ( !defined( 'DATAVALUES_INTERFACES_VERSION' ) ) { - throw new Exception( 'You need to have DataValuesInterfaces loaded in order to use Maps' ); -} - // Only initialize the extension when all dependencies are present. -if ( !defined( 'DATAVALUES_COMMON_VERSION' ) ) { - throw new Exception( 'You need to have DataValuesCommon loaded in order to use Maps' ); +if ( !defined( 'Validator_VERSION' ) ) { + throw new Exception( 'You need to have Validator installed in order to use Maps' ); } 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.' ); } -spl_autoload_register( function ( $className ) { - $className = ltrim( $className, '\\' ); - $fileName = ''; - $namespace = ''; - - if ( $lastNsPos = strripos( $className, '\\') ) { - $namespace = substr( $className, 0, $lastNsPos ); - $className = substr( $className, $lastNsPos + 1 ); - $fileName = str_replace( '\\', '/', $namespace ) . '/'; - } - - $fileName .= str_replace( '_', '/', $className ) . '.php'; - - $namespaceSegments = explode( '\\', $namespace ); - - if ( $namespaceSegments[0] === 'Maps' ) { - if ( count( $namespaceSegments ) > 1 && $namespaceSegments[1] === 'Elements' ) { - require_once __DIR__ . '/includes/' . substr( $fileName, 5 ); - } - } -} ); - call_user_func( function() { global $wgExtensionCredits, $wgExtensionAssetsPath, $wgScriptPath, $wgAutoloadClasses; global $wgResourceModules, $wgGroupPermissions, $egMapsNamespaceIndex, $wgStyleVersion; diff --git a/composer.json b/composer.json index fd59912fa..f9f258ab0 100644 --- a/composer.json +++ b/composer.json @@ -30,12 +30,15 @@ "require": { "php": ">=5.3.2", "composer/installers": ">=1.0.1", - "mediawiki/validator": "dev-master", - "data-values/geo": "~0.1" + "mediawiki/validator": "~1.0", + "data-values/geo": ">=0.1.1,<1.0" }, "autoload": { "files" : [ "Maps.php" - ] + ], + "psr-0": { + "Maps\\Elements\\": "src/" + } } } diff --git a/includes/Elements/BaseElement.php b/src/Maps/Elements/BaseElement.php similarity index 100% rename from includes/Elements/BaseElement.php rename to src/Maps/Elements/BaseElement.php diff --git a/includes/Elements/Circle.php b/src/Maps/Elements/Circle.php similarity index 100% rename from includes/Elements/Circle.php rename to src/Maps/Elements/Circle.php diff --git a/includes/Elements/ImageOverlay.php b/src/Maps/Elements/ImageOverlay.php similarity index 100% rename from includes/Elements/ImageOverlay.php rename to src/Maps/Elements/ImageOverlay.php diff --git a/includes/Elements/Line.php b/src/Maps/Elements/Line.php similarity index 100% rename from includes/Elements/Line.php rename to src/Maps/Elements/Line.php diff --git a/includes/Elements/Location.php b/src/Maps/Elements/Location.php similarity index 100% rename from includes/Elements/Location.php rename to src/Maps/Elements/Location.php diff --git a/includes/Elements/Polygon.php b/src/Maps/Elements/Polygon.php similarity index 100% rename from includes/Elements/Polygon.php rename to src/Maps/Elements/Polygon.php diff --git a/includes/Elements/Rectangle.php b/src/Maps/Elements/Rectangle.php similarity index 100% rename from includes/Elements/Rectangle.php rename to src/Maps/Elements/Rectangle.php diff --git a/includes/Elements/WmsOverlay.php b/src/Maps/Elements/WmsOverlay.php similarity index 100% rename from includes/Elements/WmsOverlay.php rename to src/Maps/Elements/WmsOverlay.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php index ed221c4b0..d6a15742b 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,8 +9,8 @@ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ -require_once( __DIR__ . '/evilMediaWikiBootstrap.php' ); +echo exec( 'composer update' ) . "\n"; -require_once( __DIR__ . '/../Maps.php' ); +require_once( __DIR__ . '/evilMediaWikiBootstrap.php' ); -//require_once( __DIR__ . '/testLoader.php' ); +// Note: You do need to include Maps.php from your LocalSettings.php file. \ No newline at end of file