r100040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100039‎ | r100040 | r100041 >
Date:15:48, 17 October 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Rename HTMLFormField clone and derived classes, about which my IDE was complaining extremely vocally...
Modified paths:
  • /trunk/extensions/StyleGuideDemo/HTMLStyleForm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/StyleGuideDemo/HTMLStyleForm.php
@@ -60,29 +60,29 @@
6161 */
6262 class HTMLStyleForm {
6363
64 - # A mapping of 'type' inputs onto standard HTMLFormField subclasses
 64+ # A mapping of 'type' inputs onto standard HTMLStyleFormField subclasses
6565 static $typeMappings = array(
66 - 'text' => 'HTMLTextField',
67 - 'textarea' => 'HTMLTextAreaField',
68 - 'select' => 'HTMLSelectField',
69 - 'radio' => 'HTMLRadioField',
70 - 'multiselect' => 'HTMLMultiSelectField',
71 - 'check' => 'HTMLCheckField',
72 - 'toggle' => 'HTMLCheckField',
73 - 'int' => 'HTMLIntField',
74 - 'float' => 'HTMLFloatField',
75 - 'info' => 'HTMLInfoField',
76 - 'selectorother' => 'HTMLSelectOrOtherField',
77 - 'selectandother' => 'HTMLSelectAndOtherField',
78 - 'submit' => 'HTMLSubmitField',
79 - 'hidden' => 'HTMLHiddenField',
80 - 'edittools' => 'HTMLEditTools',
 66+ 'text' => 'HTMLStyleTextField',
 67+ 'textarea' => 'HTMLStyleTextAreaField',
 68+ 'select' => 'HTMLStyleSelectField',
 69+ 'radio' => 'HTMLStyleRadioField',
 70+ 'multiselect' => 'HTMLStyleMultiSelectField',
 71+ 'check' => 'HTMLStyleCheckField',
 72+ 'toggle' => 'HTMLStyleCheckField',
 73+ 'int' => 'HTMLStyleIntField',
 74+ 'float' => 'HTMLStyleFloatField',
 75+ 'info' => 'HTMLStyleInfoField',
 76+ 'selectorother' => 'HTMLStyleSelectOrOtherField',
 77+ 'selectandother' => 'HTMLStyleSelectAndOtherField',
 78+ 'submit' => 'HTMStyleLSubmitField',
 79+ 'hidden' => 'HTMLStyleHiddenField',
 80+ 'edittools' => 'HTMLStyleEditTools',
8181
82 - # HTMLTextField will output the correct type="" attribute automagically.
 82+ # HTMLStyleTextField will output the correct type="" attribute automagically.
8383 # There are about four zillion other HTML5 input types, like url, but
8484 # we don't use those at the moment, so no point in adding all of them.
85 - 'email' => 'HTMLTextField',
86 - 'password' => 'HTMLTextField',
 85+ 'email' => 'HTMLStyleTextField',
 86+ 'password' => 'HTMLStyleTextField',
8787 );
8888
8989 protected $mMessagePrefix;
@@ -118,7 +118,7 @@
119119 protected $mWrapperLegend = false;
120120
121121 /**
122 - * Build a new HTMLForm from an array of field attributes
 122+ * Build a new HTMLStyleForm from an array of field attributes
123123 * @param $descriptor Array of Field constructs, as described above
124124 * @param $context RequestContext available since 1.18, will become compulsory in 1.19.
125125 * Obviates the need to call $form->setTitle()
@@ -176,7 +176,7 @@
177177 }
178178
179179 /**
180 - * Add the HTMLForm-specific JavaScript, if it hasn't been
 180+ * Add the HTMLStyleForm-specific JavaScript, if it hasn't been
181181 * done already.
182182 * @deprecated since 1.18 load modules with ResourceLoader instead
183183 */
@@ -185,7 +185,7 @@
186186 /**
187187 * Initialise a new Object for the field
188188 * @param $descriptor input Descriptor, as described above
189 - * @return HTMLFormField subclass
 189+ * @return HTMLStyleFormField subclass
190190 */
191191 static function loadInputFromParameters( $fieldname, $descriptor ) {
192192 if ( isset( $descriptor['class'] ) ) {
@@ -214,7 +214,7 @@
215215 function prepareForm() {
216216 # Check if we have the info we need
217217 if ( !$this->mTitle instanceof Title && $this->mTitle !== false ) {
218 - throw new MWException( "You must call setTitle() on an HTMLForm" );
 218+ throw new MWException( "You must call setTitle() on an HTMLStyleForm" );
219219 }
220220
221221 # Load data from the request.
@@ -290,7 +290,7 @@
291291 * Set a callback to a function to do something with the form
292292 * once it's been successfully validated.
293293 * @param $cb String function name. The function will be passed
294 - * the output from HTMLForm::filterDataForSubmit, and must
 294+ * the output from HTMLStyleForm::filterDataForSubmit, and must
295295 * return Bool true on success, Bool false if no submission
296296 * was attempted, or String HTML output to display on error.
297297 */
@@ -373,7 +373,7 @@
374374 /**
375375 * Display the form (sending to wgOut), with an appropriate error
376376 * message or stack of messages, and any validation errors, etc.
377 - * @param $submitResult Mixed output from HTMLForm::trySubmit()
 377+ * @param $submitResult Mixed output from HTMLStyleForm::trySubmit()
378378 */
379379 function displayForm( $submitResult ) {
380380 # For good measure (it is the default)
@@ -792,7 +792,7 @@
793793 * The parent class to generate form fields. Any field type should
794794 * be a subclass of this.
795795 */
796 -abstract class HTMLFormField {
 796+abstract class HTMLStyleFormField {
797797
798798 protected $mValidationCallback;
799799 protected $mFilterCallback;
@@ -804,7 +804,7 @@
805805 protected $mDefault;
806806
807807 /**
808 - * @var HTMLForm
 808+ * @var HTMLStyleForm
809809 */
810810 public $mParent;
811811
@@ -872,7 +872,7 @@
873873
874874 /**
875875 * Initialise the object
876 - * @param $params array Associative Array. See HTMLForm doc for syntax.
 876+ * @param $params array Associative Array. See HTMLStyleForm doc for syntax.
877877 */
878878 function __construct( $params ) {
879879 $this->mParams = $params;
@@ -1116,7 +1116,7 @@
11171117 }
11181118 }
11191119
1120 -class HTMLTextField extends HTMLFormField {
 1120+class HTMLStyleTextField extends HTMLStyleFormField {
11211121 function getSize() {
11221122 return isset( $this->mParams['size'] )
11231123 ? $this->mParams['size']
@@ -1180,7 +1180,7 @@
11811181 return Html::element( 'input', $attribs );
11821182 }
11831183 }
1184 -class HTMLTextAreaField extends HTMLFormField {
 1184+class HTMLStyleTextAreaField extends HTMLStyleFormField {
11851185 function getCols() {
11861186 return isset( $this->mParams['cols'] )
11871187 ? $this->mParams['cols']
@@ -1223,7 +1223,7 @@
12241224 /**
12251225 * A field that will contain a numeric value
12261226 */
1227 -class HTMLFloatField extends HTMLTextField {
 1227+class HTMLStyleFloatField extends HTMLStyleTextField {
12281228 function getSize() {
12291229 return isset( $this->mParams['size'] )
12301230 ? $this->mParams['size']
@@ -1270,7 +1270,7 @@
12711271 /**
12721272 * A field that must contain a number
12731273 */
1274 -class HTMLIntField extends HTMLFloatField {
 1274+class HTMLStyleIntField extends HTMLStyleFloatField {
12751275 function validate( $value, $alldata ) {
12761276 $p = parent::validate( $value, $alldata );
12771277
@@ -1296,7 +1296,7 @@
12971297 /**
12981298 * A checkbox field
12991299 */
1300 -class HTMLCheckField extends HTMLFormField {
 1300+class HTMLStyleCheckField extends HTMLStyleFormField {
13011301 function getInputHTML( $value ) {
13021302 if ( !empty( $this->mParams['invert'] ) ) {
13031303 $value = !$value;
@@ -1315,7 +1315,7 @@
13161316
13171317 /**
13181318 * For a checkbox, the label goes on the right hand side, and is
1319 - * added in getInputHTML(), rather than HTMLFormField::getRow()
 1319+ * added in getInputHTML(), rather than HTMLStyleFormField::getRow()
13201320 */
13211321 function getLabel() {
13221322 return ' ';
@@ -1349,7 +1349,7 @@
13501350 /**
13511351 * A select dropdown field. Basically a wrapper for Xmlselect class
13521352 */
1353 -class HTMLSelectField extends HTMLFormField {
 1353+class HTMLStyleSelectField extends HTMLStyleFormField {
13541354 function validate( $value, $alldata ) {
13551355 $p = parent::validate( $value, $alldata );
13561356
@@ -1357,7 +1357,7 @@
13581358 return $p;
13591359 }
13601360
1361 - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
 1361+ $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] );
13621362
13631363 if ( in_array( $value, $validOptions ) )
13641364 return true;
@@ -1391,7 +1391,7 @@
13921392 /**
13931393 * Select dropdown field, with an additional "other" textbox.
13941394 */
1395 -class HTMLSelectOrOtherField extends HTMLTextField {
 1395+class HTMLStyleSelectOrOtherField extends HTMLStyleTextField {
13961396 static $jsAdded = false;
13971397
13981398 function __construct( $params ) {
@@ -1416,7 +1416,7 @@
14171417 if ( $value !== false ) {
14181418 $valInSelect = in_array(
14191419 $value,
1420 - HTMLFormField::flattenOptions( $this->mParams['options'] )
 1420+ HTMLStyleFormField::flattenOptions( $this->mParams['options'] )
14211421 );
14221422 }
14231423
@@ -1474,7 +1474,7 @@
14751475 /**
14761476 * Multi-select field
14771477 */
1478 -class HTMLMultiSelectField extends HTMLFormField {
 1478+class HTMLStyleMultiSelectField extends HTMLStyleFormField {
14791479
14801480 public function __construct( $params ){
14811481 parent::__construct( $params );
@@ -1496,7 +1496,7 @@
14971497
14981498 # If all options are valid, array_intersect of the valid options
14991499 # and the provided options will return the provided options.
1500 - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
 1500+ $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] );
15011501
15021502 $validValues = array_intersect( $value, $validOptions );
15031503 if ( count( $validValues ) == count( $value ) ) {
@@ -1590,7 +1590,7 @@
15911591 * select dropdown.
15921592 * @todo FIXME: If made 'required', only the text field should be compulsory.
15931593 */
1594 -class HTMLSelectAndOtherField extends HTMLSelectField {
 1594+class HTMLStyleSelectAndOtherField extends HTMLStyleSelectField {
15951595
15961596 function __construct( $params ) {
15971597 if ( array_key_exists( 'other', $params ) ) {
@@ -1607,7 +1607,7 @@
16081608 $params['options'] = self::parseMessage( wfMsg( $params['options-message'], $params['other'] ) );
16091609 } else {
16101610 # Sulk
1611 - throw new MWException( 'HTMLSelectAndOtherField called without any options' );
 1611+ throw new MWException( 'HTMLStyleSelectAndOtherField called without any options' );
16121612 }
16131613 $this->mFlatOptions = self::flattenOptions( $params['options'] );
16141614
@@ -1723,7 +1723,7 @@
17241724 }
17251725
17261726 function validate( $value, $alldata ) {
1727 - # HTMLSelectField forces $value to be one of the options in the select
 1727+ # HTMLStyleSelectField forces $value to be one of the options in the select
17281728 # field, which is not useful here. But we do want the validation further up
17291729 # the chain
17301730 $p = parent::validate( $value[1], $alldata );
@@ -1743,7 +1743,7 @@
17441744 /**
17451745 * Radio checkbox fields.
17461746 */
1747 -class HTMLRadioField extends HTMLFormField {
 1747+class HTMLStyleRadioField extends HTMLStyleFormField {
17481748 function validate( $value, $alldata ) {
17491749 $p = parent::validate( $value, $alldata );
17501750
@@ -1755,7 +1755,7 @@
17561756 return false;
17571757 }
17581758
1759 - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] );
 1759+ $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] );
17601760
17611761 if ( in_array( $value, $validOptions ) ) {
17621762 return true;
@@ -1766,7 +1766,7 @@
17671767
17681768 /**
17691769 * This returns a block of all the radio options, in one cell.
1770 - * @see includes/HTMLFormField#getInputHTML()
 1770+ * @see includes/HTMLStyleFormField#getInputHTML()
17711771 */
17721772 function getInputHTML( $value ) {
17731773 $html = $this->formatOptions( $this->mParams['options'], $value );
@@ -1813,7 +1813,7 @@
18141814 /**
18151815 * An information field (text blob), not a proper input.
18161816 */
1817 -class HTMLInfoField extends HTMLFormField {
 1817+class HTMLStyleInfoField extends HTMLStyleFormField {
18181818 function __construct( $info ) {
18191819 $info['nodata'] = true;
18201820
@@ -1837,7 +1837,7 @@
18381838 }
18391839 }
18401840
1841 -class HTMLHiddenField extends HTMLFormField {
 1841+class HTMLStyleHiddenField extends HTMLStyleFormField {
18421842 public function __construct( $params ) {
18431843 parent::__construct( $params );
18441844
@@ -1866,9 +1866,9 @@
18671867
18681868 /**
18691869 * Add a submit button inline in the form (as opposed to
1870 - * HTMLForm::addButton(), which will add it at the end).
 1870+ * HTMLStyleForm::addButton(), which will add it at the end).
18711871 */
1872 -class HTMLSubmitField extends HTMLFormField {
 1872+class HTMLStyleSubmitField extends HTMLStyleFormField {
18731873
18741874 function __construct( $info ) {
18751875 $info['nodata'] = true;
@@ -1898,7 +1898,7 @@
18991899 }
19001900 }
19011901
1902 -class HTMLEditTools extends HTMLFormField {
 1902+class HTMLStyleEditTools extends HTMLStyleFormField {
19031903 public function getInputHTML( $value ) {
19041904 return '';
19051905 }

Status & tagging log