Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php |
— | — | @@ -61,36 +61,36 @@ |
62 | 62 | $allowedTypes = self::getTypeNames(); |
63 | 63 | |
64 | 64 | $egMapsServices[self::SERVICE_NAME]['parameters'] = array( |
65 | | - 'type' => array( |
66 | | - 'aliases' => array( 'map-type', 'map type' ), |
67 | | - 'criteria' => array( |
68 | | - 'in_array' => $allowedTypes |
69 | | - ), |
70 | | - 'default' => $egMapsGMaps3Type, // FIXME: default value should not be used when not present in types parameter. |
71 | | - 'output-type' => 'gmap3type' |
72 | | - ), |
73 | | - /* |
74 | | - 'types' => array( |
75 | | - 'type' => array('string', 'list'), |
76 | | - 'aliases' => array('map-types', 'map types'), |
77 | | - 'criteria' => array( |
78 | | - 'in_array' => $allowedTypes |
79 | | - ), |
80 | | - 'default' => $egMapsGMaps3Types, |
81 | | - 'output-types' => array('gmap3types', 'list') |
82 | | - ), |
83 | | - */ |
84 | | - ); |
| 65 | + 'type' => array( |
| 66 | + 'aliases' => array( 'map-type', 'map type' ), |
| 67 | + 'criteria' => array( |
| 68 | + 'in_array' => $allowedTypes |
| 69 | + ), |
| 70 | + 'default' => $egMapsGMaps3Type, // FIXME: default value should not be used when not present in types parameter. |
| 71 | + 'output-type' => 'gmap3type' |
| 72 | + ), |
| 73 | + /* |
| 74 | + 'types' => array( |
| 75 | + 'type' => array('string', 'list'), |
| 76 | + 'aliases' => array('map-types', 'map types'), |
| 77 | + 'criteria' => array( |
| 78 | + 'in_array' => $allowedTypes |
| 79 | + ), |
| 80 | + 'default' => $egMapsGMaps3Types, |
| 81 | + 'output-types' => array('gmap3types', 'list') |
| 82 | + ), |
| 83 | + */ |
| 84 | + ); |
85 | 85 | } |
86 | 86 | |
87 | 87 | private static $mapTypes = array( |
88 | | - 'normal' => 'ROADMAP', |
89 | | - 'roadmap' => 'ROADMAP', |
90 | | - 'satellite' => 'SATELLITE', |
91 | | - 'hybrid' => 'HYBRID', |
92 | | - 'terrain' => 'TERRAIN', |
93 | | - 'physical' => 'TERRAIN' |
94 | | - ); |
| 88 | + 'normal' => 'ROADMAP', |
| 89 | + 'roadmap' => 'ROADMAP', |
| 90 | + 'satellite' => 'SATELLITE', |
| 91 | + 'hybrid' => 'HYBRID', |
| 92 | + 'terrain' => 'TERRAIN', |
| 93 | + 'physical' => 'TERRAIN' |
| 94 | + ); |
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Returns the names of all supported map types. |
— | — | @@ -137,9 +137,29 @@ |
138 | 138 | if ( empty( $egGMaps3OnThisPage ) ) { |
139 | 139 | $egGMaps3OnThisPage = 0; |
140 | 140 | |
141 | | - $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$wgLang->getCode()}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
| 141 | + $languageCode = self::getMappedLanguageCode( $wgLang->getCode() ); |
| 142 | + $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&language={$languageCode}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>"; |
142 | 143 | } |
143 | 144 | } |
144 | 145 | |
| 146 | + /** |
| 147 | + * Maps language codes to Google Maps API v3 compatible values. |
| 148 | + * |
| 149 | + * @param string $code |
| 150 | + * |
| 151 | + * @return string The mapped code |
| 152 | + */ |
| 153 | + private static function getMappedLanguageCode( $code ) { |
| 154 | + $mappings = array( |
| 155 | + 'en_gb' => 'en-gb',// v3 supports en_gb - but wants us to call it en-gb |
| 156 | + 'he' => 'iw', // iw is googlish for hebrew |
| 157 | + 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative |
| 158 | + ); |
| 159 | + if ( array_key_exists( $code, $mappings ) ) { |
| 160 | + $code = $mappings[$code]; |
| 161 | + } |
| 162 | + return $code; |
| 163 | + } |
| 164 | + |
145 | 165 | } |
146 | 166 | |
\ No newline at end of file |
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php |
— | — | @@ -207,11 +207,32 @@ |
208 | 208 | |
209 | 209 | MapsGoogleMaps::validateGoogleMapsKey(); |
210 | 210 | |
211 | | - $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$wgLang->getCode()}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>"; |
| 211 | + $langCode = self::getMappedLanguageCode( $wgLang->getCode() ); |
| 212 | + $output .= "<script src='http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl={$langCode}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>"; |
212 | 213 | } |
213 | 214 | } |
214 | 215 | |
215 | 216 | /** |
| 217 | + * Maps language codes to Google Maps API v2 compatible values. |
| 218 | + * |
| 219 | + * @param string $code |
| 220 | + * |
| 221 | + * @return string The mapped code |
| 222 | + */ |
| 223 | + private static function getMappedLanguageCode( $code ) { |
| 224 | + $mappings = array( |
| 225 | + 'en_gb' => 'en',// v2 does not support en_gb - use english :( |
| 226 | + 'he' => 'iw', // iw is googlish for hebrew |
| 227 | + 'fj' => 'fil', // google does not support Fijian - use Filipino as close(?) supported relative |
| 228 | + 'or' => 'en' // v2 does not support Oriya. |
| 229 | + ); |
| 230 | + if ( array_key_exists( $code, $mappings ) ) { |
| 231 | + $code = $mappings[$code]; |
| 232 | + } |
| 233 | + return $code; |
| 234 | + } |
| 235 | + |
| 236 | + /** |
216 | 237 | * This function ensures backward compatibility with Semantic Google Maps and other extensions |
217 | 238 | * using $wgGoogleMapsKey instead of $egGoogleMapsKey. |
218 | 239 | * |
— | — | @@ -295,10 +316,9 @@ |
296 | 317 | } |
297 | 318 | |
298 | 319 | /** |
| 320 | + * Add CSS for the overlays. |
299 | 321 | * |
300 | | - * |
301 | 322 | * @param $output |
302 | | - * @return unknown_type |
303 | 323 | */ |
304 | 324 | private static function addOverlayCss( &$output ) { |
305 | 325 | $css = <<<END |