r54218 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54217‎ | r54218 | r54219 >
Date:18:06, 2 August 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Mapper.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.php
@@ -14,11 +14,11 @@
1515 die( 'Not an entry point.' );
1616 }
1717
18 -define('Maps_VERSION', '0.2');
 18+define('Maps_VERSION', '0.3');
1919
2020 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
2121 $egMapsIP = $IP . '/extensions/Maps';
22 -$egMapsIncludePath = 'http://' . $_SERVER["HTTP_HOST"] . $egMapsScriptPath;
 22+$egMapsIncludePath = $wgServer . $egMapsScriptPath;
2323
2424 // Include the settings file
2525 require_once($egMapsIP . '/Maps_Settings.php');
@@ -37,20 +37,25 @@
3838 $wgAutoloadClasses['MapsGeocoder'] = $egMapsIP . '/Maps_Geocoder.php';
3939 $wgAutoloadClasses['MapsBaseGeocoder'] = $egMapsIP . '/Maps_BaseGeocoder.php';
4040
 41+// Add the services
 42+$wgAutoloadClasses['MapsGoogleMaps'] = $egMapsIP . '/GoogleMaps/Maps_GoogleMaps.php';
 43+$wgAutoloadClasses['MapsYahooMaps'] = $egMapsIP . '/YahooMaps/Maps_YahooMaps.php';
 44+$wgAutoloadClasses['MapsOpenLayers'] = $egMapsIP . '/OpenLayers/Maps_OpenLayers.php';
 45+
4146 // Array containing all map services made available by Maps.
4247 // This does not reflect the enabled mapping services, see $egMapsAvailableServices in Maps_Settings.php for this.
4348 // Each array item represents a service: the key is the main service name (used in switch statements),
4449 // and the array values are the aliases for the main name (so can also be used as service=alias).
45 -$egMapsServices = array('googlemaps' => array('google', 'googlemap', 'gmap', 'gmaps'),
46 - 'openlayers' => array('layers', 'openlayer'),
47 - 'yahoomaps' => array('yahoo', 'yahoomap', 'ymap', 'ymaps')
48 - );
49 -
 50+$egMapsServices = array();
 51+$egMapsServices['googlemaps'] = array('aliases' => array('google', 'googlemap', 'gmap', 'gmaps'));
 52+$egMapsServices['openlayers'] = array('aliases' => array('layers', 'openlayer'));
 53+$egMapsServices['yahoomaps'] = array('aliases' => array('yahoo', 'yahoomap', 'ymap', 'ymaps'));
 54+
5055 /**
5156 * Initialization function for the Maps extension
5257 */
5358 function efMapsSetup() {
54 - global $wgExtensionCredits, $wgExtensionCredits, $wgOut;
 59+ global $wgExtensionCredits, $wgOut;
5560 global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsMainServices, $egMapsScriptPath, $egMapsDefaultGeoService, $egMapsAvailableGeoServices;
5661
5762 efMapsValidateGoogleMapsKey();
@@ -61,8 +66,6 @@
6267
6368 $egMapsMainServices = array_keys($egMapsServices);
6469
65 - foreach($egMapsMainServices as $service) efMapsInitFormat($service);
66 -
6770 $services_list = implode(', ', $egMapsMainServices);
6871
6972 wfLoadExtensionMessages( 'Maps' );
@@ -74,7 +77,7 @@
7578 'author' => array("[http://bn2vs.com Jeroen De Dauw]", "[http://www.mediawiki.org/wiki/User:Yaron_Koren Yaron Koren]", "Robert Buzink", "Matt Williamson", "[http://www.sergeychernyshev.com Sergey Chernyshev]"),
7679 'url' => 'http://www.mediawiki.org/wiki/Extension:Maps',
7780 'description' => wfMsg( 'maps_desc', $services_list ),
78 - 'descriptionmsg' => array( 'maps_desc', $services_list ),
 81+ 'descriptionmsg' => wfMsg( 'maps_desc', $services_list ),
7982 );
8083
8184 efMapsAddParserHooks();
@@ -111,33 +114,6 @@
112115 }
113116
114117 /**
115 - * Initializes the result format depending on the map service
116 - */
117 -function efMapsInitFormat( $format ) {
118 - global $wgAutoloadClasses, $egMapsIP;
119 -
120 - switch ($format) {
121 - case 'googlemaps':
122 - $class = 'MapsGoogleMaps';
123 - $file = $egMapsIP . '/GoogleMaps/Maps_GoogleMaps';
124 - break;
125 - case 'openlayers':
126 - $class = 'MapsOpenLayers';
127 - $file = $egMapsIP . '/OpenLayers/Maps_OpenLayers';
128 - break;
129 - case 'yahoomaps':
130 - $class = 'MapsYahooMaps';
131 - $file = $egMapsIP . '/YahooMaps/Maps_YahooMaps';
132 - break;
133 - }
134 -
135 - if (isset($class) && isset($file)) {
136 - $wgAutoloadClasses[$class] = $file . '.php';
137 - }
138 -
139 -}
140 -
141 -/**
142118 * Adds the magic words for the parser functions
143119 */
144120 function efMapsFunctionMagic( &$magicWords, $langCode ) {
Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -196,8 +196,8 @@
197197 global $egMapsServices;
198198
199199 if (!array_key_exists($service, $egMapsServices)) {
200 - foreach ($egMapsServices as $serviceName => $aliasList) {
201 - if (in_array($service, $aliasList)) {
 200+ foreach ($egMapsServices as $serviceName => $serviceInfo) {
 201+ if (in_array($service, $serviceInfo['aliases'])) {
202202 $service = $serviceName;
203203 }
204204 }
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
@@ -8,6 +8,10 @@
99 * @author Jeroen De Dauw
1010 */
1111
 12+if( !defined( 'MEDIAWIKI' ) ) {
 13+ die( 'Not an entry point.' );
 14+}
 15+
1216 class MapsYahooMaps extends MapsBaseMap {
1317
1418 // http://developer.yahoo.com/maps/ajax

Status & tagging log