Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispPoint.php |
— | — | @@ -21,8 +21,6 @@ |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | */ |
24 | 24 | final class MapsGoogleMaps3DispPoint extends MapsBasePointMap { |
25 | | - |
26 | | - public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
27 | 25 | |
28 | 26 | protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon, "title", "label", "icon")'; |
29 | 27 | |
— | — | @@ -38,7 +36,7 @@ |
39 | 37 | public function doMapServiceLoad() { |
40 | 38 | global $egGMaps3OnThisPage; |
41 | 39 | |
42 | | - MapsGoogleMaps3::addDependencies( $this->parser ); |
| 40 | + $this->mService->addDependencies( $this->parser ); |
43 | 41 | $egGMaps3OnThisPage++; |
44 | 42 | |
45 | 43 | $this->elementNr = $egGMaps3OnThisPage; |
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3DispMap.php |
— | — | @@ -22,8 +22,6 @@ |
23 | 23 | */ |
24 | 24 | final class MapsGoogleMaps3DispMap extends MapsBaseMap { |
25 | 25 | |
26 | | - public $serviceName = MapsGoogleMaps3::SERVICE_NAME; |
27 | | - |
28 | 26 | protected function getDefaultZoom() { |
29 | 27 | global $egMapsGMaps3Zoom; |
30 | 28 | return $egMapsGMaps3Zoom; |
— | — | @@ -36,7 +34,7 @@ |
37 | 35 | public function doMapServiceLoad() { |
38 | 36 | global $egGMaps3OnThisPage; |
39 | 37 | |
40 | | - MapsGoogleMaps3::addDependencies( $this->parser ); |
| 38 | + $this->mService->addDependencies( $this->parser ); |
41 | 39 | $egGMaps3OnThisPage++; |
42 | 40 | |
43 | 41 | $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 |
1 | 19 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php |
— | — | @@ -20,12 +20,6 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -$wgAutoloadClasses['MapsGoogleMaps3'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3.php'; |
25 | | - |
26 | | -$wgHooks['MappingServiceLoad'][] = 'MapsGoogleMaps3::initialize'; |
27 | | - |
28 | | -$wgAutoloadClasses['MapsGoogleMaps3DispMap'] = dirname( __FILE__ ) . '/Maps_GoogleMaps3DispMap.php'; |
29 | | - |
30 | 24 | /** |
31 | 25 | * Class for Google Maps v3 initialization. |
32 | 26 | * |
— | — | @@ -33,34 +27,24 @@ |
34 | 28 | * |
35 | 29 | * @author Jeroen De Dauw |
36 | 30 | */ |
37 | | -class MapsGoogleMaps3 implements iMappingService { |
| 31 | +class MapsGoogleMaps3 extends MapsMappingService { |
38 | 32 | |
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 | + ); |
57 | 38 | } |
58 | 39 | |
59 | | - protected static function initializeParams() { |
| 40 | + protected function initParameterInfo( array &$parameters ) { |
60 | 41 | global $egMapsServices, $egMapsGMaps3Type, $egMapsGMaps3Types; |
61 | 42 | |
| 43 | + Validator::addOutputFormat( 'gmap3type', array( __CLASS__, 'setGMapType' ) ); |
| 44 | + Validator::addOutputFormat( 'gmap3types', array( __CLASS__, 'setGMapTypes' ) ); |
| 45 | + |
62 | 46 | $allowedTypes = self::getTypeNames(); |
63 | 47 | |
64 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 48 | + $parameters = array( |
65 | 49 | 'type' => array( |
66 | 50 | 'aliases' => array( 'map-type', 'map type' ), |
67 | 51 | 'criteria' => array( |
— | — | @@ -126,33 +110,20 @@ |
127 | 111 | } |
128 | 112 | |
129 | 113 | /** |
130 | | - * Loads the Google Maps API v3 and required JS files. |
131 | | - * |
132 | | - * @param mixed $parserOrOut |
| 114 | + * @see MapsMappingService::getDependencies |
| 115 | + * |
| 116 | + * @return array |
133 | 117 | */ |
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; |
137 | 121 | |
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 | + ); |
157 | 128 | } |
158 | 129 | |
159 | 130 | /** |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispPoint.php |
— | — | @@ -20,8 +20,6 @@ |
21 | 21 | */ |
22 | 22 | class MapsYahooMapsDispPoint extends MapsBasePointMap { |
23 | 23 | |
24 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME; |
25 | | - |
26 | 24 | protected $markerStringFormat = 'getYMarkerData(lat, lon, "title", "label", "icon")'; |
27 | 25 | |
28 | 26 | protected function getDefaultZoom() { |
— | — | @@ -36,7 +34,7 @@ |
37 | 35 | public function doMapServiceLoad() { |
38 | 36 | global $egYahooMapsOnThisPage; |
39 | 37 | |
40 | | - MapsYahooMaps::addDependencies( $this->parser ); |
| 38 | + $this->mService->addDependencies( $this->parser ); |
41 | 39 | $egYahooMapsOnThisPage++; |
42 | 40 | |
43 | 41 | $this->elementNr = $egYahooMapsOnThisPage; |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMapsDispMap.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | class MapsYahooMapsDispMap extends MapsBaseMap { |
18 | 18 | |
19 | | - public $serviceName = MapsYahooMaps::SERVICE_NAME; |
20 | | - |
21 | 19 | protected function getDefaultZoom() { |
22 | 20 | global $egMapsYahooMapsZoom; |
23 | 21 | return $egMapsYahooMapsZoom; |
— | — | @@ -28,7 +26,7 @@ |
29 | 27 | public function doMapServiceLoad() { |
30 | 28 | global $egYahooMapsOnThisPage; |
31 | 29 | |
32 | | - MapsYahooMaps::addDependencies( $this->parser ); |
| 30 | + $this->mService->addDependencies( $this->parser ); |
33 | 31 | $egYahooMapsOnThisPage++; |
34 | 32 | |
35 | 33 | $this->elementNr = $egYahooMapsOnThisPage; |
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php |
— | — | @@ -20,13 +20,6 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
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 | | - |
31 | 24 | /** |
32 | 25 | * Class for Yahoo! Maps initialization. |
33 | 26 | * |
— | — | @@ -34,35 +27,36 @@ |
35 | 28 | * |
36 | 29 | * @author Jeroen De Dauw |
37 | 30 | */ |
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 | + ); |
39 | 44 | |
40 | | - const SERVICE_NAME = 'yahoomaps'; |
| 45 | + function __construct() { |
| 46 | + parent::__construct( |
| 47 | + 'yahoomaps', |
| 48 | + array( 'yahoo', 'yahoomap', 'ymap', 'ymaps' ) |
| 49 | + ); |
| 50 | + } |
41 | 51 | |
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; |
52 | 54 | |
53 | | - self::initializeParams(); |
54 | | - |
55 | 55 | Validator::addOutputFormat( 'ymaptype', array( __CLASS__, 'setYMapType' ) ); |
56 | | - Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) ); |
| 56 | + Validator::addOutputFormat( 'ymaptypes', array( __CLASS__, 'setYMapTypes' ) ); |
57 | 57 | |
58 | | - return true; |
59 | | - } |
60 | | - |
61 | | - protected static function initializeParams() { |
62 | | - global $egMapsServices, $egMapsYahooAutozoom, $egMapsYahooMapsType, $egMapsYahooMapsTypes, $egMapsYahooMapsZoom, $egMapsYMapControls; |
63 | | - |
64 | 58 | $allowedTypes = MapsYahooMaps::getTypeNames(); |
65 | 59 | |
66 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 60 | + $parameters = array( |
67 | 61 | 'controls' => array( |
68 | 62 | 'type' => array( 'string', 'list' ), |
69 | 63 | 'criteria' => array( |
— | — | @@ -96,16 +90,24 @@ |
97 | 91 | 'output-type' => 'boolstr' |
98 | 92 | ), |
99 | 93 | ); |
100 | | - |
101 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 1, 13 ); |
| 94 | + |
| 95 | + $parameters['zoom']['criteria']['in_range'] = array( 1, 13 ); |
102 | 96 | } |
103 | 97 | |
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 | + } |
110 | 112 | |
111 | 113 | /** |
112 | 114 | * Returns the names of all supported map types. |
— | — | @@ -151,32 +153,4 @@ |
152 | 154 | } |
153 | 155 | } |
154 | 156 | |
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 | | - |
183 | 157 | } |
\ 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 |
1 | 21 | + native |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispPoint.php |
— | — | @@ -20,8 +20,6 @@ |
21 | 21 | */ |
22 | 22 | class MapsOpenLayersDispPoint extends MapsBasePointMap { |
23 | 23 | |
24 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME; |
25 | | - |
26 | 24 | protected $markerStringFormat = 'getOLMarkerData(lon, lat, "title", "label", "icon")'; |
27 | 25 | |
28 | 26 | protected function getDefaultZoom() { |
— | — | @@ -35,7 +33,7 @@ |
36 | 34 | public function doMapServiceLoad() { |
37 | 35 | global $egOpenLayersOnThisPage; |
38 | 36 | |
39 | | - MapsOpenLayers::addDependencies( $this->parser ); |
| 37 | + $this->mService->addDependencies( $this->parser ); |
40 | 38 | $egOpenLayersOnThisPage++; |
41 | 39 | |
42 | 40 | $this->elementNr = $egOpenLayersOnThisPage; |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayersDispMap.php |
— | — | @@ -15,8 +15,6 @@ |
16 | 16 | |
17 | 17 | class MapsOpenLayersDispMap extends MapsBaseMap { |
18 | 18 | |
19 | | - public $serviceName = MapsOpenLayers::SERVICE_NAME; |
20 | | - |
21 | 19 | protected function getDefaultZoom() { |
22 | 20 | global $egMapsOpenLayersZoom; |
23 | 21 | return $egMapsOpenLayersZoom; |
— | — | @@ -28,7 +26,7 @@ |
29 | 27 | public function doMapServiceLoad() { |
30 | 28 | global $egOpenLayersOnThisPage; |
31 | 29 | |
32 | | - MapsOpenLayers::addDependencies( $this->parser ); |
| 30 | + $this->mService->addDependencies( $this->parser ); |
33 | 31 | $egOpenLayersOnThisPage++; |
34 | 32 | |
35 | 33 | $this->elementNr = $egOpenLayersOnThisPage; |
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php |
— | — | @@ -20,13 +20,6 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
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 | | - |
31 | 24 | /** |
32 | 25 | * Class for OpenLayers initialization. |
33 | 26 | * |
— | — | @@ -34,34 +27,24 @@ |
35 | 28 | * |
36 | 29 | * @author Jeroen De Dauw |
37 | 30 | */ |
38 | | -class MapsOpenLayers implements iMappingService { |
| 31 | +class MapsOpenLayers extends MapsMappingService { |
39 | 32 | |
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 | + ); |
44 | 38 | |
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; |
53 | 40 | $egMapsOLLoadedLayers = array(); |
54 | | - |
55 | | - self::initializeParams(); |
56 | | - |
57 | | - Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) ); |
58 | | - |
59 | | - return true; |
60 | | - } |
| 41 | + } |
61 | 42 | |
62 | | - protected static function initializeParams() { |
| 43 | + protected function initParameterInfo( array &$parameters ) { |
63 | 44 | global $egMapsServices, $egMapsOLLayers, $egMapsOLControls, $egMapsOpenLayersZoom; |
64 | 45 | |
65 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 46 | + Validator::addOutputFormat( 'olgroups', array( __CLASS__, 'unpackLayerGroups' ) ); |
| 47 | + |
| 48 | + $parameters = array( |
66 | 49 | 'controls' => array( |
67 | 50 | 'type' => array( 'string', 'list' ), |
68 | 51 | 'criteria' => array( |
— | — | @@ -84,10 +67,27 @@ |
85 | 68 | ), |
86 | 69 | ); |
87 | 70 | |
88 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 19 ); |
| 71 | + $parameters['zoom']['criteria']['in_range'] = array( 0, 19 ); |
89 | 72 | } |
90 | 73 | |
91 | 74 | /** |
| 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 | + /** |
92 | 92 | * Returns the names of all supported controls. |
93 | 93 | * This data is a copy of the one used to actually translate the names |
94 | 94 | * into the controls, since this resides client side, in OpenLayerFunctions.js. |
— | — | @@ -118,43 +118,13 @@ |
119 | 119 | if ( $includeGroups ) $keys = array_merge( $keys, array_keys( $egMapsOLLayerGroups ) ); |
120 | 120 | return $keys; |
121 | 121 | } |
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; |
131 | 122 | |
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 | | - |
154 | 123 | /** |
155 | 124 | * Build up a csv string with the layers, to be outputted as a JS array |
156 | 125 | * |
157 | 126 | * @param string $output |
158 | | - * @param string $layers |
| 127 | + * @param array $layers |
| 128 | + * |
159 | 129 | * @return csv string |
160 | 130 | */ |
161 | 131 | 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 |
1 | 21 | + 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 |
1 | 173 | + native |
Index: trunk/extensions/Maps/Services/Maps_iMappingService.php |
— | — | @@ -22,8 +22,8 @@ |
23 | 23 | */ |
24 | 24 | interface iMappingService { |
25 | 25 | |
26 | | - static function initialize(); |
| 26 | + function addDependencies( &$parserOrOut ); |
27 | 27 | |
28 | | - static function addDependencies( &$parserOrOut ); |
| 28 | + function getParameterInfo(); |
29 | 29 | |
30 | 30 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispMap.php |
— | — | @@ -22,16 +22,15 @@ |
23 | 23 | */ |
24 | 24 | final class MapsGoogleMapsDispMap extends MapsBaseMap { |
25 | 25 | |
26 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
27 | | - |
28 | 26 | protected function getDefaultZoom() { |
29 | 27 | global $egMapsGoogleMapsZoom; |
30 | 28 | return $egMapsGoogleMapsZoom; |
31 | 29 | } |
32 | 30 | |
33 | | - public function getSpecificParameterInfo() { |
| 31 | + protected function initSpecificParamInfo( array &$parameters ) { |
34 | 32 | global $egMapsGMapOverlays; |
35 | | - $this->specificParameters = array( |
| 33 | + |
| 34 | + $parameters = array( |
36 | 35 | 'overlays' => array( |
37 | 36 | 'type' => array( 'string', 'list' ), |
38 | 37 | 'criteria' => array( |
— | — | @@ -40,7 +39,6 @@ |
41 | 40 | 'default' => $egMapsGMapOverlays, |
42 | 41 | ), |
43 | 42 | ); |
44 | | - return $this->specificParameters; |
45 | 43 | } |
46 | 44 | |
47 | 45 | /** |
— | — | @@ -49,7 +47,7 @@ |
50 | 48 | public function doMapServiceLoad() { |
51 | 49 | global $egGoogleMapsOnThisPage; |
52 | 50 | |
53 | | - MapsGoogleMaps::addDependencies( $this->parser ); |
| 51 | + $this->mService->addDependencies( $this->parser ); |
54 | 52 | $egGoogleMapsOnThisPage++; |
55 | 53 | |
56 | 54 | $this->elementNr = $egGoogleMapsOnThisPage; |
— | — | @@ -96,5 +94,4 @@ |
97 | 95 | |
98 | 96 | } |
99 | 97 | |
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 |
1 | 21 | + native |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -20,13 +20,6 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
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 | | - |
31 | 24 | /** |
32 | 25 | * Class for Google Maps initialization. |
33 | 26 | * |
— | — | @@ -34,37 +27,26 @@ |
35 | 28 | * |
36 | 29 | * @author Jeroen De Dauw |
37 | 30 | */ |
38 | | -class MapsGoogleMaps implements iMappingService { |
| 31 | +class MapsGoogleMaps extends MapsMappingService { |
39 | 32 | |
40 | | - const SERVICE_NAME = 'googlemaps2'; |
| 33 | + function __construct() { |
| 34 | + parent::__construct( |
| 35 | + 'googlemaps2', |
| 36 | + array( 'googlemaps', 'google', 'googlemap', 'gmap', 'gmaps' ) |
| 37 | + ); |
| 38 | + } |
41 | 39 | |
42 | | - public static function initialize() { |
43 | | - global $wgAutoloadClasses, $egMapsServices; |
| 40 | + protected function initParameterInfo( array &$parameters ) { |
| 41 | + global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls; |
44 | 42 | |
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 | | - |
55 | 43 | Validator::addOutputFormat( 'gmaptype', array( __CLASS__, 'setGMapType' ) ); |
56 | 44 | Validator::addOutputFormat( 'gmaptypes', array( __CLASS__, 'setGMapTypes' ) ); |
57 | 45 | |
58 | | - Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) ); |
| 46 | + Validator::addValidationFunction( 'is_google_overlay', array( __CLASS__, 'isGOverlay' ) ); |
59 | 47 | |
60 | | - return true; |
61 | | - } |
62 | | - |
63 | | - protected static function initializeParams() { |
64 | | - global $egMapsServices, $egMapsGoogleMapsType, $egMapsGoogleMapsTypes, $egMapsGoogleAutozoom, $egMapsGMapControls; |
65 | | - |
66 | 48 | $allowedTypes = self::getTypeNames(); |
67 | 49 | |
68 | | - $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
| 50 | + $parameters = array( |
69 | 51 | 'controls' => array( |
70 | 52 | 'type' => array( 'string', 'list' ), |
71 | 53 | 'criteria' => array( |
— | — | @@ -99,7 +81,7 @@ |
100 | 82 | ), |
101 | 83 | ); |
102 | 84 | |
103 | | - $egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range'] = array( 0, 20 ); |
| 85 | + $parameters['zoom']['criteria']['in_range'] = array( 0, 20 ); |
104 | 86 | } |
105 | 87 | |
106 | 88 | // http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP |
— | — | @@ -196,36 +178,21 @@ |
197 | 179 | } |
198 | 180 | |
199 | 181 | /** |
200 | | - * Loads the Google Maps API and required JS files. |
201 | | - * |
202 | | - * @param mixed $parserOrOut |
| 182 | + * @see MapsMappingService::getDependencies |
| 183 | + * |
| 184 | + * @return array |
203 | 185 | */ |
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; |
207 | 189 | |
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 | + ); |
230 | 197 | } |
231 | 198 | |
232 | 199 | /** |
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMapsDispPoint.php |
— | — | @@ -21,8 +21,6 @@ |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | */ |
24 | 24 | final class MapsGoogleMapsDispPoint extends MapsBasePointMap { |
25 | | - |
26 | | - public $serviceName = MapsGoogleMaps::SERVICE_NAME; |
27 | 25 | |
28 | 26 | protected $markerStringFormat = 'getGMarkerData(lat, lon, "title", "label", "icon")'; |
29 | 27 | |
— | — | @@ -31,10 +29,10 @@ |
32 | 30 | return $egMapsGoogleMapsZoom; |
33 | 31 | } |
34 | 32 | |
35 | | - public function getSpecificParameterInfo() { |
| 33 | + protected function initSpecificParamInfo( array &$parameters ) { |
36 | 34 | 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( |
39 | 37 | 'overlays' => array( |
40 | 38 | 'type' => array( 'string', 'list' ), |
41 | 39 | 'criteria' => array( |
— | — | @@ -43,7 +41,6 @@ |
44 | 42 | 'default' => $egMapsGMapOverlays, |
45 | 43 | ), |
46 | 44 | ); |
47 | | - return $this->specificParameters; |
48 | 45 | } |
49 | 46 | |
50 | 47 | /** |
— | — | @@ -52,7 +49,7 @@ |
53 | 50 | public function doMapServiceLoad() { |
54 | 51 | global $egGoogleMapsOnThisPage; |
55 | 52 | |
56 | | - MapsGoogleMaps::addDependencies( $this->parser ); |
| 53 | + $this->mService->addDependencies( $this->parser ); |
57 | 54 | $egGoogleMapsOnThisPage++; |
58 | 55 | |
59 | 56 | $this->elementNr = $egGoogleMapsOnThisPage; |
— | — | @@ -102,5 +99,4 @@ |
103 | 100 | |
104 | 101 | } |
105 | 102 | |
106 | | -} |
107 | | - |
| 103 | +} |
\ No newline at end of file |
Index: trunk/extensions/Maps/Includes/Maps_Mapper.php |
— | — | @@ -97,12 +97,13 @@ |
98 | 98 | |
99 | 99 | // Get rid of any aliases. |
100 | 100 | $service = self::getMainServiceName( $service ); |
| 101 | + |
101 | 102 | // 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 ); |
103 | 104 | |
104 | 105 | // If it should not be changed, ensure the service supports this feature. |
105 | 106 | if ( ! $shouldChange ) { |
106 | | - $shouldChange = !array_key_exists( $feature, $egMapsServices[$service]['features'] ); |
| 107 | + $shouldChange = $egMapsServices[$service]->getFeature( $feature ) === false; |
107 | 108 | } |
108 | 109 | |
109 | 110 | // Change the service to the most specific default value available. |
— | — | @@ -125,15 +126,16 @@ |
126 | 127 | * and changes it into the main service name if this is the case. |
127 | 128 | * |
128 | 129 | * @param string $service |
| 130 | + * |
129 | 131 | * @return string |
130 | 132 | */ |
131 | 133 | private static function getMainServiceName( $service ) { |
132 | 134 | global $egMapsServices; |
133 | 135 | |
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(); |
138 | 140 | break; |
139 | 141 | } |
140 | 142 | } |
— | — | @@ -238,7 +240,7 @@ |
239 | 241 | |
240 | 242 | foreach ( $egMapsAvailableServices as $availableService ) { |
241 | 243 | $allServiceValues[] = $availableService; |
242 | | - $allServiceValues = array_merge( $allServiceValues, $egMapsServices[$availableService]['aliases'] ); |
| 244 | + $allServiceValues = array_merge( $allServiceValues, $egMapsServices[$availableService]->getAliases() ); |
243 | 245 | } |
244 | 246 | |
245 | 247 | return $allServiceValues; |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | 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>.'; |
35 | 35 | } |
36 | 36 | else { |
37 | | - define( 'Maps_VERSION', '0.6.3 alpha 2' ); |
| 37 | + define( 'Maps_VERSION', '0.6.3 a3' ); |
38 | 38 | |
39 | 39 | // The different coordinate notations. |
40 | 40 | define( 'Maps_COORDS_FLOAT', 'float' ); |
— | — | @@ -59,8 +59,6 @@ |
60 | 60 | $egMapsFeatures = array(); |
61 | 61 | $egMapsServices = array(); |
62 | 62 | |
63 | | - require_once $egMapsDir . 'Services/Maps_iMappingService.php'; |
64 | | - |
65 | 63 | // Include the settings file. |
66 | 64 | require_once $egMapsDir . 'Maps_Settings.php'; |
67 | 65 | |
— | — | @@ -84,11 +82,11 @@ |
85 | 83 | global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService, $egMapsScriptPath; |
86 | 84 | global $egMapsDir, $egMapsAvailableFeatures, $egMapsUseMinJs, $egMapsJsExt, $egMapsStyleVersion; |
87 | 85 | |
88 | | - // Autoload the general classes. |
| 86 | + // Autoload the includes/ classes. |
89 | 87 | $wgAutoloadClasses['MapsMapper'] = $egMapsDir . 'Includes/Maps_Mapper.php'; |
90 | 88 | $wgAutoloadClasses['MapsCoordinateParser'] = $egMapsDir . 'Includes/Maps_CoordinateParser.php'; |
91 | 89 | $wgAutoloadClasses['MapsDistanceParser'] = $egMapsDir . 'Includes/Maps_DistanceParser.php'; |
92 | | - |
| 90 | + |
93 | 91 | // This function has been deprecated in 1.16, but needed for earlier versions. |
94 | 92 | // It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point. |
95 | 93 | if ( function_exists( 'wfLoadExtensionMessages' ) ) { |
— | — | @@ -97,6 +95,10 @@ |
98 | 96 | |
99 | 97 | wfRunHooks( 'MappingFeatureLoad' ); |
100 | 98 | |
| 99 | + // Load the service/ classes and interfaces. |
| 100 | + require_once $egMapsDir . 'Services/Maps_iMappingService.php'; |
| 101 | + $wgAutoloadClasses['MapsMappingService'] = $egMapsDir . 'Services/Maps_MappingService.php'; |
| 102 | + |
101 | 103 | wfRunHooks( 'MappingServiceLoad' ); |
102 | 104 | |
103 | 105 | // Remove all hooked in services that should not be available. |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -55,13 +55,16 @@ |
56 | 56 | # Commenting or removing a mapping service will make Maps completely ignore it, and so improve performance. |
57 | 57 | |
58 | 58 | # Google Maps API v2 |
59 | | - include_once $egMapsDir . 'Services/GoogleMaps/Maps_GoogleMaps.php'; |
| 59 | + include_once $egMapsDir . 'Services/GoogleMaps/GoogleMaps.php'; |
| 60 | + |
60 | 61 | # Google Maps API v3 |
61 | | - include_once $egMapsDir . 'Services/GoogleMaps3/Maps_GoogleMaps3.php'; |
| 62 | + include_once $egMapsDir . 'Services/GoogleMaps3/GoogleMaps3.php'; |
| 63 | + |
62 | 64 | # OpenLayers API |
63 | | - include_once $egMapsDir . 'Services/OpenLayers/Maps_OpenLayers.php'; |
| 65 | + include_once $egMapsDir . 'Services/OpenLayers/OpenLayers.php'; |
| 66 | + |
64 | 67 | # Yahoo! Maps API |
65 | | - include_once $egMapsDir . 'Services/YahooMaps/Maps_YahooMaps.php'; |
| 68 | + include_once $egMapsDir . 'Services/YahooMaps/YahooMaps.php'; |
66 | 69 | |
67 | 70 | # Array of String. Array containing all the mapping services that will be made available to the user. |
68 | 71 | # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers. |
Index: trunk/extensions/Maps/Features/DisplayPoint/Maps_BasePointMap.php |
— | — | @@ -24,18 +24,22 @@ |
25 | 25 | */ |
26 | 26 | abstract class MapsBasePointMap implements iMapParserFunction { |
27 | 27 | |
28 | | - public $serviceName; |
| 28 | + public $mService; |
29 | 29 | |
30 | 30 | protected $centreLat, $centreLon; |
31 | 31 | |
32 | 32 | protected $output = ''; |
33 | 33 | |
34 | | - protected $specificParameters = false; |
| 34 | + private $specificParameters = false; |
35 | 35 | protected $featureParameters = false; |
36 | 36 | |
37 | 37 | private $markerData = array(); |
38 | 38 | protected $markerString; |
39 | 39 | |
| 40 | + public function __construct( MapsMappingService $service ) { |
| 41 | + $this->mService = $service; |
| 42 | + } |
| 43 | + |
40 | 44 | /** |
41 | 45 | * Sets the map properties as class fields. |
42 | 46 | * |
— | — | @@ -54,13 +58,30 @@ |
55 | 59 | } |
56 | 60 | |
57 | 61 | /** |
| 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 | + * |
58 | 65 | * @return array |
59 | 66 | */ |
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; |
62 | 74 | } |
63 | 75 | |
64 | 76 | /** |
| 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 | + /** |
65 | 86 | * @return array |
66 | 87 | */ |
67 | 88 | public function getFeatureParameters() { |
— | — | @@ -227,7 +248,7 @@ |
228 | 249 | } |
229 | 250 | } |
230 | 251 | 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() ); |
232 | 253 | |
233 | 254 | // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
234 | 255 | if ( $this->centre ) { |
— | — | @@ -248,4 +269,4 @@ |
249 | 270 | $this->centreLat = $egMapsMapLat; |
250 | 271 | $this->centreLon = $egMapsMapLon; |
251 | 272 | } |
252 | | -} |
| 273 | +} |
\ No newline at end of file |
Index: trunk/extensions/Maps/Features/Maps_iMapParserFunction.php |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | */ |
24 | 24 | interface iMapParserFunction { |
| 25 | + function __construct( MapsMappingService $service ); |
| 26 | + |
25 | 27 | function getMapHtml( Parser &$parser, array $params ); |
26 | 28 | |
27 | 29 | /** |
— | — | @@ -32,4 +34,6 @@ |
33 | 35 | * Adds the HTML specific to the mapping service to the output. |
34 | 36 | */ |
35 | 37 | function addSpecificMapHTML(); |
| 38 | + |
| 39 | + function getSpecificParameterInfo(); |
36 | 40 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Features/DisplayMap/Maps_BaseMap.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | */ |
26 | 26 | abstract class MapsBaseMap implements iMapParserFunction { |
27 | 27 | |
28 | | - public $serviceName; |
| 28 | + protected $mService; |
29 | 29 | |
30 | 30 | protected $centreLat, $centreLon; |
31 | 31 | |
— | — | @@ -32,9 +32,13 @@ |
33 | 33 | |
34 | 34 | protected $parser; |
35 | 35 | |
36 | | - protected $specificParameters = false; |
| 36 | + private $specificParameters = false; |
37 | 37 | protected $featureParameters = false; |
38 | 38 | |
| 39 | + public function __construct( MapsMappingService $service ) { |
| 40 | + $this->mService = $service; |
| 41 | + } |
| 42 | + |
39 | 43 | /** |
40 | 44 | * Sets the map properties as class fields. |
41 | 45 | * |
— | — | @@ -53,13 +57,30 @@ |
54 | 58 | } |
55 | 59 | |
56 | 60 | /** |
| 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 | + * |
57 | 64 | * @return array |
58 | 65 | */ |
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; |
61 | 73 | } |
62 | 74 | |
63 | 75 | /** |
| 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 | + /** |
64 | 85 | * @return array |
65 | 86 | */ |
66 | 87 | public function getFeatureParameters() { |
— | — | @@ -90,7 +111,7 @@ |
91 | 112 | * Handles the request from the parser hook by doing the work that's common for all |
92 | 113 | * mapping services, calling the specific methods and finally returning the resulting output. |
93 | 114 | * |
94 | | - * @param unknown_type $parser |
| 115 | + * @param Parser $parser |
95 | 116 | * @param array $params |
96 | 117 | * |
97 | 118 | * @return html |
— | — | @@ -116,16 +137,14 @@ |
117 | 138 | } |
118 | 139 | |
119 | 140 | /** |
120 | | - * Sets the $centre_lat and $centre_lon fields. |
| 141 | + * Sets the $centreLat and $centreLon fields. |
121 | 142 | */ |
122 | 143 | private function setCentre() { |
123 | 144 | 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(); |
127 | 146 | } |
128 | 147 | 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() ); |
130 | 149 | |
131 | 150 | // If the centre is not false, it will be a valid coordinate, which can be used to set the latitude and longitutde. |
132 | 151 | if ( $this->coordinates ) { |
— | — | @@ -134,11 +153,19 @@ |
135 | 154 | } |
136 | 155 | else { // If it's false, the coordinate was invalid, or geocoding failed. Either way, the default's should be used. |
137 | 156 | // TODO: Some warning this failed would be nice here. |
138 | | - global $egMapsMapLat, $egMapsMapLon; |
139 | | - $this->centreLat = $egMapsMapLat; |
140 | | - $this->centreLon = $egMapsMapLon; |
| 157 | + $this->setDefaultCentre(); |
141 | 158 | } |
142 | 159 | } |
143 | 160 | } |
144 | 161 | |
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 @@ |
68 | 68 | $name = strtolower( trim( array_shift( $split ) ) ); |
69 | 69 | if ( count( $split ) > 0 && self::inParamAliases( $name, 'service', MapsMapper::getCommonParameters() ) ) { |
70 | 70 | if ( !$setService ) { |
71 | | - $service = implode( '=', $split ); |
72 | | - $parameters[] = 'service=' . $service; |
| 71 | + $serviceName = implode( '=', $split ); |
| 72 | + $parameters[] = 'service=' . $serviceName; |
73 | 73 | $setService = true; |
74 | 74 | } |
75 | 75 | } else { |
— | — | @@ -76,9 +76,14 @@ |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
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]; |
82 | 83 | |
| 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 | + |
83 | 88 | $manager = new ValidatorManager(); |
84 | 89 | |
85 | 90 | /* |
— | — | @@ -89,7 +94,7 @@ |
90 | 95 | * and finally by the specific parameters (the ones specific to a service-feature combination). |
91 | 96 | */ |
92 | 97 | $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() ); |
94 | 99 | $parameterInfo = array_merge_recursive( $parameterInfo, $mapClass->getSpecificParameterInfo() ); |
95 | 100 | |
96 | 101 | $displayMap = $manager->manageParameters( |
— | — | @@ -134,4 +139,4 @@ |
135 | 140 | |
136 | 141 | return $equals; |
137 | 142 | } |
138 | | -} |
| 143 | +} |
\ No newline at end of file |