r82991 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82990‎ | r82991 | r82992 >
Date:00:14, 1 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r82988
Modified paths:
  • /branches/Maps0.8/includes/features/Maps_BaseMap.php (modified) (history)
  • /branches/Maps0.8/includes/features/Maps_BasePointMap.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMapsDispMap.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMapsDispPoint.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js (modified) (history)

Diff [purge]

Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMapsDispMap.php
@@ -13,9 +13,7 @@
1414 /**
1515 * @see MapsBaseMap::getMapHTML()
1616 */
17 - public function getMapHTML( array $params, Parser $parser ) {
18 - $mapName = $this->service->getMapId();
19 -
 17+ public function getMapHTML( array $params, Parser $parser, $mapName ) {
2018 $output = $this->service->getOverlayOutput( $mapName, $params['overlays'], $params['controls'] );
2119
2220 return $output . Html::element(
Index: branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js
@@ -25,8 +25,8 @@
2626 ];
2727
2828 for ( i in window.maps.googlemaps2 ) {
29 - var map = new googleMap( jQuery );
30 - map.initializeGoogleMap( 'foo',{},[] );
 29+ var map = new GoogleMap( jQuery, window.maps.googlemaps2[i] );
 30+ map.initiate( i );
3131 }
3232 }
3333 }
@@ -37,8 +37,14 @@
3838 function () { loadGoogleMaps(); }
3939 );
4040
41 -var googleMap = function($) {
 41+var GoogleMap = function( $, args ) {
4242
 43+ var args = args;
 44+
 45+ this.initiate = function( mapName ) {
 46+ //alert( mapName );
 47+ }
 48+
4349 /**
4450 * Returns GMarker object on the provided location. It will show a popup baloon
4551 * with title and label when clicked, if either of these is set.
@@ -92,7 +98,7 @@
9399 * Returns GMap2 object with the provided properties and markers.
94100 * This is done by setting the map centre and size, and passing the arguments to function createGoogleMap.
95101 */
96 - var initializeGoogleMap = function(mapName, mapOptions, markers) {
 102+ this.initializeGoogleMap = function(mapName, mapOptions, markers) {
97103 if (GBrowserIsCompatible()) {
98104 mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null;
99105 //mapOptions.size = new GSize(mapOptions.width, mapOptions.height);
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMapsDispPoint.php
@@ -13,9 +13,7 @@
1414 /**
1515 * @see MapsBasePointMap::getMapHTML
1616 */
17 - public function getMapHTML( array $params, Parser $parser ) {
18 - $mapName = $this->service->getMapId();
19 -
 17+ public function getMapHTML( array $params, Parser $parser, $mapName ) {
2018 $output = $this->service->getOverlayOutput( $mapName, $params['overlays'], $params['controls'] );
2119
2220 return $output . Html::element(
Index: branches/Maps0.8/includes/features/Maps_BasePointMap.php
@@ -26,10 +26,11 @@
2727 *
2828 * @param array $params
2929 * @param Parser $parser
 30+ * @param string $mapName
3031 *
3132 * @return string
3233 */
33 - protected abstract function getMapHTML( array $params, Parser $parser );
 34+ protected abstract function getMapHTML( array $params, Parser $parser, $mapName );
3435
3536 public function __construct( iMappingService $service ) {
3637 $this->service = $service;
@@ -71,8 +72,10 @@
7273 public final function renderMap( array $params, Parser $parser ) {
7374 $this->handleMarkerData( $params );
7475
75 - $output = $this->getMapHTML( $params, $parser ) . $this->getJSON( $params, $parser );
 76+ $mapName = $this->service->getMapId();
7677
 78+ $output = $this->getMapHTML( $params, $parser, $mapName ) . $this->getJSON( $params, $parser, $mapName );
 79+
7780 global $wgTitle;
7881 if ( $wgTitle->isSpecialPage() ) {
7982 global $wgOut;
@@ -92,10 +95,11 @@
9396 *
9497 * @param array $params
9598 * @param Parser $parser
 99+ * @param string $mapName
96100 *
97101 * @return string
98102 */
99 - protected function getJSON( array $params, Parser $parser ) {
 103+ protected function getJSON( array $params, Parser $parser, $mapName ) {
100104 $object = $this->getJSONObject( $params, $parser );
101105
102106 if ( $object === false ) {
@@ -103,7 +107,7 @@
104108 }
105109
106110 // TODO
107 - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}'].push(" . json_encode( $object ) . ')' );
 111+ return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' );
108112 }
109113
110114 /**
Index: branches/Maps0.8/includes/features/Maps_BaseMap.php
@@ -29,14 +29,15 @@
3030 /**
3131 * Returns the HTML to display the map.
3232 *
33 - * @since 0.7.3
 33+ * @since 0.8
3434 *
3535 * @param array $params
36 - * @param $parser
 36+ * @param Parser $parser
 37+ * @param string $mapName
3738 *
3839 * @return string
3940 */
40 - protected abstract function getMapHTML( array $params, Parser $parser );
 41+ protected abstract function getMapHTML( array $params, Parser $parser, $mapName );
4142
4243 /**
4344 * Constructor.
@@ -73,8 +74,10 @@
7475 $params['zoom'] = $this->service->getDefaultZoom();
7576 }
7677
77 - $output = $this->getMapHTML( $params, $parser ) . $this->getJSON( $params, $parser );
 78+ $mapName = $this->service->getMapId();
7879
 80+ $output = $this->getMapHTML( $params, $parser, $mapName ) . $this->getJSON( $params, $parser, $mapName );
 81+
7982 global $wgTitle;
8083 if ( $wgTitle->isSpecialPage() ) {
8184 global $wgOut;
@@ -94,10 +97,11 @@
9598 *
9699 * @param array $params
97100 * @param Parser $parser
 101+ * @param string $mapName
98102 *
99103 * @return string
100104 */
101 - protected function getJSON( array $params, Parser $parser ) {
 105+ protected function getJSON( array $params, Parser $parser, $mapName ) {
102106 $object = $this->getJSONObject( $params, $parser );
103107
104108 if ( $object === false ) {
@@ -105,7 +109,7 @@
106110 }
107111
108112 // TODO
109 - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}'].push(" . json_encode( $object ) . ')' );
 113+ return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' );
110114 }
111115
112116 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r82998follow up to r82991jeroendedauw01:37, 1 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82988more cleanup and work on the google maps jsjeroendedauw00:00, 1 March 2011

Status & tagging log