r74033 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74032‎ | r74033 | r74034 >
Date:18:42, 30 September 2010
Author:kaldari
Status:ok
Tags:
Comment:
moving geoIP lookup to end of page so it doesn't slow things down
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -89,6 +89,7 @@
9090 $wgHooks['BeforePageDisplay'][] = 'efCentralNoticeLoader';
9191 $wgHooks['MakeGlobalVariablesScript'][] = 'efCentralNoticeDefaults';
9292 $wgHooks['SiteNoticeAfter'][] = 'efCentralNoticeDisplay';
 93+ $wgHooks['SkinAfterBottomScripts'][] = 'efCentralNoticeGeoLoader';
9394 }
9495
9596 $wgSpecialPages['BannerLoader'] = 'SpecialBannerLoader';
@@ -144,19 +145,23 @@
145146 global $wgUser, $wgOut, $wgCentralDBname;
146147
147148 $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl();
 149+
 150+ // Insert the banner controller Javascript into the <head>
 151+ $wgOut->addScriptFile( $centralLoader );
148152
 153+ return true;
 154+}
 155+
 156+function efCentralNoticeGeoLoader( $skin, &$text ) {
 157+ global $wgCentralDBname;
149158 if ( $wgCentralDBname ) {
150159 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
151160 $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 'not_enabled = 1', 'not_geo = 1' ) );
152161 if ( $row ) {
153 - // Insert the geo IP lookup into the <head>
154 - $wgOut->addScriptFile( 'http://geoiplookup.wikimedia.org/' );
 162+ // Insert the geo IP lookup
 163+ $text .= '<script type="text/javascript" src="http://geoiplookup.wikimedia.org/"></script>';
155164 }
156165 }
157 -
158 - // Insert the banner controller Javascript into the <head>
159 - $wgOut->addScriptFile( $centralLoader );
160 -
161166 return true;
162167 }
163168

Status & tagging log