Commit graph

152 commits

Author SHA1 Message Date
C. Scott Ananian
d8e612ffaa Replace deprecated call to OutputPage::parse() in HTMLForm
Use OutputPage::parseAsInterface() to tidy the output and make the
selection of user interface language explicit.

Follow-up to Ifeb1ca6eb8b5c743421b8f9e329f1e3658050e47.

Bug: T198214
Change-Id: Ia4b63715380d97ccb3133bf39a260834c20b4f5a
2018-11-01 17:26:10 -04:00
jenkins-bot
e044600d9d Merge "HTMLForm: Remove parameters 'notice', 'notice-messages', 'notice-message'" 2018-10-24 17:14:34 +00:00
Moriel Schottlender
07a5c71646 TitlesMultiselectWidget: Add a widget that allows selection of multiple titles
Add the widget in both PHP and JS for OOUI, and into HTMLForm
definitions.

In JS, the widget uses the engine from mw.widgets.TitleWidget
with the async support from OO.ui.mixin.RequestManager.

The PHP version provides a textarea, like UsersMultiselectWidget.php
which is then infused if JS is available.

Also, add highlightSearchQuery option for TitleWidget to allow for
not highlighting the partial search query the user typed in, if the
UI requires it. This option (highlighting partial result) is already
optional in the TitleOptionWidget, so this config exposes that
optionality in the TitleWidget widget for its menu children.

Notes:

HTMLTitlesMultiselectField is a duplication of HTMLUsersMultiselectField
except for:
- The configuration variable changed to 'titles' (from 'users')
- OOUI modules were adjusted for the TitlesMultiselectWidget
- The PHP version instantiates a MediaWiki\Widget\TitlesMultiselectWidget

TitlesMultiselectWidget is a duplication of UsersMultiselectWidget
except for:
- $usersArray was renamed to $titlesArray
- getJavascriptClassName returns the correct js class for
  mw.widgets.TitlesMultiselectWidget for infusion.

Bug: T197109
Depends-On: I675316dddf272fd0d6172ecad3882160752bf780
Change-Id: Ie96947a35f70b76731e16ae5b85de815dfa4a8ce
2018-10-24 00:46:48 +00:00
Bartosz Dziewoński
54d9b373cd HTMLForm: Remove parameters 'notice', 'notice-messages', 'notice-message'
Bug: T197179
Change-Id: I911cabc1e1e1c2abb8e91a55c05eaa1c76134087
2018-10-22 12:19:58 -07:00
Bartosz Dziewoński
45ced4dfef EditWatchlistNormalHTMLForm: Fix double-escaping of section legends
Parent getLegend() returns a plain string, and this method should
do the same.

Form section legends are escaped by the wrapFieldSetSection() method.

Change-Id: I2059b9182fba7362f3d6226252bdc3e032a06c57
2018-09-03 22:09:13 +02:00
Brian Wolff
2db0dc2438 Add taint annotation to HtmlForm::getHTML()
This is to help AbuseFilter pass phan-taint-check.

Change-Id: I73a6a626337037f6b0cee04b0afb5a59907d3be6
2018-08-31 19:32:46 +00:00
Bartosz Dziewoński
76e7016993 HTMLForm: Deprecate parameters 'notice', 'notice-messages', 'notice-message'
Bug: T197179
Change-Id: I603436e0720fdc0f08f35f3c0630b79865a9c82a
2018-08-29 22:02:52 +02:00
jenkins-bot
33afb7440a Merge "Expand documentation about options in HTMLForm" 2018-08-25 06:51:43 +00:00
Ed Sanders
e5911a826c Pass through 'helpInline' to OOUI FieldLayout and make true by default
This change is meant to improve the layout of Special:Preferences in
particular, but it will affect any OOUI form using help messages. It
should be a harmless or beneficial change for most of them.

Previous behavior can be restored by passing `'help-inline' => false`
to the HTMLForm factory after 'help-message'/'help-messages'/'help'.

For example:

* Special:Preferences?ooui=1#mw-prefsection-watchlist
  * Before: https://phabricator.wikimedia.org/F25025213
  * After:  https://phabricator.wikimedia.org/F25025181

