Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnPremium.php |
— | — | @@ -0,0 +1,162 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class PayflowProGateway_Form_TwoStepTwoColumnPremium extends PayflowProGateway_Form_TwoStepTwoColumn { |
| 5 | + public function __construct( &$form_data, &$form_errors ) { |
| 6 | + global $wgScriptPath; |
| 7 | + |
| 8 | + // set the path to css, before the parent constructor is called, checking to make sure some child class hasn't already set this |
| 9 | + if ( !strlen( $this->getStylePath() ) ) { |
| 10 | + $this->setStylePath( $wgScriptPath . '/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoStepTwoColumnLetter.css' ); |
| 11 | + } |
| 12 | + |
| 13 | + parent::__construct( $form_data, $form_errors ); |
| 14 | + } |
| 15 | + |
| 16 | + public function generateFormStart() { |
| 17 | + global $wgOut, $wgRequest; |
| 18 | + |
| 19 | + $form = parent::generateBannerHeader(); |
| 20 | + |
| 21 | + $form .= Xml::openElement( 'table', array( 'width' => '100%', 'cellspacing' => 0, 'cellpadding' => 0, 'border' => 0 ) ); |
| 22 | + $form .= Xml::openElement( 'tr' ); |
| 23 | + $form .= Xml::openElement( 'td', array( 'id' => 'appeal', 'valign' => 'top' ) ); |
| 24 | + |
| 25 | + $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' ); |
| 26 | + // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
| 27 | + if ( $wgRequest->getText( 'language' ) ) $text_template .= '/' . $this->form_data[ 'language' ]; |
| 28 | + |
| 29 | + $template = ( strlen( $text_template ) ) ? $wgOut->parse( '{{' . $text_template . '}}' ) : ''; |
| 30 | + // if the template doesn't exist, prevent the display of the red link |
| 31 | + if ( preg_match( '/redlink\=1/', $template ) ) $template = NULL; |
| 32 | + $form .= $template; |
| 33 | + |
| 34 | + $form .= Xml::closeElement( 'td' ); |
| 35 | + |
| 36 | + $form .= Xml::openElement( 'td', array( 'id' => 'donate', 'valign' => 'top' ) ); |
| 37 | + |
| 38 | + // add noscript tags for javascript disabled browsers |
| 39 | + $form .= $this->getNoScript(); |
| 40 | + |
| 41 | + $form .= Xml::tags( 'h2', array( 'id' => 'donate-head' ), wfMsg( 'payflowpro_gateway-please-complete' ) ); |
| 42 | + |
| 43 | + // provide a place at the top of the form for displaying general messages |
| 44 | + if ( $this->form_errors['general'] ) { |
| 45 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' ) ); |
| 46 | + if ( is_array( $this->form_errors['general'] ) ) { |
| 47 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 48 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 49 | + } |
| 50 | + } else { |
| 51 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 52 | + } |
| 53 | + $form .= Xml::closeElement( 'div' ); // close div#mw-payflow-general-error |
| 54 | + } |
| 55 | + |
| 56 | + // Xml::element seems to convert html to htmlentities |
| 57 | + $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 58 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => $this->getNoCacheAction(), 'onsubmit' => 'return formCheck(this)', 'autocomplete' => 'off' ) ); |
| 59 | + |
| 60 | + $form .= $this->generateBillingContainer(); |
| 61 | + return $form; |
| 62 | + } |
| 63 | + |
| 64 | + public function generateFormEnd() { |
| 65 | + $form = ''; |
| 66 | + $form .= $this->generateFormClose(); |
| 67 | + return $form; |
| 68 | + } |
| 69 | + |
| 70 | + protected function generateBillingContainer() { |
| 71 | + $form = ''; |
| 72 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' ) ); |
| 73 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
| 74 | + $form .= $this->generateBillingFields(); |
| 75 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
| 76 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
| 77 | + |
| 78 | + return $form; |
| 79 | + } |
| 80 | + |
| 81 | + protected function generateBillingFields() { |
| 82 | + global $wgScriptPath; |
| 83 | + |
| 84 | + $form = ''; |
| 85 | + |
| 86 | + // name |
| 87 | + $form .= $this->getNameField(); |
| 88 | + |
| 89 | + // email |
| 90 | + $form .= $this->getEmailField(); |
| 91 | + |
| 92 | + // amount |
| 93 | + $form .= '<tr>'; |
| 94 | + $form .= '<td colspan="2"><span class="creditcard-error-msg">' . $this->form_errors['invalidamount'] . '</span></td>'; |
| 95 | + $form .= '</tr>'; |
| 96 | + $form .= '<tr>'; |
| 97 | + $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-amount' ), 'amount' ) . '</td>'; |
| 98 | + $form .= '<td>' . Xml::input( 'amount', '7', $this->form_data['amount'], array( 'type' => 'text', 'maxlength' => '10', 'id' => 'amount' ) ) . |
| 99 | + ' ' . $this->generateCurrencyDropdown() . '</td>'; |
| 100 | + $form .= '</tr>'; |
| 101 | + |
| 102 | + // card logos |
| 103 | + if ( $this->form_data[ 'currency' ] == 'USD' ) { |
| 104 | + $form .= '<tr id="four_cards" style="display:table-row;">'; |
| 105 | + $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" ) ) . '</td>'; |
| 106 | + $form .= '</tr>'; |
| 107 | + $form .= '<tr id="two_cards" style="display:none;">'; |
| 108 | + $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos3.gif" ) ) . '</td>'; |
| 109 | + $form .= '</tr>'; |
| 110 | + } else { |
| 111 | + $form .= '<tr id="four_cards" style="display:none;">'; |
| 112 | + $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" ) ) . '</td>'; |
| 113 | + $form .= '</tr>'; |
| 114 | + $form .= '<tr id="two_cards" style="display:table-row;">'; |
| 115 | + $form .= '<td class="label"> </td><td>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos3.gif" ) ) . '</td>'; |
| 116 | + $form .= '</tr>'; |
| 117 | + } |
| 118 | + |
| 119 | + // card number |
| 120 | + $form .= $this->getCardNumberField(); |
| 121 | + |
| 122 | + // cvv |
| 123 | + $form .= $this->getCvvField(); |
| 124 | + |
| 125 | + // expiry |
| 126 | + $form .= $this->getExpiryField(); |
| 127 | + |
| 128 | + // street |
| 129 | + $form .= $this->getStreetField(); |
| 130 | + |
| 131 | + // city |
| 132 | + $form .= $this->getCityField(); |
| 133 | + |
| 134 | + // state |
| 135 | + $form .= $this->getStateField(); |
| 136 | + // zip |
| 137 | + $form .= $this->getZipField(); |
| 138 | + |
| 139 | + // country |
| 140 | + $form .= $this->getCountryField(); |
| 141 | + |
| 142 | + return $form; |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * Generate form closing elements |
| 147 | + */ |
| 148 | + public function generateFormClose() { |
| 149 | + $form = ''; |
| 150 | + // add hidden fields |
| 151 | + $hidden_fields = $this->getHiddenFields(); |
| 152 | + foreach ( $hidden_fields as $field => $value ) { |
| 153 | + $form .= Html::hidden( $field, $value ); |
| 154 | + } |
| 155 | + |
| 156 | + $form .= Xml::closeElement( 'form' ); // close form 'payment' |
| 157 | + $form .= $this->generateDonationFooter(); |
| 158 | + $form .= Xml::closeElement( 'td' ); |
| 159 | + $form .= Xml::closeElement( 'tr' ); |
| 160 | + $form .= Xml::closeElement( 'table' ); |
| 161 | + return $form; |
| 162 | + } |
| 163 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -36,6 +36,7 @@ |
37 | 37 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetterCA' ] = $dir . 'forms/TwoStepTwoColumnLetterCA.php'; |
38 | 38 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter2' ] = $dir . 'forms/TwoStepTwoColumnLetter2.php'; |
39 | 39 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter3' ] = $dir . 'forms/TwoStepTwoColumnLetter3.php'; |
| 40 | +$wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnPremium' ] = $dir . 'forms/TwoStepTwoColumnPremium.php'; |
40 | 41 | $wgAutoloadClasses[ 'PayflowProGateway_Form_RapidHtml' ] = $dir . 'forms/RapidHtml.php'; |
41 | 42 | $wgAutoloadClasses[ 'PayflowProGateway_Form_SingleColumn' ] = $dir . 'forms/SingleColumn.php'; |
42 | 43 | $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php'; |