Index: trunk/extensions/StyleGuideDemo/HTMLStyleForm.php |
— | — | @@ -60,29 +60,29 @@ |
61 | 61 | */ |
62 | 62 | class HTMLStyleForm { |
63 | 63 | |
64 | | - # A mapping of 'type' inputs onto standard HTMLFormField subclasses |
| 64 | + # A mapping of 'type' inputs onto standard HTMLStyleFormField subclasses |
65 | 65 | 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', |
81 | 81 | |
82 | | - # HTMLTextField will output the correct type="" attribute automagically. |
| 82 | + # HTMLStyleTextField will output the correct type="" attribute automagically. |
83 | 83 | # There are about four zillion other HTML5 input types, like url, but |
84 | 84 | # 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', |
87 | 87 | ); |
88 | 88 | |
89 | 89 | protected $mMessagePrefix; |
— | — | @@ -118,7 +118,7 @@ |
119 | 119 | protected $mWrapperLegend = false; |
120 | 120 | |
121 | 121 | /** |
122 | | - * Build a new HTMLForm from an array of field attributes |
| 122 | + * Build a new HTMLStyleForm from an array of field attributes |
123 | 123 | * @param $descriptor Array of Field constructs, as described above |
124 | 124 | * @param $context RequestContext available since 1.18, will become compulsory in 1.19. |
125 | 125 | * Obviates the need to call $form->setTitle() |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
180 | | - * Add the HTMLForm-specific JavaScript, if it hasn't been |
| 180 | + * Add the HTMLStyleForm-specific JavaScript, if it hasn't been |
181 | 181 | * done already. |
182 | 182 | * @deprecated since 1.18 load modules with ResourceLoader instead |
183 | 183 | */ |
— | — | @@ -185,7 +185,7 @@ |
186 | 186 | /** |
187 | 187 | * Initialise a new Object for the field |
188 | 188 | * @param $descriptor input Descriptor, as described above |
189 | | - * @return HTMLFormField subclass |
| 189 | + * @return HTMLStyleFormField subclass |
190 | 190 | */ |
191 | 191 | static function loadInputFromParameters( $fieldname, $descriptor ) { |
192 | 192 | if ( isset( $descriptor['class'] ) ) { |
— | — | @@ -214,7 +214,7 @@ |
215 | 215 | function prepareForm() { |
216 | 216 | # Check if we have the info we need |
217 | 217 | 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" ); |
219 | 219 | } |
220 | 220 | |
221 | 221 | # Load data from the request. |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | * Set a callback to a function to do something with the form |
292 | 292 | * once it's been successfully validated. |
293 | 293 | * @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 |
295 | 295 | * return Bool true on success, Bool false if no submission |
296 | 296 | * was attempted, or String HTML output to display on error. |
297 | 297 | */ |
— | — | @@ -373,7 +373,7 @@ |
374 | 374 | /** |
375 | 375 | * Display the form (sending to wgOut), with an appropriate error |
376 | 376 | * 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() |
378 | 378 | */ |
379 | 379 | function displayForm( $submitResult ) { |
380 | 380 | # For good measure (it is the default) |
— | — | @@ -792,7 +792,7 @@ |
793 | 793 | * The parent class to generate form fields. Any field type should |
794 | 794 | * be a subclass of this. |
795 | 795 | */ |
796 | | -abstract class HTMLFormField { |
| 796 | +abstract class HTMLStyleFormField { |
797 | 797 | |
798 | 798 | protected $mValidationCallback; |
799 | 799 | protected $mFilterCallback; |
— | — | @@ -804,7 +804,7 @@ |
805 | 805 | protected $mDefault; |
806 | 806 | |
807 | 807 | /** |
808 | | - * @var HTMLForm |
| 808 | + * @var HTMLStyleForm |
809 | 809 | */ |
810 | 810 | public $mParent; |
811 | 811 | |
— | — | @@ -872,7 +872,7 @@ |
873 | 873 | |
874 | 874 | /** |
875 | 875 | * 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. |
877 | 877 | */ |
878 | 878 | function __construct( $params ) { |
879 | 879 | $this->mParams = $params; |
— | — | @@ -1116,7 +1116,7 @@ |
1117 | 1117 | } |
1118 | 1118 | } |
1119 | 1119 | |
1120 | | -class HTMLTextField extends HTMLFormField { |
| 1120 | +class HTMLStyleTextField extends HTMLStyleFormField { |
1121 | 1121 | function getSize() { |
1122 | 1122 | return isset( $this->mParams['size'] ) |
1123 | 1123 | ? $this->mParams['size'] |
— | — | @@ -1180,7 +1180,7 @@ |
1181 | 1181 | return Html::element( 'input', $attribs ); |
1182 | 1182 | } |
1183 | 1183 | } |
1184 | | -class HTMLTextAreaField extends HTMLFormField { |
| 1184 | +class HTMLStyleTextAreaField extends HTMLStyleFormField { |
1185 | 1185 | function getCols() { |
1186 | 1186 | return isset( $this->mParams['cols'] ) |
1187 | 1187 | ? $this->mParams['cols'] |
— | — | @@ -1223,7 +1223,7 @@ |
1224 | 1224 | /** |
1225 | 1225 | * A field that will contain a numeric value |
1226 | 1226 | */ |
1227 | | -class HTMLFloatField extends HTMLTextField { |
| 1227 | +class HTMLStyleFloatField extends HTMLStyleTextField { |
1228 | 1228 | function getSize() { |
1229 | 1229 | return isset( $this->mParams['size'] ) |
1230 | 1230 | ? $this->mParams['size'] |
— | — | @@ -1270,7 +1270,7 @@ |
1271 | 1271 | /** |
1272 | 1272 | * A field that must contain a number |
1273 | 1273 | */ |
1274 | | -class HTMLIntField extends HTMLFloatField { |
| 1274 | +class HTMLStyleIntField extends HTMLStyleFloatField { |
1275 | 1275 | function validate( $value, $alldata ) { |
1276 | 1276 | $p = parent::validate( $value, $alldata ); |
1277 | 1277 | |
— | — | @@ -1296,7 +1296,7 @@ |
1297 | 1297 | /** |
1298 | 1298 | * A checkbox field |
1299 | 1299 | */ |
1300 | | -class HTMLCheckField extends HTMLFormField { |
| 1300 | +class HTMLStyleCheckField extends HTMLStyleFormField { |
1301 | 1301 | function getInputHTML( $value ) { |
1302 | 1302 | if ( !empty( $this->mParams['invert'] ) ) { |
1303 | 1303 | $value = !$value; |
— | — | @@ -1315,7 +1315,7 @@ |
1316 | 1316 | |
1317 | 1317 | /** |
1318 | 1318 | * 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() |
1320 | 1320 | */ |
1321 | 1321 | function getLabel() { |
1322 | 1322 | return ' '; |
— | — | @@ -1349,7 +1349,7 @@ |
1350 | 1350 | /** |
1351 | 1351 | * A select dropdown field. Basically a wrapper for Xmlselect class |
1352 | 1352 | */ |
1353 | | -class HTMLSelectField extends HTMLFormField { |
| 1353 | +class HTMLStyleSelectField extends HTMLStyleFormField { |
1354 | 1354 | function validate( $value, $alldata ) { |
1355 | 1355 | $p = parent::validate( $value, $alldata ); |
1356 | 1356 | |
— | — | @@ -1357,7 +1357,7 @@ |
1358 | 1358 | return $p; |
1359 | 1359 | } |
1360 | 1360 | |
1361 | | - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
| 1361 | + $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] ); |
1362 | 1362 | |
1363 | 1363 | if ( in_array( $value, $validOptions ) ) |
1364 | 1364 | return true; |
— | — | @@ -1391,7 +1391,7 @@ |
1392 | 1392 | /** |
1393 | 1393 | * Select dropdown field, with an additional "other" textbox. |
1394 | 1394 | */ |
1395 | | -class HTMLSelectOrOtherField extends HTMLTextField { |
| 1395 | +class HTMLStyleSelectOrOtherField extends HTMLStyleTextField { |
1396 | 1396 | static $jsAdded = false; |
1397 | 1397 | |
1398 | 1398 | function __construct( $params ) { |
— | — | @@ -1416,7 +1416,7 @@ |
1417 | 1417 | if ( $value !== false ) { |
1418 | 1418 | $valInSelect = in_array( |
1419 | 1419 | $value, |
1420 | | - HTMLFormField::flattenOptions( $this->mParams['options'] ) |
| 1420 | + HTMLStyleFormField::flattenOptions( $this->mParams['options'] ) |
1421 | 1421 | ); |
1422 | 1422 | } |
1423 | 1423 | |
— | — | @@ -1474,7 +1474,7 @@ |
1475 | 1475 | /** |
1476 | 1476 | * Multi-select field |
1477 | 1477 | */ |
1478 | | -class HTMLMultiSelectField extends HTMLFormField { |
| 1478 | +class HTMLStyleMultiSelectField extends HTMLStyleFormField { |
1479 | 1479 | |
1480 | 1480 | public function __construct( $params ){ |
1481 | 1481 | parent::__construct( $params ); |
— | — | @@ -1496,7 +1496,7 @@ |
1497 | 1497 | |
1498 | 1498 | # If all options are valid, array_intersect of the valid options |
1499 | 1499 | # and the provided options will return the provided options. |
1500 | | - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
| 1500 | + $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] ); |
1501 | 1501 | |
1502 | 1502 | $validValues = array_intersect( $value, $validOptions ); |
1503 | 1503 | if ( count( $validValues ) == count( $value ) ) { |
— | — | @@ -1590,7 +1590,7 @@ |
1591 | 1591 | * select dropdown. |
1592 | 1592 | * @todo FIXME: If made 'required', only the text field should be compulsory. |
1593 | 1593 | */ |
1594 | | -class HTMLSelectAndOtherField extends HTMLSelectField { |
| 1594 | +class HTMLStyleSelectAndOtherField extends HTMLStyleSelectField { |
1595 | 1595 | |
1596 | 1596 | function __construct( $params ) { |
1597 | 1597 | if ( array_key_exists( 'other', $params ) ) { |
— | — | @@ -1607,7 +1607,7 @@ |
1608 | 1608 | $params['options'] = self::parseMessage( wfMsg( $params['options-message'], $params['other'] ) ); |
1609 | 1609 | } else { |
1610 | 1610 | # Sulk |
1611 | | - throw new MWException( 'HTMLSelectAndOtherField called without any options' ); |
| 1611 | + throw new MWException( 'HTMLStyleSelectAndOtherField called without any options' ); |
1612 | 1612 | } |
1613 | 1613 | $this->mFlatOptions = self::flattenOptions( $params['options'] ); |
1614 | 1614 | |
— | — | @@ -1723,7 +1723,7 @@ |
1724 | 1724 | } |
1725 | 1725 | |
1726 | 1726 | 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 |
1728 | 1728 | # field, which is not useful here. But we do want the validation further up |
1729 | 1729 | # the chain |
1730 | 1730 | $p = parent::validate( $value[1], $alldata ); |
— | — | @@ -1743,7 +1743,7 @@ |
1744 | 1744 | /** |
1745 | 1745 | * Radio checkbox fields. |
1746 | 1746 | */ |
1747 | | -class HTMLRadioField extends HTMLFormField { |
| 1747 | +class HTMLStyleRadioField extends HTMLStyleFormField { |
1748 | 1748 | function validate( $value, $alldata ) { |
1749 | 1749 | $p = parent::validate( $value, $alldata ); |
1750 | 1750 | |
— | — | @@ -1755,7 +1755,7 @@ |
1756 | 1756 | return false; |
1757 | 1757 | } |
1758 | 1758 | |
1759 | | - $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
| 1759 | + $validOptions = HTMLStyleFormField::flattenOptions( $this->mParams['options'] ); |
1760 | 1760 | |
1761 | 1761 | if ( in_array( $value, $validOptions ) ) { |
1762 | 1762 | return true; |
— | — | @@ -1766,7 +1766,7 @@ |
1767 | 1767 | |
1768 | 1768 | /** |
1769 | 1769 | * This returns a block of all the radio options, in one cell. |
1770 | | - * @see includes/HTMLFormField#getInputHTML() |
| 1770 | + * @see includes/HTMLStyleFormField#getInputHTML() |
1771 | 1771 | */ |
1772 | 1772 | function getInputHTML( $value ) { |
1773 | 1773 | $html = $this->formatOptions( $this->mParams['options'], $value ); |
— | — | @@ -1813,7 +1813,7 @@ |
1814 | 1814 | /** |
1815 | 1815 | * An information field (text blob), not a proper input. |
1816 | 1816 | */ |
1817 | | -class HTMLInfoField extends HTMLFormField { |
| 1817 | +class HTMLStyleInfoField extends HTMLStyleFormField { |
1818 | 1818 | function __construct( $info ) { |
1819 | 1819 | $info['nodata'] = true; |
1820 | 1820 | |
— | — | @@ -1837,7 +1837,7 @@ |
1838 | 1838 | } |
1839 | 1839 | } |
1840 | 1840 | |
1841 | | -class HTMLHiddenField extends HTMLFormField { |
| 1841 | +class HTMLStyleHiddenField extends HTMLStyleFormField { |
1842 | 1842 | public function __construct( $params ) { |
1843 | 1843 | parent::__construct( $params ); |
1844 | 1844 | |
— | — | @@ -1866,9 +1866,9 @@ |
1867 | 1867 | |
1868 | 1868 | /** |
1869 | 1869 | * 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). |
1871 | 1871 | */ |
1872 | | -class HTMLSubmitField extends HTMLFormField { |
| 1872 | +class HTMLStyleSubmitField extends HTMLStyleFormField { |
1873 | 1873 | |
1874 | 1874 | function __construct( $info ) { |
1875 | 1875 | $info['nodata'] = true; |
— | — | @@ -1898,7 +1898,7 @@ |
1899 | 1899 | } |
1900 | 1900 | } |
1901 | 1901 | |
1902 | | -class HTMLEditTools extends HTMLFormField { |
| 1902 | +class HTMLStyleEditTools extends HTMLStyleFormField { |
1903 | 1903 | public function getInputHTML( $value ) { |
1904 | 1904 | return ''; |
1905 | 1905 | } |