r100838 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100837‎ | r100838 | r100839 >
Date:18:40, 26 October 2011
Author:awjrichards
Status:ok
Tags:fundraising 
Comment:
Moved resources that get loaded in TwoStepTwoColumn forms out of the constructors into their own function for finer-grained control.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_forms/Form.php
@@ -61,6 +61,10 @@
6262 * add form-specific css - the path can be set in child classes
6363 * using $this->setStylePath, which should be called before
6464 * calling parent::__construct()
 65+ *
 66+ * @TODO ditch this and start using ResourceLoader. Perhaps do something
 67+ * similar to how resources are getting loaded in TwoStepTwoColumn and
 68+ * its children.
6569 */
6670 if ( !strlen( $this->getStylePath() ) ) {
6771 $this->setStylePath();
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumn.php
@@ -4,9 +4,6 @@
55
66 public function __construct( &$gateway, &$form_errors ) {
77 parent::__construct( $gateway, $form_errors );
8 - // load validation and placeholder JS
9 - $this->loadValidateJs();
10 - $this->loadPlaceholders();
118 }
129
1310 public function loadPlaceholders() {
@@ -21,6 +18,7 @@
2219 * @return string The entire form HTML
2320 */
2421 public function getForm() {
 22+ $this->loadResources();
2523 $form = $this->generateFormStart();
2624 $form .= $this->getCaptchaHTML();
2725 $form .= $this->generateFormSubmit();
@@ -28,6 +26,19 @@
2927 return $form;
3028 }
3129
 30+ /**
 31+ * Load resources required by this form
 32+ *
 33+ * This will get called in getForm(). If getForm() is not defined in any
 34+ * child classes, but child classes should not load the same resources
 35+ * as are defined here, just overload this method in the child class
 36+ * to define what (if any) resources ought to be loaded.
 37+ */
 38+ public function loadResources() {
 39+ $this->loadValidateJs();
 40+ $this->loadPlaceholders();
 41+ }
 42+
3243 public function generateFormStart() {
3344 $form = $this->generateBannerHeader();
3445
Index: trunk/extensions/DonationInterface/gateway_forms/TwoStepTwoColumnLetter3.php
@@ -12,6 +12,15 @@
1313 parent::__construct( $gateway, $form_errors );
1414 }
1515
 16+ /**
 17+ * Load resources required by this form
 18+ *
 19+ * @see parent::loadResources()
 20+ */
 21+ public function loadResources() {
 22+ $this->loadValidateJs();
 23+ }
 24+
1625 public function loadPlaceholders() {
1726 global $wgOut;
1827 // form placeholder values

Status & tagging log