r76529 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76528‎ | r76529 | r76530 >
Date:18:49, 11 November 2010
Author:kaldari
Status:deferred
Tags:
Comment:
new 1-step
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter6.php (added) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter6.css (added) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/TwoColumnLetter6.php
@@ -0,0 +1,254 @@
 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/TwoColumnLetter5.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(), '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+ $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+ $form .= Xml::openElement( 'table', array( 'id' => 'payflow-table-cc' ) );
 145+
 146+ // name
 147+ $form .= $this->getNameField();
 148+
 149+ // email
 150+ $form .= $this->getEmailField();
 151+
 152+ // card number
 153+ $form .= $this->getCardNumberField();
 154+
 155+ // cvv
 156+ $form .= $this->getCvvField();
 157+
 158+ // expiry
 159+ $form .= $this->getExpiryField();
 160+
 161+ // street
 162+ $form .= $this->getStreetField();
 163+
 164+ // city
 165+ $form .= $this->getCityField();
 166+
 167+ // state
 168+ $form .= $this->getStateField();
 169+
 170+ // zip
 171+ $form .= '<tr>';
 172+ $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>';
 173+ $form .= '</tr>';
 174+ $form .= '<tr>';
 175+ $form .= '<td class="label">' . Xml::label( wfMsg( 'payflowpro_gateway-donor-postal' ), 'zip' ) . '</td>';
 176+ $form .= '<td>' . Xml::input( 'zip', '15', $this->form_data['zip'], array( 'type' => 'text', 'maxlength' => '15', 'id' => 'zip' ) ) .
 177+ '</td>';
 178+ $form .= '</tr>';
 179+ // country
 180+ $form .= $this->getCountryField();
 181+
 182+ /*
 183+ $comment_opt_value = ( $wgRequest->wasPosted() ) ? $this->form_data[ 'comment-option' ] : true;
 184+ $form .= '<tr>';
 185+ $form .= '<td class="check-option" colspan="2">' . Xml::check( 'comment-option', $comment_opt_value );
 186+ $form .= ' ' . Xml::label( wfMsg( 'payflowpro_gateway-anon-message' ), 'comment-option' ) . '</td>';
 187+ $form .= '</tr>';
 188+
 189+ $form .= $this->getEmailOptField();
 190+ */
 191+
 192+ return $form;
 193+ }
 194+
 195+ public function generateFormSubmit() {
 196+ // cc submit button
 197+ $form = Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit' ) );
 198+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) );
 199+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-donor-submit' ), 'onclick' => 'document.payment.PaypalRedirect.value=0;submit_form( this );', 'type' => 'submit' ) );
 200+ $form .= Xml::closeElement( 'div' ); // close div#mw-donate-submit-button
 201+ $form .= Xml::openElement( 'div', array( 'class' => 'mw-donate-submessage', 'id' => 'payflowpro_gateway-donate-submessage' ) ) .
 202+ wfMsg( 'payflowpro_gateway-donate-click' );
 203+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 204+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 205+
 206+ // paypal submit button
 207+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-form-submit-paypal' ) );
 208+ $form .= Xml::openElement( 'div', array( 'id' => 'mw-donate-submit-button' ) );
 209+ $form .= Html::hidden( 'PaypalRedirect', 0 );
 210+ $form .= Xml::element( 'input', array( 'class' => 'button-plain', 'value' => wfMsg( 'payflowpro_gateway-donor-submit' ), 'onclick' => 'document.payment.PaypalRedirect.value=1;document.payment.submit();', 'type' => 'submit' ) );
 211+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-submessage
 212+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-form-submit
 213+
 214+ return $form;
 215+ }
 216+
 217+ /**
 218+ * Generate form closing elements
 219+ */
 220+ public function generateFormClose() {
 221+ $form = '';
 222+ // add hidden fields
 223+ $hidden_fields = $this->getHiddenFields();
 224+ foreach ( $hidden_fields as $field => $value ) {
 225+ $form .= Html::hidden( $field, $value );
 226+ }
 227+
 228+ $form .= Xml::closeElement( 'form' ); // close form 'payment'
 229+ $form .= $this->generateDonationFooter();
 230+ $form .= Xml::closeElement( 'td' );
 231+ $form .= Xml::closeElement( 'tr' );
 232+ $form .= Xml::closeElement( 'table' );
 233+ return $form;
 234+ }
 235+
 236+ /**
 237+ * Generates the donation footer ("There are other ways to give...")
 238+ * @returns string of HTML
 239+ */
 240+ public function generateDonationFooter() {
 241+ global $wgScriptPath;
 242+ $form = '';
 243+ $form .= Xml::openElement( 'div', array( 'class' => 'payflow-cc-form-section', 'id' => 'payflowpro_gateway-donate-addl-info' ) );
 244+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-secure-logos' ) );
 245+ $form .= Xml::tags( 'p', array( 'class' => '' ), Xml::openElement( 'img', array( 'src' => $wgScriptPath . "/extensions/DonationInterface/payflowpro_gateway/includes/rapidssl_ssl_certificate-nonanimated.png" ) ) );
 246+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-secure-logos
 247+ $form .= Xml::openElement( 'div', array( 'id' => 'payflowpro_gateway-donate-addl-info-text' ) );
 248+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-otherways-short' ) );
 249+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-credit-storage-processing' ) );
 250+ $form .= Xml::tags( 'p', array( 'class' => '' ), wfMsg( 'payflowpro_gateway-question-comment' ) );
 251+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info-text
 252+ $form .= Xml::closeElement( 'div' ); // close div#payflowpro_gateway-donate-addl-info
 253+ return $form;
 254+ }
 255+}
