Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | } |
56 | 56 | |
57 | 57 | private static function initializeParams() { |
58 | | - global $egMapsAvailableServices, $egMapsDefaultService, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
| 58 | + global $egMapsAvailableServices, $egMapsDefaultServices, $egMapsAvailableGeoServices, $egMapsDefaultGeoService; |
59 | 59 | |
60 | 60 | self::$parameters = array( |
61 | 61 | 'service' => array( |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | 'criteria' => array( |
64 | 64 | 'in_array' => $egMapsAvailableServices |
65 | 65 | ), |
66 | | - 'default' => $egMapsDefaultService |
| 66 | + 'default' => $egMapsDefaultServices['pf'] |
67 | 67 | ), |
68 | 68 | 'coordinates' => array( |
69 | 69 | 'aliases' => array('coords', 'location', 'locations'), |
— | — | @@ -335,6 +335,6 @@ |
336 | 336 | } |
337 | 337 | |
338 | 338 | return $paramValue; |
339 | | - } |
| 339 | + } |
340 | 340 | |
341 | 341 | } |
\ No newline at end of file |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -23,40 +23,49 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
| 27 | +// Include the Validator extension if that hasn't been done yet, since it's required for Maps to work. |
27 | 28 | if( !defined( 'Validator_VERSION' ) ) { |
28 | | - // Include the Validator extension if that hasn't been done yet, since it's required for Maps to work. |
29 | | - include_once('extensions/Validator/Validator.php'); |
| 29 | + @include_once('extensions/Validator/Validator.php'); |
30 | 30 | } |
31 | 31 | |
32 | | -define('Maps_VERSION', '0.5 a16'); |
| 32 | +// Only initialize the extension when all dependencies are present. |
| 33 | +if (defined( 'Validator_VERSION' )) { |
| 34 | + define('Maps_VERSION', '0.5 a18'); |
| 35 | + |
| 36 | + $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
| 37 | + $egMapsIP = $IP . '/extensions/Maps'; |
| 38 | + |
| 39 | + $egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION; |
| 40 | + |
| 41 | + // Include the settings file |
| 42 | + require_once($egMapsIP . '/Maps_Settings.php'); |
| 43 | + |
| 44 | + // Register the initialization function of Maps. |
| 45 | + $wgExtensionFunctions[] = 'efMapsSetup'; |
| 46 | + |
| 47 | + $wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php'; |
| 48 | + |
| 49 | + $wgHooks['AdminLinks'][] = 'efMapsAddToAdminLinks'; |
| 50 | + |
| 51 | + // Autoload the general classes |
| 52 | + $wgAutoloadClasses['MapsMapFeature'] = $egMapsIP . '/Maps_MapFeature.php'; |
| 53 | + $wgAutoloadClasses['MapsMapper'] = $egMapsIP . '/Maps_Mapper.php'; |
| 54 | + $wgAutoloadClasses['MapsUtils'] = $egMapsIP . '/Maps_Utils.php'; |
| 55 | + |
| 56 | + if (empty($egMapsServices)) $egMapsServices = array(); |
| 57 | +} |
33 | 58 | |
34 | | -$egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
35 | | -$egMapsIP = $IP . '/extensions/Maps'; |
36 | | - |
37 | | -$egMapsStyleVersion = $wgStyleVersion . '-' . Maps_VERSION; |
38 | | - |
39 | | -// Include the settings file |
40 | | -require_once($egMapsIP . '/Maps_Settings.php'); |
41 | | - |
42 | | -$wgExtensionFunctions[] = 'efMapsSetup'; |
43 | | - |
44 | | -$wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php'; |
45 | | - |
46 | | -$wgHooks['AdminLinks'][] = 'efMapsAddToAdminLinks'; |
47 | | - |
48 | | -// Autoload the general classes |
49 | | -$wgAutoloadClasses['MapsMapFeature'] = $egMapsIP . '/Maps_MapFeature.php'; |
50 | | -$wgAutoloadClasses['MapsMapper'] = $egMapsIP . '/Maps_Mapper.php'; |
51 | | -$wgAutoloadClasses['MapsUtils'] = $egMapsIP . '/Maps_Utils.php'; |
52 | | - |
53 | | -if (empty($egMapsServices)) $egMapsServices = array(); |
54 | | - |
55 | 59 | /** |
56 | 60 | * Initialization function for the Maps extension. |
57 | 61 | */ |
58 | 62 | function efMapsSetup() { |
59 | 63 | global $wgExtensionCredits, $wgLang, $wgAutoloadClasses, $IP; |
60 | 64 | global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsIP, $egMapsAvailableFeatures; |
| 65 | + |
| 66 | + // Remove all hooked in services that should not be available. |
| 67 | + foreach($egMapsServices as $service => $data) { |
| 68 | + if (! in_array($service, $egMapsAvailableServices)) unset($egMapsServices[$service]); |
| 69 | + } |
61 | 70 | |
62 | 71 | // Enure that the default service and geoservice are one of the enabled ones. |
63 | 72 | $egMapsDefaultService = in_array($egMapsDefaultService, $egMapsAvailableServices) ? $egMapsDefaultService : $egMapsAvailableServices[0]; |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | * |
113 | 113 | * @return string |
114 | 114 | */ |
115 | | - private function getStaticMap() { |
| 115 | + private function getStaticMap() { |
116 | 116 | $clickToActivate = wfMsg('maps_click_to_activate'); |
117 | 117 | |
118 | 118 | $mode = MapsOSM::getModeData($this->mode); |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export', |
82 | 82 | |
83 | 83 | 'format' => 'png', |
84 | | - 'numZoomLevels' => 19, |
| 84 | + 'numZoomLevels' => 16, |
85 | 85 | 'maxResolution' => 156543.0339, |
86 | 86 | 'unit' => 'm', |
87 | 87 | 'sphericalMercator' => true, |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export', |
106 | 106 | |
107 | 107 | 'format' => 'png', |
108 | | - 'numZoomLevels' => 19, |
| 108 | + 'numZoomLevels' => 16, |
109 | 109 | 'maxResolution' => 156543.0339, |
110 | 110 | 'unit' => 'm', |
111 | 111 | 'sphericalMercator' => true |
Index: trunk/extensions/Maps/Maps_Mapper.php |
— | — | @@ -24,8 +24,7 @@ |
25 | 25 | private static $mainParams; |
26 | 26 | |
27 | 27 | public static function initializeMainParams() { |
28 | | - global $egMapsAvailableServices, $egMapsDefaultService, $egMapsAvailableGeoServices, $egMapsDefaultGeoService, $egMapsDefaultCentre; |
29 | | - global $egMapsSizeRestrictions, $egMapsMapWidth, $egMapsMapHeight, $egMapsDefaultTitle, $egMapsDefaultLabel; |
| 28 | + global $egMapsSizeRestrictions, $egMapsMapWidth, $egMapsMapHeight; |
30 | 29 | |
31 | 30 | self::$mainParams = array |
32 | 31 | ( |
— | — | @@ -106,55 +105,8 @@ |
107 | 106 | if ($toLower) $itemString = strtolower($itemString); |
108 | 107 | return $itemString; |
109 | 108 | } |
110 | | - |
111 | | - /** |
112 | | - * Returns a valid service. When an invalid service is provided, the default one will be returned. |
113 | | - * Aliases are also chancged into the main service names @see MapsMapper::getMainServiceName(). |
114 | | - * |
115 | | - * @param string $service |
116 | | - * @param string $feature |
117 | | - * |
118 | | - * @return string |
119 | | - */ |
120 | | - public static function getValidService($service, $feature) { |
121 | | - global $egMapsAvailableServices, $egMapsDefaultService, $egMapsDefaultServices, $egMapsServices; |
122 | | - |
123 | | - $service = self::getMainServiceName($service); |
124 | | - |
125 | | - $shouldChange = ! array_key_exists($service, $egMapsServices); |
126 | | - if (! $shouldChange) $shouldChange = ! array_key_exists($feature, $egMapsServices[$service]); |
127 | | - |
128 | | - if ($shouldChange) { |
129 | | - $service = array_key_exists($feature, $egMapsDefaultServices) ? $egMapsDefaultServices[$feature] : $egMapsDefaultService; |
130 | | - } |
131 | | - |
132 | | - if(! in_array($service, $egMapsAvailableServices)) $service = $egMapsDefaultService; |
133 | | - |
134 | | - return $service; |
135 | | - } |
136 | 109 | |
137 | 110 | /** |
138 | | - * Checks if the service name is an alias for an actual service, |
139 | | - * and changes it into the main service name if this is the case. |
140 | | - * |
141 | | - * @param string $service |
142 | | - * @return string |
143 | | - */ |
144 | | - public static function getMainServiceName($service) { |
145 | | - global $egMapsServices; |
146 | | - |
147 | | - if (! array_key_exists($service, $egMapsServices)) { |
148 | | - foreach ($egMapsServices as $serviceName => $serviceInfo) { |
149 | | - if (in_array($service, $serviceInfo['aliases'])) { |
150 | | - $service = $serviceName; |
151 | | - } |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - return $service; |
156 | | - } |
157 | | - |
158 | | - /** |
159 | 111 | * Returns a valid version of the types. |
160 | 112 | * |
161 | 113 | * @param array $types |
— | — | @@ -198,5 +150,51 @@ |
199 | 151 | return $types; |
200 | 152 | } |
201 | 153 | |
202 | | - |
| 154 | + /** |
| 155 | + * Returns a valid service. When an invalid service is provided, the default one will be returned. |
| 156 | + * Aliases are also chancged into the main service names @see MapsMapper::getMainServiceName(). |
| 157 | + * |
| 158 | + * @param string $service |
| 159 | + * @param string $feature |
| 160 | + * |
| 161 | + * @return string |
| 162 | + */ |
| 163 | + public static function getValidService($service, $feature) { |
| 164 | + global $egMapsAvailableServices, $egMapsDefaultService, $egMapsDefaultServices, $egMapsServices; |
| 165 | + |
| 166 | + $service = self::getMainServiceName($service); |
| 167 | + |
| 168 | + $shouldChange = ! array_key_exists($service, $egMapsServices); |
| 169 | + if (! $shouldChange) $shouldChange = ! array_key_exists($feature, $egMapsServices[$service]); |
| 170 | + |
| 171 | + if ($shouldChange) { |
| 172 | + $service = array_key_exists($feature, $egMapsDefaultServices) ? $egMapsDefaultServices[$feature] : $egMapsDefaultService; |
| 173 | + } |
| 174 | + |
| 175 | + if(! in_array($service, $egMapsAvailableServices)) $service = $egMapsDefaultService; |
| 176 | + |
| 177 | + return $service; |
| 178 | + } |
| 179 | + |
| 180 | + /** |
| 181 | + * Checks if the service name is an alias for an actual service, |
| 182 | + * and changes it into the main service name if this is the case. |
| 183 | + * |
| 184 | + * @param string $service |
| 185 | + * @return string |
| 186 | + */ |
| 187 | + private static function getMainServiceName($service) { |
| 188 | + global $egMapsServices; |
| 189 | + |
| 190 | + if (! array_key_exists($service, $egMapsServices)) { |
| 191 | + foreach ($egMapsServices as $serviceName => $serviceInfo) { |
| 192 | + if (in_array($service, $serviceInfo['aliases'])) { |
| 193 | + $service = $serviceName; |
| 194 | + break; |
| 195 | + } |
| 196 | + } |
| 197 | + } |
| 198 | + |
| 199 | + return $service; |
| 200 | + } |
203 | 201 | } |
Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | 'maps_googlemaps' => 'Google Maps', |
37 | 37 | 'maps_yahoomaps' => 'Yahoo! Maps', |
38 | 38 | 'maps_openlayers' => 'OpenLayers', |
39 | | - 'maps_osm' => 'OpenStreetMaps', |
| 39 | + 'maps_osm' => 'OpenStreetMap', |
40 | 40 | |
41 | 41 | // Static maps |
42 | 42 | 'maps_click_to_activate' => 'Click to activate map', |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | include_once $egMapsIP . '/OpenLayers/Maps_OpenLayers.php'; // OpenLayers |
67 | 67 | include_once $egMapsIP . '/YahooMaps/Maps_YahooMaps.php'; // Yahoo! Maps |
68 | 68 | include_once $egMapsIP . '/OpenStreetMap/Maps_OSM.php'; // OpenLayers optimized for OSM |
69 | | - |
| 69 | + |
70 | 70 | # Array of String. Array containing all the mapping services that will be made available to the user. |
71 | 71 | # Currently Maps provides the following services: googlemaps, yahoomaps, openlayers |
72 | 72 | $egMapsAvailableServices = array('googlemaps', 'yahoomaps', 'openlayers', 'osm'); |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | # Array of String. The default mapping service for each feature, which will be used when no valid service is provided by the user. |
80 | 80 | # Each service needs to be enabled, if not, the first one from the available services will be taken. |
81 | 81 | # Note: The default service needs to be available for the feature you set it for, since it's used as a fallback mechanism. |
82 | | -$egMapsDefaultServices = array('pf' => 'googlemaps', 'qp' => 'googlemaps', 'fi' => 'googlemaps'); |
| 82 | +$egMapsDefaultServices = array('pf' => 'googlemaps'); |
83 | 83 | |
84 | 84 | |
85 | 85 | |