Index: trunk/extensions/SemanticMaps/Services/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -23,18 +23,25 @@ |
24 | 24 | class SMYahooMapsFormInput extends SMFormInput { |
25 | 25 | |
26 | 26 | /** |
27 | | - * @see MapsMapFeature::setMapSettings() |
| 27 | + * @see SMFormInput::getEarthZoom |
| 28 | + * |
| 29 | + * @since 0.6.5 |
28 | 30 | */ |
29 | | - protected function setMapSettings() { |
30 | | - global $egMapsYahooMapsPrefix; |
31 | | - |
32 | | - $this->elementNamePrefix = $egMapsYahooMapsPrefix; |
33 | | - $this->showAddresFunction = 'showYAddress'; |
34 | | - |
35 | | - $this->earthZoom = 17; |
36 | | - } |
| 31 | + protected function getEarthZoom() { |
| 32 | + return 17; |
| 33 | + } |
37 | 34 | |
38 | 35 | /** |
| 36 | + * @see SMFormInput::getShowAddressFunction |
| 37 | + * |
| 38 | + * @since 0.6.5 |
| 39 | + */ |
| 40 | + protected function getShowAddressFunction() { |
| 41 | + global $egYahooMapsKey; |
| 42 | + return $egYahooMapsKey == '' ? false : 'showYAddress'; |
| 43 | + } |
| 44 | + |
| 45 | + /** |
39 | 46 | * @see MapsMapFeature::addFormDependencies() |
40 | 47 | */ |
41 | 48 | protected function addFormDependencies() { |
— | — | @@ -52,8 +59,6 @@ |
53 | 60 | |
54 | 61 | /** |
55 | 62 | * @see MapsMapFeature::addSpecificMapHTML |
56 | | - * |
57 | | - * TODO: fix map name |
58 | 63 | */ |
59 | 64 | protected function addSpecificMapHTML() { |
60 | 65 | global $wgOut; |
— | — | @@ -92,12 +97,4 @@ |
93 | 98 | |
94 | 99 | } |
95 | 100 | |
96 | | - /** |
97 | | - * @see SMFormInput::manageGeocoding() |
98 | | - */ |
99 | | - protected function manageGeocoding() { |
100 | | - global $egYahooMapsKey; |
101 | | - return $egYahooMapsKey != ''; |
102 | | - } |
103 | | - |
104 | 101 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/Services/OpenLayers/SM_OpenLayersFormInput.php |
— | — | @@ -23,15 +23,13 @@ |
24 | 24 | class SMOpenLayersFormInput extends SMFormInput { |
25 | 25 | |
26 | 26 | /** |
27 | | - * @see MapsMapFeature::setMapSettings() |
| 27 | + * @see SMFormInput::getEarthZoom |
| 28 | + * |
| 29 | + * @since 0.6.5 |
28 | 30 | */ |
29 | | - protected function setMapSettings() { |
30 | | - global $egMapsOpenLayersPrefix; |
31 | | - |
32 | | - $this->elementNamePrefix = $egMapsOpenLayersPrefix; |
33 | | - |
34 | | - $this->earthZoom = 1; |
35 | | - } |
| 31 | + protected function getEarthZoom() { |
| 32 | + return 1; |
| 33 | + } |
36 | 34 | |
37 | 35 | /** |
38 | 36 | * @see MapsMapFeature::addFormDependencies() |
— | — | @@ -51,8 +49,6 @@ |
52 | 50 | |
53 | 51 | /** |
54 | 52 | * @see MapsMapFeature::addSpecificMapHTML |
55 | | - * |
56 | | - * TODO: fix map name |
57 | 53 | */ |
58 | 54 | protected function addSpecificMapHTML() { |
59 | 55 | global $wgOut, $wgLang; |
Index: trunk/extensions/SemanticMaps/Services/GoogleMaps/SM_GoogleMapsFormInput.php |
— | — | @@ -27,15 +27,22 @@ |
28 | 28 | class SMGoogleMapsFormInput extends SMFormInput { |
29 | 29 | |
30 | 30 | /** |
31 | | - * @see MapsMapFeature::setMapSettings() |
| 31 | + * @see SMFormInput::getEarthZoom |
| 32 | + * |
| 33 | + * @since 0.6.5 |
32 | 34 | */ |
33 | | - protected function setMapSettings() { |
34 | | - global $egMapsGoogleMapsPrefix; |
35 | | - |
36 | | - $this->elementNamePrefix = $egMapsGoogleMapsPrefix; |
37 | | - $this->showAddresFunction = 'showGAddress'; |
38 | | - |
39 | | - $this->earthZoom = 1; |
| 35 | + protected function getEarthZoom() { |
| 36 | + return 1; |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @see SMFormInput::getShowAddressFunction |
| 41 | + * |
| 42 | + * @since 0.6.5 |
| 43 | + */ |
| 44 | + protected function getShowAddressFunction() { |
| 45 | + global $egGoogleMapsKey; |
| 46 | + return $egGoogleMapsKey == '' ? false : 'showGAddress'; |
40 | 47 | } |
41 | 48 | |
42 | 49 | /** |
— | — | @@ -100,13 +107,5 @@ |
101 | 108 | EOT |
102 | 109 | ); |
103 | 110 | } |
104 | | - |
105 | | - /** |
106 | | - * @see SMFormInput::manageGeocoding |
107 | | - */ |
108 | | - protected function manageGeocoding() { |
109 | | - global $egGoogleMapsKey; |
110 | | - return $egGoogleMapsKey != ''; |
111 | | - } |
112 | | - |
| 111 | + |
113 | 112 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMaps/SemanticMaps.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | // Only initialize the extension when all dependencies are present. |
38 | 38 | if ( defined( 'Maps_VERSION' ) && defined( 'SMW_VERSION' ) ) { |
39 | | - define( 'SM_VERSION', '0.6.5 a4' ); |
| 39 | + define( 'SM_VERSION', '0.6.5 a6' ); |
40 | 40 | |
41 | 41 | $useExtensionPath = version_compare( $wgVersion, '1.16', '>=' ) && isset( $wgExtensionAssetsPath ) && $wgExtensionAssetsPath; |
42 | 42 | $smgScriptPath = ( $useExtensionPath ? $wgExtensionAssetsPath : $wgScriptPath . '/extensions' ) . '/SemanticMaps'; |
Index: trunk/extensions/SemanticMaps/Features/FormInputs/SM_FormInput.php |
— | — | @@ -20,36 +20,33 @@ |
21 | 21 | */ |
22 | 22 | protected abstract function addFormDependencies(); |
23 | 23 | |
24 | | - protected $service; |
| 24 | + /** |
| 25 | + * Returns the zoom level at which the whole earth is visible. |
| 26 | + */ |
| 27 | + protected abstract function getEarthZoom(); |
25 | 28 | |
26 | 29 | /** |
27 | | - * @var string |
28 | | - */ |
29 | | - protected $mapName; |
| 30 | + * @var iMappingService |
| 31 | + */ |
| 32 | + protected $service; |
30 | 33 | |
31 | 34 | /** |
32 | 35 | * @var array |
33 | 36 | */ |
34 | 37 | protected $markerCoords; |
35 | | - |
36 | | - protected $earthZoom; |
37 | 38 | |
38 | | - protected $showAddresFunction; |
| 39 | + protected $errorList; |
39 | 40 | |
40 | | - protected $enableGeocoding; |
| 41 | + protected $specificParameters = false; |
41 | 42 | |
42 | | - protected $errorList; |
43 | | - |
44 | 43 | private $coordinates; |
45 | 44 | |
46 | | - protected $specificParameters = false; |
47 | | - |
48 | 45 | /** |
49 | 46 | * Constructor. |
50 | 47 | * |
51 | | - * @param MapsMappingService $service |
| 48 | + * @param iMappingService $service |
52 | 49 | */ |
53 | | - public function __construct( MapsMappingService $service ) { |
| 50 | + public function __construct( iMappingService $service ) { |
54 | 51 | $this->service = $service; |
55 | 52 | } |
56 | 53 | |
— | — | @@ -148,17 +145,16 @@ |
149 | 146 | return array( $this->errorList ); |
150 | 147 | } |
151 | 148 | |
152 | | - $this->enableGeocoding = $this->manageGeocoding(); |
153 | | - |
154 | 149 | $this->setCoordinates(); |
155 | 150 | $this->setCentre(); |
156 | 151 | $this->setZoom(); |
157 | 152 | |
158 | 153 | // Create html element names. |
159 | 154 | $mapName = $this->service->getMapId(); |
160 | | - $this->geocodeFieldName = $mapName . '_geocode_' . $sfgTabIndex; |
161 | | - $this->coordsFieldName = $mapName . '_coords_' . $sfgTabIndex; |
162 | | - $this->infoFieldName = $mapName . '_info_' . $sfgTabIndex; |
| 155 | + $coordsFieldName = $mapName . '_coords_' . $sfgTabIndex; |
| 156 | + $infoFieldName = $mapName . '_info_' . $sfgTabIndex; |
| 157 | + |
| 158 | + $geocodingFunction = $this->getShowAddressFunction(); |
163 | 159 | |
164 | 160 | // Create the non specific form HTML. |
165 | 161 | $this->output .= Html::input( |
— | — | @@ -168,7 +164,7 @@ |
169 | 165 | array( |
170 | 166 | 'size' => 42, #_O |
171 | 167 | 'tabindex' => $sfgTabIndex, |
172 | | - 'id' => $this->coordsFieldName |
| 168 | + 'id' => $coordsFieldName |
173 | 169 | ) |
174 | 170 | ); |
175 | 171 | |
— | — | @@ -176,11 +172,13 @@ |
177 | 173 | 'span', |
178 | 174 | array( |
179 | 175 | 'class' => 'error_message', |
180 | | - 'id' => $this->infoFieldName |
| 176 | + 'id' => $infoFieldName |
181 | 177 | ) |
182 | 178 | ); |
183 | 179 | |
184 | | - if ( $this->enableGeocoding ) $this->addGeocodingField( $mapName ); |
| 180 | + if ( $geocodingFunction !== false ) { |
| 181 | + $this->addGeocodingField( $geocodingFunction, $mapName, $mapName . '_geocode_' . $sfgTabIndex ); |
| 182 | + } |
185 | 183 | |
186 | 184 | if ( $this->markerCoords === false ) { |
187 | 185 | $this->markerCoords = array( |
— | — | @@ -197,7 +195,14 @@ |
198 | 196 | return array( $this->output . $this->errorList, '' ); |
199 | 197 | } |
200 | 198 | |
201 | | - private function addGeocodingField( $mapName ) { |
| 199 | + /** |
| 200 | + * Adds geocoding controls to the form. |
| 201 | + * |
| 202 | + * @param string $geocodingFunction |
| 203 | + * @param string $mapName |
| 204 | + * @param string $geocodeFieldName |
| 205 | + */ |
| 206 | + private function addGeocodingField( $geocodingFunction, $mapName, $geocodeFieldName ) { |
202 | 207 | global $sfgTabIndex, $wgOut, $smgAddedFormJs; |
203 | 208 | $sfgTabIndex++; |
204 | 209 | |
— | — | @@ -222,24 +227,24 @@ |
223 | 228 | ); |
224 | 229 | } |
225 | 230 | |
226 | | - $adress_field = SMFormInput::getDynamicInput( |
227 | | - $this->geocodeFieldName, |
228 | | - wfMsg( 'semanticmaps_enteraddresshere' ), |
| 231 | + $adressField = SMFormInput::getDynamicInput( |
| 232 | + $geocodeFieldName, |
| 233 | + htmlspecialchars( wfMsg( 'semanticmaps_enteraddresshere' ) ), |
229 | 234 | 'size="30" name="geocode" style="color: #707070" tabindex="' . htmlspecialchars( $sfgTabIndex ) . '"' |
230 | 235 | ); |
231 | 236 | |
232 | 237 | $notFoundText = Xml::escapeJsString( wfMsg( 'semanticmaps_notfound' ) ); |
233 | 238 | $mapName = Xml::escapeJsString( $mapName ); |
234 | | - $geoFieldName = Xml::escapeJsString( $this->geocodeFieldName ); |
235 | | - $coordFieldName = Xml::escapeJsString( $this->coordsFieldName ); |
| 239 | + $geoFieldName = Xml::escapeJsString( $geocodeFieldName ); |
| 240 | + $coordFieldName = Xml::escapeJsString( $geocodeFieldName ); |
236 | 241 | |
237 | | - $this->output .= '<p>' . $adress_field . |
| 242 | + $this->output .= '<p>' . $adressField . |
238 | 243 | Html::input( |
239 | 244 | 'geosubmit', |
240 | 245 | wfMsg( 'semanticmaps_lookupcoordinates' ), |
241 | 246 | 'submit', |
242 | 247 | array( |
243 | | - 'onClick' => "$this->showAddresFunction( document.forms['createbox'].$geoFieldName.value, '$mapName', '$coordFieldName', '$notFoundText'); return false" |
| 248 | + 'onClick' => "$geocodingFunction( document.forms['createbox'].$geoFieldName.value, '$mapName', '$coordFieldName', '$notFoundText'); return false" |
244 | 249 | ) |
245 | 250 | ) . |
246 | 251 | '</p>'; |
— | — | @@ -251,7 +256,7 @@ |
252 | 257 | */ |
253 | 258 | private function setZoom() { |
254 | 259 | if ( empty( $this->coordinates ) ) { |
255 | | - $this->zoom = $this->earthZoom; |
| 260 | + $this->zoom = $this->getEarthZoom(); |
256 | 261 | } else if ( $this->zoom == 'null' ) { |
257 | 262 | $this->zoom = $this->defaultZoom; |
258 | 263 | } |
— | — | @@ -305,17 +310,18 @@ |
306 | 311 | * @return string (html) |
307 | 312 | */ |
308 | 313 | private static function getDynamicInput( $id, $value, $args = '' ) { |
309 | | - // TODO: escape properly |
| 314 | + // TODO: escape properly, use Html class |
310 | 315 | return '<input id="' . $id . '" ' . $args . ' value="' . $value . '" onfocus="if (this.value==\'' . $value . '\') {this.value=\'\';}" onblur="if (this.value==\'\') {this.value=\'' . $value . '\';}" />'; |
311 | 316 | } |
312 | 317 | |
313 | 318 | /** |
314 | | - * Determine if geocoding will be enabled and load the required dependencies. |
315 | | - * Override in deriving classes to enable geocoding functionallity there. |
| 319 | + * Returns the name of the JavaScript function to use for live geocoding, |
| 320 | + * or false to indicate there is no such function. Override this method |
| 321 | + * to implement geocoding functionallity. |
316 | 322 | * |
317 | | - * @return boolean |
| 323 | + * @return mixed: string or false |
318 | 324 | */ |
319 | | - protected function manageGeocoding() { |
| 325 | + protected function getShowAddressFunction() { |
320 | 326 | return false; |
321 | 327 | } |
322 | 328 | |