r65944 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65943‎ | r65944 | r65945 >
Date:08:51, 5 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - added workaround to script file inclusion issue due to a bug in pre 1.16 mw
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Mapper.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -161,7 +161,7 @@
162162 }
163163 else if ( $parserOrOut instanceof OutputPage ) {
164164 $out = $parserOrOut;
165 - $out->addScriptFile( "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" );
 165+ MapsMapper::addScriptFile( $out, "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" );
166166 $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion" );
167167 }
168168 }
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php
@@ -185,7 +185,7 @@
186186 }
187187 else if ( $parserOrOut instanceof OutputPage ) {
188188 $out = $parserOrOut;
189 - $out->addScriptFile( "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" );
 189+ MapsMapper::addScriptFile( $out, "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" );
190190 $out->addScriptFile( "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
191191 }
192192 }
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php
@@ -234,9 +234,9 @@
235235 }
236236 else if ( $parserOrOut instanceof OutputPage ) {
237237 $out = $parserOrOut;
238 - $out->addScriptFile( "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" );
 238+ MapsMapper::addScriptFile( $out, "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" );
239239 $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
240 - }
 240+ }
241241 }
242242 }
243243
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 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>.';
3535 }
3636 else {
37 - define( 'Maps_VERSION', '0.6 a20' );
 37+ define( 'Maps_VERSION', '0.6 rc1' );
3838
3939 // The different coordinate notations.
4040 define( 'Maps_COORDS_FLOAT', 'float' );
Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -220,6 +220,25 @@
221221 }
222222
223223 /**
 224+ * Add a JavaScript file out of skins/common, or a given relative path.
 225+ *
 226+ * This is a copy of the native function in OutputPage to work around a pre 1.16 bug.
 227+ * Should be used for adding external files, like the Google Maps API.
 228+ *
 229+ * @param OutputPage $out
 230+ * @param string $file
 231+ */
 232+ public static function addScriptFile( OutputPage $out, $file ) {
 233+ global $wgStylePath, $wgStyleVersion;
 234+ if( substr( $file, 0, 1 ) == '/' || preg_match( '#^[a-z]*://#i', $file ) ) {
 235+ $path = $file;
 236+ } else {
 237+ $path = "{$wgStylePath}/common/{$file}";
 238+ }
 239+ $out->addScript( Html::linkedScript( wfAppendQuery( $path, $wgStyleVersion ) ) );
 240+ }
 241+
 242+ /**
224243 * This function returns the definitions for the parameters used by every map feature.
225244 *
226245 * @return array

Status & tagging log