r91152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91151‎ | r91152 | r91153 >
Date:01:33, 30 June 2011
Author:kaldari
Status:ok
Tags:
Comment:
since we need to be able to pull fundraising flag and landingpages even if we are forcing the banner (rather than pulling it from bannerlistloader) we need to get these on the server-side rather than client-side
Modified paths:
  • /trunk/extensions/CentralNotice/special/SpecialBannerController.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialBannerController.php
@@ -54,12 +54,11 @@
5555 'getVars': {}
5656 },
5757 'fn': {
58 - 'loadBanner': function( bannerName, fundraising, landingPages, campaign ) {
 58+ 'loadBanner': function( bannerName, campaign ) {
5959 // Get the requested banner
6060 var bannerPageQuery = $.param( {
6161 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage,
62 - 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country,
63 - 'fundraising': fundraising, 'landingpages': landingPages
 62+ 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country
6463 } );
6564 var bannerPage = '?title=Special:BannerLoader&' + bannerPageQuery;
6665 JAVASCRIPT;
@@ -119,8 +118,6 @@
120119 // Load a random banner from our groomed list
121120 $.centralNotice.fn.loadBanner(
122121 groomedBannerList[pointer].name,
123 - groomedBannerList[pointer].fundraising,
124 - groomedBannerList[pointer].landing_pages,
125122 groomedBannerList[pointer].campaign
126123 );
127124 },
Index: trunk/extensions/CentralNotice/special/SpecialBannerLoader.php
@@ -23,9 +23,7 @@
2424 // Get values from the query string
2525 $this->language = $wgRequest->getText( 'userlang', 'en' );
2626 $this->siteName = $wgRequest->getText( 'sitename', 'Wikipedia' );
27 - $this->campaign = $wgRequest->getText( 'campaign', 'unknown' );
28 - $this->fundraising = $wgRequest->getBool( 'fundraising', false );
29 - $this->landingPages = $wgRequest->getText( 'landingpages' );
 27+ $this->campaign = $wgRequest->getText( 'campaign', 'undefined' );
3028
3129 if ( $wgRequest->getText( 'banner' ) ) {
3230 $bannerName = $wgRequest->getText( 'banner' );
@@ -76,8 +74,8 @@
7775 'bannerName' => $bannerName,
7876 'bannerHtml' => $bannerHtml,
7977 'campaign' => $this->campaign,
80 - 'fundraising' => $this->fundraising,
81 - 'landingPages' => $this->landingPages
 78+ 'fundraising' => $this->getFundraising( $bannerName ),
 79+ 'landingPages' => $this->getLandingPages( $bannerName )
8280 );
8381 $bannerJs = 'insertBanner('.FormatJson::encode( $bannerArray ).');';
8482 return $bannerJs;
@@ -196,6 +194,22 @@
197195 }
198196 return $count;
199197 }
 198+
 199+ function getFundraising( $bannerName ) {
 200+ global $wgCentralDBname;
 201+ $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
 202+ $eBannerName = htmlspecialchars( $bannerName );
 203+ $row = $dbr->selectRow( 'cn_templates', 'tmp_fundraising', array( 'tmp_name' => $eBannerName ) );
 204+ return $row->tmp_fundraising;
 205+ }
 206+
 207+ function getLandingPages( $bannerName ) {
 208+ global $wgCentralDBname;
 209+ $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
 210+ $eBannerName = htmlspecialchars( $bannerName );
 211+ $row = $dbr->selectRow( 'cn_templates', 'tmp_landing_pages', array( 'tmp_name' => $eBannerName ) );
 212+ return $row->tmp_landing_pages;
 213+ }
200214 }
201215 /**
202216 * @defgroup Exception Exception

Status & tagging log