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

Revision: 75671
Author:   reedy
Date:     2010-10-29 20:45:31 +0000 (Fri, 29 Oct 2010)
Log Message:
-----------
Whiles to foreach

Remove unused globals and variables

Modified Paths:
--------------
    trunk/extensions/ContactPageFundraiser/SpecialContact.php
    trunk/extensions/ContributionReporting/ContributionHistory_body.php
    trunk/extensions/ContributionReporting/ContributionStatistics_body.php
    trunk/extensions/ContributionReporting/ContributionTotal_body.php
    
trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php
    trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
    trunk/extensions/ContributionTracking/ContributionTracking.php
    trunk/extensions/ContributionTracking/ContributionTracking_body.php

Modified: trunk/extensions/ContactPageFundraiser/SpecialContact.php
===================================================================
--- trunk/extensions/ContactPageFundraiser/SpecialContact.php   2010-10-29 
20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContactPageFundraiser/SpecialContact.php   2010-10-29 
20:45:31 UTC (rev 75671)
@@ -27,7 +27,6 @@
         * Constructor
         */
        function __construct() {
-               global $wgOut;
                parent::__construct( 'Contact', '', true );
        }
 
@@ -38,7 +37,6 @@
        function execute( $par ) {
                global $wgUser, $wgOut, $wgRequest, $wgEnableEmail, 
$wgContactUser;
 
-               wfLoadExtensionMessages( 'ContactPageFundraiser' );
                $fname = "SpecialContact::execute";
 
                if ( $wgRequest->wasPosted() ) {
@@ -56,7 +54,7 @@
                        $form['url']       = $wgRequest->getVal('url');
                        $form['country']   = $wgRequest->getVal('country');
                        $form['citytown']  = $wgRequest->getVal('city-town');
-                       $form['provstat']  = $wgRequest->getVal('prov-state');  
+                       $form['provstat']  = $wgRequest->getVal('prov-state');  
                        $form['story']     = $wgRequest->getVal('story');
                        $form['followup']  = $wgRequest->getVal('follow-up');
 
@@ -67,57 +65,53 @@
                        $f->setText( $text );
                        $f->doSubmit();
                }
+               if( !$wgEnableEmail || !$wgContactUser ) {
+                       $wgOut->showErrorPage( "nosuchspecialpage", 
"nospecialpagetext" );
+                       return;
+               }
 
-               else {
-                               
-                       }               
-                       if( !$wgEnableEmail || !$wgContactUser ) {
-                               $wgOut->showErrorPage( "nosuchspecialpage", 
"nospecialpagetext" );
-                               return;
-                       }
+               $action = $wgRequest->getVal( 'action' );
 
-                       $action = $wgRequest->getVal( 'action' );
+               $nu = User::newFromName( $wgContactUser );
+               if( is_null( $nu ) || !$nu->canReceiveEmail() ) {
+                       wfDebug( "Target is invalid user or can't receive.\n" );
+                       $wgOut->showErrorPage( "noemailtitle", "noemailtext" );
+                       return;
+               }
 
-                       $nu = User::newFromName( $wgContactUser );
-                       if( is_null( $nu ) || !$nu->canReceiveEmail() ) {
-                               wfDebug( "Target is invalid user or can't 
receive.\n" );
-                               $wgOut->showErrorPage( "noemailtitle", 
"noemailtext" );
-                               return;
-                       }
+               $f = new EmailContactForm( $nu );
 
-                       $f = new EmailContactForm( $nu );
+               if ( "success" == $action ) {
+                       wfDebug( "$fname: success.\n" );
+                       $f->showSuccess( );
+               } else if ( "submit" == $action && $wgRequest->wasPosted() && 
$f->hasAllInfo() ) {
+                       $token = $wgRequest->getVal( 'wpEditToken' );
 
-                       if ( "success" == $action ) {
-                               wfDebug( "$fname: success.\n" );
-                               $f->showSuccess( );
-                       } else if ( "submit" == $action && 
$wgRequest->wasPosted() && $f->hasAllInfo() ) {
-                               $token = $wgRequest->getVal( 'wpEditToken' );
-
-                               if( $wgUser->isAnon() ) {
-                                       # Anonymous users may not have a session
-                                       # open. Check for suffix anyway.
-                                       $tokenOk = ( EDIT_TOKEN_SUFFIX == 
$token );
-                               } else {
-                                       $tokenOk = $wgUser->matchEditToken( 
$token );
-                               }
-
-                               if ( !$tokenOk ) {
-                                       wfDebug( "$fname: bad token 
(".($wgUser->isAnon()?'anon':'user')."): $token\n" );
-                                       $wgOut->addWikiText( wfMsg( 
'sessionfailure' ) );
-                                       $f->showForm();
-                               } else if ( !$f->passCaptcha() ) {
-                                       wfDebug( "$fname: captcha failed" );
-                                       $wgOut->addWikiText( wfMsg( 
'contactpage-captcha-failed' ) ); //TODO: provide a message for this!
-                                       $f->showForm();
-                               } else {
-                                       wfDebug( "$fname: submit\n" );
-                                       $f->doSubmit();
-                               }
+                       if( $wgUser->isAnon() ) {
+                               # Anonymous users may not have a session
+                               # open. Check for suffix anyway.
+                               $tokenOk = ( EDIT_TOKEN_SUFFIX == $token );
                        } else {
-                               wfDebug( "$fname: form\n" );
+                               $tokenOk = $wgUser->matchEditToken( $token );
+                       }
+
+                       if ( !$tokenOk ) {
+                               wfDebug( "$fname: bad token 
(".($wgUser->isAnon()?'anon':'user')."): $token\n" );
+                               $wgOut->addWikiText( wfMsg( 'sessionfailure' ) 
);
                                $f->showForm();
+                       } else if ( !$f->passCaptcha() ) {
+                               wfDebug( "$fname: captcha failed" );
+                               $wgOut->addWikiText( wfMsg( 
'contactpage-captcha-failed' ) ); //TODO: provide a message for this!
+                               $f->showForm();
+                       } else {
+                               wfDebug( "$fname: submit\n" );
+                               $f->doSubmit();
                        }
+               } else {
+                       wfDebug( "$fname: form\n" );
+                       $f->showForm();
                }
+       }
 }
 
 /**
@@ -135,7 +129,6 @@
         */
        function __construct( $target ) {
                global $wgRequest, $wgUser;
-               global $wgCaptchaClass;
 
                $this->target = $target;
                $this->text = $wgRequest->getText( 'wpText' );
@@ -284,8 +277,8 @@
 
        function doSubmit( ) {
                global $wgOut, $wgRequest;
-               global $wgEnableEmail, $wgUserEmailUseReplyTo, 
$wgEmergencyContact;
-               global $wgContactUser, $wgContactSender, $wgContactSenderName;
+               global $wgUserEmailUseReplyTo, $wgEmergencyContact;
+               global $wgContactSender, $wgContactSenderName;
 
                $csender = $wgContactSender ? $wgContactSender : 
$wgEmergencyContact;
                $cname = $wgContactSenderName;

Modified: trunk/extensions/ContributionReporting/ContributionHistory_body.php
===================================================================
--- trunk/extensions/ContributionReporting/ContributionHistory_body.php 
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionReporting/ContributionHistory_body.php 
2010-10-29 20:45:31 UTC (rev 75671)
@@ -16,9 +16,6 @@
                $offset = $wgRequest->getIntOrNull( 'offset' );
                $show = 100;
                
-               wfLoadExtensionMessages( 'ContributionReporting' );
-               wfLoadExtensionMessages( 'ContributionReporting', $language );
-               
                $this->setHeaders();
                
                $db = efContributionReportingConnection();
@@ -109,8 +106,8 @@
                                'LIMIT' => $show
                        )
                );
-               $alt = TRUE;
-               while ( $row = $res->fetchRow() ) {
+               $alt = true;
+               foreach ( $res as $row ) {
             if ( $this->isTiny( $row ) ) {
                 continue; // Skip over micro payments generally < $1
             }

Modified: trunk/extensions/ContributionReporting/ContributionStatistics_body.php
===================================================================
--- trunk/extensions/ContributionReporting/ContributionStatistics_body.php      
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionReporting/ContributionStatistics_body.php      
2010-10-29 20:45:31 UTC (rev 75671)
@@ -20,13 +20,9 @@
        public function __construct() {
                // Initialize special page
                parent::__construct( 'ContributionStatistics' );
-               
-               // Internationalization
-               wfLoadExtensionMessages( 'ContributionReporting' );
        }
        
        public function execute( $sub ) {
-               global $wgRequest, $wgOut, $wgUser;
                global $egContributionStatisticsViewDays;
                
                $this->evalDateRange();
@@ -124,8 +120,7 @@
                
                $months = $this->getMonthlyTotals();
                $total = $this->getTotalContributions();
-               
-               $msg = '';
+
                if ( $this->mMode == 'range' ) {
                        $msg = wfMsgExt( 'contribstats-month-range-totals', 
array( 'parsemag' ), $wgLang->formatNum( count( $months ) ) );
                } else {
@@ -216,8 +211,7 @@
        
        public function showContributionBreakdown() {
                global $wgOut, $wgLang;
-               
-               $msg = '';
+
                if ( $this->mMode == 'range' ) {
                        $msg = wfMsg( 
'contribstats-contribution-range-breakdown',
                                $wgLang->date( wfTimestamp( TS_MW, 
$this->mStartDate ) ),
@@ -252,7 +246,6 @@
                         wfMsg( 'contribstats-value-over', $wgLang->formatNum( 
1000 ) ) => array( 1000, 999999999999.99 ),
                );
                foreach( $list as $label => $range ) {
-                       $data = array();
                        if( isset( $range[1] ) ) {
                                $data = $this->getNumContributionsWithin( 
$range[0], $range[1] );
                        } else {
@@ -301,7 +294,7 @@
                
                // Build day/value array
                $totals = array();
-               while ( $row = $dbr->fetchRow( $res ) ) {
+               foreach ( $res as $row ) {
                        /*
                        $median = $dbr->selectField( 'public_reporting',
                                array( 'converted_amount' ),
@@ -347,7 +340,7 @@
                
                // Build day/value array
                $totals = array();
-               while ( $row = $dbr->fetchRow( $res ) ) {
+               foreach ( $res as $row ) {
                        $median = $dbr->selectField( 'public_reporting',
                                array( 'converted_amount' ),
                                array(
@@ -390,7 +383,7 @@
                );
                
                $totals = array();
-               while ( $row = $dbr->fetchRow( $res ) ) {
+               foreach ( $res as $row ) {
                        $median = $dbr->selectField( 'public_reporting',
                                array( 'converted_amount' ),
                                array_merge(

Modified: trunk/extensions/ContributionReporting/ContributionTotal_body.php
===================================================================
--- trunk/extensions/ContributionReporting/ContributionTotal_body.php   
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionReporting/ContributionTotal_body.php   
2010-10-29 20:45:31 UTC (rev 75671)
@@ -8,8 +8,6 @@
        function execute( $par ) {
                global $wgRequest, $wgOut;
 
-               wfLoadExtensionMessages( 'ContributionReporting' );
-
                $this->setHeaders();
 
                # Get request data from, e.g.

Modified: 
trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php
===================================================================
--- 
trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php  
    2010-10-29 20:44:26 UTC (rev 75670)
+++ 
trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php  
    2010-10-29 20:45:31 UTC (rev 75671)
@@ -15,9 +15,6 @@
        public function __construct() {
                // Initialize special page
                parent::__construct( 'ContributionTrackingStatistics' );
-
-               // Internationalization
-               wfLoadExtensionMessages( 'ContributionReporting' );
        }
 
        public function execute( $sub ) {
@@ -75,10 +72,6 @@
        // Generic Table Display for Totals
        // FORMAT: 1 daily, 2 weekly, 3 Monthly, 4 Combined
        public function showTotalsForRange( $range, $format ) {
-               global $wgOut;
-               global $wgAllowedTempaltes, $wgAllowedSupport, 
-                       $wgAllowedPaymentMethod, 
$wgContributionReportingBaseURL;
-
                list( $start, $end ) = $range;
                $current = $end;
                
@@ -121,7 +114,7 @@
 
        public function createTable( $totals ) {
                // Table headers
-               global $wgOut, $wgAllowedTemplates, $wgAllowedSupport;
+               global $wgAllowedTemplates, $wgAllowedSupport;
                global $wgAllowedPaymentMethod, $wgContributionReportingBaseURL;
 
                $htmlOut = Xml::openElement( 'table',
@@ -145,11 +138,16 @@
                foreach( $totals as $template ) {
                        //grab info from utm_src, 'unpack' template, landing 
page, donation page thus far
                        $expanded_template = explode(".", $template[0]);
-                       if(!isset($expanded_template[1])){ 
$expanded_template[1] = "";}
-                       if(!isset($expanded_template[2])){ 
$expanded_template[2] = "";}
+                       if(!isset($expanded_template[1])) {
+                               $expanded_template[1] = "";
+                       }
+                       if(!isset($expanded_template[2])) {
+                               $expanded_template[2] = "";
+                       }
 
-                       if ( ! in_array($expanded_template[0], 
$wgAllowedTemplates ) )
+                       if ( ! in_array($expanded_template[0], 
$wgAllowedTemplates ) ) {
                                continue;
+                       }
                        if( ($expanded_template[1] != "") && (! 
in_array($expanded_template[1], $wgAllowedSupport)) ){
                                continue;
                        }
@@ -250,7 +248,7 @@
 
                );
 
-               while ( $row = $dbr->fetchRow( $res ) ) {
+               foreach ( $res as $row ) {
                        $result[] = array(
                                        $row[0],
                                        $row[1],

Modified: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
===================================================================
--- trunk/extensions/ContributionReporting/FundraiserStatistics_body.php        
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionReporting/FundraiserStatistics_body.php        
2010-10-29 20:45:31 UTC (rev 75671)
@@ -12,7 +12,6 @@
 
        public function __construct() {
                parent::__construct( 'FundraiserStatistics' );
-               wfLoadExtensionMessages( 'ContributionReporting' );
        }
        
        public function execute( $sub ) {
@@ -88,7 +87,7 @@
                }
                // Scale factors
                foreach ( $charts as $name => $chart ) {                        
-                       $charts[$name]['factor'] = $factor = 300 / 
$chart['max'];
+                       $charts[$name]['factor'] = 300 / $chart['max'];
                }
                // HTML-time!
                $view = 0;

Modified: trunk/extensions/ContributionTracking/ContributionTracking.php
===================================================================
--- trunk/extensions/ContributionTracking/ContributionTracking.php      
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionTracking/ContributionTracking.php      
2010-10-29 20:45:31 UTC (rev 75671)
@@ -26,7 +26,6 @@
 //this only works if contribution tracking is inside a mediawiki DB, which 
typically it isn't.
 //$wgHooks['LoadExtensionSchemaUpdates'][] = 
'efContributionTrackingLoadUpdates'; 
 
-
 $wgContributionTrackingDBserver = $wgDBserver;
 $wgContributionTrackingDBname = $wgDBname;
 $wgContributionTrackingDBuser = $wgDBuser;

Modified: trunk/extensions/ContributionTracking/ContributionTracking_body.php
===================================================================
--- trunk/extensions/ContributionTracking/ContributionTracking_body.php 
2010-10-29 20:44:26 UTC (rev 75670)
+++ trunk/extensions/ContributionTracking/ContributionTracking_body.php 
2010-10-29 20:45:31 UTC (rev 75671)
@@ -29,14 +29,11 @@
 
        function execute( $language ) {
                global $wgRequest, $wgOut;
-               wfLoadExtensionMessages( 'ContributionTracking' );
                
                if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
                        $language = 'en';
                }
                $this->lang = Language::factory( $language );
-               wfLoadExtensionMessages( 'ContributionTracking' );
-               wfLoadExtensionMessages( 'ContributionTracking', $language );
                
                $this->setHeaders();
                


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to