r106226 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106225‎ | r106226 | r106227 >
Date:19:00, 14 December 2011
Author:mah
Status:ok
Tags:
Comment:
w/s ugh
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNotice.i18n.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNoticePager.php (modified) (history)
  • /trunk/extensions/CentralNotice/TemplatePager.php (modified) (history)
  • /trunk/extensions/CentralNotice/bannerstats.js (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerController.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerListLoader.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialBannerLoader.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialHideBanners.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php (modified) (history)
  • /trunk/extensions/CentralNotice/tests/CentralNoticeTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialBannerListLoader.php
@@ -9,27 +9,27 @@
1010 public $location; // User country
1111 protected $sharedMaxAge = 300; // Cache for 5 minutes on the server side
1212 protected $maxAge = 300; // Cache for 5 minutes on the client side
13 -
 13+
1414 function __construct() {
1515 // Register special page
1616 parent::__construct( "BannerListLoader" );
1717 }
18 -
 18+
1919 function execute( $par ) {
2020 global $wgOut, $wgRequest;
21 -
 21+
2222 $wgOut->disable();
2323 $this->sendHeaders();
24 -
 24+
2525 // Get project language from the query string
2626 $this->language = $wgRequest->getText( 'language', 'en' );
27 -
 27+
2828 // Get project name from the query string
2929 $this->project = $wgRequest->getText( 'project', 'wikipedia' );
30 -
 30+
3131 // Get location from the query string
3232 $this->location = $wgRequest->getText( 'country' );
33 -
 33+
3434 if ( $this->project && $this->language ) {
3535 $content = $this->getJsonList();
3636 if ( strlen( $content ) == 0 ) {
@@ -42,7 +42,7 @@
4343 echo "/* No site specified */";
4444 }
4545 }
46 -
 46+
4747 /**
4848 * Generate the HTTP response headers for the banner file
4949 */
@@ -51,16 +51,16 @@
5252 header( "Content-type: $wgJsMimeType; charset=utf-8" );
5353 header( "Cache-Control: public, s-maxage=$this->sharedMaxAge, max-age=$this->maxAge" );
5454 }
55 -
 55+
5656 /**
5757 * Generate JSON for the specified site
5858 */
5959 function getJsonList() {
6060 $banners = array();
61 -
 61+
6262 // See if we have any preferred campaigns for this language and project
6363 $campaigns = CentralNoticeDB::getCampaigns( $this->project, $this->language, null, 1, 1, $this->location );
64 -
 64+
6565 // Quick short circuit to show preferred campaigns
6666 if ( $campaigns ) {
6767 // Pull banners
@@ -69,11 +69,11 @@
7070
7171 // Didn't find any preferred banners so do an old style lookup
7272 if ( !$banners ) {
73 - $banners = CentralNoticeDB::getBannersByTarget(
 73+ $banners = CentralNoticeDB::getBannersByTarget(
7474 $this->project, $this->language, $this->location );
7575 }
76 -
 76+
7777 return FormatJson::encode( $banners );
7878 }
79 -
 79+
8080 }
Index: trunk/extensions/CentralNotice/special/SpecialBannerController.php
@@ -14,10 +14,10 @@
1515
1616 function execute( $par ) {
1717 global $wgOut;
18 -
 18+
1919 $wgOut->disable();
2020 $this->sendHeaders();
21 -
 21+
2222 $content = $this->getOutput();
2323 if ( strlen( $content ) == 0 ) {
2424 // Hack for IE/Mac 0-length keepalive problem, see RawPage.php
@@ -26,7 +26,7 @@
2727 echo $content;
2828 }
2929 }
30 -
 30+
3131 /**
3232 * Generate the HTTP response headers for the banner controller
3333 */
@@ -44,7 +44,7 @@
4545 */
4646 function getOutput() {
4747 global $wgCentralPagePath, $wgContLang;
48 -
 48+
4949 $js = $this->getScriptFunctions() . $this->getToggleScripts();
5050 $js .= <<<JAVASCRIPT
5151 ( function( $ ) {
@@ -59,19 +59,19 @@
6060 // Store the bannerType in case we need to set a banner hiding cookie later
6161 $.centralNotice.data.bannerType = bannerType;
6262 // Get the requested banner
63 - var bannerPageQuery = $.param( {
64 - 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage,
 63+ var bannerPageQuery = $.param( {
 64+ 'banner': bannerName, 'campaign': campaign, 'userlang': wgUserLanguage,
6565 'db': wgDBname, 'sitename': wgSiteName, 'country': Geo.country
6666 } );
6767 var bannerPage = '?title=Special:BannerLoader&' + bannerPageQuery;
6868 JAVASCRIPT;
69 - $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"" .
 69+ $js .= "\n\t\t\t\tvar bannerScript = '<script type=\"text/javascript\" src=\"" .
7070 Xml::escapeJsString( $wgCentralPagePath ) .
7171 "' + bannerPage + '\"></script>';\n";
7272 $js .= <<<JAVASCRIPT
7373 if ( document.cookie.indexOf( 'centralnotice_'+bannerType+'=hide' ) == -1 ) {
74 - jQuery( '#siteNotice' ).prepend( '<div id="centralNotice" class="' +
75 - ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) +
 74+ jQuery( '#siteNotice' ).prepend( '<div id="centralNotice" class="' +
 75+ ( wgNoticeToggleState ? 'expanded' : 'collapsed' ) +
7676 ' cn-' + bannerType + '">'+bannerScript+'</div>' );
7777 }
7878 },
@@ -83,7 +83,7 @@
8484 }
8585 var bannerListQuery = $.param( { 'language': wgContentLanguage, 'project': wgNoticeProject, 'country': geoLocation } );
8686 JAVASCRIPT;
87 - $js .= "\n\t\t\t\tvar bannerListURL = wgScript + '?title=' + encodeURIComponent('" .
 87+ $js .= "\n\t\t\t\tvar bannerListURL = wgScript + '?title=' + encodeURIComponent('" .
8888 $wgContLang->specialPage( 'BannerListLoader' ) .
8989 "') + '&cache=/cn.js&' + bannerListQuery;\n";
9090 $js .= <<<JAVASCRIPT
@@ -96,16 +96,16 @@
9797 'chooseBanner': function( bannerList ) {
9898 // Convert the json object to a true array
9999 bannerList = Array.prototype.slice.call( bannerList );
100 -
 100+
101101 // Make sure there are some banners to choose from
102102 if ( bannerList.length == 0 ) return false;
103 -
 103+
104104 var groomedBannerList = [];
105 -
 105+
106106 for( var i = 0; i < bannerList.length; i++ ) {
107107 // Only include this banner if it's intended for the current user
108 - if( ( wgUserName && bannerList[i].display_account ) ||
109 - ( !wgUserName && bannerList[i].display_anon == 1 ) )
 108+ if( ( wgUserName && bannerList[i].display_account ) ||
 109+ ( !wgUserName && bannerList[i].display_anon == 1 ) )
110110 {
111111 // add the banner to our list once per weight
112112 for( var j=0; j < bannerList[i].weight; j++ ) {
@@ -113,15 +113,15 @@
114114 }
115115 }
116116 }
117 -
 117+
118118 // Return if there's nothing left after the grooming
119119 if( groomedBannerList.length == 0 ) return false;
120 -
 120+
121121 // Choose a random key
122122 var pointer = Math.floor( Math.random() * groomedBannerList.length );
123 -
 123+
124124 // Load a random banner from our groomed list
125 - $.centralNotice.fn.loadBanner(
 125+ $.centralNotice.fn.loadBanner(
126126 groomedBannerList[pointer].name,
127127 groomedBannerList[pointer].campaign,
128128 ( groomedBannerList[pointer].fundraising ? 'fundraising' : 'default' )
@@ -151,9 +151,9 @@
152152 } )( jQuery );
153153 JAVASCRIPT;
154154 return $js;
155 -
 155+
156156 }
157 -
 157+
158158 function getToggleScripts() {
159159 $script = "var wgNoticeToggleState = (document.cookie.indexOf('hidesnmessage=1')==-1);\n\n";
160160 return $script;
@@ -166,7 +166,7 @@
167167 jQuery( 'div#centralNotice' ).prepend( bannerJson.bannerHtml );
168168 if ( bannerJson.autolink ) {
169169 JAVASCRIPT;
170 - $script .= "\n\t\tvar url = '" .
 170+ $script .= "\n\t\tvar url = '" .
171171 Xml::escapeJsString( $wgNoticeFundraisingUrl ) . "';\n";
172172 $script .= <<<JAVASCRIPT
173173 if ( ( bannerJson.landingPages !== null ) && bannerJson.landingPages.length ) {
@@ -175,8 +175,8 @@
176176 'landing_page': targets[Math.floor( Math.random() * targets.length )].replace( /^\s+|\s+$/, '' )
177177 } );
178178 url += "&" + jQuery.param( {
179 - 'utm_medium': 'sitenotice', 'utm_campaign': bannerJson.campaign,
180 - 'utm_source': bannerJson.bannerName, 'language': wgUserLanguage,
 179+ 'utm_medium': 'sitenotice', 'utm_campaign': bannerJson.campaign,
 180+ 'utm_source': bannerJson.bannerName, 'language': wgUserLanguage,
181181 'country': Geo.country
182182 } );
183183 jQuery( '#cn-landingpage-link' ).attr( 'href', url );
Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -51,8 +51,8 @@
5252 // Handle form submissions from "Manage campaigns" or "Add a campaign" interface
5353 if ( $this->editable && $wgRequest->wasPosted() ) {
5454
55 - // Check authentication token
56 - if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
 55+ // Check authentication token
 56+ if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
5757
5858 // Handle adding a campaign
5959 if ( $method == 'addCampaign' ) {
@@ -1385,7 +1385,7 @@
13861386 $startDate = $dbr->timestamp( $start );
13871387 $endDate = $dbr->timestamp( $end );
13881388
1389 - $dbw = wfGetDB( DB_MASTER );
 1389+ $dbw = wfGetDB( DB_MASTER );
13901390 $res = $dbw->update( 'cn_notices',
13911391 array(
13921392 'not_start' => $startDate,
@@ -1419,8 +1419,8 @@
14201420 $dbw = wfGetDB( DB_MASTER );
14211421 $noticeId = CentralNotice::getNoticeId( $noticeName );
14221422 $dbw->update( 'cn_assignments',
1423 - array ( 'tmp_weight' => $weight ),
1424 - array(
 1423+ array ( 'tmp_weight' => $weight ),
 1424+ array(
14251425 'tmp_id' => $templateId,
14261426 'not_id' => $noticeId
14271427 )
Index: trunk/extensions/CentralNotice/special/SpecialBannerAllocation.php
@@ -167,7 +167,7 @@
168168 $accountWeight = 0;
169169
170170 if ( $banners ) {
171 -
 171+
172172 foreach ( $banners as $banner ) {
173173 if ( $banner['display_anon'] ) {
174174 $anonBanners[] = $banner;
@@ -178,12 +178,12 @@
179179 $accountBanners[] = $banner;
180180 $accountWeight += $banner['weight'];
181181 }
182 -
 182+
183183 if ( $banner['campaign'] ) {
184184 $campaigns[] = "'".$banner['campaign']."'";
185185 }
186186 }
187 -
 187+
188188 // Build campaign list for bannerstats.js
189189 $campaignList = implode( ', ', $campaigns );
190190 $js = "wgCentralNoticeAllocationCampaigns = array( $campaignList );";
@@ -234,10 +234,10 @@
235235
236236 $htmlOut .= wfMsg ( 'percent', $wgLang->formatNum( $percentage ) );
237237 $htmlOut .= Html::closeElement( 'td' );
238 -
 238+
239239 $htmlOut .= Xml::openElement( 'td', array( 'valign' => 'top' ) );
240240 // The span class is used by bannerstats.js to find where to insert the stats
241 - $htmlOut .= Html::openElement( 'span',
 241+ $htmlOut .= Html::openElement( 'span',
242242 array( 'class' => 'cn-'.$banner['campaign'].'-'.$banner['name'] ) );
243243 $htmlOut .= $sk->makeLinkObj( $viewBanner, htmlspecialchars( $banner['name'] ),
244244 'template=' . urlencode( $banner['name'] ) );
Index: trunk/extensions/CentralNotice/special/SpecialBannerLoader.php
@@ -8,23 +8,23 @@
99 public $language = 'en'; // User language
1010 protected $sharedMaxAge = 600; // Cache for 10 minutes on the server side
1111 protected $maxAge = 0; // No client-side banner caching so we get all impressions
12 -
 12+
1313 function __construct() {
1414 // Register special page
1515 parent::__construct( "BannerLoader" );
1616 }
17 -
 17+
1818 function execute( $par ) {
1919 global $wgOut, $wgRequest;
20 -
 20+
2121 $wgOut->disable();
2222 $this->sendHeaders();
23 -
 23+
2424 // Get values from the query string
2525 $this->language = $wgRequest->getText( 'userlang', 'en' );
2626 $this->siteName = $wgRequest->getText( 'sitename', 'Wikipedia' );
2727 $this->campaign = $wgRequest->getText( 'campaign', 'undefined' );
28 -
 28+
2929 if ( $wgRequest->getText( 'banner' ) ) {
3030 $bannerName = $wgRequest->getText( 'banner' );
3131 try {
@@ -44,7 +44,7 @@
4545 echo "/* No banner specified */";
4646 }
4747 }
48 -
 48+
4949 /**
5050 * Generate the HTTP response headers for the banner file
5151 */
@@ -53,10 +53,10 @@
5454 header( "Content-type: $wgJsMimeType; charset=utf-8" );
5555 header( "Cache-Control: public, s-maxage=$this->sharedMaxAge, max-age=$this->maxAge" );
5656 }
57 -
 57+
5858 /**
5959 * Generate the JS for the requested banner
60 - * @return a string of Javascript containing a call to insertBanner()
 60+ * @return a string of Javascript containing a call to insertBanner()
6161 * with JSON containing the banner content as the parameter
6262 * @throws SpecialBannerLoaderException
6363 */
@@ -82,7 +82,7 @@
8383 return $bannerJs;
8484 }
8585 }
86 -
 86+
8787 /**
8888 * Generate the HTML for the requested banner
8989 * @throws SpecialBannerLoaderException
@@ -184,7 +184,7 @@
185185 $count = intval( $counter_value );
186186 if ( !$count ) {
187187 // Pull long-cached amount
188 - $count = intval( $wgMemc->get(
 188+ $count = intval( $wgMemc->get(
189189 wfMemcKey( 'centralnotice', 'counter', 'fallback' ) ) );
190190 if ( !$count ) {
191191 throw new DonationAmountUnknownException();
@@ -197,7 +197,7 @@
198198 }
199199 return $count;
200200 }
201 -
 201+
202202 function getFundraising( $bannerName ) {
203203 global $wgCentralDBname;
204204 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
@@ -205,7 +205,7 @@
206206 $row = $dbr->selectRow( 'cn_templates', 'tmp_fundraising', array( 'tmp_name' => $eBannerName ) );
207207 return $row->tmp_fundraising;
208208 }
209 -
 209+
210210 function getAutolink( $bannerName ) {
211211 global $wgCentralDBname;
212212 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
@@ -213,7 +213,7 @@
214214 $row = $dbr->selectRow( 'cn_templates', 'tmp_autolink', array( 'tmp_name' => $eBannerName ) );
215215 return $row->tmp_autolink;
216216 }
217 -
 217+
218218 function getLandingPages( $bannerName ) {
219219 global $wgCentralDBname;
220220 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
@@ -231,7 +231,7 @@
232232 *
233233 * This exception is being thrown whenever
234234 * some fatal error occurs that may affect
235 - * how the banner is presented.
 235+ * how the banner is presented.
236236 *
237237 * @ingroup Exception
238238 */
Index: trunk/extensions/CentralNotice/special/SpecialNoticeTemplate.php
@@ -7,12 +7,12 @@
88
99 class SpecialNoticeTemplate extends UnlistedSpecialPage {
1010 var $editable, $centralNoticeError;
11 -
 11+
1212 function __construct() {
1313 // Register special page
1414 parent::__construct( 'NoticeTemplate' );
1515 }
16 -
 16+
1717 /**
1818 * Handle different types of page requests
1919 */
@@ -21,13 +21,13 @@
2222
2323 // Begin output
2424 $this->setHeaders();
25 -
 25+
2626 // Output ResourceLoader module for styling and javascript functions
2727 $wgOut->addModules( 'ext.centralNotice.interface' );
2828
2929 // Check permissions
3030 $this->editable = $wgUser->isAllowed( 'centralnotice-admin' );
31 -
 31+
3232 // Initialize error variable
3333 $this->centralNoticeError = false;
3434
@@ -39,12 +39,12 @@
4040
4141 // Begin Banners tab content
4242 $wgOut->addHTML( Html::openElement( 'div', array( 'id' => 'preferences' ) ) );
43 -
 43+
4444 $method = $wgRequest->getVal( 'wpMethod' );
45 -
 45+
4646 // Handle form submissions
4747 if ( $this->editable && $wgRequest->wasPosted() ) {
48 -
 48+
4949 // Check authentication token
5050 if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
5151
@@ -89,7 +89,7 @@
9090 $this->showError( 'centralnotice-null-string' );
9191 }
9292 }
93 -
 93+
9494 // Handle editing banner
9595 if ( $method == 'editTemplate' ) {
9696 $this->editTemplate(
@@ -103,11 +103,11 @@
104104 );
105105 $sub = 'view';
106106 }
107 -
 107+
108108 } else {
109109 $this->showError( 'sessionfailure' );
110110 }
111 -
 111+
112112 }
113113
114114 // Handle viewing of a banner in all languages
@@ -132,36 +132,36 @@
133133 $wgOut->addHTML( Html::closeElement( 'div' ) );
134134 return;
135135 }
136 -
 136+
137137 // Handle cloning a specific banner
138138 if ( $sub == 'clone' ) {
139 -
 139+
140140 // Check authentication token
141141 if ( $wgUser->matchEditToken( $wgRequest->getVal( 'authtoken' ) ) ) {
142 -
 142+
143143 $oldTemplate = $wgRequest->getVal( 'oldTemplate' );
144144 $newTemplate = $wgRequest->getVal( 'newTemplate' );
145145 // We use the returned name in case any special characters had to be removed
146146 $template = $this->cloneTemplate( $oldTemplate, $newTemplate );
147 - $wgOut->redirect(
 147+ $wgOut->redirect(
148148 $this->getTitle( 'view' )->getLocalUrl( "template=$template" ) );
149149 return;
150 -
 150+
151151 } else {
152152 $this->showError( 'sessionfailure' );
153153 }
154 -
 154+
155155 }
156 -
 156+
157157 }
158158
159159 // Show list of banners by default
160160 $this->showList();
161 -
 161+
162162 // End Banners tab content
163163 $wgOut->addHTML( Html::closeElement( 'div' ) );
164164 }
165 -
 165+
166166 /**
167167 * Show a list of available banners. Newer banners are shown first.
168168 */
@@ -170,13 +170,13 @@
171171
172172 $sk = $wgUser->getSkin();
173173 $pager = new TemplatePager( $this );
174 -
 174+
175175 // Begin building HTML
176176 $htmlOut = '';
177 -
 177+
178178 // Begin Manage Banners fieldset
179179 $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
180 -
 180+
181181 if ( !$pager->getNumRows() ) {
182182 $htmlOut .= Html::element( 'p', null, wfMsg( 'centralnotice-no-templates' ) );
183183 } else {
@@ -184,14 +184,14 @@
185185 $htmlOut .= Html::openElement( 'form', array( 'method' => 'post' ) );
186186 }
187187 $htmlOut .= Html::element( 'h2', null, wfMsg( 'centralnotice-manage-templates' ) );
188 -
 188+
189189 // Show paginated list of banners
190 - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ),
 190+ $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ),
191191 $pager->getNavigationBar() );
192192 $htmlOut .= $pager->getBody();
193 - $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ),
 193+ $htmlOut .= Xml::tags( 'div', array( 'class' => 'cn-pager' ),
194194 $pager->getNavigationBar() );
195 -
 195+
196196 if ( $this->editable ) {
197197 $htmlOut .= Html::closeElement( 'form' );
198198 }
@@ -202,29 +202,29 @@
203203 $newPage = $this->getTitle( 'add' );
204204 $htmlOut .= $sk->makeLinkObj( $newPage, wfMsgHtml( 'centralnotice-add-template' ) );
205205 }
206 -
 206+
207207 // End Manage Banners fieldset
208208 $htmlOut .= Html::closeElement( 'fieldset' );
209209
210210 $wgOut->addHTML( $htmlOut );
211211 }
212 -
 212+
213213 /**
214214 * Show "Add a banner" interface
215215 */
216216 function showAdd() {
217 - global $wgOut, $wgUser, $wgExtensionAssetsPath, $wgLang, $wgRequest,
 217+ global $wgOut, $wgUser, $wgExtensionAssetsPath, $wgLang, $wgRequest,
218218 $wgNoticeEnableFundraising;
219219 $scriptPath = "$wgExtensionAssetsPath/CentralNotice";
220220
221221 // Build HTML
222222 $htmlOut = '';
223223 $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
224 - $htmlOut .= Html::openElement( 'form',
 224+ $htmlOut .= Html::openElement( 'form',
225225 array( 'method' => 'post', 'onsubmit' => 'return validateBannerForm(this)' ) );
226226 $htmlOut .= Html::element( 'h2', null, wfMsg( 'centralnotice-add-template' ) );
227227 $htmlOut .= Html::hidden( 'wpMethod', 'addTemplate' );
228 -
 228+
229229 // If there was an error, we'll need to restore the state of the form
230230 if ( $wgRequest->wasPosted() ) {
231231 $templateName = $wgRequest->getVal( 'templateName' );
@@ -243,93 +243,93 @@
244244 $landingPages = '';
245245 $body = '';
246246 }
247 -
 247+
248248 $htmlOut .= Xml::tags( 'p', null,
249 - Xml::inputLabel(
250 - wfMsg( 'centralnotice-banner-name' ),
251 - 'templateName', 'templateName', 25, $templateName
 249+ Xml::inputLabel(
 250+ wfMsg( 'centralnotice-banner-name' ),
 251+ 'templateName', 'templateName', 25, $templateName
252252 )
253253 );
254 -
 254+
255255 // Display settings
256256 $htmlOut .= Html::openElement( 'p', null );
257257 $htmlOut .= wfMsg( 'centralnotice-banner-display' );
258258 $htmlOut .= Xml::check( 'displayAnon', $displayAnon, array( 'id' => 'displayAnon' ) );
259259 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
260 - $htmlOut .= Xml::check( 'displayAccount', $displayAccount,
 260+ $htmlOut .= Xml::check( 'displayAccount', $displayAccount,
261261 array( 'id' => 'displayAccount' ) );
262262 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );
263263 $htmlOut .= Html::closeElement( 'p' );
264 -
 264+
265265 // Fundraising settings
266266 if ( $wgNoticeEnableFundraising ) {
267 -
 267+
268268 // Checkbox for indicating if it is a fundraising banner
269269 $htmlOut .= Html::openElement( 'p', null );
270270 $htmlOut .= Xml::check( 'fundraising', $fundraising, array( 'id' => 'fundraising' ) );
271271 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ), 'fundraising' );
272272 $htmlOut .= Html::closeElement( 'p' );
273 -
 273+
274274 // Checkbox for whether or not to automatically create landing page link
275275 $htmlOut .= Html::openElement( 'p', null );
276276 $htmlOut .= Xml::check( 'autolink', $autolink, array( 'id' => 'autolink' ) );
277277 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-autolink' ), 'autolink' );
278278 $htmlOut .= Html::closeElement( 'p' );
279 -
 279+
280280 // Interface for setting the landing pages
281 - $htmlOut .= Html::openElement( 'div',
 281+ $htmlOut .= Html::openElement( 'div',
282282 array( 'id' => 'autolinkInterface', 'style' => 'display: none;' ) );
283 - $htmlOut .= Xml::tags( 'p', array(),
 283+ $htmlOut .= Xml::tags( 'p', array(),
284284 wfMsg( 'centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01' ) );
285285 $htmlOut .= Xml::tags( 'p', array(),
286 - Xml::inputLabel(
287 - wfMsg( 'centralnotice-banner-landing-pages' ),
288 - 'landingPages', 'landingPages', 40, $landingPages,
 286+ Xml::inputLabel(
 287+ wfMsg( 'centralnotice-banner-landing-pages' ),
 288+ 'landingPages', 'landingPages', 40, $landingPages,
289289 array( 'maxlength' => 255 )
290290 )
291291 );
292292 $htmlOut .= Html::closeElement( 'div' );
293293 }
294 -
 294+
295295 // Begin banner body section
296296 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-banner' ) );
297297 $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' );
298298 $buttons = array();
299 - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' .
 299+ $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' .
300300 wfMsg( 'centralnotice-close-button' ) . '</a>';
301301 $htmlOut .= Xml::tags( 'div',
302302 array( 'style' => 'margin-bottom: 0.2em;' ),
303 - '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' .
 303+ '<img src="'.$scriptPath.'/down-arrow.png" style="vertical-align:baseline;"/>' .
304304 wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) )
305305 );
306 -
 306+
307307 $htmlOut .= Xml::textarea( 'templateBody', $body, 60, 20 );
308308 $htmlOut .= Html::closeElement( 'fieldset' );
309309 $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
310 -
 310+
311311 // Submit button
312 - $htmlOut .= Xml::tags( 'div',
313 - array( 'class' => 'cn-buttons' ),
314 - Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) )
 312+ $htmlOut .= Xml::tags( 'div',
 313+ array( 'class' => 'cn-buttons' ),
 314+ Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) )
315315 );
316 -
 316+
317317 $htmlOut .= Html::closeElement( 'form' );
318318 $htmlOut .= Html::closeElement( 'fieldset' );
319319
320320 // Output HTML
321321 $wgOut->addHTML( $htmlOut );
322322 }
323 -
 323+
