r67904 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67903‎ | r67904 | r67905 >
Date:16:15, 12 June 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6.3 - rewrote service handling (incompatible with SM for now)
Modified paths:
  • /trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php (modified) (history)
  • /trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php (modified) (history)
  • /trunk/extensions/Maps/Features/Maps_ParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/Features/Maps_iMapParserFunction.php (modified) (history)
  • /trunk/extensions/Maps/Includes/Maps_Mapper.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/GoogleMaps.php (added) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispMap.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps3/GoogleMaps3.php (added) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispMap.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispPoint.php (modified) (history)
  • /trunk/extensions/Maps/Services/Maps_MappingService.php (added) (history)
  • /trunk/extensions/Maps/Services/Maps_iMappingService.php (modified) (history)
  • /trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispMap.php (modified) (history)
  • /trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/Services/OpenLayers/OpenLayers.php (added) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php (modified) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispMap.php (modified) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/YahooMaps.php (added) (history)

Diff [purge]

Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
@@ -21,8 +21,6 @@
2222 * @author Jeroen De Dauw
2323 */
2424 final class MapsGoogleMaps3DispPoint extends MapsBasePointMap {
25 -
26 - public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
2725
2826 protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon, "title", "label", "icon")';
2927
@@ -38,7 +36,7 @@
3937 public function doMapServiceLoad() {
4038 global $egGMaps3OnThisPage;
4139
42 - MapsGoogleMaps3::addDependencies( $this->parser );
 40+ $this->mService->addDependencies( $this->parser );
4341 $egGMaps3OnThisPage++;
4442
4543 $this->elementNr = $egGMaps3OnThisPage;
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispMap.php
@@ -22,8 +22,6 @@
2323 */
2424 final class MapsGoogleMaps3DispMap extends MapsBaseMap {
2525
26 - public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
27 -
2826 protected function getDefaultZoom() {
2927 global $egMapsGMaps3Zoom;
3028 return $egMapsGMaps3Zoom;
@@ -36,7 +34,7 @@
3735 public function doMapServiceLoad() {
3836 global $egGMaps3OnThisPage;
3937
40 - MapsGoogleMaps3::addDependencies( $this->parser );
 38+ $this->mService->addDependencies( $this->parser );
4139 $egGMaps3OnThisPage++;
4240
4341 $this->elementNr = $egGMaps3OnThisPage;
Index: trunk/extensions/Maps/Services/GoogleMaps3/GoogleMaps3.php
@@ -0,0 +1,17 @@
 2+<?php
 3+
 4+$wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps3';
 5+
 6+function efMapsInitGoogleMaps3() {
 7+ global $egMapsServices, $wgAutoloadClasses;
 8+
 9+ $wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php';
 10+ $wgAutoloadClasses['MapsGoogleMaps3DispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3DispMap.php';
 11+
 12+ $googleMaps = new MapsGoogleMaps3();
 13+ $googleMaps->addFeature( 'display_map', 'MapsGoogleMaps3DispMap' );
 14+
 15+ $egMapsServices[$googleMaps->getName()] = $googleMaps;
 16+
 17+ return true;
 18+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Services/GoogleMaps3/GoogleMaps3.php
___________________________________________________________________
Name: svn:eol-style
119 + native
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -20,12 +20,6 @@
2121 die( 'Not an entry point.' );
2222 }
2323
24 -$wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php';
25 -
26 -$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps3::initialize';
27 -
28 -$wgAutoloadClasses['MapsGoogleMaps3DispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3DispMap.php';
29 -
3024 /**
3125 * Class for Google Maps v3 initialization.
3226 *
@@ -33,34 +27,24 @@
3428 *
3529 * @author Jeroen De Dauw
3630 */
37 -class MapsGoogleMaps3 implements iMappingService {
 31+class MapsGoogleMaps3 extends MapsMappingService {
3832
39 - const SERVICE_NAME = 'googlemaps3';
40 -
41 - public static function initialize() {
42 - global $wgAutoloadClasses, $egMapsServices;
43 -
44 - $egMapsServices[self::SERVICE_NAME] = array(
45 - 'aliases' => array( 'google3', 'googlemap3', 'gmap3', 'gmaps3' ),
46 - 'features' => array(
47 - 'display_map' => 'MapsGoogleMaps3DispMap',
48 - )
49 - );
50 -
51 - self::initializeParams();
52 -
53 - Validator::addOutputFormat( 'gmap3type', array( __CLASS__, 'setGMapType' ) );
54 - Validator::addOutputFormat( 'gmap3types', array( __CLASS__, 'setGMapTypes' ) );
55 -
56 - return true;
 33+ function __construct() {
 34+ parent::__construct(
 35+ 'googlemaps3',
 36+ array( 'google3', 'googlemap3', 'gmap3', 'gmaps3' )
 37+ );
5738 }
5839
59 - protected static function initializeParams() {
 40+ protected function initParameterInfo( array &$parameters ) {
6041 global $egMapsServices, $egMapsGMaps3Type, $egMapsGMaps3Types;
6142
 43+ Validator::addOutputFormat( 'gmap3type', array( __CLASS__, 'setGMapType' ) );
 44+ Validator::addOutputFormat( 'gmap3types', array( __CLASS__, 'setGMapTypes' ) );
 45+
6246 $allowedTypes = self::getTypeNames();
6347
64 - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
 48+ $parameters = array(
6549 'type' => array(
6650 'aliases' => array( 'map-type', 'map type' ),
6751 'criteria' => array(
@@ -126,33 +110,20 @@
127111 }
128112
129113 /**
130 - * Loads the Google Maps API v3 and required JS files.
131 - *
132 - * @param mixed $parserOrOut
 114+ * @see MapsMappingService::getDependencies
 115+ *
 116+ * @return array
133117 */
134 - public static function addDependencies( &$parserOrOut ) {
135 - global $wgJsMimeType, $wgLang;
136 - global $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
 118+ protected function getDependencies() {
 119+ global $wgLang;
 120+ global $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
137121
138 - if ( empty( $egGMaps3OnThisPage ) ) {
139 - $egGMaps3OnThisPage = 0;
140 -
141 - $languageCode = self::getMappedLanguageCode( $wgLang->getCode() );
142 -
143 - if ( $parserOrOut instanceof Parser ) {
144 - $parser = $parserOrOut;
145 -
146 - $parser->getOutput()->addHeadItem(
147 - Html::linkedScript( "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" ) .
148 - Html::linkedScript( "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion" )
149 - );
150 - }
151 - else if ( $parserOrOut instanceof OutputPage ) {
152 - $out = $parserOrOut;
153 - MapsMapper::addScriptFile( $out, "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" );
154 - $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion" );
155 - }
156 - }
 122+ $languageCode = self::getMappedLanguageCode( $wgLang->getCode() );
 123+
 124+ return array(
 125+ Html::linkedScript( "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" ),
 126+ Html::linkedScript( "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion" ),
 127+ );
157128 }
158129
159130 /**
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispPoint.php
@@ -20,8 +20,6 @@
2121 */
2222 class MapsYahooMapsDispPoint extends MapsBasePointMap {
2323
24 - public $serviceName = MapsYahooMaps::SERVICE_NAME;
25 -
2624 protected $markerStringFormat = 'getYMarkerData(lat, lon, "title", "label", "icon")';
2725
2826 protected function getDefaultZoom() {
@@ -36,7 +34,7 @@
3735 public function doMapServiceLoad() {
3836 global $egYahooMapsOnThisPage;
3937
40 - MapsYahooMaps::addDependencies( $this->parser );
 38+ $this->mService->addDependencies( $this->parser );
4139 $egYahooMapsOnThisPage++;
4240
4341 $this->elementNr = $egYahooMapsOnThisPage;
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispMap.php
@@ -15,8 +15,6 @@
1616
1717 class MapsYahooMapsDispMap extends MapsBaseMap {
1818
19 - public $serviceName = MapsYahooMaps::SERVICE_NAME;
20 -
2119 protected function getDefaultZoom() {
2220 global $egMapsYahooMapsZoom;
2321 return $egMapsYahooMapsZoom;
@@ -28,7 +26,7 @@
2927 public function doMapServiceLoad() {
3028 global $egYahooMapsOnThisPage;
3129
32 - MapsYahooMaps::addDependencies( $this->parser );
 30+ $this->mService->addDependencies( $this->parser );
3331 $egYahooMapsOnThisPage++;
3432
3533 $this->elementNr = $egYahooMapsOnThisPage;
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php
@@ -20,13 +20,6 @@
2121 die( 'Not an entry point.' );
2222 }
2323
24 -$wgAutoloadClasses['MapsYahooMaps'] = dirname( __FILE__ ) . '/Maps_YahooMaps.php';
25 -
26 -$wgHooks['MappingServiceLoad'][] = 'MapsYahooMaps::initialize';
27 -
28 -$wgAutoloadClasses['MapsYahooMapsDispMap'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispMap.php';
29 -$wgAutoloadClasses['MapsYahooMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispPoint.php';
30 -
3124 /**
3225 * Class for Yahoo! Maps initialization.
3326 *
@@ -34,35 +27,36 @@
3528 *
3629 * @author Jeroen De Dauw
3730 */
38 -class MapsYahooMaps implements iMappingService {
 31+class MapsYahooMaps extends MapsMappingService {
 32+
 33+ /**
 34+ * Mapping for Yahoo! Maps map types.
 35+ * See http://developer.yahoo.com/maps/ajax
 36+ *
 37+ * @var array
 38+ */
 39+ protected static $mapTypes = array(
 40+ 'normal' => 'YAHOO_MAP_REG',
 41+ 'satellite' => 'YAHOO_MAP_SAT',
 42+ 'hybrid' => 'YAHOO_MAP_HYB',
 43+ );
3944
40 - const SERVICE_NAME = 'yahoomaps';
 45+ function __construct() {
 46+ parent::__construct(
 47+ 'yahoomaps',
 48+ array( 'yahoo', 'yahoomap', 'ymap', 'ymaps' )
 49+ );
 50+ }
4151
42 - public static function initialize() {
43 - global $wgAutoloadClasses, $egMapsServices;
44 -
45 - $egMapsServices[self::SERVICE_NAME] = array(
46 - 'aliases' => array( 'yahoo', 'yahoomap', 'ymap', 'ymaps' ),
47 - 'features' => array(
48 - 'display_point' => 'MapsYahooMapsDispPoint',
49 - 'display_map' => 'MapsYahooMapsDispMap',
50 - )
51 - );
 52+ protected function initParameterInfo( array &$parameters ) {
 53+ global $egMapsServices, $egMapsYahooAutozoom, $egMapsYahooMapsType, $egMapsYahooMapsTypes, $egMapsYahooMapsZoom, $egMapsYMapControls;
5254
53 - self::initializeParams();
54 -
5555 Validator::addOutputFormat( 'ymaptype', array( __CLASS__, 'setYMapType' ) );
56 - Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) );
 56+ Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) );
5757
58 - return true;
59 - }
60 -
61 - protected static function initializeParams() {
62 - global $egMapsServices, $egMapsYahooAutozoom, $egMapsYahooMapsType, $egMapsYahooMapsTypes, $egMapsYahooMapsZoom, $egMapsYMapControls;
63 -
6458 $allowedTypes = MapsYahooMaps::getTypeNames();
6559
66 - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
 60+ $parameters = array(
6761 'controls' => array(
6862 'type' => array( 'string', 'list' ),
6963 'criteria' => array(
@@ -96,16 +90,24 @@
9791 'output-type' => 'boolstr'
9892 ),
9993 );
100 -
101 - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 );
 94+
 95+ $parameters['zoom']['criteria']['in_range'] = array( 1, 13 );
10296 }
10397
104 - // http://developer.yahoo.com/maps/ajax
105 - protected static $mapTypes = array(
106 - 'normal' => 'YAHOO_MAP_REG',
107 - 'satellite' => 'YAHOO_MAP_SAT',
108 - 'hybrid' => 'YAHOO_MAP_HYB',
109 - );
 98+ /**
 99+ * @see MapsMappingService::getDependencies
 100+ *
 101+ * @return array
 102+ */
 103+ protected function getDependencies() {
 104+ global $wgJsMimeType;
 105+ global $egYahooMapsKey, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt;
 106+
 107+ return array(
 108+ Html::linkedScript( "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" ),
 109+ Html::linkedScript( "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" ),
 110+ );
 111+ }
110112
111113 /**
112114 * Returns the names of all supported map types.
@@ -151,32 +153,4 @@
152154 }
153155 }
154156
155 - /**
156 - * Loads the Yahoo! Maps API and required JS files.
157 - *
158 - * @param mixed $parserOrOut
159 - */
160 - public static function addDependencies( &$parserOrOut ) {
161 - global $wgJsMimeType;
162 - global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
163 -
164 - if ( empty( $egYahooMapsOnThisPage ) ) {
165 - $egYahooMapsOnThisPage = 0;
166 -
167 - if ( $parserOrOut instanceof Parser ) {
168 - $parser = $parserOrOut;
169 -
170 - $parser->getOutput()->addHeadItem(
171 - Html::linkedScript( "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" ) .
172 - Html::linkedScript( "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" )
173 - );
174 - }
175 - else if ( $parserOrOut instanceof OutputPage ) {
176 - $out = $parserOrOut;
177 - MapsMapper::addScriptFile( $out, "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" );
178 - $out->addScriptFile( "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
179 - }
180 - }
181 - }
182 -
183157 }
\ No newline at end of file
Index: trunk/extensions/Maps/Services/YahooMaps/YahooMaps.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+$wgHooks['MappingServiceLoad'][] = 'efMapsInitYahooMaps';
 5+
 6+function efMapsInitYahooMaps() {
 7+ global $egMapsServices, $wgAutoloadClasses;
 8+
 9+ $wgAutoloadClasses['MapsYahooMaps'] = dirname( __FILE__ ) . '/Maps_YahooMaps.php';
 10+ $wgAutoloadClasses['MapsYahooMapsDispMap'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispMap.php';
 11+ $wgAutoloadClasses['MapsYahooMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_YahooMapsDispPoint.php';
 12+
 13+ $yahooMaps = new MapsYahooMaps();
 14+ $yahooMaps->addFeature( 'display_point', 'MapsYahooMapsDispPoint' );
 15+ $yahooMaps->addFeature( 'display_map', 'MapsYahooMapsDispMap' );
 16+
 17+ $egMapsServices[$yahooMaps->getName()] = $yahooMaps;
 18+
 19+ return true;
 20+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Services/YahooMaps/YahooMaps.php
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispPoint.php
@@ -20,8 +20,6 @@
2121 */
2222 class MapsOpenLayersDispPoint extends MapsBasePointMap {
2323
24 - public $serviceName = MapsOpenLayers::SERVICE_NAME;
25 -
2624 protected $markerStringFormat = 'getOLMarkerData(lon, lat, "title", "label", "icon")';
2725
2826 protected function getDefaultZoom() {
@@ -35,7 +33,7 @@
3634 public function doMapServiceLoad() {
3735 global $egOpenLayersOnThisPage;
3836
39 - MapsOpenLayers::addDependencies( $this->parser );
 37+ $this->mService->addDependencies( $this->parser );
4038 $egOpenLayersOnThisPage++;
4139
4240 $this->elementNr = $egOpenLayersOnThisPage;
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispMap.php
@@ -15,8 +15,6 @@
1616
1717 class MapsOpenLayersDispMap extends MapsBaseMap {
1818
19 - public $serviceName = MapsOpenLayers::SERVICE_NAME;
20 -
2119 protected function getDefaultZoom() {
2220 global $egMapsOpenLayersZoom;
2321 return $egMapsOpenLayersZoom;
@@ -28,7 +26,7 @@
2927 public function doMapServiceLoad() {
3028 global $egOpenLayersOnThisPage;
3129
32 - MapsOpenLayers::addDependencies( $this->parser );
 30+ $this->mService->addDependencies( $this->parser );
3331 $egOpenLayersOnThisPage++;
3432
3533 $this->elementNr = $egOpenLayersOnThisPage;
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php
@@ -20,13 +20,6 @@
2121 die( 'Not an entry point.' );
2222 }
2323
24 -$wgAutoloadClasses['MapsOpenLayers'] = dirname( __FILE__ ) . '/Maps_OpenLayers.php';
25 -
26 -$wgHooks['MappingServiceLoad'][] = 'MapsOpenLayers::initialize';
27 -
28 -$wgAutoloadClasses['MapsOpenLayersDispMap'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispMap.php';
29 -$wgAutoloadClasses['MapsOpenLayersDispPoint'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispPoint.php';
30 -
3124 /**
3225 * Class for OpenLayers initialization.
3326 *
@@ -34,34 +27,24 @@
3528 *
3629 * @author Jeroen De Dauw
3730 */
38 -class MapsOpenLayers implements iMappingService {
 31+class MapsOpenLayers extends MapsMappingService {
3932
40 - const SERVICE_NAME = 'openlayers';
41 -
42 - public static function initialize() {
43 - global $wgAutoloadClasses, $egMapsServices, $egMapsOLLoadedLayers;
 33+ function __construct() {
 34+ parent::__construct(
 35+ 'openlayers',
 36+ array( 'layers', 'openlayer' )
 37+ );
4438
45 - $egMapsServices[self::SERVICE_NAME] = array(
46 - 'aliases' => array( 'layers', 'openlayer' ),
47 - 'features' => array(
48 - 'display_point' => 'MapsOpenLayersDispPoint',
49 - 'display_map' => 'MapsOpenLayersDispMap',
50 - )
51 - );
52 -
 39+ global $egMapsOLLoadedLayers;
5340 $egMapsOLLoadedLayers = array();
54 -
55 - self::initializeParams();
56 -
57 - Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) );
58 -
59 - return true;
60 - }
 41+ }
6142
62 - protected static function initializeParams() {
 43+ protected function initParameterInfo( array &$parameters ) {
6344 global $egMapsServices, $egMapsOLLayers, $egMapsOLControls, $egMapsOpenLayersZoom;
6445
65 - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
 46+ Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) );
 47+
 48+ $parameters = array(
6649 'controls' => array(
6750 'type' => array( 'string', 'list' ),
6851 'criteria' => array(
@@ -84,10 +67,27 @@
8568 ),
8669 );
8770
88 - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 );
 71+ $parameters['zoom']['criteria']['in_range'] = array( 0, 19 );
8972 }
9073
9174 /**
 75+ * @see MapsMappingService::getDependencies
 76+ *
 77+ * @return array
 78+ */
 79+ protected function getDependencies() {
 80+ global $wgJsMimeType;
 81+ global $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
 82+
 83+ return array(
 84+ Html::linkedScript( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css" ),
 85+ Html::linkedScript( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js?$egMapsStyleVersion" ),
 86+ Html::linkedScript( "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion" ),
 87+ Html::inlineScript( 'initOLSettings(200, 100);' )
 88+ );
 89+ }
 90+
 91+ /**
9292 * Returns the names of all supported controls.
9393 * This data is a copy of the one used to actually translate the names
9494 * into the controls, since this resides client side, in OpenLayerFunctions.js.
@@ -118,43 +118,13 @@
119119 if ( $includeGroups ) $keys = array_merge( $keys, array_keys( $egMapsOLLayerGroups ) );
120120 return $keys;
121121 }
122 -
123 - /**
124 - * If this is the first open layers map on the page, load the API, styles and extra JS functions.
125 - *
126 - * @param mixed $parserOrOut
127 - */
128 - public static function addDependencies( &$parserOrOut ) {
129 - global $wgJsMimeType;
130 - global $egOpenLayersOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
131122
132 - if ( empty( $egOpenLayersOnThisPage ) ) {
133 - $egOpenLayersOnThisPage = 0;
134 -
135 - if ( $parserOrOut instanceof Parser ) {
136 - $parser = $parserOrOut;
137 -
138 - $parser->getOutput()->addHeadItem(
139 - Html::linkedStyle( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css" ) .
140 - Html::linkedScript( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js?$egMapsStyleVersion" ) .
141 - Html::linkedScript( "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion" ) .
142 - Html::inlineScript( 'initOLSettings(200, 100);' )
143 - );
144 - }
145 - else if ( $parserOrOut instanceof OutputPage ) {
146 - $out = $parserOrOut;
147 - $out->addStyle( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css" );
148 - $out->addScriptFile( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js?$egMapsStyleVersion" );
149 - $out->addScriptFile( "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
150 - }
151 - }
152 - }
153 -
154123 /**
155124 * Build up a csv string with the layers, to be outputted as a JS array
156125 *
157126 * @param string $output
158 - * @param string $layers
 127+ * @param array $layers
 128+ *
159129 * @return csv string
160130 */
161131 public static function createLayersStringAndLoadDependencies( &$output, array $layers ) {
Index: trunk/extensions/Maps/Services/OpenLayers/OpenLayers.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+$wgHooks['MappingServiceLoad'][] = 'efMapsInitOpenLayers';
 5+
 6+function efMapsInitOpenLayers() {
 7+ global $egMapsServices, $wgAutoloadClasses;
 8+
 9+ $wgAutoloadClasses['MapsOpenLayers'] = dirname( __FILE__ ) . '/Maps_OpenLayers.php';
 10+ $wgAutoloadClasses['MapsOpenLayersDispMap'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispMap.php';
 11+ $wgAutoloadClasses['MapsOpenLayersDispPoint'] = dirname( __FILE__ ) . '/Maps_OpenLayersDispPoint.php';
 12+
 13+ $openLayers = new MapsOpenLayers();
 14+ $openLayers->addFeature( 'display_point', 'MapsOpenLayersDispPoint' );
 15+ $openLayers->addFeature( 'display_map', 'MapsOpenLayersDispMap' );
 16+
 17+ $egMapsServices[$openLayers->getName()] = $openLayers;
 18+
 19+ return true;
 20+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Services/OpenLayers/OpenLayers.php
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/extensions/Maps/Services/Maps_MappingService.php
@@ -0,0 +1,171 @@
 2+<?php
 3+
 4+/**
 5+ * This file holds the general information for the Google Maps service
 6+ *
 7+ * @file Maps_MappingService.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if ( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsMappingService implements iMappingService {
 18+
 19+ /**
 20+ *
 21+ * @var string
 22+ */
 23+ protected $mServiceName;
 24+
 25+ /**
 26+ *
 27+ * @var array
 28+ */
 29+ protected $mAliases;
 30+
 31+ /**
 32+ *
 33+ * @var array
 34+ */
 35+ protected $mFeatures;
 36+
 37+ /**
 38+ *
 39+ * @var mixed Array or false
 40+ */
 41+ private $mParameterInfo = false;
 42+
 43+ /**
 44+ *
 45+ * @var array
 46+ */
 47+ private $mAddedDependencies = array();
 48+
 49+ /**
 50+ * Constructor. Creates a new instance of MapsMappingService.
 51+ *
 52+ * @param string $serviceName
 53+ * @param array $aliases
 54+ */
 55+ function __construct( $serviceName, array $aliases = array() ) {
 56+ $this->mServiceName = $serviceName;
 57+ $this->mAliases = $aliases;
 58+ }
 59+
 60+ /**
 61+ * Returns the service parameters by first checking if they have been initialized yet,
 62+ * doing to work if this is not the case, and then returning them.
 63+ *
 64+ * @return array
 65+ */
 66+ public final function getParameterInfo() {
 67+ if ( $this->mParameterInfo === false ) {
 68+ $this->mParameterInfo = array();
 69+ $this->initParameterInfo( $this->mParameterInfo );
 70+ }
 71+
 72+ return $this->mParameterInfo;
 73+ }
 74+
 75+ /**
 76+ * Initializes the service parameters.
 77+ *
 78+ * You can override this method to set service specific parameters in the inheriting class.
 79+ */
 80+ protected function initParameterInfo( array &$parameters ) {
 81+ }
 82+
 83+ /**
 84+ * Adds a feature to this service. This is to indicate this service has support for this feature.
 85+ *
 86+ * @param string $featureName
 87+ * @param string $handlingClass
 88+ */
 89+ public function addFeature( $featureName, $handlingClass ) {
 90+ $this->mFeatures[$featureName] = $handlingClass;
 91+ }
 92+
 93+ /**
 94+ * Adds the mapping services dependencies to the header.
 95+ *
 96+ * @param mixed $parserOrOut
 97+ */
 98+ public final function addDependencies( &$parserOrOut ) {
 99+ $allDependencies = $this->getDependencies();
 100+ $dependencies = array();
 101+
 102+ // Only add dependnecies that have not yet been added.
 103+ foreach ( $allDependencies as $dependency ) {
 104+ if ( !in_array( $dependency, $this->mAddedDependencies ) ) {
 105+ $dependencies[] = $dependency;
 106+ $this->mAddedDependencies[] = $dependency;
 107+ }
 108+ }
 109+
 110+ // If there are dependencies, put them all together in a string and add them to the header.
 111+ if ( count( $dependencies ) > 0 ) {
 112+ $dependencies = implode( '', $dependencies );
 113+
 114+ if ( $parserOrOut instanceof Parser ) {
 115+ $parserOrOut->getOutput()->addHeadItem( $dependencies );
 116+ }
 117+ else if ( $parserOrOut instanceof OutputPage ) {
 118+ $parserOrOut->addHeadItem( $dependencies );
 119+ }
 120+ }
 121+ }
 122+
 123+ /**
 124+ * Returns a list of html fragments, such as script includes, the current service depends on.
 125+ *
 126+ * @return array
 127+ */
 128+ protected function getDependencies() {
 129+ return array();
 130+ }
 131+
 132+ /**
 133+ * Returns the internal name of the service.
 134+ *
 135+ * @return string
 136+ */
 137+ public function getName() {
 138+ return $this->mServiceName;
 139+ }
 140+
 141+ /**
 142+ * Returns the name of the class that handles the provided feature in this service, or false if there is none.
 143+ *
 144+ * @param string $featureName.
 145+ *
 146+ * @return mixed String or false
 147+ */
 148+ public function getFeature( $featureName ) {
 149+ return array_key_exists( $featureName, $this->mFeatures ) ? $this->mFeatures[$featureName] : false;
 150+ }
 151+
 152+ /**
 153+ * Returns a list of aliases.
 154+ *
 155+ * @return array
 156+ */
 157+ public function getAliases() {
 158+ return $this->mAliases;
 159+ }
 160+
 161+ /**
 162+ * Returns if the service has a certain alias or not.
 163+ *
 164+ * @param string $alias
 165+ *
 166+ * @return boolean
 167+ */
 168+ public function hasAlias( $alias ) {
 169+ return in_array( $alias, $this->mAliases );
 170+ }
 171+
 172+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Services/Maps_MappingService.php
___________________________________________________________________
Name: svn:eol-style
1173 + native
Index: trunk/extensions/Maps/Services/Maps_iMappingService.php
@@ -22,8 +22,8 @@
2323 */
2424 interface iMappingService {
2525
26 - static function initialize();
 26+ function addDependencies( &$parserOrOut );
2727
28 - static function addDependencies( &$parserOrOut );
 28+ function getParameterInfo();
2929
3030 }
\ No newline at end of file
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispMap.php
@@ -22,16 +22,15 @@
2323 */
2424 final class MapsGoogleMapsDispMap extends MapsBaseMap {
2525
26 - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
27 -
2826 protected function getDefaultZoom() {
2927 global $egMapsGoogleMapsZoom;
3028 return $egMapsGoogleMapsZoom;
3129 }
3230
33 - public function getSpecificParameterInfo() {
 31+ protected function initSpecificParamInfo( array &$parameters ) {
3432 global $egMapsGMapOverlays;
35 - $this->specificParameters = array(
 33+
 34+ $parameters = array(
3635 'overlays' => array(
3736 'type' => array( 'string', 'list' ),
3837 'criteria' => array(
@@ -40,7 +39,6 @@
4140 'default' => $egMapsGMapOverlays,
4241 ),
4342 );
44 - return $this->specificParameters;
4543 }
4644
4745 /**
@@ -49,7 +47,7 @@
5048 public function doMapServiceLoad() {
5149 global $egGoogleMapsOnThisPage;
5250
53 - MapsGoogleMaps::addDependencies( $this->parser );
 51+ $this->mService->addDependencies( $this->parser );
5452 $egGoogleMapsOnThisPage++;
5553
5654 $this->elementNr = $egGoogleMapsOnThisPage;
@@ -96,5 +94,4 @@
9795
9896 }
9997
100 -}
101 -
 98+}
\ No newline at end of file
Index: trunk/extensions/Maps/Services/GoogleMaps/GoogleMaps.php
@@ -0,0 +1,19 @@
 2+<?php
 3+
 4+$wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps';
 5+
 6+function efMapsInitGoogleMaps() {
 7+ global $egMapsServices, $wgAutoloadClasses;
 8+
 9+ $wgAutoloadClasses['MapsGoogleMaps'] = dirname( __FILE__ ) . '/Maps_GoogleMaps.php';
 10+ $wgAutoloadClasses['MapsGoogleMapsDispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispMap.php';
 11+ $wgAutoloadClasses['MapsGoogleMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispPoint.php';
 12+
 13+ $googleMaps = new MapsGoogleMaps();
 14+ $googleMaps->addFeature( 'display_point', 'MapsGoogleMapsDispPoint' );
 15+ $googleMaps->addFeature( 'display_map', 'MapsGoogleMapsDispMap' );
 16+
 17+ $egMapsServices[$googleMaps->getName()] = $googleMaps;
 18+
 19+ return true;
 20+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/Services/GoogleMaps/GoogleMaps.php
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php
@@ -20,13 +20,6 @@
2121 die( 'Not an entry point.' );
2222 }
2323
24 -$wgAutoloadClasses['MapsGoogleMaps'] = dirname( __FILE__ ) . '/Maps_GoogleMaps.php';
25 -
26 -$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps::initialize';
27 -
28 -$wgAutoloadClasses['MapsGoogleMapsDispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispMap.php';
29 -$wgAutoloadClasses['MapsGoogleMapsDispPoint'] = dirname( __FILE__ ) . '/Maps_GoogleMapsDispPoint.php';
30 -
3124 /**
3225 * Class for Google Maps initialization.
3326 *
@@ -34,37 +27,26 @@
3528 *
3629 * @author Jeroen De Dauw
3730 */
38 -class MapsGoogleMaps implements iMappingService {
 31+class MapsGoogleMaps extends MapsMappingService {
3932
40 - const SERVICE_NAME = 'googlemaps2';
 33+ function __construct() {
 34+ parent::__construct(
 35+ 'googlemaps2',
 36+ array( 'googlemaps', 'google', 'googlemap', 'gmap', 'gmaps' )
 37+ );
 38+ }
4139
42 - public static function initialize() {
43 - global $wgAutoloadClasses, $egMapsServices;
 40+ protected function initParameterInfo( array &$parameters ) {
 41+ global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls;
4442
45 - $egMapsServices[self::SERVICE_NAME] = array(
46 - 'aliases' => array( 'googlemaps', 'google', 'googlemap', 'gmap', 'gmaps' ),
47 - 'features' => array(
48 - 'display_point' => 'MapsGoogleMapsDispPoint',
49 - 'display_map' => 'MapsGoogleMapsDispMap',
50 - )
51 - );
52 -
53 - self::initializeParams();
54 -
5543 Validator::addOutputFormat( 'gmaptype', array( __CLASS__, 'setGMapType' ) );
5644 Validator::addOutputFormat( 'gmaptypes', array( __CLASS__, 'setGMapTypes' ) );
5745
58 - Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) );
 46+ Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) );
5947
60 - return true;
61 - }
62 -
63 - protected static function initializeParams() {
64 - global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls;
65 -
6648 $allowedTypes = self::getTypeNames();
6749
68 - $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
 50+ $parameters = array(
6951 'controls' => array(
7052 'type' => array( 'string', 'list' ),
7153 'criteria' => array(
@@ -99,7 +81,7 @@
10082 ),
10183 );
10284
103 - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 );
 85+ $parameters['zoom']['criteria']['in_range'] = array( 0, 20 );
10486 }
10587
10688 // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP
@@ -196,36 +178,21 @@
197179 }
198180
199181 /**
200 - * Loads the Google Maps API and required JS files.
201 - *
202 - * @param mixed $parserOrOut
 182+ * @see MapsMappingService::getDependencies
 183+ *
 184+ * @return array
203185 */
204 - public static function addDependencies( &$parserOrOut ) {
205 - global $wgJsMimeType, $wgLang;
206 - global $egGoogleMapsKey, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
 186+ protected function getDependencies() {
 187+ global $wgLang;
 188+ global $egGoogleMapsKey, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
207189
208 - if ( empty( $egGoogleMapsOnThisPage ) ) {
209 - $egGoogleMapsOnThisPage = 0;
210 -
211 - MapsGoogleMaps::validateGoogleMapsKey();
212 -
213 - $langCode = self::getMappedLanguageCode( $wgLang->getCode() );
214 -
215 - if ( $parserOrOut instanceof Parser ) {
216 - $parser = $parserOrOut;
217 -
218 - $parser->getOutput()->addHeadItem(
219 - Html::linkedScript( "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" ) .
220 - Html::linkedScript( "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" ) .
221 - Html::inlineScript( 'window.unload = GUnload;' )
222 - );
223 - }
224 - else if ( $parserOrOut instanceof OutputPage ) {
225 - $out = $parserOrOut;
226 - MapsMapper::addScriptFile( $out, "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" );
227 - $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
228 - }
229 - }
 190+ $langCode = self::getMappedLanguageCode( $wgLang->getCode() );
 191+
 192+ return array(
 193+ Html::linkedScript( "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" ),
 194+ Html::linkedScript( "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" ),
 195+ Html::inlineScript( 'window.unload = GUnload;' )
 196+ );
230197 }
231198
232199 /**
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispPoint.php
@@ -21,8 +21,6 @@
2222 * @author Jeroen De Dauw
2323 */
2424 final class MapsGoogleMapsDispPoint extends MapsBasePointMap {
25 -
26 - public $serviceName = MapsGoogleMaps::SERVICE_NAME;
2725
2826 protected $markerStringFormat = 'getGMarkerData(lat, lon, "title", "label", "icon")';
2927
@@ -31,10 +29,10 @@
3230 return $egMapsGoogleMapsZoom;
3331 }
3432
35 - public function getSpecificParameterInfo() {
 33+ protected function initSpecificParamInfo( array &$parameters ) {
3634 global $egMapsGMapOverlays;
37 - // TODO: it'd be cool to have this static so it can be cheched in order to only init it once.
38 - $this->specificParameters = array(
 35+
 36+ $parameters = array(
3937 'overlays' => array(
4038 'type' => array( 'string', 'list' ),
4139 'criteria' => array(
@@ -43,7 +41,6 @@
4442 'default' => $egMapsGMapOverlays,
4543 ),
4644 );
47 - return $this->specificParameters;
4845 }
4946
5047 /**
@@ -52,7 +49,7 @@
5350 public function doMapServiceLoad() {
5451 global $egGoogleMapsOnThisPage;
5552
56 - MapsGoogleMaps::addDependencies( $this->parser );
 53+ $this->mService->addDependencies( $this->parser );
5754 $egGoogleMapsOnThisPage++;
5855
5956 $this->elementNr = $egGoogleMapsOnThisPage;
@@ -102,5 +99,4 @@
103100
104101 }
105102
106 -}
107 -
 103+}
\ No newline at end of file
Index: trunk/extensions/Maps/Includes/Maps_Mapper.php
@@ -97,12 +97,13 @@
9898
9999 // Get rid of any aliases.
100100 $service = self::getMainServiceName( $service );
 101+
101102 // If the service is not loaded into maps, it should be changed.
102 - $shouldChange = ! array_key_exists( $service, $egMapsServices );
 103+ $shouldChange = !array_key_exists( $service, $egMapsServices );
103104
104105 // If it should not be changed, ensure the service supports this feature.
105106 if ( ! $shouldChange ) {
106 - $shouldChange = !array_key_exists( $feature, $egMapsServices[$service]['features'] );
 107+ $shouldChange = $egMapsServices[$service]->getFeature( $feature ) === false;
107108 }
108109
109110 // Change the service to the most specific default value available.
@@ -125,15 +126,16 @@
126127 * and changes it into the main service name if this is the case.
127128 *
128129 * @param string $service
 130+ *
129131 * @return string
130132 */
131133 private static function getMainServiceName( $service ) {
132134 global $egMapsServices;
133135
134 - if ( ! array_key_exists( $service, $egMapsServices ) ) {
135 - foreach ( $egMapsServices as $serviceName => $serviceInfo ) {
136 - if ( in_array( $service, $serviceInfo['aliases'] ) ) {
137 - $service = $serviceName;
 136+ if ( !array_key_exists( $service, $egMapsServices ) ) {
 137+ foreach ( $egMapsServices as $serviceObject ) {
 138+ if ( $serviceObject->hasAlias( $service ) ) {
 139+ $service = $serviceObject->getName();
138140 break;
139141 }
140142 }
@@ -238,7 +240,7 @@
239241
240242 foreach ( $egMapsAvailableServices as $availableService ) {
241243 $allServiceValues[] = $availableService;
242 - $allServiceValues = array_merge( $allServiceValues, $egMapsServices[$availableService]['aliases'] );
 244+ $allServiceValues = array_merge( $allServiceValues, $egMapsServices[$availableService]->getAliases() );
243245 }
244246
245247 return $allServiceValues;
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 echo '<b>Warning:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.';
3535 }
3636 else {
37 - define( 'Maps_VERSION', '0.6.3 alpha 2' );
 37+ define( 'Maps_VERSION', '0.6.3 a3' );
3838
3939 // The different coordinate notations.
4040 define( 'Maps_COORDS_FLOAT', 'float' );
@@ -59,8 +59,6 @@
6060 $egMapsFeatures = array();
6161 $egMapsServices = array();
6262
63 - require_once $egMapsDir . 'Services/Maps_iMappingService.php';
64 -
6563 // Include the settings file.
6664 require_once $egMapsDir . 'Maps_Settings.php';
6765
@@ -84,11 +82,11 @@
8583 global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService, $egMapsScriptPath;
8684 global $egMapsDir, $egMapsAvailableFeatures, $egMapsUseMinJs, $egMapsJsExt, $egMapsStyleVersion;
8785
88 - // Autoload the general classes.
 86+ // Autoload the includes/ classes.
8987 $wgAutoloadClasses['MapsMapper'] = $egMapsDir . 'Includes/Maps_Mapper.php';
9088 $wgAutoloadClasses['MapsCoordinateParser'] = $egMapsDir . 'Includes/Maps_CoordinateParser.php';
9189 $wgAutoloadClasses['MapsDistanceParser'] = $egMapsDir . 'Includes/Maps_DistanceParser.php';
92 -
 90+
9391 // This function has been deprecated in 1.16, but needed for earlier versions.
9492 // It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point.
9593 if ( function_exists( 'wfLoadExtensionMessages' ) ) {
@@ -97,6 +95,10 @@
9896
9997 wfRunHooks( 'MappingFeatureLoad' );
10098
 99+ // Load the service/ classes and interfaces.
 100+ require_once $egMapsDir . 'Services/Maps_iMappingService.php';
 101+ $wgAutoloadClasses['MapsMappingService'] = $egMapsDir . 'Services/Maps_MappingService.php';
 102+
101103 wfRunHooks( 'MappingServiceLoad' );
102104
103105 // Remove all hooked in services that should not be available.
Index: trunk/extensions/Maps/Maps_Settings.php
@@ -55,13 +55,16 @@
5656 # Commenting or removing a mapping service will make Maps completely ignore it, and so improve performance.
5757
5858 # Google Maps API v2
59 - include_once $egMapsDir . 'Services/GoogleMaps/Maps_GoogleMaps.php';
 59+ include_once $egMapsDir . 'Services/GoogleMaps/GoogleMaps.php';
 60+
6061 # Google Maps API v3
61 - include_once $egMapsDir . 'Services/GoogleMaps3/Maps_GoogleMaps3.php';
 62+ include_once $egMapsDir . 'Services/GoogleMaps3/GoogleMaps3.php';
 63+
6264 # OpenLayers API
63 - include_once $egMapsDir . 'Services/OpenLayers/Maps_OpenLayers.php';
 65+ include_once $egMapsDir . 'Services/OpenLayers/OpenLayers.php';
 66+
6467 # Yahoo! Maps API
65 - include_once $egMapsDir . 'Services/YahooMaps/Maps_YahooMaps.php';
 68+ include_once $egMapsDir . 'Services/YahooMaps/YahooMaps.php';
6669
6770 # Array of String. Array containing all the mapping services that will be made available to the user.
6871 # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers.
Index: trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php
@@ -24,18 +24,22 @@
2525 */
2626 abstract class MapsBasePointMap implements iMapParserFunction {
2727
28 - public $serviceName;
 28+ public $mService;
2929
3030 protected $centreLat, $centreLon;
3131
3232 protected $output = '';
3333
34 - protected $specificParameters = false;
 34+ private $specificParameters = false;
3535 protected $featureParameters = false;
3636
3737 private $markerData = array();
3838 protected $markerString;
3939
 40+ public function __construct( MapsMappingService $service ) {
 41+ $this->mService = $service;
 42+ }
 43+
4044 /**
4145 * Sets the map properties as class fields.
4246 *
@@ -54,13 +58,30 @@
5559 }
5660
5761 /**
 62+ * Returns the specific parameters by first checking if they have been initialized yet,
 63+ * doing to work if this is not the case, and then returning them.
 64+ *
5865 * @return array
5966 */
60 - public function getSpecificParameterInfo() {
61 - return array();
 67+ public final function getSpecificParameterInfo() {
 68+ if ( $this->specificParameters === false ) {
 69+ $this->specificParameters = array();
 70+ $this->initSpecificParamInfo( $this->specificParameters );
 71+ }
 72+
 73+ return $this->specificParameters;
6274 }
6375
6476 /**
 77+ * Initializes the specific parameters.
 78+ *
 79+ * Override this method to set parameters specific to a feature service comibination in
 80+ * the inheriting class.
 81+ */
 82+ protected function initSpecificParamInfo( array &$parameters ) {
 83+ }
 84+
 85+ /**
6586 * @return array
6687 */
6788 public function getFeatureParameters() {
@@ -227,7 +248,7 @@
228249 }
229250 }
230251 else { // If a centre value is set, geocode when needed and use it.
231 - $this->centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->serviceName );
 252+ $this->centre = MapsGeocoder::attemptToGeocode( $this->centre, $this->geoservice, $this->mService->getName() );
232253
233254 // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde.
234255 if ( $this->centre ) {
@@ -248,4 +269,4 @@
249270 $this->centreLat = $egMapsMapLat;
250271 $this->centreLon = $egMapsMapLon;
251272 }
252 -}
 273+}
\ No newline at end of file
Index: trunk/extensions/Maps/Features/Maps_iMapParserFunction.php
@@ -21,6 +21,8 @@
2222 * @author Jeroen De Dauw
2323 */
2424 interface iMapParserFunction {
 25+ function __construct( MapsMappingService $service );
 26+
2527 function getMapHtml( Parser &$parser, array $params );
2628
2729 /**
@@ -32,4 +34,6 @@
3335 * Adds the HTML specific to the mapping service to the output.
3436 */
3537 function addSpecificMapHTML();
 38+
 39+ function getSpecificParameterInfo();
3640 }
\ No newline at end of file
Index: trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php
@@ -24,7 +24,7 @@
2525 */
2626 abstract class MapsBaseMap implements iMapParserFunction {
2727
28 - public $serviceName;
 28+ protected $mService;
2929
3030 protected $centreLat, $centreLon;
3131
@@ -32,9 +32,13 @@
3333
3434 protected $parser;
3535
36 - protected $specificParameters = false;
 36+ private $specificParameters = false;
3737 protected $featureParameters = false;
3838
 39+ public function __construct( MapsMappingService $service ) {
 40+ $this->mService = $service;
 41+ }
 42+
3943 /**
4044 * Sets the map properties as class fields.
4145 *
@@ -53,13 +57,30 @@
5458 }
5559
5660 /**
 61+ * Returns the specific parameters by first checking if they have been initialized yet,
 62+ * doing to work if this is not the case, and then returning them.
 63+ *
5764 * @return array
5865 */
59 - public function getSpecificParameterInfo() {
60 - return array();
 66+ public final function getSpecificParameterInfo() {
 67+ if ( $this->specificParameters === false ) {
 68+ $this->specificParameters = array();
 69+ $this->initSpecificParamInfo( $this->specificParameters );
 70+ }
 71+
 72+ return $this->specificParameters;
6173 }
6274
6375 /**
 76+ * Initializes the specific parameters.
 77+ *
 78+ * Override this method to set parameters specific to a feature service comibination in
 79+ * the inheriting class.
 80+ */
 81+ protected function initSpecificParamInfo( array &$parameters ) {
 82+ }
 83+
 84+ /**
6485 * @return array
6586 */
6687 public function getFeatureParameters() {
@@ -90,7 +111,7 @@
91112 * Handles the request from the parser hook by doing the work that's common for all
92113 * mapping services, calling the specific methods and finally returning the resulting output.
93114 *
94 - * @param unknown_type $parser
 115+ * @param Parser $parser
95116 * @param array $params
96117 *
97118 * @return html
@@ -116,16 +137,14 @@
117138 }
118139
119140 /**
120 - * Sets the $centre_lat and $centre_lon fields.
 141+ * Sets the $centreLat and $centreLon fields.
121142 */
122143 private function setCentre() {
123144 if ( empty( $this->coordinates ) ) { // If centre is not set, use the default latitude and longitutde.
124 - global $egMapsMapLat, $egMapsMapLon;
125 - $this->centreLat = $egMapsMapLat;
126 - $this->centreLon = $egMapsMapLon;
 145+ $this->setDefaultCentre();
127146 }
128147 else { // If a centre value is set, geocode when needed and use it.
129 - $this->coordinates = MapsGeocoder::attemptToGeocode( $this->coordinates, $this->geoservice, $this->serviceName );
 148+ $this->coordinates = MapsGeocoder::attemptToGeocode( $this->coordinates, $this->geoservice, $this->mService->getName() );
130149
131150 // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde.
132151 if ( $this->coordinates ) {
@@ -134,11 +153,19 @@
135154 }
136155 else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used.
137156 // TODO: Some warning this failed would be nice here.
138 - global $egMapsMapLat, $egMapsMapLon;
139 - $this->centreLat = $egMapsMapLat;
140 - $this->centreLon = $egMapsMapLon;
 157+ $this->setDefaultCentre();
141158 }
142159 }
143160 }
144161
145 -}
 162+ /**
 163+ * Sets the centre lat and lon to their default.
 164+ */
 165+ private function setDefaultCentre() {
 166+ global $egMapsMapLat, $egMapsMapLon;
 167+
 168+ $this->centreLat = $egMapsMapLat;
 169+ $this->centreLon = $egMapsMapLon;
 170+ }
 171+
 172+}
\ No newline at end of file
Index: trunk/extensions/Maps/Features/Maps_ParserFunctions.php
@@ -67,8 +67,8 @@
6868 $name = strtolower( trim( array_shift( $split ) ) );
6969 if ( count( $split ) > 0 && self::inParamAliases( $name, 'service', MapsMapper::getCommonParameters() ) ) {
7070 if ( !$setService ) {
71 - $service = implode( '=', $split );
72 - $parameters[] = 'service=' . $service;
 71+ $serviceName = implode( '=', $split );
 72+ $parameters[] = 'service=' . $serviceName;
7373 $setService = true;
7474 }
7575 } else {
@@ -76,9 +76,14 @@
7777 }
7878 }
7979
80 - $service = MapsMapper::getValidService( $setService ? $service : '', $parserFunction );
81 - $mapClass = new $egMapsServices[$service]['features'][$parserFunction]();
 80+ // Make sure the service name is valid, and then get the class associated with it.
 81+ $serviceName = MapsMapper::getValidService( $setService ? $serviceName : '', $parserFunction );
 82+ $service = $egMapsServices[$serviceName];
8283
 84+ // Get the name of the class handling the current parser function and service.
 85+ $className = $service->getFeature( $parserFunction );
 86+ $mapClass = new $className( $service );
 87+
8388 $manager = new ValidatorManager();
8489
8590 /*
@@ -89,7 +94,7 @@
9095 * and finally by the specific parameters (the ones specific to a service-feature combination).
9196 */
9297 $parameterInfo = array_merge_recursive( MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() );
93 - $parameterInfo = array_merge_recursive( $parameterInfo, $egMapsServices[$service]['parameters'] );
 98+ $parameterInfo = array_merge_recursive( $parameterInfo, $service->getParameterInfo() );
9499 $parameterInfo = array_merge_recursive( $parameterInfo, $mapClass->getSpecificParameterInfo() );
95100
96101 $displayMap = $manager->manageParameters(
@@ -134,4 +139,4 @@
135140
136141 return $equals;
137142 }
138 -}
 143+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r67905Follow up to r67904 - documentation updatejeroendedauw16:31, 12 June 2010
r67906Changes for 0.6.3 - follow up to r67904 - not all features are working for nowjeroendedauw16:44, 12 June 2010
r67945Changes for 0.6.3 - Follow up to r67904jeroendedauw13:55, 13 June 2010
r67946Changes for 0.6.3 - Follow up to r67904jeroendedauw13:56, 13 June 2010
r67947Changes for 0.6.3 - Follow up to r67904jeroendedauw14:09, 13 June 2010
r67952Changes for 0.6.3 - Follow up to r67904jeroendedauw14:41, 13 June 2010
r67953Changes for 0.6.3 - Follow up to r67904jeroendedauw14:41, 13 June 2010

Status & tagging log