Index: trunk/extensions/DonationInterface/globalcollect_gateway/forms/TwoStepAmount.php |
— | — | @@ -102,44 +102,73 @@ |
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | | - * Get the form messages |
| 106 | + * Get the form messages by type. |
107 | 107 | * |
| 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 |
108 | 112 | * @param array $options |
109 | 113 | * |
110 | 114 | * @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. |
112 | 117 | * |
113 | 118 | * @return string Returns an HTML string |
114 | 119 | */ |
115 | | - public function getFormMessages( $options = array() ) { |
| 120 | + protected function getFormMessagesByType( $type, $options = array() ) { |
116 | 121 | |
| 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 | + |
117 | 132 | $return = ''; |
118 | 133 | |
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 ] ) ) { |
124 | 135 | |
125 | | - if ( is_array( $this->form_errors['general'] ) ) { |
| 136 | + if ( is_array( $this->form_errors[ $type ] ) ) { |
126 | 137 | |
127 | 138 | // 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 ); |
130 | 141 | } |
131 | 142 | } else { |
132 | 143 | |
133 | 144 | // 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 ); |
135 | 146 | } |
136 | 147 | } |
137 | 148 | |
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 = ''; |
141 | 162 | |
| 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 | + |
142 | 172 | $return .= Xml::closeElement( 'div' ); // payment_form_messages |
143 | | - //$return .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
144 | 173 | |
145 | 174 | return $return; |
146 | 175 | } |
— | — | @@ -152,7 +181,7 @@ |
153 | 182 | * |
154 | 183 | * @return string Returns an HTML string |
155 | 184 | */ |
156 | | - public function getFormSectionHeaderTag( $section, $options = array() ) { |
| 185 | + protected function getFormSectionHeaderTag( $section, $options = array() ) { |
157 | 186 | |
158 | 187 | // Make sure $section does not get overridden. |
159 | 188 | if ( isset( $options['section'] ) ) { |
— | — | @@ -230,7 +259,7 @@ |
231 | 260 | * |
232 | 261 | * @return string Returns an HTML string |
233 | 262 | */ |
234 | | - public function setAppeal( $appeal, $options = array() ) { |
| 263 | + protected function setAppeal( $appeal, $options = array() ) { |
235 | 264 | |
236 | 265 | $this->appeal = $appeal; |
237 | 266 | } |
— | — | @@ -242,7 +271,7 @@ |
243 | 272 | * |
244 | 273 | * @return string Returns an HTML string |
245 | 274 | */ |
246 | | - public function getAppeal( $options = array() ) { |
| 275 | + protected function getAppeal( $options = array() ) { |
247 | 276 | |
248 | 277 | $return = ''; |
249 | 278 | |
— | — | @@ -260,13 +289,31 @@ |
261 | 290 | } |
262 | 291 | |
263 | 292 | /** |
| 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 | + /** |
264 | 311 | * Generate the direct debit component |
265 | 312 | * |
266 | 313 | * @param array $options |
267 | 314 | * |
268 | 315 | * @return string Returns an HTML string |
269 | 316 | */ |
270 | | - public function getDirectDebit( $options = array() ) { |
| 317 | + protected function getDirectDebit( $options = array() ) { |
271 | 318 | |
272 | 319 | extract( $options ); |
273 | 320 | |
— | — | @@ -473,6 +520,56 @@ |
474 | 521 | return $return; |
475 | 522 | } |
476 | 523 | |
| 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 | + |
477 | 574 | //////////////////////////////////////////////////////////////////////////// |
478 | 575 | // |
479 | 576 | // Form sections |
— | — | @@ -609,6 +706,10 @@ |
610 | 707 | |
611 | 708 | $return .= $this->getDirectDebit(); |
612 | 709 | |
| 710 | + $return .= $this->getBankTransfer(); |
| 711 | + |
| 712 | + $return .= $this->getRealTimeBankTransfer(); |
| 713 | + |
613 | 714 | $return .= Xml::closeElement( 'table' ); // close $id . '_table' |
614 | 715 | |
615 | 716 | $return .= Xml::closeElement( 'div' ); // $id |