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.5.1 a1'); |
| 37 | + define('Maps_VERSION', '0.5.1 a2'); |
38 | 38 | |
39 | 39 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
40 | 40 | $egMapsIP = $IP . '/extensions/Maps'; |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMCgiBin.php |
— | — | @@ -63,21 +63,24 @@ |
64 | 64 | * @return string |
65 | 65 | */ |
66 | 66 | public function getUrl() { |
67 | | - $args = |
68 | | - $this->options['base_url'] |
69 | | - . '?' |
70 | | - . 'bbox=' . implode( ',', $this->bounds ) |
71 | | - . '&scale=' . $this->scale |
72 | | - . '&format=' . $this->options['format']; |
73 | | - |
74 | | - // Hack to support my custom cgi-bin/export script |
75 | | - if ( isset( $this->options['get_args'] ) ) { |
76 | | - $args .= |
77 | | - '&maptype=' . $this->options['get_args']['maptype'] |
78 | | - . '&locale=' . $this->lang; |
| 67 | + $urlElements = array(); |
| 68 | + |
| 69 | + $urlElements[] = $this->options['base_url']; |
| 70 | + $urlElements[] = '?bbox='; |
| 71 | + $urlElements[] = implode( ',', $this->bounds ); |
| 72 | + $urlElements[] = '&scale='; |
| 73 | + $urlElements[] = $this->scale; |
| 74 | + $urlElements[] = '&format='; |
| 75 | + $urlElements[] = $this->options['format']; |
| 76 | + $urlElements[] = '&locale='; |
| 77 | + $urlElements[] = $this->lang; |
| 78 | + |
| 79 | + if (array_key_exists('maptype', $this->options)) { |
| 80 | + $urlElements[] = '&maptype='; |
| 81 | + $urlElements[] = $this->options['maptype']; |
79 | 82 | } |
80 | 83 | |
81 | | - return $args; |
| 84 | + return implode('', $urlElements); |
82 | 85 | } |
83 | 86 | |
84 | 87 | /** |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | * |
24 | 24 | */ |
25 | 25 | protected function setMapSettings() { |
26 | | - global $egMapsOSMZoom, $egMapsOSMPrefix; |
| 26 | + global $egMapsOSMZoom, $egMapsOSMPrefix,$egMapsOSMStaticAsDefault, $egMapsOSMStaticActivatable; |
27 | 27 | |
28 | 28 | $this->elementNamePrefix = $egMapsOSMPrefix; |
29 | 29 | $this->defaultZoom = $egMapsOSMZoom; |
— | — | @@ -34,14 +34,20 @@ |
35 | 35 | 'criteria' => array( |
36 | 36 | 'in_array' => array('yes', 'no') |
37 | 37 | ), |
38 | | - 'default' => 'no' |
| 38 | + 'default' => $egMapsOSMStaticAsDefault ? 'yes' : 'no' |
39 | 39 | ), |
40 | 40 | 'mode' => array( |
41 | 41 | 'criteria' => array( |
42 | 42 | 'in_array' => $modes |
43 | 43 | ), |
44 | | - 'default' => $modes[0] |
45 | | - ), |
| 44 | + 'default' => $modes[0] |
| 45 | + ), |
| 46 | + 'activatable' => array( |
| 47 | + 'criteria' => array( |
| 48 | + 'in_array' => array('yes', 'no') |
| 49 | + ), |
| 50 | + 'default' => $egMapsOSMStaticActivatable ? 'yes' : 'no' |
| 51 | + ), |
46 | 52 | ); |
47 | 53 | } |
48 | 54 | |
— | — | @@ -84,7 +90,6 @@ |
85 | 91 | EOT; |
86 | 92 | |
87 | 93 | $this->output .= $this->static == 'yes' ? $this->getStaticMap() : $this->getDynamicMap(); |
88 | | - |
89 | 94 | } |
90 | 95 | |
91 | 96 | /** |
— | — | @@ -110,30 +115,35 @@ |
111 | 116 | * @return string |
112 | 117 | */ |
113 | 118 | private function getStaticMap() { |
114 | | - $clickToActivate = wfMsg('maps_click_to_activate'); |
115 | | - |
116 | 119 | $mode = MapsOSM::getModeData($this->mode); |
117 | 120 | |
118 | | - $staticType = $mode['static_rendering']['type']; |
119 | | - $staticOptions = $mode['static_rendering']['options']; |
| 121 | + $staticType = $mode['handler']; |
| 122 | + $staticOptions = $mode['options']; |
120 | 123 | |
121 | | - $static = new $staticType($this->centre_lat, $this->centre_lon, $this->zoom, $this->width, $this->height, $this->lang, $staticOptions); |
122 | | - $rendering_url = $static->getUrl(); |
| 124 | + $static = new $staticType($this->centre_lat, $this->centre_lon, $this->zoom, $this->width, $this->height, $this->lang, $staticOptions); |
| 125 | + $rendering_url = $static->getUrl(); |
123 | 126 | |
| 127 | + $alt = wfMsg('maps_centred_on') . " $this->centre_lat, $this->centre_lon."; |
| 128 | + |
| 129 | + if ($this->activatable != 'no') { |
| 130 | + $title = wfMsg('maps_click_to_activate'); |
| 131 | + $activationCode = "onclick=\"slippymaps['$this->mapName'].init();\""; |
| 132 | + } |
| 133 | + else { |
| 134 | + $activationCode = ''; |
| 135 | + $title = $alt; |
| 136 | + } |
| 137 | + |
124 | 138 | return <<<EOT |
125 | | - <!-- map div --> |
126 | 139 | <div id="$this->mapName" class="map" style="width:{$this->width}px; height:{$this->height}px;"> |
127 | | - <!-- Static preview --> |
128 | | - <img |
129 | | - id="$this->mapName-preview" |
| 140 | + <img id="$this->mapName-preview" |
130 | 141 | class="mapPreview" |
131 | | - src="{$rendering_url}" |
132 | | - onclick="slippymaps['$this->mapName'].init();" |
| 142 | + src="{$rendering_url}" |
133 | 143 | width="$this->width" |
134 | 144 | height="$this->height" |
135 | | - alt="Map centred on $this->centre_lat, $this->centre_lon." |
136 | | - title="$clickToActivate"/> |
137 | | - <!-- /map div --> |
| 145 | + alt="$alt" |
| 146 | + title="$title" |
| 147 | + $activationCode /> |
138 | 148 | </div> |
139 | 149 | EOT; |
140 | 150 | } |
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php |
— | — | @@ -94,57 +94,49 @@ |
95 | 95 | |
96 | 96 | private static $modes = array( |
97 | 97 | 'osm-wm' => array( |
98 | | - // First layer = default |
99 | | - 'layers' => array( 'osm-like' ), |
| 98 | + 'handler' => 'MapsOSMCgiBin', |
| 99 | + 'options' => array( |
| 100 | + 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export', |
| 101 | + |
| 102 | + 'format' => 'png', |
| 103 | + 'numZoomLevels' => 16, |
| 104 | + 'maxResolution' => 156543.0339, |
| 105 | + 'unit' => 'm', |
| 106 | + 'sphericalMercator' => true, |
100 | 107 | |
101 | | - 'static_rendering' => array( |
102 | | - 'type' => 'MapsOSMCgiBin', |
103 | | - 'options' => array( |
104 | | - 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export', |
105 | | - |
106 | | - 'format' => 'png', |
107 | | - 'numZoomLevels' => 16, |
108 | | - 'maxResolution' => 156543.0339, |
109 | | - 'unit' => 'm', |
110 | | - 'sphericalMercator' => true, |
111 | | - |
112 | | - // More GET arguments |
113 | | - 'get_args' => array( |
114 | | - 'locale' => true, // Will use $wgContLang->getCode() |
115 | | - 'maptype' => 'osm-like' |
116 | | - ), |
117 | | - ), |
| 108 | + 'maptype' => 'osm-like' |
118 | 109 | ), |
119 | 110 | ), |
120 | 111 | |
121 | 112 | 'osm' => array( |
122 | | - // First layer = default |
123 | | - 'layers' => array( 'mapnik', 'osmarender', 'maplint', 'cycle' ), |
124 | | - |
125 | | - 'static_rendering' => array( |
126 | | - 'type' => 'MapsOSMCgiBin', |
127 | | - 'options' => array( |
128 | | - 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export', |
129 | | - |
130 | | - 'format' => 'png', |
131 | | - 'numZoomLevels' => 16, |
132 | | - 'maxResolution' => 156543.0339, |
133 | | - 'unit' => 'm', |
134 | | - 'sphericalMercator' => true |
135 | | - ), |
| 113 | + 'handler' => 'MapsOSMCgiBin', |
| 114 | + 'options' => array( |
| 115 | + 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export', |
| 116 | + |
| 117 | + 'format' => 'png', |
| 118 | + 'numZoomLevels' => 16, |
| 119 | + 'maxResolution' => 156543.0339, |
| 120 | + 'unit' => 'm', |
| 121 | + 'sphericalMercator' => true |
136 | 122 | ), |
137 | 123 | ), |
138 | | - |
139 | | - 'satellite' => array( |
140 | | - 'layers' => array( 'urban', 'landsat', 'bluemarble' ), |
141 | | - 'static_rendering' => null, |
142 | | - ), |
143 | 124 | ); |
144 | 125 | |
| 126 | + /** |
| 127 | + * Returns an array containing the names of all modes. |
| 128 | + * |
| 129 | + * @return array |
| 130 | + */ |
145 | 131 | public static function getModeNames() { |
146 | 132 | return array_keys(self::$modes); |
147 | 133 | } |
148 | 134 | |
| 135 | + /** |
| 136 | + * Returns the data of a mode. |
| 137 | + * |
| 138 | + * @param string $modeName |
| 139 | + * @return array |
| 140 | + */ |
149 | 141 | public static function getModeData($modeName) { |
150 | 142 | return self::$modes[$modeName]; |
151 | 143 | } |
Index: trunk/extensions/Maps/Maps.i18n.php |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | |
41 | 41 | // Static maps |
42 | 42 | 'maps_click_to_activate' => 'Click to activate map', |
| 43 | + 'maps_centred_on' => 'Map centred on', |
43 | 44 | |
44 | 45 | // Google Maps overlays |
45 | 46 | 'maps_overlays' => 'Overlays', |
Index: trunk/extensions/Maps/Maps_Settings.php |
— | — | @@ -171,7 +171,7 @@ |
172 | 172 | $egMapsGoogleAutozoom = true; |
173 | 173 | |
174 | 174 | # Array of String. The default controls for Google Maps. This value will only be used when the user does not provide one. |
175 | | -# Available values: auto, large, small, large-original, small-original, zoom, type, type-menu, overview-map, scale, nav-label |
| 175 | +# Available values: auto, large, small, large-original, small-original, zoom, type, type-menu, overview-map, scale, nav-label, overlays |
176 | 176 | $egMapsGMapControls = array('auto', 'scale', 'type', 'overlays'); |
177 | 177 | |
178 | 178 | # Array. The default overlays for the Google Maps overlays control, and wether they should be shown at pageload. |
— | — | @@ -237,4 +237,7 @@ |
238 | 238 | |
239 | 239 | # Array of String. The default controls for OSM maps. This value will only be used when the user does not provide one. |
240 | 240 | # Available values: layerswitcher, mouseposition, autopanzoom, panzoom, panzoombar, scaleline, navigation, keyboarddefaults, overviewmap, permalink |
241 | | -$egMapsOSMControls = array('layerswitcher', 'mouseposition', 'autopanzoom', 'scaleline', 'navigation'); |
\ No newline at end of file |
| 241 | +$egMapsOSMControls = array('layerswitcher', 'mouseposition', 'autopanzoom', 'scaleline', 'navigation'); |
| 242 | + |
| 243 | +$egMapsOSMStaticAsDefault = false; |
| 244 | +$egMapsOSMStaticActivatable = true; |
\ No newline at end of file |
Index: trunk/extensions/Maps/Geocoders/Maps_BaseGeocoder.php |
— | — | @@ -58,7 +58,6 @@ |
59 | 59 | if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) |
60 | 60 | curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); |
61 | 61 | // TODO else curl_setopt($ch, CURLOPT_USERAGENT, "MediaWiki/Maps extension"); |
62 | | - //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
63 | 62 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
64 | 63 | |
65 | 64 | $result = curl_exec($ch); |