324324 /**
325325 * View or edit an individual banner
326326 */
327327 private function showView() {
328 - global $wgOut, $wgUser, $wgRequest, $wgLanguageCode, $wgExtensionAssetsPath, $wgLang,
 328+ global $wgOut, $wgUser, $wgRequest, $wgLanguageCode, $wgExtensionAssetsPath, $wgLang,
329329 $wgNoticeEnableFundraising;
330 -
 330+
331331 $scriptPath = "$wgExtensionAssetsPath/CentralNotice";
332332 $sk = $wgUser->getSkin();
333 -
 333+
334334 if ( $this->editable ) {
335335 $readonly = array();
336336 $disabled = array();
@@ -343,22 +343,22 @@
344344
345345 // Get current banner
346346 $currentTemplate = $wgRequest->getText( 'template' );
347 -
 347+
348348 $bannerSettings = CentralNoticeDB::getBannerSettings( $currentTemplate );
349 -
 349+
350350 if ( !$bannerSettings ) {
351351 $this->showError( 'centralnotice-banner-doesnt-exist' );
352352 return;
353353 } else {
354354 // Begin building HTML
355355 $htmlOut = '';
356 -
 356+
357357 // Begin View Banner fieldset
358358 $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
359 -
360 - $htmlOut .= Html::element( 'h2', null,
 359+
 360+ $htmlOut .= Html::element( 'h2', null,
361361 wfMsg( 'centralnotice-banner-heading', $currentTemplate ) );
362 -
 362+
363363 // Show preview of banner
364364 $render = new SpecialBannerLoader();
365365 $render->siteName = 'Wikipedia';
@@ -369,7 +369,7 @@
370370 $preview = wfMsg( 'centralnotice-nopreview' );
371371 }
372372 if ( $render->language != '' ) {
373 - $htmlOut .= Xml::fieldset(
 373+ $htmlOut .= Xml::fieldset(
374374 wfMsg( 'centralnotice-preview' ) . " ($render->language)",
375375 $preview
376376 );
@@ -378,18 +378,18 @@
379379 $preview
380380 );
381381 }
382 -
 382+
383383 // Pull banner text and respect any inc: markup
384 - $bodyPage = Title::newFromText(
 384+ $bodyPage = Title::newFromText(
385385 "Centralnotice-template-{$currentTemplate}", NS_MEDIAWIKI );
386386 $curRev = Revision::newFromTitle( $bodyPage );
387387 $body = $curRev ? $curRev->getText() : '';
388 -
 388+
389389 // Extract message fields from the banner body
390390 $fields = array();
391391 $allowedChars = Title::legalChars();
392392 preg_match_all( "/\{\{\{([$allowedChars]+)\}\}\}/u", $body, $fields );
393 -
 393+
394394 // If there are any message fields in the banner, display translation tools.
395395 if ( count( $fields[0] ) > 0 ) {
396396 if ( $this->editable ) {
@@ -406,49 +406,49 @@
407407 'width' => '100%'
408408 )
409409 );
410 -
 410+
411411 // Table headers
412 - $htmlOut .= Html::element( 'th', array( 'width' => '15%' ),
 412+ $htmlOut .= Html::element( 'th', array( 'width' => '15%' ),
413413 wfMsg( 'centralnotice-message' ) );
414 - $htmlOut .= Html::element( 'th', array( 'width' => '5%' ),
 414+ $htmlOut .= Html::element( 'th', array( 'width' => '5%' ),
415415 wfMsg ( 'centralnotice-number-uses' ) );
416 - $htmlOut .= Html::element( 'th', array( 'width' => '40%' ),
 416+ $htmlOut .= Html::element( 'th', array( 'width' => '40%' ),
417417 wfMsg ( 'centralnotice-english' ) );
418418 $languages = Language::getLanguageNames();
419 - $htmlOut .= Html::element( 'th', array( 'width' => '40%' ),
 419+ $htmlOut .= Html::element( 'th', array( 'width' => '40%' ),
420420 $languages[$wpUserLang] );
421 -
 421+
422422 // Remove duplicate message fields
423423 $filteredFields = array();
424424 foreach ( $fields[1] as $field ) {
425 - $filteredFields[$field] = array_key_exists( $field, $filteredFields )
 425+ $filteredFields[$field] = array_key_exists( $field, $filteredFields )
426426 ? $filteredFields[$field] + 1 : 1;
427427 }
428 -
 428+
429429 // Table rows
430430 foreach ( $filteredFields as $field => $count ) {
431431 // Message
432 - $message = ( $wpUserLang == 'en' )
433 - ? "Centralnotice-{$currentTemplate}-{$field}"
 432+ $message = ( $wpUserLang == 'en' )
 433+ ? "Centralnotice-{$currentTemplate}-{$field}"
434434 : "Centralnotice-{$currentTemplate}-{$field}/{$wpUserLang}";
435 -
 435+
436436 // English value
437437 $htmlOut .= Html::openElement( 'tr' );
438 -
 438+
439439 $title = Title::newFromText( "MediaWiki:{$message}" );
440440 $htmlOut .= Xml::tags( 'td', null,
441441 $sk->makeLinkObj( $title, htmlspecialchars( $field ) )
442442 );
443 -
 443+
444444 $htmlOut .= Html::element( 'td', null, $count );
445 -
 445+
446446 // English text
447447 $englishText = wfMsg( 'centralnotice-message-not-set' );
448448 $englishTextExists = false;
449 - if (
450 - Title::newFromText(
451 - "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI
452 - )->exists() )
 449+ if (
 450+ Title::newFromText(
 451+ "Centralnotice-{$currentTemplate}-{$field}", NS_MEDIAWIKI
 452+ )->exists() )
453453 {
454454 $englishText = wfMsgExt( "Centralnotice-{$currentTemplate}-{$field}",
455455 array( 'language' => 'en' )
@@ -457,14 +457,14 @@
458458 }
459459 $htmlOut .= Xml::tags( 'td', null,
460460 Html::element( 'span',
461 - array(
462 - 'style' => 'font-style:italic;' .
463 - ( !$englishTextExists ? 'color:silver' : '' )
 461+ array(
 462+ 'style' => 'font-style:italic;' .
 463+ ( !$englishTextExists ? 'color:silver' : '' )
464464 ),
465465 $englishText
466466 )
467467 );
468 -
 468+
469469 // Foreign text input
470470 $foreignText = '';
471471 $foreignTextExists = false;
@@ -475,37 +475,37 @@
476476 $foreignTextExists = true;
477477 }
478478 $htmlOut .= Xml::tags( 'td', null,
479 - Xml::input(
480 - "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]",
481 - '',
 479+ Xml::input(
 480+ "updateText[{$wpUserLang}][{$currentTemplate}-{$field}]",
 481+ '',
482482 $foreignText,
483483 wfArrayMerge( $readonly,
484 - array( 'style' => 'width:100%;' .
 484+ array( 'style' => 'width:100%;' .
485485 ( !$foreignTextExists ? 'color:red' : '' ) ) )
486486 )
487487 );
488488 $htmlOut .= Html::closeElement( 'tr' );
489489 }
490490 $htmlOut .= Html::closeElement( 'table' );
491 -
 491+
492492 if ( $this->editable ) {
493493 $htmlOut .= Html::hidden( 'wpUserLanguage', $wpUserLang );
494494 $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
495495 $htmlOut .= Xml::tags( 'div',
496 - array( 'class' => 'cn-buttons' ),
497 - Xml::submitButton(
498 - wfMsg( 'centralnotice-modify' ),
499 - array( 'name' => 'update' )
500 - )
 496+ array( 'class' => 'cn-buttons' ),
 497+ Xml::submitButton(
 498+ wfMsg( 'centralnotice-modify' ),
 499+ array( 'name' => 'update' )
 500+ )
501501 );
502502 }
503 -
 503+
504504 $htmlOut .= Html::closeElement( 'fieldset' );
505 -
 505+
506506 if ( $this->editable ) {
507507 $htmlOut .= Html::closeElement( 'form' );
508508 }
509 -
 509+
510510 // Show language selection form
511511 $actionTitle = $this->getTitleFor( 'NoticeTemplate', 'view' );
512512 $actionUrl = $actionTitle->getLocalURL();
@@ -514,9 +514,9 @@
515515 $htmlOut .= Html::hidden( 'template', $currentTemplate );
516516 $htmlOut .= Html::openElement( 'table', array ( 'cellpadding' => 9 ) );
517517 list( $lsLabel, $lsSelect ) = Xml::languageSelector( $wpUserLang );
518 -
 518+
519519 $newPage = $this->getTitle( 'view' );
520 -
 520+
521521 $htmlOut .= Xml::tags( 'tr', null,
522522 Xml::tags( 'td', null, $lsLabel ) .
523523 Xml::tags( 'td', null, $lsSelect ) .
@@ -526,29 +526,29 @@
527527 );
528528 $htmlOut .= Xml::tags( 'tr', null,
529529 Xml::tags( 'td', null, '' ) .
530 - Xml::tags( 'td', null,
531 - $sk->makeLinkObj(
532 - $newPage,
533 - wfMsgHtml( 'centralnotice-preview-all-template-translations' ),
534 - "template=$currentTemplate&wpUserLanguage=all" )
 530+ Xml::tags( 'td', null,
 531+ $sk->makeLinkObj(
 532+ $newPage,
 533+ wfMsgHtml( 'centralnotice-preview-all-template-translations' ),
 534+ "template=$currentTemplate&wpUserLanguage=all" )
535535 )
536536 );
537537 $htmlOut .= Html::closeElement( 'table' );
538538 $htmlOut .= Html::closeElement( 'fieldset' );
539539 $htmlOut .= Html::closeElement( 'form' );
540540 }
541 -
 541+
542542 // Show edit form
543543 if ( $this->editable ) {
544 - $htmlOut .= Html::openElement( 'form',
545 - array(
546 - 'method' => 'post',
547 - 'onsubmit' => 'return validateBannerForm(this)'
548 - )
 544+ $htmlOut .= Html::openElement( 'form',
 545+ array(
 546+ 'method' => 'post',
 547+ 'onsubmit' => 'return validateBannerForm(this)'
 548+ )
549549 );
550550 $htmlOut .= Html::hidden( 'wpMethod', 'editTemplate' );
551551 }
552 -
 552+
553553 // If there was an error, we'll need to restore the state of the form
554554 if ( $wgRequest->wasPosted() && $wgRequest->getVal( 'mainform' ) ) {
555555 $displayAnon = $wgRequest->getCheck( 'displayAnon' );
@@ -565,56 +565,56 @@
566566 $landingPages = $bannerSettings['landingpages'];
567567 // $body default is defined prior to message interface code
568568 }
569 -
 569+
570570 // Show banner settings
571571 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-settings' ) );
572572 $htmlOut .= Html::openElement( 'p', null );
573573 $htmlOut .= wfMsg( 'centralnotice-banner-display' );
574 - $htmlOut .= Xml::check( 'displayAnon', $displayAnon,
 574+ $htmlOut .= Xml::check( 'displayAnon', $displayAnon,
575575 wfArrayMerge( $disabled, array( 'id' => 'displayAnon' ) ) );
576576 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-anonymous' ), 'displayAnon' );
577 - $htmlOut .= Xml::check( 'displayAccount', $displayAccount,
 577+ $htmlOut .= Xml::check( 'displayAccount', $displayAccount,
578578 wfArrayMerge( $disabled, array( 'id' => 'displayAccount' ) ) );
579579 $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-logged-in' ), 'displayAccount' );
580580 $htmlOut .= Html::closeElement( 'p' );
581 -
 581+
582582 // Fundraising settings
583583 if ( $wgNoticeEnableFundraising ) {
584 -
 584+
585585 // Checkbox for indicating if it is a fundraising banner
586586 $htmlOut .= Html::openElement( 'p', null );
587 - $htmlOut .= Xml::check( 'fundraising', $fundraising,
 587+ $htmlOut .= Xml::check( 'fundraising', $fundraising,
588588 wfArrayMerge( $disabled, array( 'id' => 'fundraising' ) ) );
589 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ),
 589+ $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-fundraising' ),
590590 'fundraising' );
591591 $htmlOut .= Html::closeElement( 'p' );
592 -
 592+
593593 // Checkbox for whether or not to automatically create landing page link
594594 $htmlOut .= Html::openElement( 'p', null );
595 - $htmlOut .= Xml::check( 'autolink', $autolink,
 595+ $htmlOut .= Xml::check( 'autolink', $autolink,
596596 wfArrayMerge( $disabled, array( 'id' => 'autolink' ) ) );
597 - $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-autolink' ),
 597+ $htmlOut .= Xml::label( wfMsg( 'centralnotice-banner-autolink' ),
598598 'autolink' );
599599 $htmlOut .= Html::closeElement( 'p' );
600 -
 600+
601601 // Interface for setting the landing pages
602602 if ( $autolink ) {
603603 $htmlOut .= Html::openElement( 'div', array( 'id'=>'autolinkInterface' ) );
604604 } else {
605 - $htmlOut .= Html::openElement( 'div',
 605+ $htmlOut .= Html::openElement( 'div',
606606 array( 'id'=>'autolinkInterface', 'style'=>'display:none;' ) );
607607 }
608 - $htmlOut .= Xml::tags( 'p', array(),
 608+ $htmlOut .= Xml::tags( 'p', array(),
609609 wfMsg( 'centralnotice-banner-autolink-help', 'id="cn-landingpage-link"', 'JimmyAppeal01' ) );
610610 $htmlOut .= Xml::tags( 'p', array(),
611 - Xml::inputLabel(
612 - wfMsg( 'centralnotice-banner-landing-pages' ),
613 - 'landingPages', 'landingPages', 40, $landingPages,
 611+ Xml::inputLabel(
 612+ wfMsg( 'centralnotice-banner-landing-pages' ),
 613+ 'landingPages', 'landingPages', 40, $landingPages,
614614 array( 'maxlength' => 255 )
615615 )
616616 );
617617 $htmlOut .= Html::closeElement( 'div' );
618 -
 618+
619619 }
620620
621621 // Begin banner body section
@@ -623,12 +623,12 @@
624624 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-edit-template' ) );
625625 $htmlOut .= wfMsg( 'centralnotice-edit-template-summary' );
626626 $buttons = array();
627 - $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' .
 627+ $buttons[] = '<a href="#" onclick="insertButton(\'close\');return false;">' .
628628 wfMsg( 'centralnotice-close-button' ) . '</a>';
629629 $htmlOut .= Xml::tags( 'div',
630630 array( 'style' => 'margin-bottom: 0.2em;' ),
631 - '<img src="' . $scriptPath . '/down-arrow.png" ' .
632 - 'style="vertical-align:baseline;"/>' .
 631+ '<img src="' . $scriptPath . '/down-arrow.png" ' .
 632+ 'style="vertical-align:baseline;"/>' .
633633 wfMsg( 'centralnotice-insert', $wgLang->commaList( $buttons ) )
634634 );
635635 } else {
@@ -640,13 +640,13 @@
641641 // Indicate which form was submitted
642642 $htmlOut .= Html::hidden( 'mainform', 'true' );
643643 $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
644 - $htmlOut .= Xml::tags( 'div',
645 - array( 'class' => 'cn-buttons' ),
646 - Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) )
 644+ $htmlOut .= Xml::tags( 'div',
 645+ array( 'class' => 'cn-buttons' ),
 646+ Xml::submitButton( wfMsg( 'centralnotice-save-banner' ) )
647647 );
648648 $htmlOut .= Html::closeElement( 'form' );
649649 }
650 -
 650+
651651 // Show clone form
652652 if ( $this->editable ) {
653653 $htmlOut .= Html::openElement ( 'form',
@@ -655,33 +655,33 @@
656656 'action' => $this->getTitle( 'clone' )->getLocalUrl()
657657 )
658658 );
659 -
 659+
660660 $htmlOut .= Xml::fieldset( wfMsg( 'centralnotice-clone-notice' ) );
661661 $htmlOut .= Html::openElement( 'table', array( 'cellpadding' => 9 ) );
662662 $htmlOut .= Html::openElement( 'tr' );
663 - $htmlOut .= Xml::inputLabel(
664 - wfMsg( 'centralnotice-clone-name' ),
 663+ $htmlOut .= Xml::inputLabel(
 664+ wfMsg( 'centralnotice-clone-name' ),
665665 'newTemplate', 'newTemplate', '25' );
666 - $htmlOut .= Xml::submitButton(
667 - wfMsg( 'centralnotice-clone' ),
 666+ $htmlOut .= Xml::submitButton(
 667+ wfMsg( 'centralnotice-clone' ),
668668 array ( 'id' => 'clone' ) );
669669 $htmlOut .= Html::hidden( 'oldTemplate', $currentTemplate );
670 -
 670+
671671 $htmlOut .= Html::closeElement( 'tr' );
672672 $htmlOut .= Html::closeElement( 'table' );
673673 $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
674674 $htmlOut .= Html::closeElement( 'fieldset' );
675675 $htmlOut .= Html::closeElement( 'form' );
676676 }
677 -
 677+
678678 // End View Banner fieldset
679679 $htmlOut .= Html::closeElement( 'fieldset' );
680 -
 680+
681681 // Output HTML
682682 $wgOut->addHTML( $htmlOut );
683683 }
684684 }
685 -
 685+
686686 /**
687687 * Preview all available translations of a banner
688688 */
@@ -696,10 +696,10 @@
697697 // Pull all available text for a banner
698698 $langs = array_keys( $this->getTranslations( $template ) );
699699 $htmlOut = '';
700 -
 700+
701701 // Begin View Banner fieldset
702702 $htmlOut .= Html::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
703 -
 703+
704704 $htmlOut .= Html::element( 'h2', null, wfMsg( 'centralnotice-banner-heading', $template ) );
705705
706706 foreach ( $langs as $lang ) {
@@ -723,13 +723,13 @@
724724 )
725725 );
726726 }
727 -
 727+
728728 // End View Banner fieldset
729729 $htmlOut .= Html::closeElement( 'fieldset' );
730 -
 730+
731731 return $wgOut->addHtml( $htmlOut );
732732 }
733 -
 733+
734734 /**
735735 * Add or update a message
736736 */
@@ -741,7 +741,7 @@
742742 $article = new Article( $title );
743743 $article->doEdit( $translation, '', EDIT_FORCE_BOT );
744744 }
745 -
 745+
746746 private static function getTemplateId ( $templateName ) {
747747 $dbr = wfGetDB( DB_SLAVE );
748748 $res = $dbr->select( 'cn_templates', 'tmp_id',
@@ -755,7 +755,7 @@
756756 }
757757 return null;
758758 }
759 -
 759+
760760 public static function getBannerName( $bannerId ) {
761761 $dbr = wfGetDB( DB_MASTER );
762762 if ( is_numeric( $bannerId ) ) {
@@ -778,7 +778,7 @@
779779 } else {
780780 // Log the removal of the banner
781781 $this->logBannerChange( 'removed', $id );
782 -
 782+
783783 $dbw = wfGetDB( DB_MASTER );
784784 $dbw->begin();
785785 $dbw->delete( 'cn_templates',
@@ -805,9 +805,9 @@
806806 * @param $landingPages string list of landing pages (optional)
807807 * @return true or false depending on whether banner was successfully added
808808 */
809 - public function addTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising = 0,
 809+ public function addTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising = 0,
810810 $autolink = 0, $landingPages = '' ) {
811 -
 811+
812812 if ( $body == '' || $name == '' ) {
813813 $this->showError( 'centralnotice-null-string' );
814814 return false;
@@ -847,7 +847,7 @@
848848 Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI )
849849 );
850850 $article->doEdit( $body, '', EDIT_FORCE_BOT );
851 -
 851+
852852 // Log the creation of the banner
853853 $beginSettings = array();
854854 $endSettings = array(
@@ -858,7 +858,7 @@
859859 'landingpages' => $landingPages
860860 );
861861 $this->logBannerChange( 'created', $bannerId, $beginSettings, $endSettings );
862 -
 862+
863863 return true;
864864 }
865865 }
@@ -866,14 +866,14 @@
867867 /**
868868 * Update a banner
869869 */
870 - private function editTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising,
 870+ private function editTemplate( $name, $body, $displayAnon, $displayAccount, $fundraising,
871871 $autolink, $landingPages ) {
872 -
 872+
873873 if ( $body == '' || $name == '' ) {
874874 $this->showError( 'centralnotice-null-string' );
875875 return;
876876 }
877 -
 877+
878878 $initialBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
879879
880880 $dbr = wfGetDB( DB_SLAVE );
@@ -894,7 +894,7 @@
895895 ),
896896 array( 'tmp_name' => $name )
897897 );
898 -
 898+
899899 // Perhaps these should move into the db as blob
900900 $article = new Article(
901901 Title::newFromText( "centralnotice-template-{$name}", NS_MEDIAWIKI )
@@ -904,13 +904,13 @@
905905
906906 $bannerId = SpecialNoticeTemplate::getTemplateId( $name );
907907 $finalBannerSettings = CentralNoticeDB::getBannerSettings( $name, true );
908 -
 908+
909909 // If there are any difference between the old settings and the new settings, log them.
910910 $diffs = array_diff_assoc( $initialBannerSettings, $finalBannerSettings );
911911 if ( $diffs ) {
912912 $this->logBannerChange( 'modified', $bannerId, $initialBannerSettings, $finalBannerSettings );
913913 }
914 -
 914+
915915 return;
916916 }
917917 }
@@ -919,16 +919,16 @@
920920 * Copy all the data from one banner to another
921921 */
922922 public function cloneTemplate( $source, $dest ) {
923 -
 923+
924924 // Reset the timer as updates on meta take a long time
925925 set_time_limit( 300 );
926 -
 926+
927927 // Pull all possible langs
928928 $langs = $this->getTranslations( $source );
929929
930930 // Normalize name
931931 $dest = preg_replace( '/[^A-Za-z0-9_]/', '', $dest );
932 -
 932+
933933 // Pull banner settings from database
934934 $dbr = wfGetDB( DB_SLAVE );
935935 $row = $dbr->selectRow( 'cn_templates',
@@ -980,8 +980,8 @@
981981 // Remove duplicates
982982 $filteredFields = array();
983983 foreach ( $fields[1] as $field ) {
984 - $filteredFields[$field] = array_key_exists( $field, $filteredFields )
985 - ? $filteredFields[$field] + 1
 984+ $filteredFields[$field] = array_key_exists( $field, $filteredFields )
 985+ ? $filteredFields[$field] + 1
986986 : 1;
987987 }
988988 return $filteredFields;
@@ -1005,8 +1005,8 @@
10061006 // Iterate through all possible message fields
10071007 foreach ( $fields as $field => $count ) {
10081008 // Put all message fields together for a lookup
1009 - $message = ( $lang == 'en' )
1010 - ? "Centralnotice-{$template}-{$field}"
 1009+ $message = ( $lang == 'en' )
 1010+ ? "Centralnotice-{$template}-{$field}"
10111011 : "Centralnotice-{$template}-{$field}/{$lang}";
10121012 if ( Title::newFromText( $message, NS_MEDIAWIKI )->exists() ) {
10131013 $translations[$lang][$field] = wfMsgExt(
@@ -1018,13 +1018,13 @@
10191019 }
10201020 return $translations;
10211021 }
1022 -
 1022+
10231023 function showError( $message ) {
10241024 global $wgOut;
10251025 $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message );
10261026 $this->centralNoticeError = true;
10271027 }
1028 -
 1028+
10291029 /**
10301030 * Log setting changes related to a banner
10311031 * @param $action string: 'created', 'modified', or 'removed'
@@ -1034,9 +1034,9 @@
10351035 */
10361036 function logBannerChange( $action, $bannerId, $beginSettings = array(), $endSettings = array() ) {
10371037 global $wgUser;
1038 -
 1038+
10391039 $dbw = wfGetDB( DB_MASTER );
1040 -
 1040+
10411041 $log = array(
10421042 'tmplog_timestamp' => $dbw->timestamp(),
10431043 'tmplog_user_id' => $wgUser->getId(),
@@ -1044,14 +1044,14 @@
10451045 'tmplog_template_id' => $bannerId,
10461046 'tmplog_template_name' => SpecialNoticeTemplate::getBannerName( $bannerId )
10471047 );
1048 -
 1048+
10491049 foreach ( $beginSettings as $key => $value ) {
10501050 $log['tmplog_begin_'.$key] = $value;
10511051 }
10521052 foreach ( $endSettings as $key => $value ) {
10531053 $log['tmplog_end_'.$key] = $value;
10541054 }
1055 -
 1055+
10561056 $res = $dbw->insert( 'cn_template_log', $log );
10571057 $log_id = $dbw->insertId();
10581058 return $log_id;
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
@@ -7,23 +7,23 @@
88
99 class SpecialCentralNoticeLogs extends UnlistedSpecialPage {
1010 public $logType = 'campaignsettings';
11 -
 11+
1212 function __construct() {
1313 // Register special page
1414 parent::__construct( "CentralNoticeLogs" );
1515 }
16 -
 16+
1717 /**
1818 * Handle different types of page requests
1919 */
2020 function execute( $sub ) {
2121 global $wgOut, $wgRequest, $wgExtensionAssetsPath;
22 -
 22+
2323 $this->logType = $wgRequest->getText( 'log', 'campaignsettings' );
2424
2525 // Begin output
2626 $this->setHeaders();
27 -
 27+
2828 // Output ResourceLoader module for styling and javascript functions
2929 $wgOut->addModules( 'ext.centralNotice.interface' );
3030
@@ -38,12 +38,12 @@
3939
4040 // Begin Banners tab content
4141 $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'preferences' ) ) );
42 -
 42+
4343 $htmlOut = '';
44 -
 44+
4545 // Begin log selection fieldset
4646 $htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
47 -
 47+
4848 $title = SpecialPage::getTitleFor( 'CentralNoticeLogs' );
4949 $actionUrl = $title->getLocalURL();
5050 $htmlOut .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $actionUrl ) );
@@ -51,21 +51,21 @@
5252 $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-switcher' ) );
5353 $title = SpecialPage::getTitleFor( 'CentralNoticeLogs' );
5454 $fullUrl = wfExpandUrl( $title->getFullUrl(), PROTO_CURRENT );
55 -
 55+
5656 // Build the radio buttons for switching the log type
57 - $htmlOut .= $this->getLogSwitcher( 'campaignsettings', 'campaignSettings',
 57+ $htmlOut .= $this->getLogSwitcher( 'campaignsettings', 'campaignSettings',
5858 'centralnotice-campaign-settings', $fullUrl );
59 - $htmlOut .= $this->getLogSwitcher( 'bannersettings', 'bannerSettings',
 59+ $htmlOut .= $this->getLogSwitcher( 'bannersettings', 'bannerSettings',
6060 'centralnotice-banner-settings', $fullUrl );
61 - $htmlOut .= $this->getLogSwitcher( 'bannercontent', 'bannerContent',
 61+ $htmlOut .= $this->getLogSwitcher( 'bannercontent', 'bannerContent',
6262 'centralnotice-banner-content', $fullUrl );
63 - $htmlOut .= $this->getLogSwitcher( 'bannermessages', 'bannerMessages',
 63+ $htmlOut .= $this->getLogSwitcher( 'bannermessages', 'bannerMessages',
6464 'centralnotice-banner-messages', $fullUrl );
65 -
 65+
6666 $htmlOut .= Xml::closeElement( 'div' );
67 -
 67+
6868 if ( $this->logType == 'campaignsettings' ) {
69 -
 69+
7070 $reset = $wgRequest->getVal( 'centralnoticelogreset' );
7171 $campaign = $wgRequest->getVal( 'campaign' );
7272 $user = $wgRequest->getVal( 'user' );
@@ -75,9 +75,9 @@
7676 $endYear = $this->getDateValue( 'end_year' );
7777 $endMonth = $this->getDateValue( 'end_month' );
7878 $endDay = $this->getDateValue( 'end_day' );
79 -
 79+
8080 $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-filters-container' ) );
81 -
 81+
8282 if ( $campaign || $user || $startYear || $startMonth || $startDay || $endYear || $endMonth || $endDay ) { // filters on
8383 $htmlOut .= '<a href="javascript:toggleFilterDisplay()">'.
8484 '<img src="'.$wgExtensionAssetsPath.'/CentralNotice/collapsed.png" id="cn-collapsed-filter-arrow" style="display:none;position:relative;top:-2px;"/>'.
@@ -93,10 +93,10 @@
9494 $htmlOut .= Xml::tags( 'span', array( 'style' => 'margin-left: 0.3em;' ), 'Log filters' );
9595 $htmlOut .= Xml::openElement( 'div', array( 'id' => 'cn-log-filters', 'style' => 'display:none;' ) );
9696 }
97 -
 97+
9898 $htmlOut .= Xml::openElement( 'table' );
9999 $htmlOut .= Xml::openElement( 'tr' );
100 -
 100+
101101 $htmlOut .= Xml::openElement( 'td' );
102102 $htmlOut .= Xml::label( wfMsg( 'centralnotice-start-date' ), 'month', array( 'class' => 'cn-log-filter-label' ) );
103103 $htmlOut .= Xml::closeElement( 'td' );
@@ -107,10 +107,10 @@
108108 $htmlOut .= $this->dateSelector( 'start', $startYear, $startMonth, $startDay );
109109 }
110110 $htmlOut .= Xml::closeElement( 'td' );
111 -
 111+
112112 $htmlOut .= Xml::closeElement( 'tr' );
113113 $htmlOut .= Xml::openElement( 'tr' );
114 -
 114+
115115 $htmlOut .= Xml::openElement( 'td' );
116116 $htmlOut .= Xml::label( wfMsg( 'centralnotice-end-date' ), 'month', array( 'class' => 'cn-log-filter-label' ) );
117117 $htmlOut .= Xml::closeElement( 'td' );
@@ -121,10 +121,10 @@
122122 $htmlOut .= $this->dateSelector( 'end', $endYear, $endMonth, $endDay );
123123 }
124124 $htmlOut .= Xml::closeElement( 'td' );
125 -
 125+
126126 $htmlOut .= Xml::closeElement( 'tr' );
127127 $htmlOut .= Xml::openElement( 'tr' );
128 -
 128+
129129 $htmlOut .= Xml::openElement( 'td' );
130130 $htmlOut .= Xml::label( wfMsg( 'centralnotice-notice' ), 'campaign', array( 'class' => 'cn-log-filter-label' ) );
131131 $htmlOut .= Xml::closeElement( 'td' );
@@ -132,10 +132,10 @@
133133 $htmlOut .= Xml::input( 'campaign', 25, ( $reset ? '' : $campaign ) );
134134 $htmlOut .= Xml::closeElement( 'span' );
135135 $htmlOut .= Xml::closeElement( 'td' );
136 -
 136+
137137 $htmlOut .= Xml::closeElement( 'tr' );
138138 $htmlOut .= Xml::openElement( 'tr' );
139 -
 139+
140140 $htmlOut .= Xml::openElement( 'td' );
141141 $htmlOut .= Xml::label( wfMsg( 'centralnotice-user' ), 'user', array( 'class' => 'cn-log-filter-label' ) );
142142 $htmlOut .= Xml::closeElement( 'td' );
@@ -143,10 +143,10 @@
144144 $htmlOut .= Xml::input( 'user', 25, ( $reset ? '' : $user ) );
145145 $htmlOut .= Xml::closeElement( 'span' );
146146 $htmlOut .= Xml::closeElement( 'td' );
147 -
 147+
148148 $htmlOut .= Xml::closeElement( 'tr' );
149149 $htmlOut .= Xml::openElement( 'tr' );
150 -
 150+
151151 $htmlOut .= Xml::openElement( 'td', array( 'colspan' => 2 ) );
152152 $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-apply-filters' ),
153153 array(
@@ -165,26 +165,26 @@
166166 )
167167 );
168168 $htmlOut .= Xml::closeElement( 'td' );
169 -
 169+
170170 $htmlOut .= Xml::closeElement( 'tr' );
171171 $htmlOut .= Xml::closeElement( 'table' );
172172 $htmlOut .= Xml::closeElement( 'div' );
173173 $htmlOut .= Xml::closeElement( 'div' );
174174 }
175 -
 175+
176176 $htmlOut .= Xml::closeElement( 'form' );
177 -
 177+
178178 // End log selection fieldset
179179 //$htmlOut .= Xml::closeElement( 'fieldset' );
180180
181181 $wgOut->addHTML( $htmlOut );
182 -
 182+
183183 $this->showLog( $this->logType );
184184
185185 // End Banners tab content
186186 $wgOut->addHTML( Xml::closeElement( 'div' ) );
187187 }
188 -
 188+
189189 private function dateSelector( $prefix, $year = 0, $month = 0, $day = 0 ) {
190190 $dateRanges = CentralNotice::getDateRanges();
191191
@@ -204,14 +204,14 @@
205205 }
206206 return $out;
207207 }
208 -
 208+
209209 /**
210210 * Show a log of changes.
211211 * @param $logType string: which type of log to show
212212 */
213213 function showLog( $logType ) {
214214 global $wgOut;
215 -
 215+
216216 switch ( $logType ) {
217217 case 'bannersettings':
218218 $pager = new CentralNoticeBannerLogPager( $this );
@@ -223,34 +223,34 @@
224224 default:
225225 $pager = new CentralNoticeCampaignLogPager( $this );
226226 }
227 -
 227+
228228 $htmlOut = '';
229 -
 229+
230230 // Begin log fieldset
231231 //$htmlOut .= Xml::openElement( 'fieldset', array( 'class' => 'prefsection' ) );
232 -
 232+
233233 // Show paginated list of log entries
234 - $htmlOut .= Xml::tags( 'div',
235 - array( 'class' => 'cn-pager' ),
 234+ $htmlOut .= Xml::tags( 'div',
 235+ array( 'class' => 'cn-pager' ),
236236 $pager->getNavigationBar() );
237237 $htmlOut .= $pager->getBody();
238 - $htmlOut .= Xml::tags( 'div',
239 - array( 'class' => 'cn-pager' ),
 238+ $htmlOut .= Xml::tags( 'div',
 239+ array( 'class' => 'cn-pager' ),
240240 $pager->getNavigationBar() );
241 -
 241+
242242 // End log fieldset
243243 $htmlOut .= Xml::closeElement( 'fieldset' );
244244
245245 $wgOut->addHTML( $htmlOut );
246246 }
247 -
 247+
248248 static function getDateValue( $type ) {
249249 global $wgRequest;
250250 $value = $wgRequest->getVal( $type );
251251 if ( $value === 'other' ) $value = null;
252252 return $value;
253253 }
254 -
 254+
255255 /**
256256 * Build a radio button that switches the log type when you click it
257257 */
Index: trunk/extensions/CentralNotice/special/SpecialHideBanners.php
@@ -6,7 +6,7 @@
77
88 /**
99 * Unlisted Special Page which sets a cookie for hiding banners across all languages of a project.
10 - * This is typically used on donation thank-you pages so that users who have donated will no longer
 10+ * This is typically used on donation thank-you pages so that users who have donated will no longer
1111 * see fundrasing banners.
1212 */
1313 class SpecialHideBanners extends UnlistedSpecialPage {
@@ -16,7 +16,7 @@
1717
1818 function execute( $par ) {
1919 global $wgOut;
20 -
 20+
2121 $this->setHideCookie();
2222
2323 $wgOut->disable();
@@ -27,7 +27,7 @@
2828
2929 readfile( dirname( __FILE__ ) . '/../1x1.png' );
3030 }
31 -
 31+
3232 /**
3333 * Set the cookie for hiding fundraising banners.
3434 */
Index: trunk/extensions/CentralNotice/TemplatePager.php
@@ -8,16 +8,16 @@
99 $this->special = $special;
1010 $this->editable = $special->editable;
1111 parent::__construct();
12 -
 12+
1313 // Override paging defaults
1414 list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset( 20, '' );
1515 $this->mLimitsShown = array( 20, 50, 100 );
16 -
 16+
1717 $msg = Xml::encodeJsVar( wfMsg( 'centralnotice-confirm-delete' ) );
1818 $this->onRemoveChange = "if( this.checked ) { this.checked = confirm( $msg ) }";
1919 $this->viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
2020 }
21 -
 21+
2222 function getQueryInfo() {
2323 // Return all the banners in the database
2424 return array(
@@ -25,7 +25,7 @@
2626 'fields' => array( 'tmp_name', 'tmp_id' ),
2727 );
2828 }
29 -
 29+
3030 /**
3131 * Sort the banner list by tmp_id
3232 */
@@ -38,10 +38,10 @@
3939 * Generate the content of each table row (1 row = 1 banner)
4040 */
4141 function formatRow( $row ) {
42 -
 42+
4343 // Begin banner row
4444 $htmlOut = Xml::openElement( 'tr' );
45 -
 45+
4646 if ( $this->editable ) {
4747 // Remove box
4848 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
@@ -53,12 +53,12 @@
5454 )
5555 );
5656 }
57 -
 57+
5858 // Link and Preview
5959 $render = new SpecialBannerLoader();
6060 $render->siteName = 'Wikipedia';
6161 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
62 - try {
 62+ try {
6363 $preview = $render->getHtmlNotice( $row->tmp_name );
6464 } catch ( SpecialBannerLoaderException $e ) {
6565 $preview = wfMsg( 'centralnotice-nopreview' );
@@ -72,10 +72,10 @@
7373 array( 'class' => 'cn-bannerpreview')
7474 )
7575 );
76 -
 76+
7777 // End banner row
7878 $htmlOut .= Xml::closeElement( 'tr' );
79 -
 79+
8080 return $htmlOut;
8181 }
8282
@@ -107,9 +107,9 @@
108108 $htmlOut .= Xml::closeElement( 'table' );
109109 if ( $this->editable ) {
110110 $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
111 - $htmlOut .= Xml::tags( 'div',
112 - array( 'class' => 'cn-buttons' ),
113 - Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
 111+ $htmlOut .= Xml::tags( 'div',
 112+ array( 'class' => 'cn-buttons' ),
 113+ Xml::submitButton( wfMsg( 'centralnotice-modify' ) )
114114 );
115115 }
116116 return $htmlOut;
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php
@@ -373,7 +373,7 @@
374374 'centralnotice-template-exists' => 'Die sjabloon bestaan reeds.
375375 Dit word nie bygevoeg nie.',
376376 'centralnotice-notice-doesnt-exist' => 'Die veldtog bestaan nie.',
377 - 'centralnotice-remove-notice-doesnt-exist' => 'Die veldtog bestaan nie.
 377+ 'centralnotice-remove-notice-doesnt-exist' => 'Die veldtog bestaan nie.
378378 Niks om te verwyder nie.',
379379 'centralnotice-banner-doesnt-exist' => 'Die banier bestaan nie.',
380380 'centralnotice-template-still-bound' => "Die sjabloon is nog aan 'n kennisgewing gekoppel.
@@ -2490,7 +2490,7 @@
24912491 'centralnotice-start-date' => 'Dyddiad cychwyn',
24922492 'centralnotice-start-time' => 'Amser cychwyn (UTC)',
24932493 'centralnotice-end-time' => 'Amser y daw i ben (UTC)',
2494 - 'centralnotice-no-templates' => 'Ni chanfuwyd unrhyw faner.
 2494+ 'centralnotice-no-templates' => 'Ni chanfuwyd unrhyw faner.
24952495 Ychwanegwch rai!',
24962496 'centralnotice-no-templates-assigned' => "Ni briodolwyd baneri i'r ymgyrch.
24972497 Ychwanegwch rai!",
@@ -2629,7 +2629,7 @@
26302630 'centralnotice-assigned-templates' => 'Tildelte bannere',
26312631 'centralnotice-no-templates' => 'Ingen bannere fundet.
26322632 Tilføj nogle!',
2633 - 'centralnotice-no-templates-assigned' => 'Ingen bannere tildelt kampagne.
 2633+ 'centralnotice-no-templates-assigned' => 'Ingen bannere tildelt kampagne.
26342634 Tilføj nogle!',
26352635 'centralnotice-available-templates' => 'Tilgængelige bannere',
26362636 'centralnotice-preview-template' => 'Forhåndsvis banner',
@@ -2738,7 +2738,7 @@
27392739 'centralnotice-template-exists' => 'Vorlage ist bereits vorhanden.
27402740 Sie wird daher nicht hinzugefügt.',
27412741 'centralnotice-notice-doesnt-exist' => 'Meldung ist nicht vorhanden.',
2742 - 'centralnotice-remove-notice-doesnt-exist' => 'Die Meldung ist nicht vorhanden.
 2742+ 'centralnotice-remove-notice-doesnt-exist' => 'Die Meldung ist nicht vorhanden.
27432743 Entfernen nicht möglich.',
27442744 'centralnotice-banner-doesnt-exist' => 'Die Vorlage ist nicht vorhanden.',
27452745 'centralnotice-template-still-bound' => 'Vorlage ist noch an eine Meldung gebunden.
@@ -3166,7 +3166,7 @@
31673167 'centralnotice-template-exists' => 'Το πρότυπο υπάρχει ήδη.
31683168 Δεν προστέθηκε',
31693169 'centralnotice-notice-doesnt-exist' => 'Καμπάνια δεν υπάρχει.',
3170 - 'centralnotice-remove-notice-doesnt-exist' => 'Καμπάνια δεν υπάρχει.
 3170+ 'centralnotice-remove-notice-doesnt-exist' => 'Καμπάνια δεν υπάρχει.
31713171 Τίποτε προς διαγραφή.',
31723172 'centralnotice-banner-doesnt-exist' => 'Το λογότυπο δεν υπάρχει.',
31733173 'centralnotice-template-still-bound' => 'Το πρότυπο είναι ακόμη συνδεδεμένο με ένα σημείωμα.
@@ -4103,7 +4103,7 @@
41044104 'centralnotice-template-exists' => 'Malline on jo olemassa.
41054105 Ei lisätä',
41064106 'centralnotice-notice-doesnt-exist' => 'Kampanjaa ei ole olemassa.',
4107 - 'centralnotice-remove-notice-doesnt-exist' => 'Kampanjaa ei ole olemassa.
 4107+ 'centralnotice-remove-notice-doesnt-exist' => 'Kampanjaa ei ole olemassa.
41084108 Ei poistettavaa.',
41094109 'centralnotice-banner-doesnt-exist' => 'Banneria ei ole olemassa.',
41104110 'centralnotice-template-still-bound' => 'Malline on vielä kytkettynä tiedotteeseen.
@@ -5284,7 +5284,7 @@
52855285 'centralnotice-no-allocation' => 'Nema dodijeljenih obavijesti.',
52865286 'centralnotice-allocation-description' => 'Dodjela obavijesti za $1.$2 u $3:',
52875287 'centralnotice-percentage' => 'Postotak',
5288 - 'centralnotice-documentwrite-error' => 'document.write() ne može se rabiti unutar obavijesti.
 5288+ 'centralnotice-documentwrite-error' => 'document.write() ne može se rabiti unutar obavijesti.
52895289 Pogledajte http://meta.wikimedia.org/wiki/Help:CentralNotice za više informacija.',
52905290 'centralnotice-preferred' => 'Željeno',
52915291 'centralnotice-talk-link' => 'razgovor',
@@ -6547,7 +6547,7 @@
65486548 'centralnotice-no-allocation' => 'ბანერები არ განაწილდა.',
65496549 'centralnotice-allocation-description' => 'ბანერთა განაწილება $1.$2-თვის $3–ში:',
65506550 'centralnotice-percentage' => 'პროცენტი',
6551 - 'centralnotice-documentwrite-error' => 'document.write() არ შეიძლება გამოყენებული იქნას ბანერის შიგნით.
 6551+ 'centralnotice-documentwrite-error' => 'document.write() არ შეიძლება გამოყენებული იქნას ბანერის შიგნით.
65526552 იხილეთ http://meta.wikimedia.org/wiki/Help:CentralNotice მეტი ინფორმაციისათვის.',
65536553 'centralnotice-preferred' => 'პრივილეგირებული',
65546554 'centralnotice-logs' => 'ჟურნალები',
@@ -8096,7 +8096,7 @@
80978097 'centralnotice-change-lang' => 'भाषांतरासाठी भाषेत बदल करा',
80988098 'centralnotice-weights' => 'वजन',
80998099 'centralnotice-notice-is-locked' => 'मथळ्यास ताळा लावला आहे. काढु नका.',
8100 - 'centralnotice-confirm-delete' => 'आपणास हा मजकुर नक्की गाळावयाचा आहे काय?
 8100+ 'centralnotice-confirm-delete' => 'आपणास हा मजकुर नक्की गाळावयाचा आहे काय?
81018101 ही कृती परतविता येणार नाही.',
81028102 'centralnotice-no-notices-exist' => 'मथळा अस्तित्वात नाही.
81038103 एक मथळा खाली जोडा.',
@@ -8696,7 +8696,7 @@
86978697 'centralnotice-no-allocation' => 'Geen banners toegewezen.',
86988698 'centralnotice-allocation-description' => 'Bannertoewijzing voor $1.$2 in $3:',
86998699 'centralnotice-percentage' => 'Percentage',
8700 - 'centralnotice-documentwrite-error' => 'document.write() kan niet worden gebruikt binnen een banner.
 8700+ 'centralnotice-documentwrite-error' => 'document.write() kan niet worden gebruikt binnen een banner.
87018701 Zie http://meta.wikimedia.org/wiki/Help:CentralNotice voor meer informatie.',
87028702 'centralnotice-preferred' => 'Voorkeur',
87038703 'centralnotice-logs' => 'Logboeken',
@@ -9357,7 +9357,7 @@
93589358 'centralnotice-no-project' => 'Żaden projekt nie został wybrany dla kampanii. Nic nie dodano.',
93599359 'centralnotice-template-exists' => 'Szablon o podanej nazwie już istnieje. Nowy szablon nie został dodany.',
93609360 'centralnotice-notice-doesnt-exist' => 'Kampania nie istnieje.',
9361 - 'centralnotice-remove-notice-doesnt-exist' => 'Kampania nie istnieje.
 9361+ 'centralnotice-remove-notice-doesnt-exist' => 'Kampania nie istnieje.
93629362 Usunięcie jest niemożliwe.',
93639363 'centralnotice-banner-doesnt-exist' => 'Baner nie istnieje.',
93649364 'centralnotice-template-still-bound' => 'Szablon nie może zostać usunięty. Jest ciągle używany przez komunikat.',
@@ -10443,17 +10443,17 @@
1044410444 'centralnotice-notice' => 'Campanie',
1044510445 'centralnotice-notice-heading' => 'Campanie: $1',
1044610446 'centralnotice-notices' => 'Notificări',
10447 - 'centralnotice-notice-exists' => 'Campania există deja.
 10447+ 'centralnotice-notice-exists' => 'Campania există deja.
1044810448 Nu se adaugă.',
1044910449 'centralnotice-no-language' => 'Nicio limbă nu a fost selectată pentru campanie. Nu se adaugă.',
1045010450 'centralnotice-no-project' => 'Niciun proiect nu a fost selectat pentru campanie. Nu se adaugă.',
10451 - 'centralnotice-template-exists' => 'Bannerul există deja.
 10451+ 'centralnotice-template-exists' => 'Bannerul există deja.
1045210452 Nu se adaugă.',
1045310453 'centralnotice-notice-doesnt-exist' => 'Campania nu există.',
10454 - 'centralnotice-remove-notice-doesnt-exist' => 'Campania nu există.
 10454+ 'centralnotice-remove-notice-doesnt-exist' => 'Campania nu există.
1045510455 Nimic de eliminat.',
1045610456 'centralnotice-banner-doesnt-exist' => 'Bannerul nu există.',
10457 - 'centralnotice-template-still-bound' => 'Bannerul este încă legat de o campanie.
 10457+ 'centralnotice-template-still-bound' => 'Bannerul este încă legat de o campanie.
1045810458 Nu se elimină.',
1045910459 'centralnotice-template-body' => 'Corpul bannerului:',
1046010460 'centralnotice-day' => 'Zi',
@@ -10489,7 +10489,7 @@
1049010490 Nu se adaugă.',
1049110491 'centralnotice-confirm-delete' => 'Sunteți sigur că doriți să ștergeți acest element?
1049210492 Acțiunea este iremediabilă.',
10493 - 'centralnotice-no-notices-exist' => 'Nu există campanii.
 10493+ 'centralnotice-no-notices-exist' => 'Nu există campanii.
1049410494 Adăugați una mai jos.',
1049510495 'centralnotice-no-templates-translate' => 'Nu există bannere de tradus.',
1049610496 'centralnotice-number-uses' => 'Utilizări',
@@ -11347,7 +11347,7 @@
1134811348 'right-centralnotice-admin' => 'ප්‍රධාන දැන්වීම් පාලනය කරන්න',
1134911349 'action-centralnotice-admin' => 'ප්‍රධාන දැන්වීම් පාලනය කරන්න',
1135011350 'centralnotice-desc' => 'ප්‍රධාන අඩවි දැන්වීමක් එකතු කරයි',
11351 - 'centralnotice-summary' => 'මෙම ඒකකය මගින් ඔබ දැනට පිහිටුවා ඇති ප්‍රධාන දැන්වීම් සංස්කරණය කළ හැකිය.
 11351+ 'centralnotice-summary' => 'මෙම ඒකකය මගින් ඔබ දැනට පිහිටුවා ඇති ප්‍රධාන දැන්වීම් සංස්කරණය කළ හැකිය.
1135211352 එය පැරැණි දැන්වීම් එකතු කිරීමට හෝ අයින් කිරීමට ද භාවිතා කළ හැකිය.',
1135311353 'centralnotice-query' => 'වත්මන් ව්‍යාපාර සංස්කරණය කරන්න',
1135411354 'centralnotice-notice-name' => 'ව්‍යාපාරයේ නම',
@@ -11390,13 +11390,13 @@
1139111391 එකතු කරනු නොලැබේ.',
1139211392 'centralnotice-no-language' => 'ව්‍යාපාරය සඳහා භාෂාවක් තෝරාගෙන නැත. එකතු කරනු නොලැබේ.',
1139311393 'centralnotice-no-project' => 'ව්‍යාපාරය සඳහා ව්‍යාපෘතියක් තෝරාගෙන නැත. එකතු කරනු නොලැබේ.',
11394 - 'centralnotice-template-exists' => 'බැනරය දැනටමත් පවතී.
 11394+ 'centralnotice-template-exists' => 'බැනරය දැනටමත් පවතී.
1139511395 එකතු කරනු නොලැබේ.',
1139611396 'centralnotice-notice-doesnt-exist' => 'ව්‍යාපාරය නොපවතී.',
1139711397 'centralnotice-remove-notice-doesnt-exist' => 'ව්‍යාපාරය නොපවතී.
1139811398 අයින් කිරීමට කිසිවක් නැත.',
1139911399 'centralnotice-banner-doesnt-exist' => 'බැනරය නොපවතී.',
11400 - 'centralnotice-template-still-bound' => 'බැනරය තවමත් ව්‍යාපාරයකට බැඳී ඇත.
 11400+ 'centralnotice-template-still-bound' => 'බැනරය තවමත් ව්‍යාපාරයකට බැඳී ඇත.
1140111401 ඉවත් නොකෙරේ.',
1140211402 'centralnotice-template-body' => 'බැනර බඳ:',
1140311403 'centralnotice-day' => 'දවස',
@@ -11417,12 +11417,12 @@
1141811418 'centralnotice-no-templates-assigned' => 'ව්‍යාපාරයට බැනර පවරා නැත.
1141911419 එකතු කරන්න!',
1142011420 'centralnotice-available-templates' => 'දැනට ඇති බැනර',
11421 - 'centralnotice-template-already-exists' => 'බැනරය දැනටමත් ව්‍යාපෘතියට බැඳී ඇත.
 11421+ 'centralnotice-template-already-exists' => 'බැනරය දැනටමත් ව්‍යාපෘතියට බැඳී ඇත.
1142211422 එකතු නොකෙරේ.',
1142311423 'centralnotice-preview-template' => 'බැනර පෙරදසුන',
1142411424 'centralnotice-change-lang' => 'පරිවර්තන භාෂාව වෙනස් කරන්න',
1142511425 'centralnotice-weights' => 'බර',
11426 - 'centralnotice-notice-is-locked' => 'ව්‍යාපාරය අගුළු ලා ඇත.
 11426+ 'centralnotice-notice-is-locked' => 'ව්‍යාපාරය අගුළු ලා ඇත.
1142711427 ඉවත් නොකෙරේ.',
1142811428 'centralnotice-overlap' => 'ව්‍යාපාරය තවත් ව්‍යාපාරයක කාල පරාසය සමග අතිච්ඡාදනය වේ.
1142911429 එකතු නොකෙරේ.',
@@ -11472,7 +11472,7 @@
1147311473 'centralnotice-no-allocation' => 'බැනර වෙන්කර නැත',
1147411474 'centralnotice-allocation-description' => '$3 හි $1.$2 සඳහා බෙැනර වෙන්කිරීම',
1147511475 'centralnotice-percentage' => 'ප්‍රතිශත',
11476 - 'centralnotice-documentwrite-error' => 'බැනරය තුළ document.write() යොදාගත නොහැකිය.
 11476+ 'centralnotice-documentwrite-error' => 'බැනරය තුළ document.write() යොදාගත නොහැකිය.
1147711477 වැඩි විස්තර සඳහා http://meta.wikimedia.org/wiki/Help:CentralNotice බලන්න.',
1147811478 'centralnotice-preferred' => 'වඩා කැමති',
1147911479 'centralnotice-logs' => 'සටහන්',
@@ -11811,7 +11811,7 @@
1181211812 'right-centralnotice-admin' => 'Menaxhoni mesazhet qendrore',
1181311813 'action-centralnotice-admin' => 'menaxhoni mesazhet qendrore',
1181411814 'centralnotice-desc' => 'Ju lejon, të krijoni mesazhe qendrore për Wiki.',
11815 - 'centralnotice-summary' => 'Ky modul ju lejon që të editoni shënimet tuaja të tanishme qendrore.
 11815+ 'centralnotice-summary' => 'Ky modul ju lejon që të editoni shënimet tuaja të tanishme qendrore.
1181611816 Ai gjithashtu mund të përdoret për të shtuar ose hequr njoftime të vjetra.',
1181711817 'centralnotice-query' => 'Ndryshoni mesazhin aktuale',
1181811818 'centralnotice-notice-name' => 'Emri i shënimit',
@@ -11848,11 +11848,11 @@
1184911849 'centralnotice-notice' => 'Mesazh',
1185011850 'centralnotice-notice-heading' => 'Mesazh: $1',
1185111851 'centralnotice-notices' => 'Mesazhet',
11852 - 'centralnotice-notice-exists' => 'Ky mesazhi ekziston.
 11852+ 'centralnotice-notice-exists' => 'Ky mesazhi ekziston.
1185311853 Prandaj mesazhi nuk është shtuar.',
1185411854 'centralnotice-no-language' => 'Për këtë mesaxh nuk është zgjedhur gjuha. Prandaj nuk u shtuar.',
1185511855 'centralnotice-no-project' => 'Për këtë projekt nuk është zgjedhur fushata. Prandaj nuk u shtuar.',
11856 - 'centralnotice-template-exists' => 'Stampa ekziston.
 11856+ 'centralnotice-template-exists' => 'Stampa ekziston.
1185711857 Prandaj stampa nuk është shtuar.',
1185811858 'centralnotice-notice-doesnt-exist' => 'Mesazhi nuk ekziston.',
1185911859 'centralnotice-remove-notice-doesnt-exist' => 'Mesazhi nuk ekziston.
@@ -11874,7 +11874,7 @@
1187511875 'centralnotice-start-time' => 'Koha e fillimit (UTC)',
1187611876 'centralnotice-end-time' => 'Koha e përfundimit',
1187711877 'centralnotice-assigned-templates' => 'Stampat e caktuara',
11878 - 'centralnotice-no-templates' => 'Nuk ka rezultate që përputhen me kërkesën.
 11878+ 'centralnotice-no-templates' => 'Nuk ka rezultate që përputhen me kërkesën.
1187911879 Shtoje prandaj!',
1188011880 'centralnotice-no-templates-assigned' => 'Nuk ka baner të lidhur me fushatën.
1188111881 Shtoni disa!',
@@ -11886,11 +11886,11 @@
1188711887 'centralnotice-weights' => 'Peshësia',
1188811888 'centralnotice-notice-is-locked' => 'Mesazhi është e bllokuar.
1188911889 Kjo nuk mund të hiqet.',
11890 - 'centralnotice-overlap' => 'Fushata përputhet me kohën e një fushate tjetër.
 11890+ 'centralnotice-overlap' => 'Fushata përputhet me kohën e një fushate tjetër.
1189111891 Nuk ka shtim.',
1189211892 'centralnotice-invalid-date-range' => 'Bashkësi e gabuar për datën.
1189311893 Nuk ka përditësim.',
11894 - 'centralnotice-null-string' => 'Nuk mund të shtoni një varg null.
 11894+ 'centralnotice-null-string' => 'Nuk mund të shtoni një varg null.
1189511895 Jo duke shtuar.',
1189611896 'centralnotice-confirm-delete' => 'Jeni i sigurt se doni ta grisni këtë artikull?
1189711897 Ky veprim do të jetë i pakthyeshëm.',
@@ -12384,7 +12384,7 @@
1238512385 'centralnotice-no-allocation' => 'Inga banners tilldelade.',
1238612386 'centralnotice-allocation-description' => 'Bannertilldelning för $1.$2 i $3:',
1238712387 'centralnotice-percentage' => 'Procent',
12388 - 'centralnotice-documentwrite-error' => 'document.write() kan inte användas inom en banner.
 12388+ 'centralnotice-documentwrite-error' => 'document.write() kan inte användas inom en banner.
1238912389 Se http://meta.wikimedia.org/wiki/Help:CentralNotice för mer information.',
1239012390 'centralnotice-preferred' => 'Föredragen',
1239112391 'centralnotice-logs' => 'Loggar',
@@ -13640,7 +13640,7 @@
1364113641 'centralnotice-no-allocation' => 'Немає розміщених банерів.',
1364213642 'centralnotice-allocation-description' => 'Розміщення банеру для $1.$2 в $3:',
1364313643 'centralnotice-percentage' => 'Відсоток',
13644 - 'centralnotice-documentwrite-error' => 'document.write() не може бути використана в банері.
 13644+ 'centralnotice-documentwrite-error' => 'document.write() не може бути використана в банері.
1364513645 Дивіться http://meta.wikimedia.org/wiki/Help:CentralNotice для отримання додаткової інформації.',
1364613646 'centralnotice-preferred' => 'Бажано',
1364713647 'centralnotice-logs' => 'Журнали',
Index: trunk/extensions/CentralNotice/bannerstats.js
@@ -1,5 +1,5 @@
22 /**
3 - * This script retrieves click-thru rates for all the banners in all the campaigns in
 3+ * This script retrieves click-thru rates for all the banners in all the campaigns in
44 * wgCentralNoticeAllocationCampaigns. It then adds the rates to the allocation tables.
55 */
66 $( document ).ready( function () {
Index: trunk/extensions/CentralNotice/CentralNoticePager.php
@@ -7,7 +7,7 @@
88 function __construct( $special ) {
99 parent::__construct( $special );
1010 }
11 -
 11+
1212 /**
1313 * Pull banners from the database
1414 */
@@ -21,9 +21,9 @@
2222 'fields' => array( 'cn_templates.tmp_name', 'cn_templates.tmp_id' ),
2323 'conds' => array( 'cn_assignments.tmp_id IS NULL' ),
2424 'join_conds' => array(
25 - 'cn_assignments' => array(
 25+ 'cn_assignments' => array(
2626 'LEFT JOIN',
27 - "cn_assignments.tmp_id = cn_templates.tmp_id " .
 27+ "cn_assignments.tmp_id = cn_templates.tmp_id " .
2828 "AND cn_assignments.not_id = $noticeId"
2929 )
3030 )
@@ -36,15 +36,15 @@
3737 );
3838 }
3939 }
40 -
 40+
4141 /**
4242 * Generate the content of each table row (1 row = 1 banner)
4343 */
4444 function formatRow( $row ) {
45 -
 45+
4646 // Begin banner row
4747 $htmlOut = Xml::openElement( 'tr' );
48 -
 48+
4949 if ( $this->editable ) {
5050 // Add box
5151 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
@@ -53,8 +53,8 @@
5454 // Weight select
5555 $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ),
5656 Xml::listDropDown( "weight[$row->tmp_id]",
57 - CentralNotice::dropDownList(
58 - wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 )
 57+ CentralNotice::dropDownList(
 58+ wfMsg( 'centralnotice-weight' ), range ( 0, 100, 5 )
5959 ) ,
6060 '',
6161 '25',
@@ -62,12 +62,12 @@
6363 '' )
6464 );
6565 }
66 -
 66+
6767 // Link and Preview
6868 $render = new SpecialBannerLoader();
6969 $render->siteName = 'Wikipedia';
7070 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
71 - try {
 71+ try {
7272 $preview = $render->getHtmlNotice( $row->tmp_name );
7373 } catch ( SpecialBannerLoaderException $e ) {
7474 $preview = wfMsg( 'centralnotice-nopreview' );
@@ -81,13 +81,13 @@
8282 array( 'class' => 'cn-bannerpreview')
8383 )
8484 );
85 -
 85+
8686 // End banner row
8787 $htmlOut .= Xml::closeElement( 'tr' );
88 -
 88+
8989 return $htmlOut;
9090 }
91 -
 91+
9292 /**
9393 * Specify table headers
9494 */
@@ -109,7 +109,7 @@
110110 $htmlOut .= Xml::closeElement( 'tr' );
111111 return $htmlOut;
112112 }
113 -
 113+
114114 /**
115115 * Close table
116116 */
Index: trunk/extensions/CentralNotice/tests/CentralNoticeTest.php
@@ -13,10 +13,10 @@
1414 self::$centralNotice = new CentralNotice;
1515 $noticeName = 'PHPUnitTestCampaign';
1616 $enabled = 0;
17 - $start = array(
18 - "month" => '07',
19 - "day" => '18',
20 - "year" => '2011',
 17+ $start = array(
 18+ "month" => '07',
 19+ "day" => '18',
 20+ "year" => '2011',
2121 "hour" => '23',
2222 "min" => '55',
2323 );
@@ -27,7 +27,7 @@
2828 self::$centralNotice->addCampaign( $noticeName, $enabled, $start, $projects,
2929 $project_languages, $geotargeted, $geo_countries );
3030 $this->campaignId = CentralNotice::getNoticeId( 'PHPUnitTestCampaign' );
31 -
 31+
3232 self::$noticeTemplate = new SpecialNoticeTemplate;
3333 $bannerName = 'PHPUnitTestBanner';
3434 $body = 'testing';
@@ -35,20 +35,20 @@
3636 $displayAccount = 1;
3737 $fundaising = 1;
3838 $landingPages = 'JA1, JA2';
39 - self::$noticeTemplate->addTemplate( $bannerName, $body, $displayAnon, $displayAccount,
 39+ self::$noticeTemplate->addTemplate( $bannerName, $body, $displayAnon, $displayAccount,
4040 $fundaising, $landingPages );
4141 self::$centralNotice->addTemplateTo( 'PHPUnitTestCampaign', 'PHPUnitTestBanner', '25' );
42 -
 42+
4343 self::$centralNoticeDB = new CentralNoticeDB;
4444 }
45 -
 45+
4646 protected function tearDown() {
4747 parent::tearDown();
4848 self::$centralNotice->removeCampaign( 'PHPUnitTestCampaign' );
4949 self::$centralNotice->removeTemplateFor( 'PHPUnitTestCampaign', 'PHPUnitTestBanner' );
5050 self::$noticeTemplate->removeTemplate ( 'PHPUnitTestBanner' );
5151 }
52 -
 52+
5353 public function testDropDownList() {
5454 $text = 'Weight';
5555 $values = range ( 0, 50, 10 );
@@ -56,28 +56,28 @@
5757 "*Weight\n**0\n**10\n**20\n**30\n**40\n**50\n",
5858 CentralNotice::dropDownList( $text, $values ) );
5959 }
60 -
 60+
6161 public function testGetNoticeProjects() {
6262 $this->assertEquals(
6363 array ( 'wikibooks', 'wikipedia' ),
6464 CentralNotice::getNoticeProjects( 'PHPUnitTestCampaign' )
6565 );
6666 }
67 -
 67+
6868 public function testGetNoticeLanguages() {
6969 $this->assertEquals(
7070 array ( 'de', 'en' ),
7171 CentralNotice::getNoticeLanguages( 'PHPUnitTestCampaign' )
7272 );
7373 }
74 -
 74+
7575 public function testGetNoticeCountries() {
7676 $this->assertEquals(
7777 array ( 'AF', 'US' ),
7878 CentralNotice::getNoticeCountries( 'PHPUnitTestCampaign' )
7979 );
8080 }
81 -
 81+
8282 public function testGetCampaignBanners() {
8383 $campaignId = CentralNotice::getNoticeId( 'PHPUnitTestCampaign' );
8484 $this->assertEquals(
@@ -85,9 +85,9 @@
8686 json_encode( CentralNoticeDB::getCampaignBanners( $campaignId ) )
8787 );
8888 }
89 -
 89+
9090 public function testGetCampaignSettings() {
91 - $campaignArray = array(
 91+ $campaignArray = array(
9292 'enabled' => 0,
9393 'end' => 20110818235500,
9494 'geo' => 1,
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -403,9 +403,9 @@
404404 $eBannerName = htmlspecialchars( $bannerName );
405405 $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 'tmp_name' => $eBannerName ) );
406406 if ( $row ) {
407 - return true;
 407+ return true;
408408 } else {
409 - return false;
 409+ return false;
410410 }
411411 }
412412

Status & tagging log