r65938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65937‎ | r65938 | r65939 >
Date:03:14, 5 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.6 - Follow up to r65937
Modified paths:
  • /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/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -128,9 +128,9 @@
129129 /**
130130 * Loads the Google Maps API v3 and required JS files.
131131 *
132 - * @param Parser $parser
 132+ * @param mixed $parserOrOut
133133 */
134 - public static function addGMap3Dependencies( Parser &$parser ) {
 134+ public static function addGMap3Dependencies( &$parserOrOut ) {
135135 global $wgJsMimeType, $wgLang;
136136 global $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
137137
@@ -138,22 +138,32 @@
139139 $egGMaps3OnThisPage = 0;
140140
141141 $languageCode = self::getMappedLanguageCode( $wgLang->getCode() );
142 - $parser->getOutput()->addHeadItem(
143 - Html::element(
144 - 'script',
145 - array(
146 - 'type' => $wgJsMimeType,
147 - 'src' => "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode"
148 - )
149 - ) .
150 - Html::element(
151 - 'script',
152 - array(
153 - 'type' => $wgJsMimeType,
154 - 'src' => "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion"
155 - )
156 - )
157 - );
 142+
 143+ if ( $parserOrOut instanceof Parser ) {
 144+ $parser = $parserOrOut;
 145+
 146+ $parser->getOutput()->addHeadItem(
 147+ Html::element(
 148+ 'script',
 149+ array(
 150+ 'type' => $wgJsMimeType,
 151+ 'src' => "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode"
 152+ )
 153+ ) .
 154+ Html::element(
 155+ 'script',
 156+ array(
 157+ 'type' => $wgJsMimeType,
 158+ 'src' => "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion"
 159+ )
 160+ )
 161+ );
 162+ }
 163+ else if ( $parserOrOut instanceof OutputPage ) {
 164+ $out = $parserOrOut;
 165+ $out->addScriptFile( "http://maps.google.com/maps/api/js?sensor=false&language=$languageCode" );
 166+ $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion" );
 167+ }
158168 }
159169 }
160170
Index: trunk/extensions/Maps/Services/YahooMaps/Maps_YahooMaps.php
@@ -154,31 +154,40 @@
155155 /**
156156 * Loads the Yahoo! Maps API and required JS files.
157157 *
158 - * @param Parser $parser
 158+ * @param mixed $parserOrOut
159159 */
160 - public static function addYMapDependencies( Parser &$parser ) {
 160+ public static function addYMapDependencies( &$parserOrOut ) {
161161 global $wgJsMimeType;
162162 global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
163163
164164 if ( empty( $egYahooMapsOnThisPage ) ) {
165165 $egYahooMapsOnThisPage = 0;
166166
167 - $parser->getOutput()->addHeadItem(
168 - Html::element(
169 - 'script',
170 - array(
171 - 'type' => $wgJsMimeType,
172 - 'src' => "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey"
173 - )
174 - ) .
175 - Html::element(
176 - 'script',
177 - array(
178 - 'type' => $wgJsMimeType,
179 - 'src' => "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion"
180 - )
181 - )
182 - );
 167+ if ( $parserOrOut instanceof Parser ) {
 168+ $parser = $parserOrOut;
 169+
 170+ $parser->getOutput()->addHeadItem(
 171+ Html::element(
 172+ 'script',
 173+ array(
 174+ 'type' => $wgJsMimeType,
 175+ 'src' => "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey"
 176+ )
 177+ ) .
 178+ Html::element(
 179+ 'script',
 180+ array(
 181+ 'type' => $wgJsMimeType,
 182+ 'src' => "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion"
 183+ )
 184+ )
 185+ );
 186+ }
 187+ else if ( $parserOrOut instanceof OutputPage ) {
 188+ $out = $parserOrOut;
 189+ $out->addScriptFile( "http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=$egYahooMapsKey" );
 190+ $out->addScriptFile( "$egMapsScriptPath/Services/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
 191+ }
183192 }
184193 }
185194
Index: trunk/extensions/Maps/Services/OpenLayers/Maps_OpenLayers.php
@@ -122,41 +122,51 @@
123123 /**
124124 * If this is the first open layers map on the page, load the API, styles and extra JS functions.
125125 *
126 - * @param Parser $parser
 126+ * @param mixed $parserOrOut
127127 */
128 - public static function addOLDependencies( Parser &$parser ) {
 128+ public static function addOLDependencies( &$parserOrOut ) {
129129 global $wgJsMimeType;
130130 global $egOpenLayersOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
131131
132132 if ( empty( $egOpenLayersOnThisPage ) ) {
133133 $egOpenLayersOnThisPage = 0;
134134
135 - $parser->getOutput()->addHeadItem(
136 - Html::element(
137 - 'link',
138 - array(
139 - 'rel' => 'stylesheet',
140 - 'type' => 'text/css',
141 - 'href' => "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css"
142 - )
143 - ) .
144 - Html::element(
145 - 'script',
146 - array(
147 - 'type' => $wgJsMimeType,
148 - 'src' => "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js"
149 - )
150 - ) .
151 - Html::element(
152 - 'script',
153 - array(
154 - 'type' => $wgJsMimeType,
155 - 'src' => "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion"
156 - )
157 - ) .
158 - Html::inlineScript( 'initOLSettings(200, 100);' )
159 - );
160 - }
 135+ if ( $parserOrOut instanceof Parser ) {
 136+ $parser = $parserOrOut;
 137+
 138+ $parser->getOutput()->addHeadItem(
 139+ Html::element(
 140+ 'link',
 141+ array(
 142+ 'rel' => 'stylesheet',
 143+ 'type' => 'text/css',
 144+ 'href' => "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css"
 145+ )
 146+ ) .
 147+ Html::element(
 148+ 'script',
 149+ array(
 150+ 'type' => $wgJsMimeType,
 151+ 'src' => "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js?$egMapsStyleVersion"
 152+ )
 153+ ) .
 154+ Html::element(
 155+ 'script',
 156+ array(
 157+ 'type' => $wgJsMimeType,
 158+ 'src' => "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion"
 159+ )
 160+ ) .
 161+ Html::inlineScript( 'initOLSettings(200, 100);' )
 162+ );
 163+ }
 164+ else if ( $parserOrOut instanceof OutputPage ) {
 165+ $out = $parserOrOut;
 166+ $out->addStyle( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/theme/default/style.css" );
 167+ $out->addScriptFile( "$egMapsScriptPath/Services/OpenLayers/OpenLayers/OpenLayers.js?$egMapsStyleVersion" );
 168+ $out->addScriptFile( "$egMapsScriptPath/Services/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
 169+ }
 170+ }
161171 }
162172
163173 /**
Index: trunk/extensions/Maps/Services/GoogleMaps/Maps_GoogleMaps.php
@@ -198,12 +198,12 @@
199199 /**
200200 * Loads the Google Maps API and required JS files.
201201 *
202 - * @param Parser $parser
 202+ * @param mixed $parserOrOut
203203 */
204 - public static function addGMapDependencies( Parser &$parser ) {
 204+ public static function addGMapDependencies( &$parserOrOut ) {
205205 global $wgJsMimeType, $wgLang;
206206 global $egGoogleMapsKey, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt, $egMapsScriptPath;
207 -
 207+
208208 if ( empty( $egGoogleMapsOnThisPage ) ) {
209209 $egGoogleMapsOnThisPage = 0;
210210
@@ -211,23 +211,32 @@
212212
213213 $langCode = self::getMappedLanguageCode( $wgLang->getCode() );
214214
215 - $parser->getOutput()->addHeadItem(
216 - Html::element(
217 - 'script',
218 - array(
219 - 'type' => $wgJsMimeType,
220 - 'src' => "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode"
221 - )
222 - ) .
223 - Html::element(
224 - 'script',
225 - array(
226 - 'type' => $wgJsMimeType,
227 - 'src' => "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion"
228 - )
229 - ) .
230 - Html::inlineScript( 'window.unload = GUnload;' )
231 - );
 215+ if ( $parserOrOut instanceof Parser ) {
 216+ $parser = $parserOrOut;
 217+
 218+ $parser->getOutput()->addHeadItem(
 219+ Html::element(
 220+ 'script',
 221+ array(
 222+ 'type' => $wgJsMimeType,
 223+ 'src' => "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode"
 224+ )
 225+ ) .
 226+ Html::element(
 227+ 'script',
 228+ array(
 229+ 'type' => $wgJsMimeType,
 230+ 'src' => "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion"
 231+ )
 232+ ) .
 233+ Html::inlineScript( 'window.unload = GUnload;' )
 234+ );
 235+ }
 236+ else if ( $parserOrOut instanceof OutputPage ) {
 237+ $out = $parserOrOut;
 238+ $out->addScriptFile( "http://maps.google.com/maps?file=api&v=2&key=$egGoogleMapsKey&hl=$langCode" );
 239+ $out->addScriptFile( "$egMapsScriptPath/Services/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion" );
 240+ }
232241 }
233242 }
234243
Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -218,7 +218,7 @@
219219
220220 return $allServiceValues;
221221 }
222 -
 222+
223223 /**
224224 * This function returns the definitions for the parameters used by every map feature.
225225 *

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65937Changes for 0.6 - Fixed bugs in the form inputs due to the other refactoringjeroendedauw03:13, 5 May 2010

Status & tagging log