r75114 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75113‎ | r75114 | r75115 >
Date:21:41, 20 October 2010
Author:kaldari
Status:deferred
Tags:
Comment:
adding new TwoColumnLetter2.php
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter2.php (added) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter2.php
@@ -0,0 +1,170 @@
 2+<?php
 3+
 4+class PayflowProGateway_Form_TwoColumnLetter extends PayflowProGateway_Form_OneStepTwoColumn {
 5+
 6+ public function __construct( &$form_data, &$form_errors ) {
 7+ global $wgOut, $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;
 84+ $scriptPath = "$wgScriptPath/extensions/DonationInterface/payflowpro_gateway/includes";
 85+
 86+ $form = '';
 87+
 88+ // PayPal button
 89+ // make sure we have a paypal url set to redirect the user to before displaying the button
 90+ if ( strlen( $wgPayflowGatewayPaypalURL )) {
 91+ $form .= '<tr>';
 92+ $form .= '<td class="label"></td>';
 93+ $form .= '<td class="paypal-button">';
 94+ $form .= Xml::hidden( 'PaypalRedirect', false );
 95+ $form .= Xml::tags( 'div',
 96+ array(),
 97+ '<a href="#" onclick="document.payment.PaypalRedirect.value=\'true\';document.payment.submit();"><img src="'.$scriptPath.'/donate_with_paypal.gif"/></a>'
 98+ );
 99+ $form .= '</td>';
 100+ $form .= '</tr>';
 101+ }
 102+
 103+ // name
 104+ $form .= $this->getNameField();
 105+
 106+ // email
 107+ $form .= $this->getEmailField();
 108+
 109+ // anonymous
 110+ $form .= '<tr>';
 111+ $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
 112+ $form .= ' ' . Xml::label( wfMsg( 'payflowpro_gateway-anon-message' ), 'comment-option' ) . '</td>';
 113+ $form .= '</tr>';
 114+
 115+ // email agreement
 116+ $form .= $this->getEmailOptField();
 117+
 118+ // amount
 119+ $form .= $this->getAmountField();
 120+
 121+ // card logos
 122+ $form .= '<tr>';
 123+ $form .= '<td />';
 124+ $form .= '<td>&nbsp;<br/>' . Xml::element( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/credit_card_logos.gif" )) . '</td>';
 125+ $form .= '</tr>';
 126+
 127+ // card number
 128+ $form .= $this->getCardNumberField();
 129+
 130+ // cvv
 131+ $form .= $this->getCvvField();
 132+
 133+ // expiry
 134+ $form .= $this->getExpiryField();
 135+
 136+ // street
 137+ $form .= $this->getStreetField();
 138+
 139+ // city
 140+ $form .= $this->getCityField();
 141+
 142+ // state
 143+ $form .= $this->getStateField();
 144+ // zip
 145+ $form .= $this->getZipField();
 146+
 147+ // country
 148+ $form .= $this->getCountryField();
 149+
 150+ return $form;
 151+ }
 152+
 153+ /**
 154+ * Generate form closing elements
 155+ */
 156+ public function generateFormClose() {
 157+ $form = '';
 158+ // add hidden fields
 159+ $hidden_fields = $this->getHiddenFields();
 160+ foreach ( $hidden_fields as $field => $value ) {
 161+ $form .= Xml::hidden( $field, $value );
 162+ }
 163+
 164+ $form .= Xml::closeElement( 'form' ); // close form 'payment'
 165+ $form .= $this->generateDonationFooter();
 166+ $form .= Xml::closeElement( 'td' );
 167+ $form .= Xml::closeElement( 'tr' );
 168+ $form .= Xml::closeElement( 'table' );
 169+ return $form;
 170+ }
 171+}

Status & tagging log