Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | * |
128 | 128 | * @var array $staged_vars |
129 | 129 | */ |
130 | | - protected $staged_vars = array( ); |
| 130 | + protected $staged_vars = array(); |
131 | 131 | protected $return_value_map; |
132 | 132 | protected $postdata; |
133 | 133 | protected $postdatadefaults; |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | * |
155 | 155 | * @see DonationData |
156 | 156 | */ |
157 | | - public function __construct( $options = array( ) ) { |
| 157 | + public function __construct( $options = array() ) { |
158 | 158 | global $wgRequest; |
159 | 159 | |
160 | 160 | // Extract the options |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | /** |
197 | 197 | * Override this in children if you want different defaults. |
198 | 198 | */ |
199 | | - function setPostDefaults( $options = array( ) ) { |
| 199 | + function setPostDefaults( $options = array() ) { |
200 | 200 | |
201 | 201 | // Extract the options |
202 | 202 | if ( is_array( $options ) ) { |
— | — | @@ -279,7 +279,7 @@ |
280 | 280 | * the configured value for Donation Interface if it exists or not. |
281 | 281 | */ |
282 | 282 | static function getGlobal( $varname ) { |
283 | | - static $gotten = array( ); //cache. |
| 283 | + static $gotten = array(); //cache. |
284 | 284 | if ( !array_key_exists( $varname, $gotten ) ) { |
285 | 285 | $globalname = self::getGlobalPrefix() . $varname; |
286 | 286 | global $$globalname; |
— | — | @@ -349,13 +349,18 @@ |
350 | 350 | throw new MWException( $msg ); |
351 | 351 | } |
352 | 352 | |
| 353 | + /** |
| 354 | + * Build a string of name/value pairs out of our donation data for submission to the payment |
| 355 | + * processor. |
| 356 | + */ |
353 | 357 | function buildRequestNameValueString() { |
| 358 | + // Look up the request structure for our current transaction type in the transactions array |
354 | 359 | $structure = $this->transactions[$this->currentTransaction()]['request']; |
355 | 360 | if ( !is_array( $structure ) ) { |
356 | 361 | return ''; |
357 | 362 | } |
358 | 363 | |
359 | | - $queryvals = array( ); |
| 364 | + $queryvals = array(); |
360 | 365 | |
361 | 366 | //we are going to assume a flat array, because... namevalue. |
362 | 367 | foreach ( $structure as $fieldname ) { |
— | — | @@ -369,10 +374,14 @@ |
370 | 375 | return $ret; |
371 | 376 | } |
372 | 377 | |
| 378 | + /** |
| 379 | + * Build an XML document out of our donation data for submission to the payment processor. |
| 380 | + */ |
373 | 381 | function buildRequestXML() { |
374 | 382 | $this->xmlDoc = new DomDocument( '1.0' ); |
375 | 383 | $node = $this->xmlDoc->createElement( 'XML' ); |
376 | 384 | |
| 385 | + // Look up the request structure for our current transaction type in the transactions array |
377 | 386 | $structure = $this->transactions[$this->currentTransaction()]['request']; |
378 | 387 | |
379 | 388 | $this->buildTransactionNodes( $structure, $node ); |
— | — | @@ -622,6 +631,12 @@ |
623 | 632 | return $headers; |
624 | 633 | } |
625 | 634 | |
| 635 | + /** |
| 636 | + * Get or set the current transaction |
| 637 | + * |
| 638 | + * @param $transaction string This is a specific transaction type like 'INSERT_ORDERWITHPAYMENT' |
| 639 | + * that maps to a first-level key in the $transactions array. |
| 640 | + */ |
626 | 641 | protected function currentTransaction( $transaction = '' ) { //get&set in one! |
627 | 642 | static $current_transaction; |
628 | 643 | if ( $transaction != '' ) { |
— | — | @@ -670,7 +685,7 @@ |
671 | 686 | // in case there is a general network issue |
672 | 687 | $i = 1; |
673 | 688 | |
674 | | - $results = array( ); |
| 689 | + $results = array(); |
675 | 690 | |
676 | 691 | while ( $i++ <= 3 ) { |
677 | 692 | self::log( $this->postdatadefaults['order_id'] . ' Preparing to send transaction to ' . self::getGatewayName() ); |
— | — | @@ -725,7 +740,7 @@ |
726 | 741 | return $result; |
727 | 742 | } |
728 | 743 | |
729 | | - public static function log( $msg, $log_level=LOG_INFO, $log_id_suffix = '' ) { |
| 744 | + public static function log( $msg, $log_level = LOG_INFO, $log_id_suffix = '' ) { |
730 | 745 | $identifier = self::getIdentifier() . "_gateway" . $log_id_suffix; |
731 | 746 | |
732 | 747 | // if we're not using the syslog facility, use wfDebugLog |
— | — | @@ -749,7 +764,7 @@ |
750 | 765 | $token = strtok( $xml, "\n" ); |
751 | 766 | $result = ''; // holds formatted version as it is built |
752 | 767 | $pad = 0; // initial indent |
753 | | - $matches = array( ); // returns from preg_matches() |
| 768 | + $matches = array(); // returns from preg_matches() |
754 | 769 | // scan each line and adjust indent based on opening/closing tags |
755 | 770 | while ( $token !== false ) : |
756 | 771 | |
— | — | @@ -815,7 +830,7 @@ |
816 | 831 | * between the $start value, and now. |
817 | 832 | */ |
818 | 833 | public function getStopwatch( $string, $reset = false ) { |
819 | | - static $start = array( ); |
| 834 | + static $start = array(); |
820 | 835 | $now = microtime( true ); |
821 | 836 | |
822 | 837 | if ( empty( $start ) || !array_key_exists( $string, $start ) || $reset === true ) { |
— | — | @@ -833,7 +848,7 @@ |
834 | 849 | * @param type $vars |
835 | 850 | */ |
836 | 851 | function saveCommunicationStats( $function = '', $additional = '', $vars = '' ) { |
837 | | - $params = array( ); |
| 852 | + $params = array(); |
838 | 853 | if ( self::getGlobal( 'SaveCommStats' ) ) { |
839 | 854 | $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
840 | 855 | |
— | — | @@ -856,7 +871,7 @@ |
857 | 872 | } |
858 | 873 | |
859 | 874 | function xmlChildrenToArray( $xml, $nodename ) { |
860 | | - $data = array( ); |
| 875 | + $data = array(); |
861 | 876 | foreach ( $xml->getElementsByTagName( $nodename ) as $node ) { |
862 | 877 | foreach ( $node->childNodes as $childnode ) { |
863 | 878 | if ( trim( $childnode->nodeValue ) != '' ) { |