* Special:ChangeEmail
  * Before: https://phabricator.wikimedia.org/F25073327
  * After:  https://phabricator.wikimedia.org/F25073328

* Special:BotPasswords/foo
  * Before: https://phabricator.wikimedia.org/F25073324
  * After:  https://phabricator.wikimedia.org/F25073326

Bug: T181854
Change-Id: Ica67fe4081dfaa8eb9e8f56fdb93530750e47012
2018-08-17 22:34:33 +02:00
Umherirrender
7b01567b00 Expand documentation about options in HTMLForm
Change-Id: Ia170f07f994680dca105981a14ad5a0d98b57a26
2018-08-13 09:16:11 +02:00
David Barratt
d609da624b
Add a method to HTMLForm that allows the preText to be accessed externally.
Currently there is no way to access the preText outside of an HTMLForm. Adding
a getPreText method to HTMLForm so the preText is accessible.

Bug: T199115
Change-Id: I937028e7025b4a7b5d333e9bf5a25920f6a88316
2018-07-09 10:42:19 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Fomafix
f02eed24ac Allow overloading of getLabel() with return ' '
This is a follow-up to 125cbd8c01.

Bug: T198338
Change-Id: I21626326dde368d70fcc33052e43ff90db5ea9c0
2018-06-28 11:25:39 +02:00
Fomafix
125cbd8c01 Use \u{00A0} instead of   or  
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or  .

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
jenkins-bot
399d9c24a8 Merge "Document nodata for HTMLFormFields" 2018-05-19 14:17:57 +00:00
Florian Schmidt
d99c3a4e6d Document nodata for HTMLFormFields
This could be a useful feature for users of HTMLForm, so they should be
able to know about it.

Bug: T156056
Change-Id: Ib444051e38292c06ebe370465b7c751e136d42b2
2018-05-19 13:48:49 +00:00
Ed Sanders
fc65ff17d9 Special:Preferences: Construct fake tabs to avoid FOUC
Bug: T192769
Bug: T189366
Change-Id: I4aabda97d14d97dce3e35abda2ce82925d721c9b
2018-05-18 18:10:45 +00:00
jenkins-bot
7583ead426 Merge "Make setSubmitProgressive() Deprecate" 2018-04-25 21:45:50 +00:00
Jayprakash12345
e7cd669bc5 Make setSubmitProgressive() Deprecate
Bug: T191586
Change-Id: Ie310ea9c3ca7c9e4b8755ba500e2ccafd0b64463
2018-04-20 23:12:51 +00:00
David Barratt
3481e3b2e0
Create Expiry Widget with Date Time Selector
Special:Block needs a date time selector for easier selection of expiry. To
accommodate this cleanly, a new Expiry Widget is created that handles this
logic.

Bug: T132220
Change-Id: I2853a2ca0ae6ccead3978f4bb50a77c2baa3a150
2018-04-19 20:24:08 -04:00
James D. Forrester
ae7237ea98 Drop HTMLForm & VFormHTMLForm::isVForm(), deprecated in 1.25
Change-Id: If5f4e146071c17a9adabd36453ef68ff38405ed4
2018-03-26 10:55:41 -07:00
Max Semenik
369b3fa977 Normalize PHPDoc attributes
Change-Id: I83e686d099de0ff0aacda7e332972e1c7ee49f04
2018-03-16 22:59:15 -07:00
Kunal Mehta
79de8fd02f Use wikimedia/object-factory 1.0.0
Deprecate the unnamespaced version and move it to includes/compat.

Bug: T147167
Depends-On: I39c805bfb98b32f32f3d0dc1eee9e823afe1c21a
Change-Id: I3780c7adf51683f3f7adb35a88f9a25a0a2e2530
2018-02-04 12:52:44 -08:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Fomafix
04ff65fc69 Simplify autocomplete attribute in HTMLForm
Follows-up 7489a3e8

Change-Id: Ifb17c88e39df7031054b3bee83772172c64d0a6b
2017-12-28 16:41:39 +01:00
Bartosz Dziewoński
7bee1a2304 HTMLForm: Do not generate wrappers for empty sections
This affects Special:Preferences, where there will no longer be an
empty <table class="mw-htmlform-nolabel"><tbody></tbody></table>
after every toplevel section heading.

Change-Id: Icb6fe957024843f2b08720715054b9afb657f395
2017-09-16 15:23:46 +02:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Umherirrender
ace44e2064 Use correct variable name in @param documentation
For some varargs a variable name is added with suffix ,... as seen for
many other varargs

Some @param are swapped, because there are in the wrong order

Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
2017-08-11 19:27:19 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Max Semenik
fd6e9ef2d4 Human-readable section ID support
It adds the ability to replace the current section ID escaping
schema (.C0.DE) with a HTML5-compliant escaping schema that is
displayed as Unicode in many modern browsers.

See the linked bug for discussion of various options that were
considered before the implementation. A few remarks:
* Because Sanitizer::escapeId() is used in a bunch of places without
  escaping, I'm deprecating it without altering its behavior.
* The bug described in comments for Parser::guessLegacySectionNameFromWikiText()
  is still there in some Edge versions that display mojibake.

Bug: T152540
Change-Id: Id304010a0342efbb7ef2d56c5b8b244f2e4fb2c5
2017-08-01 20:32:20 -07:00
Prateek Saxena
d2b05e83e3 HTMLForm: Show more options when incorrect displayFormat is set
Change-Id: I47a4684f01f5e30629e819403d7445479c4607da
2017-07-26 18:45:36 +00:00
Kunal Mehta
d1cf48a397 build: Update mediawiki/mediawiki-codesniffer to 0.10.1
And auto-fix all errors.

The `<exclude-pattern>` stanzas are now included in the default ruleset
and don't need to be repeated.

Change-Id: I928af549dc88ac2c6cb82058f64c7c7f3111598a
2017-07-22 18:24:09 -07:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
jenkins-bot
fb52b78920 Merge "UsersMultiselect widget and form field." 2017-02-01 14:37:50 +00:00
Phantom42
c70f464c07 UsersMultiselect widget and form field.
New widget and html form field, which allows selecting multiple
users using convenient single-line input (CapsuleMultiselectWidget)

Bug: T131492
Change-Id: I7b6ffe7fb47e0a7083e2a956156ab0f142444398
2017-02-01 00:35:33 +02:00
Bartosz Dziewoński
38cc8a697f HTMLForm: Suppress HTML5 form validation for non-JS users when needed
Our 'hide-if' fields are fundamentally incompatible with HTML5 form
validation attributes. If you have a checkbox field A, and field B
that is required, but hidden if A is unchecked - that's impossible to
express with HTML5 form validation. The only thing you can do is
remove the validation on B (or on the entire form).

The field contents are still validated server-side, just like if the
browser did not support HTML5 forms. The validation is also re-enabled
in JavaScript, since we have extra support for 'hide-if' field that
makes them work.

Change-Id: Ia7ffa76965a7c14af9b6d2db007b6255498398d9
2017-01-10 22:49:38 +00:00
Bartosz Dziewoński
4fc7420fea HTMLForm: Use 'mw-htmlform' CSS class
Makes it easy to identify all HTMLForms on a page.

Change-Id: I5b9494fc925ac953c14b358331acddfe80c2661d
2016-12-18 12:59:05 +00:00
Brad Jorsch
7fdbe15fb6 HTMLForm: Allow returning Message objects from HTMLFormField::validate()
It mostly already worked. HTMLForm::trySubmit() needed a little
adjustment to handle things properly.

Change-Id: Ibb17bb61ac0b2d41953249980bc2f23b8a3ae5b6
2016-11-14 13:25:14 -05:00
This, that and the other
07782d176b New HTMLForm size filter field; add size filter to Special:Newpages
The conversion of SpecialNewpages to HTMLForm seems to be half-finished.
It's not using HTMLForm to read in the request query, which means we have
to roll our own logic. Kind of defeats the purpose of using HTMLForm in
the first place.

When ProtectedPages is converted to HTMLForm (T117722), it can use this new
field type.

Bug: T12817
Change-Id: I069609fbb37b18c3df25156779ad7ac7cd5d6813
2016-10-27 12:23:18 +11:00
Volker E
7e8539d10e Replace deprecated constructive with progressive
Replacing deprecated `constructive` mediawiki.UI CSS class and OOjs UI
flag  with `progressive`.

Bug: T146923
Change-Id: I524b9722ee49692c55bb1f97d34d8a28068716ee
2016-09-30 13:18:52 -07:00
Brad Jorsch
12bdc84219 HTMLForm: Add HTMLDateTimeField
And to do that, an OOUI PHP widget for
mw.widgets.datetime.DateTimeInputWidget too.

Bug: T146340
Change-Id: Iaa8b5892b6c3a1f3698cef59684cc3cdc9d483ea
2016-09-26 12:08:56 -04:00
Florian
3706dcb5c7 Show warnings in HTMLForm and warnings as warnings on Login/Signup form
This commit changes the way how HTMLForm handles a Status object
when executed from a request. It now handles, beside the errors,
also the warnings of a Status object and prints them out, wrapped
in a warning box.

The LoginSignupPage uses this feature to show informative warnings
actually as warnings and not as more disturbing error messages.
Error messages should be reserved for errors and only for erros. An
AuthenticationProvider, which returns an UI AuthenticationResponse
can choose, if the given message is an error or a warning message.

This commit also addds a new function to Status, which allows a
developer to split the object into two new Status objects, where one only
contains the errors and the other only the warnings of the origin
Status object (splitByErrorType). StatusValue also has a new function,
splitByErrorType(), to support this.

Bug: T139179
Change-Id: I9a27911613e62b5c4cb86bea40696cb37c4f49c2
2016-09-17 16:33:39 +02:00
Gergő Tisza
1abe820088 Expose form field objects in HTMLForm
Change-Id: Id22c5b9da154d67948ff2b91702a256c25718312
2016-08-22 22:25:54 +00:00
Kunal Mehta
7f5c0cffd8 HTMLForm: Use ObjectFactory instead of Reflection
ObjectFactory has a hack that constructs an object directly if there are
less than 10 parameters, which there typically is for HTMLForm classes.
This is faster than using ReflectionClass, and whenever ObjectFactory is
updated to take advantage of the splat operator, this will automatically
use it as well.

And use ::class while we're at it.

Change-Id: I7a696c127c237713448b165b9b4faee13f4ff88e
2016-08-13 20:48:29 -07:00
jenkins-bot
71e4493c86 Merge "Allow providing 'notices' for OOUI HTMLForm fields" 2016-07-25 10:58:45 +00:00
Bartosz Dziewoński
b5237cfc1b HTMLForm: Allow distinguishing between form views and submission attempts
Calling HTMLForm::setFormIdentifier() will set an internal identifier
for this form. It will be submitted as a hidden form field, allowing
HTMLForm to determine whether the form was submitted (or just viewed).
Setting this serves two purposes:

* If you use two or more forms on one page, it allows HTMLForm to
  identify which of the forms was submitted, and not attempt to
  validate the other ones. (T102114)
* If you use checkbox or multiselect fields inside a form using the
  GET method, it allows HTMLForm to distinguish between the initial
  page view and a form submission with all checkboxes or select
  options unchecked. (T29676)

Bug: T102114
Bug: T29676
Change-Id: Ib6ce3fd8941be86211cff5c6932b5e84982490fa
2016-07-22 18:00:15 +00:00
Florian
5424788164 HTMLForm: Don't add a type=reset to links
Follow up: Ieb80e2ff36751abc6f00e2a02926fe9800666a8b

Change-Id: If88c80a46cba9729a9503b82532584443d6d5ba4
2016-06-02 22:50:55 +02:00
Gergő Tisza
0c9712c31a Improve HTMLForm (and Special:ChangeCredentials) cancel button
Add two new HTMLForm methods:
* showCancel( [bool] ) to display a cancel button
* setCancelTarget( Title|string ) to set where it should take
  the user.

The cancel button is a simple link formatted as a button.
This is faster than a real button (skips an unnecessary
submit and redirect) and avoids some UX problems:
* when clicking on a real button, HTML5 or JS  validators
  might prevent submission, which does not make sense for cancel
* form field values might get saved by the brower, which again
  does not make sense for cancelling

Use the cancel button for Special:ChangeCredentials.

Bug: T136809
Change-Id: Ieb80e2ff36751abc6f00e2a02926fe9800666a8b
2016-06-02 19:42:44 +00:00