http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74033

Revision: 74033
Author:   kaldari
Date:     2010-09-30 18:42:21 +0000 (Thu, 30 Sep 2010)

Log Message:
-----------
moving geoIP lookup to end of page so it doesn't slow things down

Modified Paths:
--------------
    trunk/extensions/CentralNotice/CentralNotice.php

Modified: trunk/extensions/CentralNotice/CentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.php    2010-09-30 18:35:38 UTC 
(rev 74032)
+++ trunk/extensions/CentralNotice/CentralNotice.php    2010-09-30 18:42:21 UTC 
(rev 74033)
@@ -89,6 +89,7 @@
                $wgHooks['BeforePageDisplay'][] = 'efCentralNoticeLoader';
                $wgHooks['MakeGlobalVariablesScript'][] = 
'efCentralNoticeDefaults';
                $wgHooks['SiteNoticeAfter'][] = 'efCentralNoticeDisplay';
+               $wgHooks['SkinAfterBottomScripts'][] = 
'efCentralNoticeGeoLoader';
        }
        
        $wgSpecialPages['BannerLoader'] = 'SpecialBannerLoader';
@@ -144,19 +145,23 @@
        global $wgUser, $wgOut, $wgCentralDBname;
 
        $centralLoader = SpecialPage::getTitleFor( 'BannerController' 
)->getLocalUrl();
+       
+       // Insert the banner controller Javascript into the <head>
+       $wgOut->addScriptFile( $centralLoader );
 
+       return true;
+}
+
+function efCentralNoticeGeoLoader( $skin, &$text ) {
+       global $wgCentralDBname;
        if ( $wgCentralDBname ) {
                $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
                $row = $dbr->selectRow( 'cn_notices', 'not_name', array( 
'not_enabled = 1', 'not_geo = 1' ) );
                if ( $row ) {
-                       // Insert the geo IP lookup into the <head>
-                       $wgOut->addScriptFile( 
'http://geoiplookup.wikimedia.org/' );
+                       // Insert the geo IP lookup
+                       $text .= '<script type="text/javascript" 
src="http://geoiplookup.wikimedia.org/";></script>';
                }
        }
-       
-       // Insert the banner controller Javascript into the <head>
-       $wgOut->addScriptFile( $centralLoader );
-
        return true;
 }
 



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to