r80486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80485‎ | r80486 | r80487 >
Date:02:17, 18 January 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r80484
Modified paths:
  • /branches/Maps0.8/includes/Maps_KMLFormatter.php (modified) (history)
  • /branches/Maps0.8/includes/Maps_MappingService.php (modified) (history)
  • /branches/Maps0.8/includes/features/Maps_BasePointMap.php (modified) (history)
  • /branches/Maps0.8/includes/iMappingService.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_Coordinates.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_DisplayMap.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_DisplayPoint.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_Distance.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_Finddestination.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_Geocode.php (modified) (history)
  • /branches/Maps0.8/includes/parserHooks/Maps_Geodistance.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js (modified) (history)

Diff [purge]

Index: branches/Maps0.8/includes/Maps_MappingService.php
@@ -50,6 +50,25 @@
5151 protected $resourceModules = array();
5252
5353 /**
 54+ * A list of dependencies (header items) that have been added.
 55+ *
 56+ * @since 0.6.3
 57+ *
 58+ * @var array
 59+ */
 60+ private $addedDependencies = array();
 61+
 62+ /**
 63+ * A list of dependencies (header items) that need to be added.
 64+ *
 65+ * @since 0.6.3
 66+ *
 67+ * @var array
 68+ */
 69+ private $dependencies = array();
 70+
 71+
 72+ /**
5473 * Constructor. Creates a new instance of MapsMappingService.
5574 *
5675 * @since 0.6.3
@@ -73,15 +92,6 @@
7493 }
7594
7695 /**
77 - * @see iMappingService::createMarkersJs
78 - *
79 - * @since 0.6.5
80 - */
81 - public function createMarkersJs( array $markers ) {
82 - return '[]';
83 - }
84 -
85 - /**
8696 * @see iMappingService::addFeature
8797 *
8898 * @since 0.6.3
@@ -96,16 +106,58 @@
97107 * @since 0.6.3
98108 */
99109 public final function addDependencies( &$parserOrOut ) {
 110+ $dependencies = $this->getDependencyHtml();
 111+
100112 // Only add a head item when there are dependencies.
101113 if ( $parserOrOut instanceof Parser ) {
 114+ if ( $dependencies ) {
 115+ $parserOrOut->getOutput()->addHeadItem( $dependencies );
 116+ }
 117+
102118 $parserOrOut->getOutput()->addModules( $this->getResourceModules() );
103119 }
104 - else if ( $parserOrOut instanceof OutputPage ) {
 120+ else if ( $parserOrOut instanceof OutputPage ) {
 121+ if ( $dependencies ) {
 122+ $parserOrOut->addHeadItem( md5( $dependencies ), $dependencies );
 123+ }
 124+
105125 $parserOrOut->addModules( $this->getResourceModules() );
106126 }
107127 }
108128
109129 /**
 130+ * @see iMappingService::getDependencyHtml
 131+ *
 132+ * @since 0.6.3
 133+ */
 134+ public final function getDependencyHtml() {
 135+ $allDependencies = array_merge( $this->getDependencies(), $this->dependencies );
 136+ $dependencies = array();
 137+
 138+ // Only add dependnecies that have not yet been added.
 139+ foreach ( $allDependencies as $dependency ) {
 140+ if ( !in_array( $dependency, $this->addedDependencies ) ) {
 141+ $dependencies[] = $dependency;
 142+ $this->addedDependencies[] = $dependency;
 143+ }
 144+ }
 145+
 146+ // If there are dependencies, put them all together in a string, otherwise return false.
 147+ return count( $dependencies ) > 0 ? implode( '', $dependencies ) : false;
 148+ }
 149+
 150+ /**
 151+ * Returns a list of html fragments, such as script includes, the current service depends on.
 152+ *
 153+ * @since 0.6.3
 154+ *
 155+ * @return array
 156+ */
 157+ protected function getDependencies() {
 158+ return array();
 159+ }
 160+
 161+ /**
110162 * @see iMappingService::getName
111163 *
112164 * @since 0.6.3
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php
@@ -134,6 +134,15 @@
135135 }
136136
137137 /**
 138+ * @see MapsMappingService::getMapObject
 139+ *
 140+ * @since 0.8
 141+ */
 142+ public function getMapObject() {
 143+
 144+ }
 145+
 146+ /**
138147 * @see MapsMappingService::createMarkersJs
139148 *
140149 * @since 0.6.5
@@ -211,7 +220,7 @@
212221 */
213222 protected function getDependencies() {
214223 global $wgLang;
215 - global $egGoogleMapsKeys, $egGoogleMapsKey, $egMapsStyleVersion, $egMapsScriptPath;
 224+ global $egGoogleMapsKeys, $egGoogleMapsKey;
216225
217226 $langCode = self::getMappedLanguageCode( $wgLang->getCode() );
218227
@@ -302,14 +311,14 @@
303312 'div',
304313 array(
305314 'class' => 'outer-more',
306 - 'id' => htmlspecialchars( "$mapName-outer-more" )
 315+ 'id' => "$mapName-outer-more"
307316 ),
308317 '<form action="">' .
309318 Html::rawElement(
310319 'div',
311320 array(
312321 'class' => 'more-box',
313 - 'id' => htmlspecialchars( "$mapName-more-box" )
 322+ 'id' => "$mapName-more-box"
314323 ),
315324 $overlayHtml
316325 ) .
@@ -320,7 +329,7 @@
321330 /**
322331 * @see MapsMappingService::getResourceModules
323332 *
324 - * @since 0.7.4
 333+ * @since 0.8
325334 *
326335 * @return array of string
327336 */
@@ -334,7 +343,7 @@
335344 /**
336345 * Register the resource modules for the resource loader.
337346 *
338 - * @since 0.7.4
 347+ * @since 0.8
339348 *
340349 * @param ResourceLoader $resourceLoader
341350 *
@@ -346,10 +355,16 @@
347356 $modules = array(
348357 'ext.maps.googlemaps2' => array(
349358 'scripts' => array(
350 - 'ext.maps.googlemaps2.js'
 359+ 'ext.maps.googlemaps2.js',
 360+ 'ext.maps.googlemaps2.css',
351361 ),
352362 'messages' => array(
353 - 'maps-markers'
 363+ 'maps-markers',
 364+ 'maps_overlays',
 365+ 'maps_photos',
 366+ 'maps_videos',
 367+ 'maps_wikipedia',
 368+ 'maps_webcams'
354369 )
355370 ),
356371 );
Index: branches/Maps0.8/includes/services/GoogleMaps/ext.maps.googlemaps2.js
@@ -18,11 +18,15 @@
1919 new GLayer("com.google.webcams")
2020 ];
2121
 22+ for ( mapName in window. ) {
 23+
 24+ }
 25+
2226 /**
2327 * Returns GMarker object on the provided location. It will show a popup baloon
2428 * with title and label when clicked, if either of these is set.
2529 */
26 - function createGMarker( markerData ) {
 30+ function createGMarker( markerData ) {
2731 var marker;
2832
2933 if ( markerData.icon != '' ) {
Index: branches/Maps0.8/includes/parserHooks/Maps_Coordinates.php
@@ -131,7 +131,7 @@
132132 /**
133133 * @see ParserHook::getDescription()
134134 *
135 - * @since 0.7.4
 135+ * @since 0.8
136136 */
137137 public function getDescription() {
138138 return wfMsg( 'maps-coordinates-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_Distance.php
@@ -113,7 +113,7 @@
114114 /**
115115 * @see ParserHook::getDescription()
116116 *
117 - * @since 0.7.4
 117+ * @since 0.8
118118 */
119119 public function getDescription() {
120120 return wfMsg( 'maps-distance-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_DisplayPoint.php
@@ -162,7 +162,7 @@
163163 /**
164164 * @see ParserHook::getDescription()
165165 *
166 - * @since 0.7.4
 166+ * @since 0.8
167167 */
168168 public function getDescription() {
169169 return wfMsg( 'maps-displaypoint-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_Finddestination.php
@@ -182,7 +182,7 @@
183183 /**
184184 * @see ParserHook::getDescription()
185185 *
186 - * @since 0.7.4
 186+ * @since 0.8
187187 */
188188 public function getDescription() {
189189 return wfMsg( 'maps-finddestination-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_DisplayMap.php
@@ -125,7 +125,7 @@
126126 /**
127127 * @see ParserHook::getDescription()
128128 *
129 - * @since 0.7.4
 129+ * @since 0.8
130130 */
131131 public function getDescription() {
132132 return wfMsg( 'maps-displaymap-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_Geocode.php
@@ -163,7 +163,7 @@
164164 /**
165165 * @see ParserHook::getDescription()
166166 *
167 - * @since 0.7.4
 167+ * @since 0.8
168168 */
169169 public function getDescription() {
170170 return wfMsg( 'maps-geocode-description' );
Index: branches/Maps0.8/includes/parserHooks/Maps_Geodistance.php
@@ -172,7 +172,7 @@
173173 /**
174174 * @see ParserHook::getDescription()
175175 *
176 - * @since 0.7.4
 176+ * @since 0.8
177177 */
178178 public function getDescription() {
179179 return wfMsg( 'maps-geodistance-description' );
Index: branches/Maps0.8/includes/iMappingService.php
@@ -113,16 +113,4 @@
114114 */
115115 function getMapId( $increment = true );
116116
117 - /**
118 - * Creates a JS array with marker meta data that can be used to construct a
119 - * map with markers via a function in this services JS file.
120 - *
121 - * @since 0.6.5
122 - *
123 - * @param array $markers
124 - *
125 - * @return string
126 - */
127 - function createMarkersJs( array $markers );
128 -
129117 }
\ No newline at end of file
Index: branches/Maps0.8/includes/Maps_KMLFormatter.php
@@ -13,7 +13,7 @@
1414 class MapsKMLFormatter {
1515
1616 /**
17 - * @since 0.7.4
 17+ * @since 0.8
1818 *
1919 * @var array
2020 */
Index: branches/Maps0.8/includes/features/Maps_BasePointMap.php
@@ -93,8 +93,6 @@
9494 $this->zoom = $this->service->getDefaultZoom();
9595 }
9696
97 - $this->markerJs = $this->service->createMarkersJs( $this->markerData );
98 -
9997 $this->addSpecificMapHTML( $parser );
10098
10199 global $wgTitle;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80484Threw out more b/c codejeroendedauw01:18, 18 January 2011

Status & tagging log