Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter7.php |
— | — | @@ -0,0 +1,270 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class PayflowProGateway_Form_TwoColumnLetter7 extends PayflowProGateway_Form_OneStepTwoColumn { |
| 5 | + |
| 6 | + public function __construct( &$form_data, &$form_errors ) { |
| 7 | + global $wgScriptPath; |
| 8 | + |
| 9 | + // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
| 10 | + if ( !strlen( $this->getStylePath() ) ) { |
| 11 | + $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter7.css' ); |
| 12 | + } |
| 13 | + |
| 14 | + parent::__construct( $form_data, $form_errors ); |
| 15 | + } |
| 16 | + |
| 17 | + public function generateFormStart() { |
| 18 | + global $wgOut, $wgRequest; |
| 19 | + |
| 20 | + $form = parent::generateBannerHeader(); |
| 21 | + |
| 22 | + $form .= Xml::openElement( 'table', array( 'width' => '100%', 'cellspacing' => 0, 'cellpadding' => 0, 'border' => 0 ) ); |
| 23 | + $form .= Xml::openElement( 'tr' ); |
| 24 | + $form .= Xml::openElement( 'td', array( 'id' => 'appeal', 'valign' => 'top' ) ); |
| 25 | + |
| 26 | + $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' ); |
| 27 | + // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
| 28 | + if ( $wgRequest->getText( 'language' ) ) $text_template .= '/' . $this->form_data[ 'language' ]; |
| 29 | + |
| 30 | + $template = ( strlen( $text_template ) ) ? $wgOut->parse( '{{' . $text_template . '}}' ) : ''; |
| 31 | + // if the template doesn't exist, prevent the display of the red link |
| 32 | + if ( preg_match( '/redlink\=1/', $template ) ) $template = NULL; |
| 33 | + $form .= $template; |
| 34 | + |
| 35 | + $form .= Xml::closeElement( 'td' ); |
| 36 | + |
| 37 | + $form .= Xml::openElement( 'td', array( 'id' => 'donate', 'valign' => 'top' ) ); |
| 38 | + |
| 39 | + // add noscript tags for javascript disabled browsers |
| 40 | + $form .= $this->getNoScript(); |
| 41 | + |
| 42 | + $form .= Xml::tags( 'h2', array( 'id' => 'donate-head' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
| 43 | + |
| 44 | + // provide a place at the top of the form for displaying general messages |
| 45 | + if ( $this->form_errors['general'] ) { |
| 46 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ) ); |
| 47 | + if ( is_array( $this->form_errors['general'] ) ) { |
| 48 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 49 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 50 | + } |
| 51 | + } else { |
| 52 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 53 | + } |
| 54 | + $form .= Xml::closeElement( 'div' ); // close div#mw-payflow-general-error |
| 55 | + } |
| 56 | + |
| 57 | + // Xml::element seems to convert html to htmlentities |
| 58 | + $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 59 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) ); |
| 60 | + |
| 61 | + $form .= $this->generateBillingContainer(); |
| 62 | + return $form; |
| 63 | + } |
| 64 | + |
| 65 | + public function generateFormEnd() { |
| 66 | + $form = ''; |
| 67 | + $form .= $this->generateFormClose(); |
| 68 | + return $form; |
| 69 | + } |
| 70 | + |
| 71 | + protected function generateBillingContainer() { |
| 72 | + $form = ''; |
| 73 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' ) ); |
| 74 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
| 75 | + $form .= $this->generateBillingFields(); |
| 76 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
| 77 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
| 78 | + |
| 79 | + return $form; |
| 80 | + } |
| 81 | + |
| 82 | + protected function generateBillingFields() { |
| 83 | + global $wgScriptPath, $wgPayflowGatewayPaypalURL, $wgRequest; |
| 84 | + $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
| 85 | + |
| 86 | + $form = ''; |
| 87 | + |
| 88 | + /* |
| 89 | + $form .= '<tr>'; |
| 90 | + $form .= '<td style="text-align:center;" colspan="2"><big><b>' . wfMsg( 'payflowpro_gateway-paypal-button' ) . '</b></big><br/><a href="#" onclick="document.payment.PaypalRedirect.value=1;document.payment.submit();"><img src="' . $scriptPath . '/paypal.png"/></a></td>'; |
| 91 | + $form .= '</tr>'; |
| 92 | + */ |
| 93 | + |
| 94 | + // amount |
| 95 | + $otherChecked = false; |
| 96 | + $amount = -1; |
| 97 | + if ( $this->form_data['amount'] != 100 && $this->form_data['amount'] != 50 && $this->form_data['amount'] != 35 && $this->form_data['amount'] != 20 && $this->form_data['amountOther'] > 0 ) { |
| 98 | + $otherChecked = true; |
| 99 | + $amount = $this->form_data['amountOther']; |
| 100 | + } |
| 101 | + $form .= '<tr>'; |
| 102 | + $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
| 103 | + $form .= '</tr>'; |
| 104 | + $form .= '<tr>'; |
| 105 | + $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>'; |
| 106 | + $form .= '<td>' . Xml::radio( 'amount', 100, $this->form_data['amount'] == 100, array( 'onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )' ) ) . '100 ' . |
| 107 | + Xml::radio( 'amount', 50, $this->form_data['amount'] == 50, array( 'onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )' ) ) . '50 ' . |
| 108 | + Xml::radio( 'amount', 35, $this->form_data['amount'] == 35, array( 'onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )' ) ) . '35 ' . |
| 109 | + Xml::radio( 'amount', 20, $this->form_data['amount'] == 20, array( 'onfocus' => 'clearField2( document.getElementById(\'amountOther\'), "Other" )' ) ) . '20 ' . |
| 110 | + '</td>'; |
| 111 | + $form .= '</tr>'; |
| 112 | + $form .= '<tr>'; |
| 113 | + $form .= '<td class="label"></td>'; |
| 114 | + $form .= '<td>' . Xml::radio( 'amount', $amount, $otherChecked, array( 'id' => 'otherRadio' ) ) . Xml::input( 'amountOther', '7', $this->form_data['amountOther'], array( 'type' => 'text', 'onfocus' => 'clearField(this, "Other");document.getElementById("otherRadio").checked=true;', 'maxlength' => '10', 'onblur' => 'document.getElementById("otherRadio").value = this.value;', 'id' => 'amountOther' ) ) . |
| 115 | + ' ' . $this->generateCurrencyDropdown() . '</td>'; |
| 116 | + $form .= '</tr>'; |
| 117 | + |
| 118 | + // email opt-in |
| 119 | + $email_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'email-opt' ] : true; |
| 120 | + $form .= '<tr>'; |
| 121 | + $form .= '<td class="label"> </td>'; |
| 122 | + $form .= '<td class="check-option">' . Xml::check( 'email-opt', $email_opt_value ); |
| 123 | + $form .= ' '; |
| 124 | + // put the label inside Xml::openElement so any HTML in the msg might get rendered (right, Germany?) |
| 125 | + $form .= Xml::openElement( 'label', array( 'for' => 'email-opt' ) ); |
| 126 | + $form .= wfMsg( 'donate_interface-email-agreement' ); |
| 127 | + $form .= Xml::closeElement( 'label' ); |
| 128 | + $form .= '</td>'; |
| 129 | + $form .= '</tr>'; |
| 130 | + |
| 131 | + $form .= '<tr>'; |
| 132 | + $form .= '<td class="label">' . wfMsg( 'payflowpro_gateway-payment-type' ) . '</td>'; |
| 133 | + $form .= '<td>' . |
| 134 | + Xml::radio( 'card', 'cc1', $this->form_data['card'] == 'cc1', array( 'id' => 'cc1radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc1radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ). '</label>' . |
| 135 | + Xml::radio( 'card', 'cc2', $this->form_data['card'] == 'cc2', array( 'id' => 'cc2radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc2radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ). '</label>' . |
| 136 | + Xml::radio( 'card', 'cc3', $this->form_data['card'] == 'cc3', array( 'id' => 'cc3radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc3radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ). '</label>' . |
| 137 | + Xml::radio( 'card', 'cc4', $this->form_data['card'] == 'cc4', array( 'id' => 'cc4radio', 'onclick' => 'switchToCreditCard()' ) ) . '<label for="cc4radio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ). '</label>' . |
| 138 | + Xml::radio( 'card', 'pp', $this->form_data['card'] == 'pp', array( 'id' => 'ppradio', 'onclick' => 'switchToPayPal()' ) ) . '<label for="ppradio">' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) . '</label>' . |
| 139 | + '</td>'; |
| 140 | + $form .= '</tr>'; |
| 141 | + |
| 142 | + $form .= '</table>'; |
| 143 | + |
| 144 | + if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) { |
| 145 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) ); |
| 146 | + } else { |
| 147 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc', 'style' => 'display: none;' ) ); |
| 148 | + } |
| 149 | + |
| 150 | + // name |
| 151 | + $form .= $this->getNameField(); |
| 152 | + |
| 153 | + // email |
| 154 | + $form .= $this->getEmailField(); |
| 155 | + |
| 156 | + $form .= '<tr>'; |
| 157 | + $form .= '<td colspan=2><span class="creditcard-error-msg"> </span></td>'; |
| 158 | + $form .= '</tr>'; |
| 159 | + |
| 160 | + // card number |
| 161 | + $form .= $this->getCardNumberField(); |
| 162 | + |
| 163 | + // cvv |
| 164 | + $form .= $this->getCvvField(); |
| 165 | + |
| 166 | + // expiry |
| 167 | + $form .= $this->getExpiryField(); |
| 168 | + |
| 169 | + // street |
| 170 | + $form .= $this->getStreetField(); |
| 171 | + |
| 172 | + // city |
| 173 | + $form .= $this->getCityField(); |
| 174 | + |
| 175 | + // state |
| 176 | + $form .= $this->getStateField(); |
| 177 | + |
| 178 | + // zip |
| 179 | + $form .= '<tr>'; |
| 180 | + $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>'; |
| 181 | + $form .= '</tr>'; |
| 182 | + $form .= '<tr>'; |
| 183 | + $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-postal' ), 'zip' ) . '</td>'; |
| 184 | + $form .= '<td>' . Xml::input( 'zip', '15', $this->form_data['zip'], array( 'type' => 'text', 'maxlength' => '15', 'id' => 'zip' ) ) . |
| 185 | + '</td>'; |
| 186 | + $form .= '</tr>'; |
| 187 | + // country |
| 188 | + $form .= $this->getCountryField(); |
| 189 | + |
| 190 | + /* |
| 191 | + $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true; |
| 192 | + $form .= '<tr>'; |
| 193 | + $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value ); |
| 194 | + $form .= ' ' . Xml::label( wfMsg( 'payflowpro_gateway-anon-message' ), 'comment-option' ) . '</td>'; |
| 195 | + $form .= '</tr>'; |
| 196 | + |
| 197 | + $form .= $this->getEmailOptField(); |
| 198 | + */ |
| 199 | + |
| 200 | + return $form; |
| 201 | + } |
| 202 | + |
| 203 | + public function generateFormSubmit() { |
| 204 | + |
| 205 | + // cc submit button |
| 206 | + if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) { |
| 207 | + $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) ); |
| 208 | + } else { |
| 209 | + $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit', 'style' => 'display: none;' ) ); |
| 210 | + } |
| 211 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) ); |
| 212 | + $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-donor-submit' ), 'onclick' => 'document.payment.PaypalRedirect.value=0;return true;', 'type' => 'submit' ) ); |
| 213 | + $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button |
| 214 | + $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) . |
| 215 | + wfMsg( 'payflowpro_gateway-donate-click' ); |
| 216 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
| 217 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
| 218 | + |
| 219 | + // paypal submit button |
| 220 | + if ( $this->form_data['card'] == 'cc1' || $this->form_data['card'] == 'cc2' || $this->form_data['card'] == 'cc3' || $this->form_data['card'] == 'cc4' ) { |
| 221 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal', 'style' => 'display: none;' ) ); |
| 222 | + } else { |
| 223 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal' ) ); |
| 224 | + } |
| 225 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) ); |
| 226 | + $form .= Html::hidden( 'PaypalRedirect', 0 ); |
| 227 | + $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-donor-submit' ), 'onclick' => 'document.payment.PaypalRedirect.value=1;return true;', 'type' => 'submit' ) ); |
| 228 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage |
| 229 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit |
| 230 | + return $form; |
| 231 | + } |
| 232 | + |
| 233 | + /** |
| 234 | + * Generate form closing elements |
| 235 | + */ |
| 236 | + public function generateFormClose() { |
| 237 | + $form = ''; |
| 238 | + // add hidden fields |
| 239 | + $hidden_fields = $this->getHiddenFields(); |
| 240 | + foreach ( $hidden_fields as $field => $value ) { |
| 241 | + $form .= Html::hidden( $field, $value ); |
| 242 | + } |
| 243 | + |
| 244 | + $form .= Xml::closeElement( 'form' ); // close form 'payment' |
| 245 | + $form .= $this->generateDonationFooter(); |
| 246 | + $form .= Xml::closeElement( 'td' ); |
| 247 | + $form .= Xml::closeElement( 'tr' ); |
| 248 | + $form .= Xml::closeElement( 'table' ); |
| 249 | + return $form; |
| 250 | + } |
| 251 | + |
| 252 | + /** |
| 253 | + * Generates the donation footer ("There are other ways to give...") |
| 254 | + * @returns string of HTML |
| 255 | + */ |
| 256 | + public function generateDonationFooter() { |
| 257 | + global $wgScriptPath; |
| 258 | + $form = ''; |
| 259 | + $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' ) ); |
| 260 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-secure-logos' ) ); |
| 261 | + $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate-nonanimated.png" ) ) ); |
| 262 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-secure-logos |
| 263 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-text' ) ); |
| 264 | + $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-otherways-short' ) ); |
| 265 | + $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-credit-storage-processing' ) ); |
| 266 | + $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-question-comment' ) ); |
| 267 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-text |
| 268 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info |
| 269 | + return $form; |
| 270 | + } |
| 271 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter4' ] = $dir . 'forms/TwoColumnLetter4.php'; |
33 | 33 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter5' ] = $dir . 'forms/TwoColumnLetter5.php'; |
34 | 34 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter6' ] = $dir . 'forms/TwoColumnLetter6.php'; |
| 35 | +$wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter7' ] = $dir . 'forms/TwoColumnLetter7.php'; |
35 | 36 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter' ] = $dir . 'forms/TwoStepTwoColumnLetter.php'; |
36 | 37 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetterCA' ] = $dir . 'forms/TwoStepTwoColumnLetterCA.php'; |
37 | 38 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter2' ] = $dir . 'forms/TwoStepTwoColumnLetter2.php'; |