r108541 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108540‎ | r108541 | r108542 >
Date:20:06, 10 January 2012
Author:khorn
Status:ok
Tags:
Comment:
Cleanup: Added a tiny bit of documentation and removed code that is either no longer used, or has been moved elsewhere.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/Form.php
@@ -106,14 +106,15 @@
107107
108108 /**
109109 * Initialize the form
110 - *
 110+ * Called by the main Form construtror, this was clearly meant to be
 111+ * overridden where necessary in child classes.
111112 */
112113 protected function init() {
113114 }
114115
115116 /**
116 - * Override the link in the logo to redirec to a particular form
117 - * rather than the main page
 117+ * Override the link in the logo to redirect to a particular form
 118+ * rather than the main page. Called by the form class constructor.
118119 */
119120 public function loadLogoLinkOverride() {
120121 global $wgOut;
@@ -147,6 +148,7 @@
148149
149150 /**
150151 * Generates the donation footer ("There are other ways to give...")
 152+ * This function is not used by any RapidHTML forms.
151153 * @return string of HTML
152154 */
153155 public function generateDonationFooter() {
@@ -171,6 +173,7 @@
172174
173175 /**
174176 * Generate the menu select of countries
 177+ * This function is not used by any RapidHTML forms.
175178 * @fixme It would be great if we could default the country to the user's locale
176179 * @fixme We should also do a locale-based asort on the country dropdown
177180 * (see http://us.php.net/asort)
@@ -214,7 +217,9 @@
215218 }
216219
217220 /**
218 - * Genereat the menu select of credit cards
 221+ * Generate the menu select of credit cards
 222+ * getCreditCardTypeField helper function, and getCreditCardTypeField is
 223+ * only used by TwoStepTwoColumn.php.
219224 *
220225 * @fixme Abstract out the setting of avaiable cards
221226 * @return string
@@ -249,6 +254,12 @@
250255 return $card_menu;
251256 }
252257
 258+ /**
 259+ * Generates the expiry month dropdown form element.
 260+ * This function is not used by any RapidHTML forms.
 261+ * @global type $wgLang
 262+ * @return type
 263+ */
253264 public function generateExpiryMonthDropdown() {
254265 global $wgLang;
255266
@@ -280,6 +291,12 @@
281292 return $expiry_month_menu;
282293 }
283294
 295+ /**
 296+ * Generates the expiry year dropdown form element.
 297+ * This function is not used by any RapidHTML forms.
 298+ * @global type $wgLang
 299+ * @return type
 300+ */
284301 public function generateExpiryYearDropdown() {
285302 // derive the previously set expiry year, if set
286303 $year = NULL;
@@ -309,6 +326,7 @@
310327
311328 /**
312329 * Generates the dropdown for states
 330+ * This function is not used by any RapidHTML forms.
313331 * @fixme Alpha sort (ideally locale alpha sort) states in dropdown
314332 * AFTER state names are translated
315333 * @return string The entire HTML select element for the state dropdown list
@@ -340,6 +358,7 @@
341359
342360 /**
343361 * Generates the dropdown list for available currencies
 362+ * This function is not used by any RapidHTML forms.
344363 *
345364 * @param string $defaultCurrencyCode default currency code to select
346365 * @param boolean $showCardsOnCurrencyChange Allow javascript onchange="showCards();" to be executed.
@@ -396,12 +415,16 @@
397416
398417 /**
399418 * Generates the radio buttons for selecting a donation amount
 419+ * This function appears to be used only by the Universal Test form, and as
 420+ * such should be moved to that class and away from the class all the forms
 421+ * are eventually descended from.
400422 *
401423 * @param array $options
402424 *
403425 * $options:
404426 * - displayCurrencyDropdown: Display the currency dropdown selector
405427 * - showCardsOnCurrencyChange: Passed to @see Gateway_Form::generateStateDropdown()
 428+ * - setCurrency: ???
406429 *
407430 * @todo
408431 * - Use Xml object to generate form elements.
@@ -410,6 +433,7 @@
411434 */
412435 public function generateAmountByRadio( $options = array() ) {
413436
 437+ //TODO: Stop using extract.
414438 extract( $options );
415439
416440 $showCardsOnCurrencyChange = isset( $showCardsOnCurrencyChange ) ? (boolean) $showCardsOnCurrencyChange : true;
@@ -470,8 +494,8 @@
471495
472496 /**
473497 * Set the hidden field array
474 - *
475498 * If you pass nothing in, we'll set the fields for you.
 499+ * This function is not used by any RapidHTML forms.
476500 * @param array $hidden_fields
477501 */
478502 public function setHiddenFields( $hidden_fields = NULL ) {
@@ -510,7 +534,7 @@
511535
512536 /**
513537 * Gets an array of the hidden fields for the form
514 - *
 538+ * This function is not used by any RapidHTML forms.
515539 * @return array
516540 */
517541 public function getHiddenFields() {
@@ -546,6 +570,14 @@
547571 $this->captcha_html = $html;
548572 }
549573
 574+ /**
 575+ * generateBannerHeader
 576+ * Generates a banner header based on the existance of set masthead data,
 577+ * and/or a gateway header defined in LocalSettings.
 578+ * This function is not used by any RapidHTML forms.
 579+ * @global type $wgOut
 580+ * @global type $wgRequest
 581+ */
550582 protected function generateBannerHeader() {
551583 global $wgOut, $wgRequest;
552584 $g = $this->gateway;
@@ -568,6 +600,13 @@
569601 }
570602 }
571603
 604+ /**
 605+ * generateTextTemplate: Loads the text from the appropraite template.
 606+ * This function is not used by any RapidHTML forms.
 607+ * @global type $wgOut
 608+ * @global type $wgRequest
 609+ * @return string
 610+ */
572611 protected function generateTextTemplate() {
573612 global $wgOut, $wgRequest;
574613 $text_template = $wgRequest->getText( 'text_template', '2010/JimmyAppealLong' );
@@ -582,6 +621,11 @@
583622 return $template;
584623 }
585624
 625+ /**
 626+ * Builds and returns the email form field
 627+ * This function is not used by any RapidHTML forms.
 628+ * @return string
 629+ */
586630 protected function getEmailField() {
587631 // email
588632 $form = '<tr>';
@@ -595,6 +639,11 @@
596640 return $form;
597641 }
598642
 643+ /**
 644+ * Builds and returns the amount form field.
 645+ * This function is not used by any RapidHTML forms.
 646+ * @return string
 647+ */
599648 protected function getAmountField() {
600649 $otherChecked = false;
601650 $amount = -1;
@@ -621,6 +670,11 @@
622671 return $form;
623672 }
624673
 674+ /**
 675+ * getCardnumberField builds and returns the credit card number field.
 676+ * This function is not used by any RapidHTML forms.
 677+ * @return string
 678+ */
625679 protected function getCardnumberField() {
626680 $card_num = ( $this->gateway->getGlobal( "Test" ) ) ? $this->getEscapedValue( 'card_num' ) : '';
627681 $form = '';
@@ -642,6 +696,11 @@
643697 return $form;
644698 }
645699
 700+ /**
 701+ * Builds and returns the cvv form field
 702+ * This function is not used by any RapidHTML forms.
 703+ * @return string
 704+ */
646705 protected function getCvvField() {
647706 $cvv = ( $this->gateway->getGlobal( "Test" ) ) ? $this->getEscapedValue( 'cvv' ) : '';
648707
@@ -656,6 +715,11 @@
657716 return $form;
658717 }
659718
 719+ /**
 720+ * Builds and returns the street form element.
 721+ * This function is not used by any RapidHTML forms.
 722+ * @return string
 723+ */
660724 protected function getStreetField() {
661725 $form = '<tr>';
662726 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['street'] . '</span></td>';
@@ -668,6 +732,11 @@
669733 return $form;
670734 }
671735
 736+ /**
 737+ * getCityField builds and returns the city form element.
 738+ * This function is not used by any RapidHTML forms.
 739+ * @return string
 740+ */
672741 protected function getCityField() {
673742 $form = '<tr>';
674743 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['city'] . '</span></td>';
@@ -680,6 +749,11 @@
681750 return $form;
682751 }
683752
 753+ /**
 754+ * Builds and returns the zip (postal) code form element.
 755+ * This function is not used by any RapidHTML forms.
 756+ * @return string
 757+ */
684758 protected function getZipField() {
685759 $form = '<tr>';
686760 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['zip'] . '</span></td>';
@@ -692,6 +766,11 @@
693767 return $form;
694768 }
695769
 770+ /**
 771+ * Builds and returns the name-related form controls.
 772+ * This function is not used by any RapidHTML forms.
 773+ * @return string
 774+ */
696775 protected function getNameField() {
697776 $form = '<tr>';
698777 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['fname'] . '</span></td>';
@@ -707,6 +786,11 @@
708787 return $form;
709788 }
710789
 790+ /**
 791+ * Builds and returns the comment message.
 792+ * This function is not used by any RapidHTML forms.
 793+ * @return string
 794+ */
711795 protected function getCommentMessageField() {
712796 $form = '<tr>';
713797 $form .= '<td colspan="2">';
@@ -716,6 +800,11 @@
717801 return $form;
718802 }
719803
 804+ /**
 805+ * Builds and returns the comment form field.
 806+ * This function is not used by any RapidHTML forms.
 807+ * @return string
 808+ */
720809 protected function getCommentField() {
721810 $form = '<tr>';
722811 $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-comment' ), 'comment' ) . '</td>';
@@ -724,6 +813,11 @@
725814 return $form;
726815 }
727816
 817+ /**
 818+ * Builds and returns the comment option checkbox.
 819+ * This function is not used by any RapidHTML forms.
 820+ * @return string
 821+ */
728822 protected function getCommentOptionField() {
729823 $comment_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'comment-option' ) : true;
730824 $form = '<tr>';
@@ -733,6 +827,11 @@
734828 return $form;
735829 }
736830
 831+ /**
 832+ * Builds and returns the email-opt checkbox.
 833+ * This function is not used by any RapidHTML forms.
 834+ * @return string
 835+ */
737836 protected function getEmailOptField() {
738837 $email_opt_value = ( $this->gateway->posted ) ? $this->getEscapedValue( 'email-opt' ) : true;
739838 $form = '<tr>';
@@ -747,6 +846,12 @@
748847 return $form;
749848 }
750849
 850+ /**
 851+ * Builds and returns the paypal button form element.
 852+ * This function is only used in TwoColumnPayPal.php.
 853+ * @global type $wgScriptPath
 854+ * @return string
 855+ */
751856 protected function getPaypalButton() {
752857 global $wgScriptPath;
753858 $scriptPath = "$wgScriptPath/extensions/DonationInterface/gateway_forms/includes";
@@ -761,6 +866,11 @@
762867 return $form;
763868 }
764869
 870+ /**
 871+ * Builds and returns the state dropdown form element.
 872+ * This function is not used by any RapidHTML forms.
 873+ * @return string
 874+ */
765875 protected function getStateField() {
766876 $form = '<tr>';
767877 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['state'] . '</span></td>';
@@ -772,6 +882,12 @@
773883 return $form;
774884 }
775885
 886+ /**
 887+ * Builds and returns the country form element.
 888+ * This function is not used by any RapidHTML forms.
 889+ * @param type $defaultCountry
 890+ * @return string
 891+ */
776892 protected function getCountryField( $defaultCountry = null ) {
777893 $form = '<tr>';
778894 $form .= '<td colspan=2><span class="creditcard-error-msg">' . $this->form_errors['country'] . '</span></td>';
@@ -783,6 +899,11 @@
784900 return $form;
785901 }
786902
 903+ /**
 904+ * Builds and returns the card type dropdown.
 905+ * This function is only used by TwoStepTwoColumn.php
 906+ * @return string
 907+ */
787908 protected function getCreditCardTypeField() {
788909 $form = '<tr>';
789910 $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-card' ), 'card_type' ) . '</td>';
@@ -791,6 +912,11 @@
792913 return $form;
793914 }
794915
 916+ /**
 917+ * Builds and returns the credit card expiry form controls.
 918+ * This function is not used by any RapidHTML forms.
 919+ * @return string
 920+ */
795921 protected function getExpiryField() {
796922 $form = '<tr>';
797923 $form .= '<td class="label">' . Xml::label( wfMsg( 'donate_interface-donor-expiration' ), 'expiration' ) . '</td>';
@@ -799,16 +925,31 @@
800926 return $form;
801927 }
802928
 929+ /**
 930+ * Uses resource loader to load the form validation javascript.
 931+ * @global type $wgOut
 932+ */
803933 protected function loadValidateJs() {
804934 global $wgOut;
805935 $wgOut->addModules( 'di.form.core.validate' );
806936 }
807937
 938+ /**
 939+ * Uses the resource loader to add the api client side javascript, usually
 940+ * only when the form is caching.
 941+ * @global type $wgOut
 942+ */
808943 protected function loadApiJs() {
809944 global $wgOut;
810945 $wgOut->addModules( 'pfp.form.core.api' );
811946 }
812947
 948+ /**
 949+ * Loads the OWA javascript.
 950+ * if OWA is enabled, this is called by the main form constructor.
 951+ * @global type $wgOut
 952+ * @global type $wgScriptPath
 953+ */
813954 protected function loadOwaJs() {
814955 global $wgOut, $wgScriptPath;
815956 $wgOut->addHeadItem( 'owa_tracker', '<script type="text/javascript" src="https://owa.wikimedia.org/owa/modules/base/js/owa.tracker-combined-min.js"></script>' );
@@ -823,7 +964,7 @@
824965
825966 /**
826967 * Generate HTML for <noscript> tags
827 - *
 968+ * This function is not used by any RapidHTML forms.
828969 * For displaying when a user does not have Javascript enabled in their browser.
829970 */
830971 protected function getNoScript() {
@@ -877,7 +1018,9 @@
8781019
8791020 /**
8801021 * Get the form id
881 - *
 1022+ * This function appears to be used only by the Universal Test form, and as
 1023+ * such should be moved to that class and away from the class all the forms
 1024+ * are eventually descended from.
8821025 * @return string
8831026 */
8841027 protected function getFormId() {
@@ -888,7 +1031,9 @@
8891032
8901033 /**
8911034 * Get the form name
892 - *
 1035+ * This function appears to be used only by the Universal Test form, and as
 1036+ * such should be moved to that class and away from the class all the forms
 1037+ * are eventually descended from.
8931038 * @return string
8941039 */
8951040 protected function getFormName() {
@@ -897,28 +1042,8 @@
8981043 }
8991044
9001045 /**
901 - * Get the payment method
902 - *
903 - * @return string
 1046+ * Create and return the Verisign logo (small size) form element.
9041047 */
905 - protected function getPaymentMethod() {
906 -
907 - return $this->getEscapedValue( 'payment_method' );
908 - }
909 -
910 - /**
911 - * Get the payment submethod
912 - *
913 - * @return string
914 - */
915 - protected function getPaymentSubmethod() {
916 - return $this->getEscapedValue( 'payment_submethod' );
917 - }
918 -
919 - /**
920 - * Create the Verisign logo (small size)
921 - *
922 - */
9231048 protected function getSmallSecureLogo() {
9241049
9251050 $form = '<table id="secureLogo" width="130" border="0" cellpadding="2" cellspacing="0" title=' . wfMsg('donate_interface-securelogo-title') . '>';

Follow-up revisions

RevisionCommit summaryAuthorDate
r112287MFT r101785, r105938, r105941, r105953, r106109, r106158, r106259, r106366, r...khorn01:29, 24 February 2012

Status & tagging log