r100457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100456‎ | r100457 | r100458 >
Date:21:50, 21 October 2011
Author:kaldari
Status:ok
Tags:
Comment:
adding some comments and tweaking some formatting
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -126,7 +126,7 @@
127127 *
128128 * @var array $staged_vars
129129 */
130 - protected $staged_vars = array( );
 130+ protected $staged_vars = array();
131131 protected $return_value_map;
132132 protected $postdata;
133133 protected $postdatadefaults;
@@ -153,7 +153,7 @@
154154 *
155155 * @see DonationData
156156 */
157 - public function __construct( $options = array( ) ) {
 157+ public function __construct( $options = array() ) {
158158 global $wgRequest;
159159
160160 // Extract the options
@@ -195,7 +195,7 @@
196196 /**
197197 * Override this in children if you want different defaults.
198198 */
199 - function setPostDefaults( $options = array( ) ) {
 199+ function setPostDefaults( $options = array() ) {
200200
201201 // Extract the options
202202 if ( is_array( $options ) ) {
@@ -279,7 +279,7 @@
280280 * the configured value for Donation Interface if it exists or not.
281281 */
282282 static function getGlobal( $varname ) {
283 - static $gotten = array( ); //cache.
 283+ static $gotten = array(); //cache.
284284 if ( !array_key_exists( $varname, $gotten ) ) {
285285 $globalname = self::getGlobalPrefix() . $varname;
286286 global $$globalname;
@@ -349,13 +349,18 @@
350350 throw new MWException( $msg );
351351 }
352352
 353+ /**
 354+ * Build a string of name/value pairs out of our donation data for submission to the payment
 355+ * processor.
 356+ */
353357 function buildRequestNameValueString() {
 358+ // Look up the request structure for our current transaction type in the transactions array
354359 $structure = $this->transactions[$this->currentTransaction()]['request'];
355360 if ( !is_array( $structure ) ) {
356361 return '';
357362 }
358363
359 - $queryvals = array( );
 364+ $queryvals = array();
360365
361366 //we are going to assume a flat array, because... namevalue.
362367 foreach ( $structure as $fieldname ) {
@@ -369,10 +374,14 @@
370375 return $ret;
371376 }
372377
 378+ /**
 379+ * Build an XML document out of our donation data for submission to the payment processor.
 380+ */
373381 function buildRequestXML() {
374382 $this->xmlDoc = new DomDocument( '1.0' );
375383 $node = $this->xmlDoc->createElement( 'XML' );
376384
 385+ // Look up the request structure for our current transaction type in the transactions array
377386 $structure = $this->transactions[$this->currentTransaction()]['request'];
378387
379388 $this->buildTransactionNodes( $structure, $node );
@@ -622,6 +631,12 @@
623632 return $headers;
624633 }
625634
 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+ */
626641 protected function currentTransaction( $transaction = '' ) { //get&set in one!
627642 static $current_transaction;
628643 if ( $transaction != '' ) {
@@ -670,7 +685,7 @@
671686 // in case there is a general network issue
672687 $i = 1;
673688
674 - $results = array( );
 689+ $results = array();
675690
676691 while ( $i++ <= 3 ) {
677692 self::log( $this->postdatadefaults['order_id'] . ' Preparing to send transaction to ' . self::getGatewayName() );
@@ -725,7 +740,7 @@
726741 return $result;
727742 }
728743
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 = '' ) {
730745 $identifier = self::getIdentifier() . "_gateway" . $log_id_suffix;
731746
732747 // if we're not using the syslog facility, use wfDebugLog
@@ -749,7 +764,7 @@
750765 $token = strtok( $xml, "\n" );
751766 $result = ''; // holds formatted version as it is built
752767 $pad = 0; // initial indent
753 - $matches = array( ); // returns from preg_matches()
 768+ $matches = array(); // returns from preg_matches()
754769 // scan each line and adjust indent based on opening/closing tags
755770 while ( $token !== false ) :
756771
@@ -815,7 +830,7 @@
816831 * between the $start value, and now.
817832 */
818833 public function getStopwatch( $string, $reset = false ) {
819 - static $start = array( );
 834+ static $start = array();
820835 $now = microtime( true );
821836
822837 if ( empty( $start ) || !array_key_exists( $string, $start ) || $reset === true ) {
@@ -833,7 +848,7 @@
834849 * @param type $vars
835850 */
836851 function saveCommunicationStats( $function = '', $additional = '', $vars = '' ) {
837 - $params = array( );
 852+ $params = array();
838853 if ( self::getGlobal( 'SaveCommStats' ) ) {
839854 $db = ContributionTrackingProcessor::contributionTrackingConnection();
840855
@@ -856,7 +871,7 @@
857872 }
858873
859874 function xmlChildrenToArray( $xml, $nodename ) {
860 - $data = array( );
 875+ $data = array();
861876 foreach ( $xml->getElementsByTagName( $nodename ) as $node ) {
862877 foreach ( $node->childNodes as $childnode ) {
863878 if ( trim( $childnode->nodeValue ) != '' ) {

Status & tagging log