r76147 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76146‎ | r76147 | r76148 >
Date:22:00, 5 November 2010
Author:tomasz
Status:ok
Tags:
Comment:
Merging in 73963, 75674, 75908, 75889
Modified paths:
  • /branches/wmf/1.16wmf4/extensions/CentralNotice (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerAllocation.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerController.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)
  • /branches/wmf/1.16wmf4/extensions/CentralNotice/TemplatePager.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.16wmf4/extensions/CentralNotice/CentralNotice.php
@@ -28,10 +28,11 @@
2929 $wgNoticeInfrastructure = true;
3030
3131 // The name of the database which hosts the centralized campaign data
32 -$wgCentralDBname = 'metawiki';
 32+$wgCentralDBname = '';
3333
3434 // The path to Special Pages on the wiki that hosts the CentralNotice infrastructure
35 -$wgCentralPagePath = 'http://meta.wikimedia.org/wiki/';
 35+// For example 'http://meta.wikimedia.org/wiki/'
 36+$wgCentralPagePath = '';
3637
3738 // Enable the loader itself
3839 // Allows to control the loader visibility, without destroying infrastructure
@@ -151,7 +152,7 @@
152153 }
153154
154155 function efCentralNoticeLoader( $out, $skin ) {
155 - global $wgUser, $wgOut, $wgCentralDBname;
 156+ global $wgOut;
156157
157158 // Include '.js' to exempt script from squid cache override
158159 $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' );
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/TemplatePager.php
@@ -54,7 +54,6 @@
5555 }
5656
5757 // Link and Preview
58 - $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
5958 $render = new SpecialBannerLoader();
6059 $render->siteName = 'Wikipedia';
6160 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialCentralNotice.php
@@ -204,7 +204,7 @@
205205 $dbr = wfGetDB( DB_SLAVE );
206206 $res = $dbr->select( 'cn_notices', 'not_name', null, __METHOD__ );
207207 $notices = array();
208 - while ( $row = $dbr->fetchObject( $res ) ) {
 208+ foreach ( $res as $row ) {
209209 $notices[] = $row->not_name;
210210 }
211211 return $notices;
@@ -351,7 +351,7 @@
352352 $htmlOut .= $this->tableRow( $headers, 'th' );
353353
354354 // Table rows
355 - while ( $row = $dbr->fetchObject( $res ) ) {
 355+ foreach ( $res as $row ) {
356356 $fields = array();
357357
358358 // Name
@@ -363,7 +363,6 @@
364364 $fields[] = htmlspecialchars( $this->getProjectName( $row->not_project ) );
365365
366366 // Languages
367 - $project_langs = array();
368367 $project_langs = $this->getNoticeLanguages( $row->not_name );
369368 $language_count = count( $project_langs );
370369 $languageList = '';
@@ -433,7 +432,7 @@
434433 $htmlOut .= Xml::closeElement( 'table' );
435434
436435 if ( $this->editable ) {
437 - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() );
 436+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
438437 $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-buttons' ) );
439438 $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-modify' ),
440439 array(
@@ -716,7 +715,7 @@
717716 }
718717 }
719718 if ( $this->editable ) {
720 - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() );
 719+ $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() );
721720
722721 // Submit button
723722 $htmlOut .= Xml::tags( 'div',
@@ -953,7 +952,7 @@
954953 wfMsg ( "centralnotice-templates" ) );
955954
956955 // Table rows
957 - while ( $row = $dbr->fetchObject( $res ) ) {
 956+ foreach( $res as $row ) {
958957
959958 $htmlOut .= Xml::openElement( 'tr' );
960959
@@ -1118,8 +1117,6 @@
11191118 function addNotice( $noticeName, $enabled, $start, $project_name,
11201119 $project_languages, $geotargeted, $geo_countries )
11211120 {
1122 - global $wgOut;
1123 -
11241121 if ( $this->noticeExists( $noticeName ) ) {
11251122 $this->showError( 'centralnotice-notice-exists' );
11261123 return;
@@ -1185,7 +1182,6 @@
11861183 }
11871184
11881185 function removeNotice( $noticeName ) {
1189 - global $wgOut;
11901186 $dbr = wfGetDB( DB_SLAVE );
11911187
11921188 $res = $dbr->select( 'cn_notices', 'not_name, not_locked',
@@ -1212,8 +1208,6 @@
12131209 }
12141210
12151211 function addTemplateTo( $noticeName, $templateName, $weight ) {
1216 - global $wgOut;
1217 -
12181212 $dbr = wfGetDB( DB_SLAVE );
12191213
12201214 $eNoticeName = htmlspecialchars ( $noticeName );
@@ -1312,8 +1306,6 @@
13131307 }
13141308
13151309 function updateNoticeDate( $noticeName, $start, $end ) {
1316 - global $wgOut;
1317 -
13181310 $dbr = wfGetDB( DB_SLAVE );
13191311
13201312 // Start/end don't line up
@@ -1346,8 +1338,6 @@
13471339 * Update the enabled/disabled state of a campaign
13481340 */
13491341 private function updateEnabled( $noticeName, $isEnabled ) {
1350 - global $wgOut;
1351 -
13521342 if ( !$this->noticeExists( $noticeName ) ) {
13531343 $this->showError( 'centralnotice-doesnt-exist' );
13541344 } else {
@@ -1380,8 +1370,6 @@
13811371 * Update the geotargeted/not geotargeted state of a campaign
13821372 */
13831373 function updateGeotargeted( $noticeName, $isGeotargeted ) {
1384 - global $wgOut;
1385 -
13861374 if ( !$this->noticeExists( $noticeName ) ) {
13871375 $this->showError( 'centralnotice-doesnt-exist' );
13881376 } else {
@@ -1397,8 +1385,6 @@
13981386 * Update the locked/unlocked state of a campaign
13991387 */
14001388 function updateLock( $noticeName, $isLocked ) {
1401 - global $wgOut;
1402 -
14031389 if ( !$this->noticeExists( $noticeName ) ) {
14041390 $this->showError( 'centralnotice-doesnt-exist' );
14051391 } else {
@@ -1519,7 +1505,6 @@
15201506 $dbw->begin();
15211507
15221508 // Get the previously assigned languages
1523 - $oldLanguages = array();
15241509 $oldLanguages = $this->getNoticeLanguages( $notice );
15251510
15261511 // Get the notice id
@@ -1709,7 +1694,6 @@
17101695 }
17111696
17121697 // Link and Preview
1713 - $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' );
17141698 $render = new SpecialBannerLoader();
17151699 $render->siteName = 'Wikipedia';
17161700 $render->language = $this->mRequest->getVal( 'wpUserLanguage' );
@@ -1755,7 +1739,6 @@
17561740 * Close table
17571741 */
17581742 function getEndBody() {
1759 - global $wgUser;
17601743 $htmlOut = '';
17611744 $htmlOut .= Xml::closeElement( 'table' );
17621745 return $htmlOut;
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerController.php
@@ -13,8 +13,7 @@
1414 }
1515
1616 function execute( $par ) {
17 - global $wgOut, $wgRequest;
18 - global $wgNoticeLang, $wgNoticeProject;
 17+ global $wgOut;
1918
2019 $wgOut->disable();
2120 $this->sendHeaders();
@@ -26,7 +25,6 @@
2726 } else {
2827 echo $content;
2928 }
30 -
3129 }
3230
3331 /**
@@ -75,7 +73,7 @@
7674 var geoLocation = Geo.country; // pull the geo info
7775 }
7876 var bannerListQuery = $.param( { 'language': wgContentLanguage, 'project': wgNoticeProject, 'country': geoLocation } );
79 - var bannerListURL = wgScript + '?title=' + wgFormattedNamespaces[-1] + ':BannerListLoader&cache=/cn.js&' + bannerListQuery;
 77+ var bannerListURL = wgScript + '?title=' + encodeURIComponent(wgFormattedNamespaces[-1]) + ':BannerListLoader&cache=/cn.js&' + bannerListQuery;
8078 var request = $.ajax( {
8179 url: bannerListURL,
8280 dataType: 'json',
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialBannerAllocation.php
@@ -19,7 +19,7 @@
2020 * Handle different types of page requests
2121 */
2222 function execute( $sub ) {
23 - global $wgOut, $wgUser, $wgRequest, $wgScriptPath, $wgNoticeProjects, $wgLanguageCode;
 23+ global $wgOut, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode;
2424
2525 if ( $wgRequest->wasPosted() ) {
2626 $this->project = $wgRequest->getText( 'project', 'wikipedia' );
Index: branches/wmf/1.16wmf4/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -680,8 +680,6 @@
681681 }
682682
683683 private function removeTemplate ( $name ) {
684 - global $wgOut;
685 -
686684 $id = $this->getTemplateId( $name );
687685 $dbr = wfGetDB( DB_SLAVE );
688686 $res = $dbr->select( 'cn_assignments', 'asn_id', array( 'tmp_id' => $id ), __METHOD__ );
@@ -709,8 +707,6 @@
710708 * Create a new banner
711709 */
712710 private function addTemplate( $name, $body, $displayAnon, $displayAccount ) {
713 - global $wgOut;
714 -
715711 if ( $body == '' || $name == '' ) {
716712 $this->showError( 'centralnotice-null-string' );
717713 return;
@@ -754,8 +750,6 @@
755751 * Update a banner
756752 */
757753 private function editTemplate( $name, $body, $displayAnon, $displayAccount ) {
758 - global $wgOut;
759 -
760754 if ( $body == '' || $name == '' ) {
761755 $this->showError( 'centralnotice-null-string' );
762756 return;
@@ -834,7 +828,6 @@
835829 * Find all message fields set for a banner
836830 */
837831 private function findFields( $template ) {
838 - $messages = array();
839832 $body = wfMsg( "Centralnotice-template-{$template}" );
840833
841834 // Generate list of message fields from parsing the body
Property changes on: branches/wmf/1.16wmf4/extensions/CentralNotice
___________________________________________________________________
Modified: svn:mergeinfo
842835 Merged /trunk/extensions/CentralNotice:r73963,75674,75889,76145

Status & tagging log