r75967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75966‎ | r75967 | r75968 >
Date:00:33, 4 November 2010
Author:kaldari
Status:deferred
Tags:
Comment:
stuff for Thursday
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter5.php (added) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter5.php
@@ -0,0 +1,220 @@
 2+<?php
 3+
 4+class PayflowProGateway_Form_TwoColumnLetter5 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/TwoColumnLetter.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 validate_form(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=\'true\';document.payment.submit();"><img src="' . $scriptPath . '/paypal.png"/></a></td>';
 91+ $form .= '</tr>';
 92+ */
 93+
 94+ // amount
 95+ $form .= $this->getAmountField();
 96+
 97+ // name
 98+ $form .= $this->getNameField();
 99+
 100+ // email
 101+ $form .= $this->getEmailField();
 102+
 103+ $form .= '<tr>';
 104+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-payment' ) ) . '</td>';
 105+ $form .= '<td>' . Xml::radio( 'method', 1, $this->form_data['amount'] == 2 ) . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) ) .
 106+ Xml::radio( 'method', 2, $this->form_data['method'] == 2 ) . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-mastercard.png" ) ) .
 107+ Xml::radio( 'method', 3, $this->form_data['method'] == 3 ) . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-amex.png" ) ) .
 108+ Xml::radio( 'method', 4, $this->form_data['method'] == 4 ) . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-discover.png" ) ) .
 109+ Xml::radio( 'method', 5, $this->form_data['method'] == 5 ) . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-paypal.png" ) ) .
 110+ '</td>';
 111+ $form .= '</tr>';
 112+
 113+
 114+ // make sure we have a paypal url set to redirect the user to before displaying the button
 115+ if ( strlen( $wgPayflowGatewayPaypalURL ) ) {
 116+ $form .= '<tr>';
 117+ $form .= '<td class="label"></td>';
 118+ $form .= '<td>';
 119+ $form .= Html::hidden( 'PaypalRedirect', false );
 120+ $form .= Xml::tags( 'div',
 121+ array(),
 122+ Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/card-visa.png" ) )
 123+ );
 124+ $form .= '</td>';
 125+ $form .= '</tr>';
 126+ }
 127+
 128+ // card number
 129+ $form .= $this->getCardNumberField();
 130+
 131+ // cvv
 132+ $form .= $this->getCvvField();
 133+
 134+ // expiry
 135+ $form .= $this->getExpiryField();
 136+
 137+ // street
 138+ $form .= $this->getStreetField();
 139+
 140+ // city
 141+ $form .= $this->getCityField();
 142+
 143+ // state
 144+ $form .= $this->getStateField();
 145+ // zip
 146+ $form .= $this->getZipField();
 147+
 148+ // country
 149+ $form .= $this->getCountryField();
 150+
 151+ // anonymous
 152+ $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true;
 153+ $form .= '<tr>';
 154+ $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
 155+ $form .= ' ' . Xml::label( wfMsg( 'payflowpro_gateway-anon-message' ), 'comment-option' ) . '</td>';
 156+ $form .= '</tr>';
 157+
 158+ // email agreement
 159+ $form .= $this->getEmailOptField();
 160+
 161+ return $form;
 162+ }
 163+
 164+ public function generateFormSubmit() {
 165+ // submit button
 166+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) );
 167+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) );
 168+ if ( $this->paypal ) {
 169+ $form .= Html::hidden( 'PaypalRedirect', false );
 170+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-paypal-button' ), 'onclick' => 'document.payment.PaypalRedirect.value=\'true\';document.payment.submit();', 'type' => 'submit' ) );
 171+ } else {
 172+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-donor-submit' ), 'onclick' => 'submit_form( this )', 'type' => 'submit' ) );
 173+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 174+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 175+ wfMsg( 'payflowpro_gateway-donate-click' );
 176+ }
 177+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 178+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 179+
 180+ return $form;
 181+ }
 182+
 183+ /**
 184+ * Generate form closing elements
 185+ */
 186+ public function generateFormClose() {
 187+ $form = '';
 188+ // add hidden fields
 189+ $hidden_fields = $this->getHiddenFields();
 190+ foreach ( $hidden_fields as $field => $value ) {
 191+ $form .= Html::hidden( $field, $value );
 192+ }
 193+
 194+ $form .= Xml::closeElement( 'form' ); // close form 'payment'
 195+ $form .= $this->generateDonationFooter();
 196+ $form .= Xml::closeElement( 'td' );
 197+ $form .= Xml::closeElement( 'tr' );
 198+ $form .= Xml::closeElement( 'table' );
 199+ return $form;
 200+ }
 201+
 202+ /**
 203+ * Generates the donation footer ("There are other ways to give...")
 204+ * @returns string of HTML
 205+ */
 206+ public function generateDonationFooter() {
 207+ global $wgScriptPath;
 208+ $form = '';
 209+ $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' ) );
 210+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-secure-logos' ) );
 211+ $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate.gif" ) ) );
 212+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-secure-logos
 213+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-text' ) );
 214+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-otherways-short' ) );
 215+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-credit-storage-processing' ) );
 216+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-question-comment' ) );
 217+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-text
 218+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info
 219+ return $form;
 220+ }
 221+}

Status & tagging log