Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoStepTwoColumnLetter.php |
— | — | @@ -0,0 +1,156 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class PayflowProGateway_Form_TwoStepTwoColumnLetter extends PayflowProGateway_Form_TwoStepTwoColumn { |
| 5 | + public function __construct( &$form_data, &$form_errors ) { |
| 6 | + global $wgOut, $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/TwoColumnLetter.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( 'div', array( 'id' => 'payflowpro_gateway-cc_form_container')); |
| 22 | + |
| 23 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_form', 'class' => 'payflowpro_gateway-cc_form_column')); |
| 24 | + |
| 25 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard' ) ); |
| 26 | + |
| 27 | + // provide a place at the top of the form for displaying general messages |
| 28 | + if ( $this->form_errors['general'] ) { |
| 29 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-payflow-general-error' )); |
| 30 | + if ( is_array( $this->form_errors['general'] )) { |
| 31 | + foreach ( $this->form_errors['general'] as $this->form_errors_msg ) { |
| 32 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 33 | + } |
| 34 | + } else { |
| 35 | + $form .= Xml::tags( 'p', array( 'class' => 'creditcard-error-msg' ), $this->form_errors_msg ); |
| 36 | + } |
| 37 | + $form .= Xml::closeElement( 'div' ); // close div#mw-payflow-general-error |
| 38 | + } |
| 39 | + |
| 40 | + // open form |
| 41 | + $form .= Xml::openElement( 'div', array( 'id' => 'mw-creditcard-form' ) ); |
| 42 | + |
| 43 | + // Xml::element seems to convert html to htmlentities |
| 44 | + $form .= "<p class='creditcard-error-msg'>" . $this->form_errors['retryMsg'] . "</p>"; |
| 45 | + $form .= Xml::openElement( 'form', array( 'name' => 'payment', 'method' => 'post', 'action' => '', 'onsubmit' => 'return validate_form(this)', 'autocomplete' => 'off' ) ); |
| 46 | + |
| 47 | + $form .= $this->generateBillingContainer(); |
| 48 | + return $form; |
| 49 | + } |
| 50 | + |
| 51 | + public function generateFormEnd() { |
| 52 | + global $wgRequest, $wgOut; |
| 53 | + $form = ''; |
| 54 | + |
| 55 | + $form .= $this->generateFormClose(); |
| 56 | + |
| 57 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter', 'class' => 'payflowpro_gateway-cc_form_column')); |
| 58 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-cc_form_letter_inside' )); |
| 59 | + |
| 60 | + $text_template = $wgRequest->getText( 'text_template' ); |
| 61 | + // if the user has uselang set, honor that, otherwise default to the language set for the form defined by 'language' in the query string |
| 62 | + if ( $wgRequest->getText( 'language' )) $text_template .= '/' . $this->form_data[ 'language' ]; |
| 63 | + |
| 64 | + $template = ( strlen( $text_template )) ? $wgOut->parse( '{{'.$text_template.'}}' ) : ''; |
| 65 | + // if the template doesn't exist, prevent the display of the red link |
| 66 | + if ( preg_match( '/redlink\=1/', $template )) $template = NULL; |
| 67 | + $form .= $template; |
| 68 | + |
| 69 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter |
| 70 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-cc_form_letter_inside |
| 71 | + return $form; |
| 72 | + } |
| 73 | + |
| 74 | + protected function generateBillingContainer() { |
| 75 | + $form = ''; |
| 76 | + $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-personal-info' )); |
| 77 | + $form .= Xml::tags( 'h3', array( 'class' => 'payflow-cc-form-header','id' => 'payflow-cc-form-header-personal' ), wfMsg( 'payflowpro_gateway-make-your-donation' )); |
| 78 | + $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-donor' ) ); |
| 79 | + $form .= $this->generateBillingFields(); |
| 80 | + $form .= Xml::closeElement( 'table' ); // close table#payflow-table-donor |
| 81 | + $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-personal-info |
| 82 | + |
| 83 | + return $form; |
| 84 | + } |
| 85 | + |
| 86 | + protected function generateBillingFields() { |
| 87 | + global $wgScriptPath; |
| 88 | + $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes"; |
| 89 | + |
| 90 | + $form = ''; |
| 91 | + |
| 92 | + // name |
| 93 | + $form .= $this->getNameField(); |
| 94 | + |
| 95 | + // email |
| 96 | + $form .= $this->getEmailField(); |
| 97 | + |
| 98 | + //comment message |
| 99 | + $form .= $this->getCommentMessageField(); |
| 100 | + |
| 101 | + //comment |
| 102 | + $form .= $this->getCommentField(); |
| 103 | + |
| 104 | + // anonymous |
| 105 | + $form .= $this->getCommentOptionField(); |
| 106 | + |
| 107 | + // email agreement |
| 108 | + $form .= $this->getEmailOptField(); |
| 109 | + |
| 110 | + // amount |
| 111 | + $form .= $this->getAmountField(); |
| 112 | + |
| 113 | + // card number |
| 114 | + $form .= $this->getCardNumberField(); |
| 115 | + |
| 116 | + // cvv |
| 117 | + $form .= $this->getCvvField(); |
| 118 | + |
| 119 | + // expiry |
| 120 | + $form .= $this->getExpiryField(); |
| 121 | + |
| 122 | + // street |
| 123 | + $form .= $this->getStreetField(); |
| 124 | + |
| 125 | + // city |
| 126 | + $form .= $this->getCityField(); |
| 127 | + |
| 128 | + // state |
| 129 | + $form .= $this->getStateField(); |
| 130 | + // zip |
| 131 | + $form .= $this->getZipField(); |
| 132 | + |
| 133 | + // country |
| 134 | + $form .= $this->getCountryField(); |
| 135 | + |
| 136 | + return $form; |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Generate form closing elements |
| 141 | + */ |
| 142 | + public function generateFormClose() { |
| 143 | + $form = ''; |
| 144 | + // add hidden fields |
| 145 | + $hidden_fields = $this->getHiddenFields(); |
| 146 | + foreach ( $hidden_fields as $field => $value ) { |
| 147 | + $form .= Xml::hidden( $field, $value ); |
| 148 | + } |
| 149 | + |
| 150 | + $form .= Xml::closeElement( 'form' ); // close form 'payment' |
| 151 | + $form .= $this->generateDonationFooter(); |
| 152 | + $form .= Xml::closeElement( 'div' ); //close div#mw-creditcard |
| 153 | + $form .= Xml::closeElement( 'div' ); //close div#payflowpro_gateway-cc_form_form |
| 154 | + $form .= Xml::closeElement( 'div' ); //close div#payflowpro_gateway-cc_form_container |
| 155 | + return $form; |
| 156 | + } |
| 157 | +} |
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumn' ] = $dir . 'forms/TwoStepTwoColumn.php'; |
28 | 28 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnPayPal' ] = $dir . 'forms/TwoColumnPayPal.php'; |
29 | 29 | $wgAutoloadClasses[ 'PayflowProGateway_Form_TwoColumnLetter' ] = $dir . 'forms/TwoColumnLetter.php'; |
| 30 | +$wgAutoloadClasses[ 'PayflowProGateway_Form_TwoStepTwoColumnLetter' ] = $dir . 'forms/TwoStepTwoColumnLetter.php'; |
30 | 31 | $wgAutoloadClasses[ 'PayflowProGateway_Form_SingleColumn' ] = $dir . 'forms/SingleColumn.php'; |
31 | 32 | $wgExtensionMessagesFiles['PayflowProGateway'] = $dir . 'payflowpro_gateway.i18n.php'; |
32 | 33 | $wgExtensionMessagesFiles['PayflowProGatewayCountries'] = $dir . 'payflowpro_gateway.countries.i18n.php'; |