http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73931
Revision: 73931
Author: jeroendedauw
Date: 2010-09-29 00:56:58 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
Changes for 0.7 - fixed centre parameter default
Modified Paths:
--------------
trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php
Modified: trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
===================================================================
--- trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
2010-09-28 23:50:02 UTC (rev 73930)
+++ trunk/extensions/Maps/includes/features/Maps_BasePointMap.php
2010-09-29 00:56:58 UTC (rev 73931)
@@ -168,24 +168,25 @@
* Sets the $centre_lat and $centre_lon fields.
* Note: this needs to be done AFTRE the maker coordinates are set.
*/
- private function setCentre() {
- if ( empty( $this->centre ) ) {
+ protected function setCentre() {
+ global $egMapsDefaultMapCentre;
+
+ if ( $this->centre === false ) {
if ( count( $this->markerData ) == 1 ) {
// If centre is not set and there is exactly
one marker, use its coordinates.
$this->centreLat = Xml::escapeJsString(
$this->markerData[0][0] );
- $this->centreLon = Xml::escapeJsString(
$this->markerData[0][1] );
+ $this->centreLon = Xml::escapeJsString(
$this->markerData[0][1] );
}
elseif ( count( $this->markerData ) > 1 ) {
// If centre is not set and there are multiple
markers, set the values to null,
// to be auto determined by the JS of the
mapping API.
$this->centreLat = 'null';
- $this->centreLon = 'null';
+ $this->centreLon = 'null';
}
- else {
- // If centre is not set and there are no
markers, use the default latitude and longitutde.
- global $egMapsDefaultMapCentre;
- // TODO
+ else {
+ $this->setCentreToDefault();
}
+
}
else { // If a centre value is set, geocode when needed and use
it.
$this->centre = MapsGeocoders::attemptToGeocode(
$this->centre, $this->geoservice, $this->service->getName() );
@@ -196,10 +197,30 @@
$this->centreLon = Xml::escapeJsString(
$this->centre['lon'] );
}
else { // If it's false, the coordinate was invalid, or
geocoding failed. Either way, the default's should be used.
- global $egMapsDefaultMapCentre;
- // TODO
+ $this->setCentreToDefault();
}
}
+
}
+ /**
+ * Attempts to set the centreLat and centreLon fields to the Maps
default.
+ * When this fails (aka the default is not valid), an exception is
thrown.
+ *
+ * @since 0.7
+ */
+ protected function setCentreToDefault() {
+ global $egMapsDefaultMapCentre;
+
+ $centre = MapsGeocoders::attemptToGeocode(
$egMapsDefaultMapCentre, $this->geoservice, $this->service->getName() );
+
+ if ( $centre === false ) {
+ throw new Exception( 'Failed to parse the default
centre for the map. Please check the value of $egMapsDefaultMapCentre.' );
+ }
+ else {
+ $this->centreLat = Xml::escapeJsString( $centre['lat']
);
+ $this->centreLon = Xml::escapeJsString( $centre['lon']
);
+ }
+ }
+
}
\ No newline at end of file
Modified: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php
===================================================================
--- trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php
2010-09-28 23:50:02 UTC (rev 73930)
+++ trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php
2010-09-29 00:56:58 UTC (rev 73931)
@@ -100,7 +100,7 @@
$params['centre'] = new Parameter(
'centre',
Parameter::TYPE_STRING,
- $egMapsDefaultMapCentre,
+ false,
array( 'center' ),
array(
new CriterionIsLocation(),
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs