Commit graph

89 commits

Author SHA1 Message Date
Gergő Tisza
08ca4e37c5 HTMLForm code style fixes
Change-Id: I30612c7cfde1d76aff7fac24fb2b0033457fbc27
2016-04-17 07:28:52 +00:00
jenkins-bot
12a57c83a4 Merge "Fix typo in HtmlForm::setName phpdoc" 2016-04-02 09:48:20 +00:00
Gergő Tisza
48467bc6b3 Fix typo in HtmlForm::setName phpdoc
Fixes I85f5492e0b99a5661dbed9814a0e3f3b9bc63d32.

Change-Id: I1a034c4fd3eb3020a4a725604ece6e992d34a271
2016-04-02 09:34:51 +00:00
jenkins-bot
e208cf8030 Merge "Unify handling of *-message(s) settings in HTMLForm" 2016-04-01 14:48:19 +00:00
Gergő Tisza
8dc5e1857d Unify handling of *-message(s) settings in HTMLForm
*-message(s) settings were documented as message key strings or arrays
of message key strings, but some actually accepted [key, params...]
arrays as well. They did not accept Message objects, which would be
the cleanest and most flexible method of message passing.

The patch adds a new method to process these settings (which accepts
a messages key, a [key, params...] array or a Message object), and
makes all *-message(s) usage call that.

Change-Id: Ida647973a58bea83fdbd53335e63b5a8615c16e4
2016-04-01 17:07:14 +03:00
Gergő Tisza
eed7a00166 Allow setting HTMLForm name
Change-Id: I85f5492e0b99a5661dbed9814a0e3f3b9bc63d32
2016-04-01 15:22:47 +03:00
Fomafix
7489a3e8f1 Preferences: Add autocomplete="off" to preferences form
This change adds a new method setAutocomplete to the class HTMLForm.
This method allows to set the HTML attribute autocomplete for the form.
This change uses this method to set autocomplete="off" for the preferences form.

Without autocomplete="off" the selections in the preferences get cached in
the browser. This can lead to wrong selected options when the settings get
changed on an other way, for example via API.

Bug: T131047
Change-Id: I2920383b5b8cfca3f1d546315f202985edf417d8
2016-03-29 04:49:20 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
jenkins-bot
de193359ce Merge "Revert "Convert Special:EmailUser to use OOUIHTMLForm"" 2016-01-12 00:09:48 +00:00
Florianschmidtwelzow
1ea58a358a Revert "Convert Special:EmailUser to use OOUIHTMLForm"
This reverts commit bc9b2162cb.

Just in case, this change[1] isn't merged before the next wmf-release (12 January) to unbreak the form.

[1] I3e0c02155428ae400bc3a6d3ed2e66e69ee441fa

Change-Id: I1a594485fbf8c75b4199df2e255dedc7fb90e74d
2016-01-10 14:20:52 +00:00
Timo Tijhof
eebc6782c4 htmform: Document "text" methods that take HTML as such
These methods have confusing names, at least document them better.

Follows-up ef8f440de.

Change-Id: Ia2d6bf474d65829d91cae3aeef7ab2d09c4023cf
2016-01-05 16:46:24 -08:00
jenkins-bot
e2d6e193c9 Merge "HTMLForm: Use <button> and allow differing label and value" 2016-01-04 08:47:01 +00:00
Florian
bc9b2162cb Convert Special:EmailUser to use OOUIHTMLForm
It already used HTMLForm for the main form, but the form, which asked for
the username didn't.

Converted the "Enter username" form to use HTMLForm and show it, if no user-
name was passed to the form, show the main "Send e-mail" form, instead.

Extra points:
 - Let HTMLForm::setSubmit*() function return it's own HTMLForm instance

Bug: T117791
Change-Id: I6231577047c93781496e0f8af6809e2ef49e662a
2016-01-02 18:11:48 +00:00
Florian
b1ff754dd7 Convert Special:ExpandTemplates to OOUI
Extra points:
 * Add error message, when $input was not fiven (previous behaviour was, that
   the form was simply displayed again.

Bug: T117748
Change-Id: Ibe4e010fe9d0b2520c2d6964bd66cb2bca3b0bc7
2016-01-02 16:27:10 +00:00
This, that and the other
400d1d300b HTMLForm: Add comment to help grepping function names
This confuses me every time I try to figure out HTMLForm's logic flow...

Change-Id: I80ff89caeeaac9af6ff435ecd5c4176615d41d82
2016-01-01 16:53:13 +11:00
Brad Jorsch
d949901f3c HTMLForm: Use <button> and allow differing label and value
Submit buttons, whether via HTMLForm::addButton() or HTMLSubmitField,
are difficult to use effectively when the submitted value has to match
the internationalized display label. HTML5 (and HTML4 for that matter)
already has <button> that does what we need, we just need to actually
use it.

But for IE6 and IE7, we can't use <button> because the browser doesn't
handle them correctly. Sniff those browsers to avoid their bugginess
(which the OOUI version should have been doing already for IE6, but
wasn't).

Bug: T121584
Change-Id: I7e15331efb162275c4116bcae61f19d6b884cbe3
2015-12-18 12:41:55 -05:00
jenkins-bot
8732532d47 Merge "Implement HTMLComboboxField" 2015-11-24 19:20:07 +00:00
jenkins-bot
3cab263105 Merge "HTMLForm: Do not render hidden elements as elements" 2015-11-19 16:28:05 +00:00
Bartosz Dziewoński
77d759aab4 Implement HTMLComboboxField
It's a dropdown select with the ability to add custom options, or a
text field with input suggestions, whichever you prefer.

This is meant to be a replacement for HTMLSelectOrOtherField and
HTMLAutoCompleteSelectField.

In regular HTML mode, it uses HTML5 `<datalist>` element with no
custom JavaScript. This is supported by a wide range of browsers
(IE 10+, modern Firefox and Chrome, Opera 12+).

In OOUI mode, it uses a ComboBoxInputWidget.

Depends on: I14b40884f185fb4e5

Bug: T118119
Change-Id: I954d3d24ed4efe90be9596a1bd9586ba3aee1e23
2015-11-12 09:48:27 +01:00
Florian
c762b6899b HTMLForm: Do not render hidden elements as elements
Hidden elements doesn't need an extra element in the DOM, but OOUIHTMLForm
would render one, wrapped into a fieldLayout div.

Fix this by adding the possibility to bypass the output, and only construct
a HTMLFormField element and run the output method.

Bug: T117768
Change-Id: I8c9d2ff862f1b14d72a9bb9e1a51e8745af6d1f4
2015-11-09 16:16:40 +00:00
Florian
ab69c83c64 Implement section support for OOUIHTMLForm
Using a PanelLayout to visually separate the outside content with
the inside one.

Bug: T117757
Change-Id: I177cd7a5f8e8ddf7dc90f452aadb804f6304b0c7
2015-11-04 19:14:24 +01:00
Siebrand Mazeland
950910dc99 Fix PHPCS warnings in includes/htmlform/
Change-Id: Ifbf050c92a84d6af59709632965f48f3d567c0da
2015-09-28 13:35:28 +02:00
jenkins-bot
c6bcef30ae Merge "Hoist validation errors from hidden fields to the top of the form" 2015-09-25 17:56:32 +00:00
Gergő Tisza
16076cbf99 Hoist validation errors from hidden fields to the top of the form
HTMLFormField subclasses are supposed to handle error display but
some (like hidden fields) have no means of doing this. Add
a HTMLFormField::canDisplayErrors() method which can be overridden
to return false, in which case HTMLForm will take care of the
error display.

Also adds a 'rawmessage' message which can be used to wrap
arbitrary text. This can be passed to methods which expect a message
specifier array but do not allow a message object (so the RawMessage
class cannot be used), such as HTMLFormField::trySubmit().

Bug: T112635
Change-Id: I5d73536805774ff2ee0ec64b5442650c4888dc84
2015-09-25 17:40:30 +00:00
jenkins-bot
0a138f1acf Merge "Move HTMLForm-specific styles out of mediawiki.legacy.shared" 2015-09-08 00:12:23 +00:00
Bartosz Dziewoński
0a6803e1e5 HTMLForm: Move header formatting OOUI-specific code to OOUIHTMLForm
* Introduce a getter getHeaderText() and override it in OOUIHTMLForm.
* While we're at it, also introduce getFooterText() (although right
  now we have no need to override this one).
* Use both in HTMLForm where appropriate.

Change-Id: I9a7234ed75b024f24e0a087c9c000bb2024b405f
2015-08-21 18:50:02 +00:00
Bartosz Dziewoński
40abd65b24 HTMLForm: Move section formatting OOUI-specific code to OOUIHTMLForm
* Introduce a new helper function formatSection() and override it
  in OOUIHTMLForm.
  * Bonus: Properly construct the form's FieldsetLayout,
    thanks to I860a96858c4fcac62d63b46e35a9153f22c0a9c9.
  * Bonus: Don't pass silly HTMLForm's classes which don't make
    sense in OOUI mode.

Change-Id: I91af6efa8762e9676efea532381292e221255862
2015-08-21 18:49:38 +00:00
Bartosz Dziewoński
d302cb2de8 Move HTMLForm-specific styles out of mediawiki.legacy.shared
Bug: T89981
Change-Id: Idcd20b4a776fe6741462b09885e05d1e08f67334
2015-08-19 22:20:21 +02:00
jenkins-bot
7a6b211c48 Merge "Revert "Use OOUI HTMLForm for Special:Watchlist"" 2015-07-30 19:05:20 +00:00
Legoktm
8fd9634774 Revert "Use OOUI HTMLForm for Special:Watchlist"
Issues with spacing (T107311), probably shouldn't have
been merged right before the branch cut.

This reverts commit 9508c5bd57.

Change-Id: Ibf2ca5a33b8ab0f7381c720c6c92fbfd7a7c819d
2015-07-30 18:55:20 +00:00
Bartosz Dziewoński
deb0bd858a HTMLForm: Correct documentation
Change-Id: I84f4d886907b2ae988956563fda48e78afb3cfa6
2015-07-29 00:52:17 +02:00
Florian
9508c5bd57 Use OOUI HTMLForm for Special:Watchlist
Bug: T99256
Change-Id: I47a8649208279a4090623a3088112fcff9abc4d3
2015-07-27 20:15:15 +00:00
Kunal Mehta
ba7acbe791 Allow HTMLTitleTextField to work on GET forms
Just skip validation if it is a GET form and the current input is an
empty string. Callers will need to check that it is not the empty string
though.

Also make sure HTMLForm::mMethod is always lowercase.

Change-Id: I605f32048fe97eebd7e04b6ffd799759aeb7f31e
2015-07-24 18:19:36 -07:00
Florian
3f7443df86 HTMLForm: Allow to set the primary flag for submit buttons
Currently, every submit button generated by HTMLForm itself (not via
the descriptor) doesn't have the primary flag and there is no (easy) way
to add it, although this generated submit button is most likely the primary
one.

Add a new function HTMLForm::setSubmitPrimary() to allow a form to set
add the primary flag to this submit button.

Change-Id: I3ce363f995389a87764edb586b4b64ab2b77b0db
2015-07-23 21:48:35 +02:00
Florian
c226b13545 Implement UserInputWidget in OOUI/MW Widgets
To use OOUI for forms with user name autocomplete, the new widget
UserInputWidget interacts like the jQuery pendant (working with css
class "mw-autocomplete-user").

It is also available in HTMLForm as "user".

Example usage: Iaeff912e6437d6ebef0d5b1919ce8cf53a7fd5f1

Change-Id: I9501c85f4288c255bbe3a5284e99b57b6169916f
2015-07-20 06:11:16 +02:00
jenkins-bot
77594dc2ba Merge "HTMLForm: Add 'title' type" 2015-07-16 18:33:13 +00:00
Bartosz Dziewoński
b524a4333f OOUIHTMLForm: Support setWrapperLegend()
Changed FormSpecialPage not to call setWrapperLegend() for OOUI
forms to preserve current default behavior.

Bonus:
* Correct documentation of setWrapperLegend() to state that it
  HTML-escapes legend text.
* Remove hard-coded class="visualClear" in getFormAttributes().
* Allow setWrapperLegend( true ) to display the wrapper without
  legend text.
* Rejigger things so that we can put the legend and "header HTML"
  into correct order.

Bug: T103026
Change-Id: I847c5e18ae5469aa3a68cc9fa37b2a6614476ca2
2015-07-13 19:20:08 +02:00
Kunal Mehta
d7d663bc54 HTMLForm: Add 'title' type
HTMLTitleTextField will automatically validate title input, can
optionally ensure the title is in a specific namespace, is creatable, or
already exists.

The field currently doesn't support GET requests since validation on
empty strings fails.

Bug: T104420
Change-Id: I45718462570d0a523a148c3830b1116b634df050
2015-07-09 15:44:09 +00:00
Bartosz Dziewoński
552568c63d OOUIHTMLForm: Correctly handle submit modifier flags
Rejigger some HTMLForm internals to remove the hardcoded assumption of
using 'mw-ui' classes.

Bug: T98903
Change-Id: Icc20453c999c761b87e19a71ccd43d93b9c1bfa7
2015-06-27 13:14:08 +00:00
Florian
fd10cd5b95 Use HTMLForm for Special:Export
* Transform all input fields to use HtmlForm as preparation for enabling
  MediaWiki UI eveywhere.
* Remove protected whitespace for HTMLCheckField (adds empty line to div-layout)
* Add a new HTMLForm input field "Text with Button" and "Namespaceselector with Button"

Bug: T73434
Change-Id: I53cc019c3ca94cec8f3c05500d0c604c1af7f688
2015-06-14 16:48:26 +00:00
Florian
091936eb2e HTMLForm: Break long lines
Change-Id: Ia09a28ccc361d1a54069bd23a412831fe9c20f34
2015-06-05 03:12:35 +02:00
Kunal Mehta
ede0147134 HTMLForm::factory() doesn't throw MWExceptions
Change-Id: I0104bf1dd9ebb813aa37f92b21515a964ca2a709
2015-05-27 22:37:33 -07:00
jenkins-bot
5eda39e04b Merge "Implement OOUI display format for HTMLForm" 2015-05-24 12:22:29 +00:00
Mark Holmquist
e85bd04bcd Implement OOUI display format for HTMLForm
Bug: T85291
Change-Id: I6ffe93c16d6b209a0ab08d714ad8ddaefb6acd52
2015-05-23 16:10:08 +02:00
Daniel A. R. Werner
def394bea7 Added documentation for HTMLFormField's "hide-if"
Change-Id: I410c58dc0586cfe97e39668c9608ce0d9e10a08b
2015-05-18 22:16:58 +00:00
jenkins-bot
8b82353738 Merge "Use HTMLForm for Special:LinkSerach" 2015-05-07 01:25:01 +00:00
Bartosz Dziewoński
9172be5a0c HTMLForm: Add wfDeprecated to isVForm
Change-Id: Idd8eb9cf63794c5a71439c130ad28564e6d3e750
2015-05-01 22:17:50 +00:00
Florian
e072d7bd8c Use HTMLForm for Special:LinkSerach
* Convert Special:LinkSearch to use HTMLForm for preparation of MediaWiki
  UI everywhere
* Add support for dir= tag in HTMLTextField

Bug: T73439
Change-Id: I8503c391a40f1654f8570578a9de9015d86c9845
2015-04-19 21:10:45 +02:00
Florianschmidtwelzow
e4f5c50652 Use HTMLForm for Special:FileDuplicateSearch
* Prepare the usage of MediaWiki UI.
* Add new HTMLForm output mode "inline" (very close to "raw")

Bug: 71436
Change-Id: I12240aaf624dff5219b344648b20373594b5ec46
2015-03-29 17:23:12 +02:00
Bartosz Dziewoński
f338a1cf31 HTMLForm: Separate VForm code to a subclass
…and in general, work with the existing HTMLForm design for defining
display formats, rather than against it.

Breaking changes:
* HTMLForm::isVForm() is now deprecated.
* You can no longer do this:
    $form = new HTMLForm( … );
    $form->setDisplayFormat( 'vform' ); // throws exception
  Instead, do this:
    $form = HTMLForm::factory( 'vform', … );
  When using FormSpecialPage, override the new getDisplayFormat() method
  instead of calling $form->setDisplayFormat() in the alterForm() method.
  (Other display formats are not affected, only 'vform'.)

Bug fixes:
* Correctly suppress empty labels for VForm fields
* Correctly disable <fieldset/> wrappers for VForms

Other benefits:
* Reduce code duplication related to $getFieldHtmlMethod
* Introduce HTMLForm::factory() method for constructing HTMLForms

Related cleanup:
* Correctly style 'reset' buttons in MediaWiki UI mode
* Label $wgHTMLFormAllowTableFormat as a mobile-specific hack
* Display checkboxes normally in MediaWiki UI mode (removed weird
  override that only broke things). Also, always render checkboxes
  in VForms as .mw-ui-checkbox.
* self:: → static::

Bug: T85285
Change-Id: I086a84f1c8cc6a16710709b7806c7f5f96462b32
2015-01-14 19:33:34 +00:00