Index: trunk/extensions/DonationInterface/payflowpro_gateway/forms/css/TwoColumnLetter6.css
@@ -0,0 +1,122 @@
 2+.payflow-cc-form-section {
 3+ float: none;
 4+ margin-right: 0em;
 5+ margin-bottom: 1em;
 6+}
 7+
 8+#payflowpro_gateway-cc_form_container {
 9+ width: 100%;
 10+}
 11+
 12+#payflowpro_gateway-cc_form_form {
 13+ width: 475px;
 14+ float: right;
 15+ margin-left: 2em;
 16+ padding-left: 2em;
 17+ border-left: 1px solid #BBBBBB;
 18+}
 19+
 20+#payflowpro_gateway-cc_form_letter {
 21+ height: 100%;
 22+}
 23+
 24+#payflowpro_gateway-cc_form_letter p {
 25+ font-size: 1.125em;
 26+ margin-bottom: 1.2em;
 27+}
 28+
 29+#payflowpro_gateway-personal-info {
 30+ margin-right:0 !important;
 31+}
 32+
 33+#payflowpro_gateway-donate-addl-info-secure-logos {
 34+ float: left;
 35+ margin-right: 2em;
 36+}
 37+
 38+#payflowpro_gateway-cc_form_letter_inside {
 39+ padding-top: .5em;
 40+}
 41+
 42+#payflowpro_gateway-cc_otherways {
 43+ padding-top: .5em;
 44+ display: block;
 45+}
 46+#payflowpro_gateway-donate-addl-info {
 47+ margin-top:3em !important;
 48+ margin-bottom:1em !important;
 49+}
 50+
 51+#appeal {
 52+ /* background-color:#F3F3F3; */
 53+ background-color: transparent;
 54+ /* border-color:silver; */
 55+ border-color: transparent;
 56+ border-style:solid;
 57+ border-width:1px 0 1px 1px;
 58+ padding:16px 24px 24px;
 59+}
 60+#appeal-head {
 61+ font-size:1.5em;
 62+ line-height:1.125em;
 63+ padding-bottom:0.5em;
 64+ padding-top:0.125em;
 65+}
 66+#appeal-body {
 67+ font-size:1.125em;
 68+ margin-bottom:1em;
 69+ padding:0.2em 0;
 70+}
 71+#donate {
 72+ background-color:#A9D9A3;
 73+ border:1px solid #5EAC58;
 74+ padding:16px 24px 24px;
 75+ width:450px;
 76+}
 77+#donate-head {
 78+ border-color:#5EAC58;
 79+ font-size:1.5em;
 80+ line-height:1.125em;
 81+ padding-bottom:0.5em;
 82+ padding-top:0.125em;
 83+}
 84+#donate-body {
 85+ font-size:1.125em;
 86+ margin-bottom:1em;
 87+}
 88+
 89+/* Hiding content border */
 90+table {
 91+ background-color: transparent;
 92+}
 93+div#content {
 94+ background-color: transparent !important;
 95+ background-image: none !important;
 96+}
 97+div#mw-head-base {
 98+ background-image: none !important;
 99+}
 100+input#fname {
 101+ width:133px !important;
 102+}
 103+input#lname {
 104+ width:155px !important;
 105+}
 106+input.fullwidth {
 107+ width:300px !important;
 108+}
 109+
 110+div#payflowpro_gateway-form-submit-paypal {
 111+ display: block;
 112+}
 113+payflowpro_gateway-form-submit {
 114+ display: none;
 115+}
 116+payflow-table-cc {
 117+ display: none;
 118+}
 119+
 120+/* Hiding stuff we don't need */
 121+h1#firstHeading, div#contentSub {
 122+ display: none;
 123+}

Status & tagging log