Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -89,6 +89,7 @@ |
90 | 90 | $wgHooks['BeforePageDisplay'][] = 'efCentralNoticeLoader'; |
91 | 91 | $wgHooks['MakeGlobalVariablesScript'][] = 'efCentralNoticeDefaults'; |
92 | 92 | $wgHooks['SiteNoticeAfter'][] = 'efCentralNoticeDisplay'; |
| 93 | + $wgHooks['SkinAfterBottomScripts'][] = 'efCentralNoticeGeoLoader'; |
93 | 94 | } |
94 | 95 | |
95 | 96 | $wgSpecialPages['BannerLoader'] = 'SpecialBannerLoader'; |
— | — | @@ -144,19 +145,23 @@ |
145 | 146 | global $wgUser, $wgOut, $wgCentralDBname; |
146 | 147 | |
147 | 148 | $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl(); |
| 149 | + |
| 150 | + // Insert the banner controller Javascript into the <head> |
| 151 | + $wgOut->addScriptFile( $centralLoader ); |
148 | 152 | |
| 153 | + return true; |
| 154 | +} |
| 155 | + |
| 156 | +function efCentralNoticeGeoLoader( $skin, &$text ) { |
| 157 | + global $wgCentralDBname; |
149 | 158 | if ( $wgCentralDBname ) { |
150 | 159 | $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
151 | 160 | $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 'not_enabled = 1', 'not_geo = 1' ) ); |
152 | 161 | 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>'; |
155 | 164 | } |
156 | 165 | } |
157 | | - |
158 | | - // Insert the banner controller Javascript into the <head> |
159 | | - $wgOut->addScriptFile( $centralLoader ); |
160 | | - |
161 | 166 | return true; |
162 | 167 | } |
163 | 168 | |