Skip to content

Commit

Permalink
Various loading tweaks and bump to 1.0 beta
Browse files Browse the repository at this point in the history
Change-Id: I8cebe9c297c21cbd4bf0fcce5242decf9e227978
  • Loading branch information
JeroenDeDauw committed Nov 30, 2013
1 parent ff2e48b commit a3280a7
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 67 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
.*
*~
*.kate-swp

!.*
.idea/

vendor/
extensions/

composer.phar
composer.lock
63 changes: 3 additions & 60 deletions Maps.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
* @author Jeroen De Dauw < [email protected] >
*/

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.

0 comments on commit a3280a7

Please sign in to comment.