http://www.mediawiki.org/wiki/Special:Code/MediaWiki/75674
Revision: 75674 Author: reedy Date: 2010-10-29 21:08:48 +0000 (Fri, 29 Oct 2010) Log Message: ----------- Nuke unused globals Fix a wrong usage of $this->viewPage to $viewPage Modified Paths: -------------- trunk/extensions/CentralNotice/CentralNotice.php trunk/extensions/CentralNotice/SpecialBannerAllocation.php trunk/extensions/CentralNotice/SpecialBannerController.php trunk/extensions/CentralNotice/SpecialCentralNotice.php trunk/extensions/CentralNotice/SpecialNoticeTemplate.php trunk/extensions/CentralNotice/TemplatePager.php Modified: trunk/extensions/CentralNotice/CentralNotice.php =================================================================== --- trunk/extensions/CentralNotice/CentralNotice.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/CentralNotice.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -142,7 +142,7 @@ } function efCentralNoticeLoader( $out, $skin ) { - global $wgUser, $wgOut, $wgCentralDBname, $wgScript; + global $wgOut; // Include '.js' to exempt script from squid cache override $centralLoader = SpecialPage::getTitleFor( 'BannerController' )->getLocalUrl( 'cache=/cn.js' ); Modified: trunk/extensions/CentralNotice/SpecialBannerAllocation.php =================================================================== --- trunk/extensions/CentralNotice/SpecialBannerAllocation.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/SpecialBannerAllocation.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -19,7 +19,7 @@ * Handle different types of page requests */ function execute( $sub ) { - global $wgOut, $wgUser, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode; + global $wgOut, $wgRequest, $wgExtensionAssetsPath, $wgNoticeProjects, $wgLanguageCode; if ( $wgRequest->wasPosted() ) { $this->project = $wgRequest->getText( 'project', 'wikipedia' ); Modified: trunk/extensions/CentralNotice/SpecialBannerController.php =================================================================== --- trunk/extensions/CentralNotice/SpecialBannerController.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/SpecialBannerController.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -13,8 +13,7 @@ } function execute( $par ) { - global $wgOut, $wgRequest; - global $wgNoticeLang, $wgNoticeProject; + global $wgOut; $wgOut->disable(); $this->sendHeaders(); @@ -26,7 +25,6 @@ } else { echo $content; } - } /** Modified: trunk/extensions/CentralNotice/SpecialCentralNotice.php =================================================================== --- trunk/extensions/CentralNotice/SpecialCentralNotice.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/SpecialCentralNotice.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -203,7 +203,7 @@ $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'cn_notices', 'not_name', null, __METHOD__ ); $notices = array(); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $notices[] = $row->not_name; } return $notices; @@ -350,7 +350,7 @@ $htmlOut .= $this->tableRow( $headers, 'th' ); // Table rows - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $fields = array(); // Name @@ -362,7 +362,6 @@ $fields[] = htmlspecialchars( $this->getProjectName( $row->not_project ) ); // Languages - $project_langs = array(); $project_langs = $this->getNoticeLanguages( $row->not_name ); $language_count = count( $project_langs ); $languageList = ''; @@ -429,7 +428,7 @@ $htmlOut .= Xml::closeElement( 'table' ); if ( $this->editable ) { - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); + $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); $htmlOut .= Xml::openElement( 'div', array( 'class' => 'cn-buttons' ) ); $htmlOut .= Xml::submitButton( wfMsg( 'centralnotice-modify' ), array( @@ -703,7 +702,7 @@ } } if ( $this->editable ) { - $htmlOut .= Xml::hidden( 'authtoken', $wgUser->editToken() ); + $htmlOut .= Html::hidden( 'authtoken', $wgUser->editToken() ); // Submit button $htmlOut .= Xml::tags( 'div', @@ -917,7 +916,7 @@ wfMsg ( "centralnotice-templates" ) ); // Table rows - while ( $row = $dbr->fetchObject( $res ) ) { + foreach( $res as $row ) { $htmlOut .= Xml::openElement( 'tr' ); @@ -1076,8 +1075,6 @@ } function addNotice( $noticeName, $enabled, $start, $project_name, $project_languages, $geotargeted, $geo_countries ) { - global $wgOut; - if ( $this->noticeExists( $noticeName ) ) { $this->showError( 'centralnotice-notice-exists' ); return; @@ -1136,7 +1133,6 @@ } function removeNotice( $noticeName ) { - global $wgOut; $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'cn_notices', 'not_name, not_locked', @@ -1163,8 +1159,6 @@ } function addTemplateTo( $noticeName, $templateName, $weight ) { - global $wgOut; - $dbr = wfGetDB( DB_SLAVE ); $eNoticeName = htmlspecialchars ( $noticeName ); @@ -1261,8 +1255,6 @@ } function updateNoticeDate( $noticeName, $start, $end ) { - global $wgOut; - $dbr = wfGetDB( DB_SLAVE ); // Start/end don't line up @@ -1295,8 +1287,6 @@ * Update the enabled/disabled state of a campaign */ private function updateEnabled( $noticeName, $isEnabled ) { - global $wgOut; - if ( !$this->noticeExists( $noticeName ) ) { $this->showError( 'centralnotice-doesnt-exist' ); } else { @@ -1329,8 +1319,6 @@ * Update the geotargeted/not geotargeted state of a campaign */ function updateGeotargeted( $noticeName, $isGeotargeted ) { - global $wgOut; - if ( !$this->noticeExists( $noticeName ) ) { $this->showError( 'centralnotice-doesnt-exist' ); } else { @@ -1346,8 +1334,6 @@ * Update the locked/unlocked state of a campaign */ function updateLock( $noticeName, $isLocked ) { - global $wgOut; - if ( !$this->noticeExists( $noticeName ) ) { $this->showError( 'centralnotice-doesnt-exist' ); } else { @@ -1457,7 +1443,6 @@ $dbw->begin(); // Get the previously assigned languages - $oldLanguages = array(); $oldLanguages = $this->getNoticeLanguages( $notice ); // Get the notice id @@ -1638,7 +1623,7 @@ $render->siteName = 'Wikipedia'; $render->language = $this->mRequest->getVal( 'wpUserLanguage' ); $htmlOut .= Xml::tags( 'td', array( 'valign' => 'top' ), - $this->getSkin()->makeLinkObj( $this->viewPage, + $this->getSkin()->makeLinkObj( $viewPage, htmlspecialchars( $row->tmp_name ), 'template=' . urlencode( $row->tmp_name ) ) . Xml::fieldset( wfMsg( 'centralnotice-preview' ), @@ -1679,7 +1664,6 @@ * Close table */ function getEndBody() { - global $wgUser; $htmlOut = ''; $htmlOut .= Xml::closeElement( 'table' ); return $htmlOut; Modified: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php =================================================================== --- trunk/extensions/CentralNotice/SpecialNoticeTemplate.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/SpecialNoticeTemplate.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -618,8 +618,6 @@ } private function removeTemplate ( $name ) { - global $wgOut; - $id = $this->getTemplateId( $name ); $dbr = wfGetDB( DB_SLAVE ); $res = $dbr->select( 'cn_assignments', 'asn_id', array( 'tmp_id' => $id ), __METHOD__ ); @@ -647,8 +645,6 @@ * Create a new banner */ private function addTemplate( $name, $body, $displayAnon, $displayAccount ) { - global $wgOut; - if ( $body == '' || $name == '' ) { $this->showError( 'centralnotice-null-string' ); return; @@ -692,8 +688,6 @@ * Update a banner */ private function editTemplate( $name, $body, $displayAnon, $displayAccount ) { - global $wgOut; - if ( $body == '' || $name == '' ) { $this->showError( 'centralnotice-null-string' ); return; @@ -772,7 +766,6 @@ * Find all message fields set for a banner */ private function findFields( $template ) { - $messages = array(); $body = wfMsg( "Centralnotice-template-{$template}" ); // Generate list of message fields from parsing the body Modified: trunk/extensions/CentralNotice/TemplatePager.php =================================================================== --- trunk/extensions/CentralNotice/TemplatePager.php 2010-10-29 21:00:18 UTC (rev 75673) +++ trunk/extensions/CentralNotice/TemplatePager.php 2010-10-29 21:08:48 UTC (rev 75674) @@ -54,7 +54,6 @@ } // Link and Preview - $viewPage = SpecialPage::getTitleFor( 'NoticeTemplate', 'view' ); $render = new SpecialBannerLoader(); $render->siteName = 'Wikipedia'; $render->language = $this->mRequest->getVal( 'wpUserLanguage' ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs