| Conditions | 6 |
| Paths | 2 |
| Total Lines | 48 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | public static function onRegistration() { |
||
|
|
|||
| 8 | if ( defined( 'Maps_COORDS_FLOAT' ) ) { |
||
| 9 | // Do not initialize more than once. |
||
| 10 | return true; |
||
| 11 | } |
||
| 12 | |||
| 13 | // The different coordinate notations. |
||
| 14 | define( 'Maps_COORDS_FLOAT', 'float' ); |
||
| 15 | define( 'Maps_COORDS_DMS', 'dms' ); |
||
| 16 | define( 'Maps_COORDS_DM', 'dm' ); |
||
| 17 | define( 'Maps_COORDS_DD', 'dd' ); |
||
| 18 | |||
| 19 | require_once __DIR__ . '/Maps_Settings.php'; |
||
| 20 | |||
| 21 | // Internationalization |
||
| 22 | $GLOBALS['wgMessagesDirs']['Maps.class'] = __DIR__ . '/i18n'; |
||
| 23 | $GLOBALS['wgExtensionMessagesFiles']['MapsMagic'] = __DIR__ . '/Maps.i18n.magic.php'; |
||
| 24 | $GLOBALS['wgExtensionMessagesFiles']['MapsAlias'] = __DIR__ . '/Maps.i18n.alias.php'; |
||
| 25 | |||
| 26 | $GLOBALS['wgExtensionFunctions'][] = function() { |
||
| 27 | if ( $GLOBALS['egMapsDisableExtension'] ) { |
||
| 28 | return true; |
||
| 29 | } |
||
| 30 | |||
| 31 | if ( defined( 'Maps_VERSION' ) ) { |
||
| 32 | // Do not initialize more than once. |
||
| 33 | return true; |
||
| 34 | } |
||
| 35 | |||
| 36 | // Only initialize the extension when all dependencies are present. |
||
| 37 | if ( !defined( 'Validator_VERSION' ) ) { |
||
| 38 | throw new Exception( 'You need to have Validator installed in order to use Maps' ); |
||
| 39 | } |
||
| 40 | |||
| 41 | if ( version_compare( $GLOBALS['wgVersion'], '1.27c', '<' ) ) { |
||
| 42 | throw new Exception( |
||
| 43 | 'This version of Maps requires MediaWiki 1.27 or above; use Maps 4.2.x for older versions.' |
||
| 44 | . ' More information at https://github.com/JeroenDeDauw/Maps/blob/master/INSTALL.md' |
||
| 45 | ); |
||
| 46 | } |
||
| 47 | |||
| 48 | ( new MapsSetup( $GLOBALS ) )->setup(); |
||
| 49 | |||
| 50 | return true; |
||
| 51 | }; |
||
| 52 | |||
| 53 | return true; |
||
| 54 | } |
||
| 55 | |||
| 60 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: