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

Revision: 75675
Author:   reedy
Date:     2010-10-29 21:16:05 +0000 (Fri, 29 Oct 2010)
Log Message:
-----------
Better tab some of the code, fix some unclear code up

Modified Paths:
--------------
    trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
    trunk/extensions/DonationInterface/donate_interface/donate_interface.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php
    
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
    trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php

Modified: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
===================================================================
--- trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php        
2010-10-29 21:08:48 UTC (rev 75674)
+++ trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php        
2010-10-29 21:16:05 UTC (rev 75675)
@@ -29,25 +29,24 @@
 * Create <donate /> tag to include landing page donation form
 */
 function efStompSetup( &$parser ) {
-            global $wgParser, ;
+       global $wgParser;
 
-               // redundant and causes Fatal Error
-            // $parser->disableCache();
+       // redundant and causes Fatal Error
+       // $parser->disableCache();
 
-            $wgParser->setHook( 'stomp', 'efStompTest' );
+       $wgParser->setHook( 'stomp', 'efStompTest' );
 
-       return true;
+       return true;
 }
 
 function efStompTest( $input, $args, &$parser ) {
+       $parser->disableCache();
 
-        $parser->disableCache();
+       $output = "STOMP Test page";
 
-        $output = "STOMP Test page";
+       wfRunHooks( 'gwStomp', array( &$transaction ) );
 
-        wfRunHooks( 'gwStomp', array( &$transaction ) );
-
-        return $output;
+       return $output;
 }
 
 /**
@@ -61,62 +60,62 @@
 * Hook to send transaction information to ActiveMQ server
 */
 function sendSTOMP( $transaction ) {
-        global $wgStompServer, $wgStompQueueName;
+       global $wgStompServer, $wgStompQueueName;
 
-        $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test';
+       $queueName = isset ( $wgStompQueueName ) ? $wgStompQueueName : 'test';
 
-        // include a library
-        require_once( "Stomp.php" );
+       // include a library
+       require_once( "Stomp.php" );
 
-        $message = json_encode( createQueueMessage( $transaction ) );
+       $message = json_encode( createQueueMessage( $transaction ) );
 
-        // make a connection
-        $con = new Stomp( $wgStompServer );
+       // make a connection
+       $con = new Stomp( $wgStompServer );
 
-        // connect
-        $con->connect();
+       // connect
+       $con->connect();
 
-        // send a message to the queue
-        $result = $con->send( "/queue/$queueName", $message, array( 
'persistent' => 'true' ) );
+       // send a message to the queue
+       $result = $con->send( "/queue/$queueName", $message, array( 
'persistent' => 'true' ) );
 
-        if ( !$result ) {
-                wfDebugLog( 'activemq_stomp', 'Send to Q failed for this 
message: ' . $message );
-}
+       if ( !$result ) {
+                       wfDebugLog( 'activemq_stomp', 'Send to Q failed for 
this message: ' . $message );
+       }
 
-        $con->disconnect();
+       $con->disconnect();
 
-        return true;
+       return true;
 }
 
 /*
 * Hook to send transaction information to ActiveMQ server
 */
 function sendPendingSTOMP( $transaction ) {
-        global $wgStompServer, $wgPendingStompQueueName;
+       global $wgStompServer, $wgPendingStompQueueName;
 
-        $queueName = isset ( $wgPendingStompQueueName ) ? 
$wgPendingStompQueueName : 'pending';
+       $queueName = isset ( $wgPendingStompQueueName ) ? 
$wgPendingStompQueueName : 'pending';
 
-        // include a library
-        require_once( "Stomp.php" );
+       // include a library
+       require_once( "Stomp.php" );
 
-        $message = json_encode( createQueueMessage( $transaction ) );
+       $message = json_encode( createQueueMessage( $transaction ) );
 
-        // make a connection
-        $con = new Stomp( $wgStompServer );
+       // make a connection
+       $con = new Stomp( $wgStompServer );
 
-        // connect
-        $con->connect();
+       // connect
+       $con->connect();
 
-        // send a message to the queue
-        $result = $con->send( "/queue/$queueName", $message, array( 
'persistent' => 'true' ) );
+       // send a message to the queue
+       $result = $con->send( "/queue/$queueName", $message, array( 
'persistent' => 'true' ) );
 
-        if ( !$result ) {
-                wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed for 
this message: ' . $message );
-}
+       if ( !$result ) {
+                       wfDebugLog( 'activemq_stomp', 'Send to Pending Q failed 
for this message: ' . $message );
+       }
 
-        $con->disconnect();
+       $con->disconnect();
 
-        return true;
+       return true;
 }
 
 /**
@@ -133,41 +132,40 @@
  * Response from Payflow is assigned to 'response'
  */
 function createQueueMessage( $transaction ) {
-        // specifically designed to match the CiviCRM API that will handle it
-        // edit this array to include/ignore transaction data sent to the 
server
-        $message = array(
-                'contribution_tracking_id' => 
$transaction['contribution_tracking_id'],
-                'optout'                 => $transaction['optout'],
-                'anonymous'              => $transaction['anonymous'],
-                'comment'                => $transaction['comment'],
-                'utm_source'             => $transaction['utm_source'],
-                'utm_medium'             => $transaction['utm_medium'],
-                'utm_campaign'           => $transaction['utm_campaign'],
-                'language'               => $transaction['language'],
-                'referrer'               => $transaction['referrer'],
-                'email'                  => $transaction['email'],
-                'first_name'             => $transaction['fname'],
-                'middle_name'            => $transaction['mname'],
-                'last_name'              => $transaction['lname'],
-                'street_address'         => $transaction['street'],
-                'supplemental_address_1' => '',
-                'city'                   => $transaction['city'],
-                'state_province'         => $transaction['state'],
-                'country'                => $transaction['country_name'],
-                'countryID'              => $transaction['country_code'],
-                'postal_code'            => $transaction['zip'],
-                'gateway'                => $transaction[ 'gateway' ],
-                'gateway_txn_id'         => $transaction['PNREF'],
-                'response'               => $transaction['RESPMSG'],
-                'currency'               => $transaction['currency'],
-                'original_currency'      => $transaction['currency'],
-                'original_gross'         => $transaction['amount'],
-                'fee'                    => '0',
-                'gross'                  => $transaction['amount'],
-                'net'                    => $transaction['amount'],
-                'date'                   => $transaction['date'],
+       // specifically designed to match the CiviCRM API that will handle it
+       // edit this array to include/ignore transaction data sent to the server
+       $message = array(
+               'contribution_tracking_id' => 
$transaction['contribution_tracking_id'],
+               'optout'                 => $transaction['optout'],
+               'anonymous'              => $transaction['anonymous'],
+               'comment'                => $transaction['comment'],
+               'utm_source'             => $transaction['utm_source'],
+               'utm_medium'             => $transaction['utm_medium'],
+               'utm_campaign'           => $transaction['utm_campaign'],
+               'language'               => $transaction['language'],
+               'referrer'               => $transaction['referrer'],
+               'email'                  => $transaction['email'],
+               'first_name'             => $transaction['fname'],
+               'middle_name'            => $transaction['mname'],
+               'last_name'              => $transaction['lname'],
+               'street_address'         => $transaction['street'],
+               'supplemental_address_1' => '',
+               'city'                   => $transaction['city'],
+               'state_province'         => $transaction['state'],
+               'country'                => $transaction['country_name'],
+               'countryID'              => $transaction['country_code'],
+               'postal_code'            => $transaction['zip'],
+               'gateway'                => $transaction[ 'gateway' ],
+               'gateway_txn_id'         => $transaction['PNREF'],
+               'response'               => $transaction['RESPMSG'],
+               'currency'               => $transaction['currency'],
+               'original_currency'      => $transaction['currency'],
+               'original_gross'         => $transaction['amount'],
+               'fee'                    => '0',
+               'gross'                  => $transaction['amount'],
+               'net'                    => $transaction['amount'],
+               'date'                   => $transaction['date'],
+       );
 
-        );
-
-        return $message;
+       return $message;
 }

Modified: 
trunk/extensions/DonationInterface/donate_interface/donate_interface.php
===================================================================
--- trunk/extensions/DonationInterface/donate_interface/donate_interface.php    
2010-10-29 21:08:48 UTC (rev 75674)
+++ trunk/extensions/DonationInterface/donate_interface/donate_interface.php    
2010-10-29 21:16:05 UTC (rev 75675)
@@ -60,7 +60,7 @@
 
        if ( !$formProcessed ) {
          // process form
-       wfRunHooks( 'DonationInterface_DisplayForm' );
+           wfRunHooks( 'DonationInterface_DisplayForm' );
                $formProcessed = true;
        }
 
@@ -89,13 +89,13 @@
        $url = $wgRequest->getRequestURL();
 
        if ( $url ) {
-       $getLang = explode( '/', $url );
-       $language = substr( $getLang[3], 0, 2 );
+               $getLang = explode( '/', $url );
+               $language = substr( $getLang[3], 0, 2 );
        }
 
        // error check and set "en" as default
        if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
-       $language = 'en';
+               $language = 'en';
        }
 
        // get payment method gateway value and name from each gateway and 
create menu of options
@@ -105,7 +105,7 @@
        $gatewayMenu = '';
 
        foreach ( $values as $current ) {
-       $gatewayMenu .= Xml::option( $current['display_name'], 
$current['form_value'] );
+               $gatewayMenu .= Xml::option( $current['display_name'], 
$current['form_value'] );
        }
 
     // get available currencies
@@ -113,9 +113,9 @@
        $currencies = array( 'USD' => "USD: U.S. Dollar" );
        // FIXME: It uses the currencies of the last gateway to be loaded. It 
should probably use the union of currencies, (currencies allowed by any 
gateway).
     foreach ( $values as $key ) {
-      if ( isset( $key['currencies'] ) ) {
-        $currencies = $key['currencies'];
-      }
+               if ( isset( $key['currencies'] ) ) {
+                       $currencies = $key['currencies'];
+               }
     }
 
        $currencyMenu = '';
@@ -156,15 +156,15 @@
 
        $currency_options = '';
     foreach ( $currencies as $code => $name ) {
-      $selected = '';
-        if ( $code == $default_currency ) {
-          $selected = ' selected="selected"';
-        }
-      $currency_options .= '<option value="' . $code . '"' . $selected . '>' . 
wfMsg( 'donate_interface-' . $code ) . '</option>';
+               $selected = '';
+               if ( $code == $default_currency ) {
+                       $selected = ' selected="selected"';
+               }
+               $currency_options .= '<option value="' . $code . '"' . 
$selected . '>' . wfMsg( 'donate_interface-' . $code ) . '</option>';
     }
 
        $currencyFields = Xml::openElement( 'select', array( 'name' => 
'currency_code', 'id' => "input_currency_code" ) ) .
-              $currency_options .
+            $currency_options .
               Xml::closeElement( 'select' );
 
        $output .= Xml::fieldset( wfMsg( 'donate_interface-currency' ), 
$currencyFields,  array( 'class' => "mw-donation-currency" ) );

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php
     2010-10-29 21:08:48 UTC (rev 75674)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/extras/minfraud/ccfd/HTTPBase.php
     2010-10-29 21:16:05 UTC (rev 75675)
@@ -20,21 +20,21 @@
  */
 
 class HTTPBase {
-  var $server;
-  var $numservers;
-  var $url;
-  var $queries;
-  var $allowed_fields;
-  var $num_allowed_fields;
-  var $outputstr;
-  var $isSecure;
-  var $timeout;
-  var $debug;
-  var $check_field;
-  var $wsIpaddrRefreshTimeout;
-  var $wsIpaddrCacheFile;
-  var $useDNS;
-  var $ipstr;
+       var $server;
+       var $numservers;
+       var $url;
+       var $queries;
+       var $allowed_fields;
+       var $num_allowed_fields;
+       var $outputstr;
+       var $isSecure;
+       var $timeout;
+       var $debug;
+       var $check_field;
+       var $wsIpaddrRefreshTimeout;
+       var $wsIpaddrCacheFile;
+       var $useDNS;
+       var $ipstr;
   function __construct() {
     $this->isSecure = 0;
     $this->debug = 0;
@@ -51,7 +51,7 @@
 
   // this function sets the checked field
   function set_check_field( $f ) {
-    $check_field = $f;
+    $this->check_field = $f;
   }
 
   // this function sets the allowed fields
@@ -344,7 +344,7 @@
         $url3 = parse_url( $url );
         $host = $url3["host"];
         $path = $url3["path"];
-       $query =  $url3["query"];
+               $query =  $url3["query"];
 
         // open the connection
         $fp = fsockopen ( $host, 80, $errno, $errstr, $this->timeout );

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
   2010-10-29 21:08:48 UTC (rev 75674)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
   2010-10-29 21:16:05 UTC (rev 75675)
@@ -216,7 +216,8 @@
 
                // save contrib tracking id early to track abondonment
                if ( $data[ 'numAttempt' ] == '0' && ( !$wgRequest->getText( 
'utm_source_id', false ) || $wgRequest->getText( '_nocache_' ) == 'true' ) ) {
-                       if ( !$tracked = 
$this->fnPayflowSaveContributionTracking( $data ) ) {
+                       $tracked = $this->fnPayflowSaveContributionTracking( 
$data );
+                       if ( !$tracked ) {
                                $when = time();
                                wfDebugLog( 'payflowpro_gateway', 'Unable to 
save data to the contribution_tracking table ' . $when );
                        }

Modified: 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
===================================================================
--- 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php    
    2010-10-29 21:08:48 UTC (rev 75674)
+++ 
trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php    
    2010-10-29 21:16:05 UTC (rev 75675)
@@ -125,21 +125,21 @@
 $wgAutoloadClasses[ 'ApiPayflowProGateway' ] = $dir . 
'api_payflowpro_gateway.php';
 
 function payflowGatewayConnection() {
-        global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
-        global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
+       global $wgPayflowGatewayDBserver, $wgPayflowGatewayDBname;
+       global $wgPayflowGatewayDBuser, $wgPayflowGatewayDBpassword;
 
-        static $db;
+       static $db;
 
-        if ( !$db ) {
-                $db = new DatabaseMysql(
-                        $wgPayflowGatewayDBserver,
-                        $wgPayflowGatewayDBuser,
-                        $wgPayflowGatewayDBpassword,
-                        $wgPayflowGatewayDBname );
-                        $db->query( "SET names utf8" );
-        }
+       if ( !$db ) {
+                       $db = new DatabaseMysql(
+                                       $wgPayflowGatewayDBserver,
+                                       $wgPayflowGatewayDBuser,
+                                       $wgPayflowGatewayDBpassword,
+                                       $wgPayflowGatewayDBname );
+                                       $db->query( "SET names utf8" );
+       }
 
-        return $db;
+       return $db;
 }
 
 /**
@@ -147,22 +147,21 @@
  * also supplies currencies supported by this gateway
  */
 function pfpGatewayValue( &$values ) {
+       $values['payflow'] = array(
+                       'gateway' => 'payflow',
+                       'display_name' => 'Credit Card',
+                       'form_value' => 'payflow',
+                       'currencies' => array(
+                                       'GBP' => 'GBP: British Pound',
+                                       'EUR' => 'EUR: Euro',
+                                       'USD' => 'USD: U.S. Dollar',
+                                       'AUD' => 'AUD: Australian Dollar',
+                                       'CAD' => 'CAD: Canadian Dollar',
+                                       'JPY' => 'JPY: Japanese Yen',
+                       ),
+       );
 
-        $values['payflow'] = array(
-                'gateway' => 'payflow',
-                'display_name' => 'Credit Card',
-                'form_value' => 'payflow',
-                'currencies' => array(
-                        'GBP' => 'GBP: British Pound',
-                        'EUR' => 'EUR: Euro',
-                        'USD' => 'USD: U.S. Dollar',
-                        'AUD' => 'AUD: Australian Dollar',
-                        'CAD' => 'CAD: Canadian Dollar',
-                        'JPY' => 'JPY: Japanese Yen',
-                ),
-        );
-
-        return true;
+       return true;
 }
 
 /**
@@ -173,15 +172,8 @@
  * the result might look like this: 
http://www.yourdomain.com/index.php?title=Special:PayflowPro&amount=75.00&currency_code=USD&payment_method=payflow
  */
 function pfpGatewayPage( &$url ) {
-        global $wgScript;
+       global $wgScript;
 
-        $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
-        return true;
+       $url['payflow'] = $wgScript . "?title=Special:PayflowProGateway";
+       return true;
 }
-
-// Add JQuery
-$wgHooks['BeforePageDisplay'][] = 'pfpAddJQuery';
-function pfpAddJQuery( $out, $sk ) {
-        $out->includeJQuery();
-        return true;
-}


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

Reply via email to