r101882 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101881‎ | r101882 | r101883 >
Date:21:07, 3 November 2011
Author:jpostlethwaite
Status:ok
Tags:fundraising 
Comment:
Added getFormMessagesByType(), getBankTransfer() and getRealTimeBankTransfer().
Modified paths:
  • /trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php
@@ -102,44 +102,73 @@
103103 }
104104
105105 /**
106 - * Get the form messages
 106+ * Get the form messages by type.
107107 *
 108+ * Since this displays to the end user, if a key does not exist, it fails
 109+ * silently and returns an empty string.
 110+ *
 111+ * @param string $type
108112 * @param array $options
109113 *
110114 * @todo
111 - * - Does retryMsg need to be displayed?
 115+ * - Move to the parent class
 116+ * - This returns error messages by paragraph tags, but it may be better to do this as a list.
112117 *
113118 * @return string Returns an HTML string
114119 */
115 - public function getFormMessages( $options = array() ) {
 120+ protected function getFormMessagesByType( $type, $options = array() ) {
116121
 122+ if ( isset( $options['type'] ) ) {
 123+ unset( $options['type'] );
 124+ }
 125+
 126+ extract( $options );
 127+
 128+ $defaultErrorClass = 'payment_error_message payment_error_message_' . strtolower( $type );
 129+
 130+ $errorClass = isset( $errorClass ) ? $errorClass : $defaultErrorClass;
 131+
117132 $return = '';
118133
119 - // We want this container to exist so it can be populated with javascript messages.
120 - $return .= Xml::openElement( 'div', array( 'id' => 'payment_form_messages' ) );
121 -
122 - // If errors are present, allow them to be displayed.
123 - if ( $this->form_errors['general'] ) {
 134+ if ( isset( $this->form_errors[ $type ] ) ) {
124135
125 - if ( is_array( $this->form_errors['general'] ) ) {
 136+ if ( is_array( $this->form_errors[ $type ] ) ) {
126137
127138 // Loop through messages and display them as paragraphs
128 - foreach ( $this->form_errors['general'] as $this->form_errors_msg ) {
129 - $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors_msg );
 139+ foreach ( $this->form_errors[ $type ] as $message ) {
 140+ $return .= Xml::tags( 'p', array( 'class' => $errorClass ), $message );
130141 }
131142 } else {
132143
133144 // Display single message
134 - $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors_msg );
 145+ $return .= Xml::tags( 'p', array( 'class' => $errorClass ), $message );
135146 }
136147 }
137148
138 - if ( $this->form_errors['invalidamount'] ) {
139 - $return .= Xml::tags( 'p', array( 'class' => 'creditcard-error-message' ), $this->form_errors['invalidamount'] );
140 - }
 149+ return $return;
 150+ }
 151+
 152+ /**
 153+ * Get the form messages
 154+ *
 155+ * @param array $options
 156+ *
 157+ * @return string Returns an HTML string
 158+ */
 159+ protected function getFormMessages( $options = array() ) {
 160+
 161+ $return = '';
141162
 163+ // We want this container to exist so it can be populated with javascript messages.
 164+ $return .= Xml::openElement( 'div', array( 'id' => 'payment_form_messages' ) );
 165+
 166+ $return .= $this->getFormMessagesByType('general');
 167+
 168+ $return .= $this->getFormMessagesByType('invalidamount');
 169+
 170+ $return .= $this->getFormMessagesByType('retryMsg');
 171+
142172 $return .= Xml::closeElement( 'div' ); // payment_form_messages
143 - //$return .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>";
144173
145174 return $return;
146175 }
@@ -152,7 +181,7 @@
153182 *
154183 * @return string Returns an HTML string
155184 */
156 - public function getFormSectionHeaderTag( $section, $options = array() ) {
 185+ protected function getFormSectionHeaderTag( $section, $options = array() ) {
157186
158187 // Make sure $section does not get overridden.
159188 if ( isset( $options['section'] ) ) {
@@ -230,7 +259,7 @@
231260 *
232261 * @return string Returns an HTML string
233262 */
234 - public function setAppeal( $appeal, $options = array() ) {
 263+ protected function setAppeal( $appeal, $options = array() ) {
235264
236265 $this->appeal = $appeal;
237266 }
@@ -242,7 +271,7 @@
243272 *
244273 * @return string Returns an HTML string
245274 */
246 - public function getAppeal( $options = array() ) {
 275+ protected function getAppeal( $options = array() ) {
247276
248277 $return = '';
249278
@@ -260,13 +289,31 @@
261290 }
262291
263292 /**
 293+ * Generate the bank transfer component
 294+ *
 295+ * Nothing is being added right now.
 296+ *
 297+ * @param array $options
 298+ *
 299+ * @return string Returns an HTML string
 300+ */
 301+ protected function getBankTransfer( $options = array() ) {
 302+
 303+ extract( $options );
 304+
 305+ $return = '';
 306+
 307+ return $return;
 308+ }
 309+
 310+ /**
264311 * Generate the direct debit component
265312 *
266313 * @param array $options
267314 *
268315 * @return string Returns an HTML string
269316 */
270 - public function getDirectDebit( $options = array() ) {
 317+ protected function getDirectDebit( $options = array() ) {
271318
272319 extract( $options );
273320
@@ -473,6 +520,56 @@
474521 return $return;
475522 }
476523
 524+ /**
 525+ * Generate the bank transfer component
 526+ *
 527+ * Nothing is being added right now.
 528+ *
 529+ * @param array $options
 530+ *
 531+ * @return string Returns an HTML string
 532+ */
 533+ protected function getRealTimeBankTransfer( $options = array() ) {
 534+
 535+ extract( $options );
 536+
 537+ $return = '';
 538+
 539+ $payment_submethod = $this->gateway->getPaymentSubmethodMeta( $this->getPaymentSubmethod() );
 540+ if ( !isset( $payment_submethod['issuerids'] ) || empty( $payment_submethod['issuerids'] ) ) {
 541+
 542+ // No issuer_id to load
 543+ return $return;
 544+ }
 545+
 546+ $selectOptions = '';
 547+
 548+ // generate dropdown of issuer_ids
 549+ foreach ( $payment_submethod['issuerids'] as $issuer_id => $issuer_id_label ) {
 550+ $selected = ( $this->form_data['issuer_id'] == $issuer_id ) ? true : false;
 551+ //$selectOptions .= Xml::option( wfMsg( 'donate_interface-rtbt-' . $issuer_id ), $issuer_id_label, $selected );
 552+ $selectOptions .= Xml::option( $issuer_id_label, $issuer_id, $selected );
 553+ }
 554+ $return .= '<tr>';
 555+ $return .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-rtbt-issuer_id' ), 'issuer_id' ) . '</td>';
 556+
 557+ $return .= '<td>';
 558+ $return .= Xml::openElement(
 559+ 'select',
 560+ array(
 561+ 'name' => 'issuer_id',
 562+ 'id' => 'issuer_id',
 563+ 'onchange' => '',
 564+ ) );
 565+ $return .= $selectOptions;
 566+ $return .= Xml::closeElement( 'select' );
 567+
 568+ $return .= '</td>';
 569+ $return .= '</tr>';
 570+
 571+ return $return;
 572+ }
 573+
477574 ////////////////////////////////////////////////////////////////////////////
478575 //
479576 // Form sections
@@ -609,6 +706,10 @@
610707
611708 $return .= $this->getDirectDebit();
612709
 710+ $return .= $this->getBankTransfer();
 711+
 712+ $return .= $this->getRealTimeBankTransfer();
 713+
613714 $return .= Xml::closeElement( 'table' ); // close $id . '_table'
614715
615716 $return .= Xml::closeElement( 'div' ); // $id

Follow-up revisions

RevisionCommit summaryAuthorDate
r102236MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:06, 7 November 2011
r102237MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:07, 7 November 2011

Status & tagging log