Commit graph

51 commits

Author SHA1 Message Date
Umherirrender
7aa0884029 phan: Remove PhanTypePossiblyInvalidDimOffset suppression
Make phan stricter about array keys
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T304887
Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1
Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385
Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
2022-03-28 23:26:49 +02:00
Gergő Tisza
499af9ccbe
Rename HTMLForm::[get|set|add]*Text() methods
Rename HTMLForm::[get|set|add][Pre|Post|Header|Footer]Text() to
HTMLForm::[get|set|add][Pre|Post|Header|Footer]Html() and
deprecate the old methods. Their arguments are rendered as raw
HTML so the old name was misleading.

Some of these are marked as stable to override and theoretically
the renaming could cause problems if callers are updated to the
new name while the overriding class is still using the old name,
but the only case known to codesearch is OOUIHTMLForm which is
also updated here.

Bug: T290771
Change-Id: I2c269eb6ab2b320fa2eef4ee8a226e96ad05fbe2
2022-01-02 21:51:48 -08:00
daniel
39a6e11310 HTMLForm: accept PageReference instead of Title.
Note that this changes the effective type of the protected mCancelTarget
field. This fields has no declared type, and does not seem to be used in
any subclass. The type of mTitle is not changed at this time, but
nothing seems to rely on that either.

Bug: T278459
Change-Id: I4bf0d46c74b53ffc9cb3e6e497c789ef6b3bab6a
2021-05-07 23:36:49 +02:00
Volker E
38ec1cb0de OOUIHTMLForm: Remove IE8 fallback code
Bug: T258766
Change-Id: I86ff63ebd2412fdfaa7e85d91dc1eb4eb8033e67
2021-02-24 15:33:11 -08:00
Umherirrender
cf8c94b163 Do not assume string is message key in OOUIHtmlForm::getErrorsOrWarnings
single string is raw html,
not a message key as documented on HTMLForm::trySubmit

Also remove is_string, any truthy value would be implicit string casted
in HtmlForm::getErrorsOrWarnings

Reorder the if in HtmlForm to look similar to OOUI

Change-Id: I5b78b0df2cca695f8f5c6b08aa4d6c015d1fa1fe
2020-11-20 14:26:15 +00:00
Thiemo Kreuz
fd7363a1e1 Fix broken PHPDoc comments that don't start with /**
Change-Id: I8db56ff0f73873864dde260e51adcd729aa74e94
2020-07-23 16:09:41 +00:00
Nikki Nikkhoui
6b0e9eafe1 HTML Classes stability annotations
Add stability annotations for HTML classes.

Bug: T247862
Change-Id: I4dad7b98213ceceb8c04b24e5d52e6fecadb3538
2020-07-13 14:54:28 +02:00
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
Bartosz Dziewoński
278b6e8506 preferences: Display error message at the top of the form as well
When there's an error in one of the fields "below the fold" or in
another tab, it's hard notice that it wasn't saved, especially since
the success message is very subtle.

In normal forms, there's a red error message at the top (in addition
to messages next to invalid fields), which was missing from the
preferences form.

I ran into this while experimenting with signature field validation.

Change-Id: If365e35d15a52939397f2093b1b8f5113a62e22b
2019-11-08 20:37:18 +01:00
Bartosz Dziewoński
97eab7f35b Improve collapsible HTMLForm styling (and accessibility, slightly)
Previously the form was only collapsible/expandable using the small
link-button on the far right. Now you can click on the entire header
to do it, and it has an appropriate pretty icon.

We add appropriate ARIA `role` and textual labels. Together with
recently added `toggleARIA` option of jquery.makeCollapsible in
Ic457bda58e56f we feature a screen reader workable output.

Bug: T222904
Change-Id: I6964296bc6870550478de662d21f12a1fc084c15
2019-09-23 10:57:26 -07:00
Bartosz Dziewoński
36d33daa03 HTMLForm: Improve method interface for collapsible forms
Also minor tweaks:
* Fix @since tags, this did not make it into 1.33
* Fix usage of FieldsetLayout 'group' in OOUIHTMLForm
* Documentation changes

Follow-up to 2896e87a10,
per my post-merge review on that commit.

Change-Id: Ib93375cde19730a46e4929878d6e472d3ac8f631
2019-05-02 14:33:20 -07:00
jdlrobson
2896e87a10 History form can be collapsed
A generic way for collapsing forms is added and used
on history.

Bug: T220555
Change-Id: I3073359210bcc25625c9ec07629100130effaed1
2019-04-09 22:57:39 +00:00
Kunal Mehta
7bd9073c4b Fix/suppress misc phan errors (#2)
* Title: phan false positive
* McrUndoAction: fixed improper use of @param
* UploadSourceAdapter: fixed wrong type
* XmlTypeCheck: Use null so phan doesn't think we're trying to call the
function ''
* Database: phan false positive
* SpecialBlock: Use phan's advanced type documentation so phan knows
specifically what's being returned
* ChangesListSpecialPage: phan false positive
* BatchRowUpdate: Have default callback take a parameter so phan doesn't
think too many arguments are being passed
* MimeAnalyzer: left FIXME for relying on PHP 7.1 unpack() signature
* LanguageConverter: Specify types for $mTables since phan couldn't
determine it automatically
* preprocessorFuzzTest: Implement User::load() method signature

Change-Id: I08080ab636c5fe67ea6a4e14b2212d7523606e21
2019-04-05 16:12:18 -07:00
jdlrobson
dc180ca64f Restore #mw-history-search id on history action fieldset
Change-Id: I3551667b1f64a3cd9227b07df2a215ccb701ea5d
2019-03-29 15:28:36 +00:00
Ed Sanders
9b277fb5da OOUI forms: Remove infusable = false
False is already the default value for infusable.

Change-Id: Ie0e9b7467b7f3f13c45372b38b7b80ba78852e55
2019-03-25 19:00:18 +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
Bartosz Dziewoński
e3fa6b8d34 OOUIHTMLForm: Prevent duplicate FieldsetLayout wrapping
The code in formatSection() assumed it was only called for the
toplevel section (the whole form), while it's actually called
for every subsection too. I think it was written before we added
support for subsections in OOUIHTMLForm.

Move code for toplevel section wrapping to wrapForm().

As a bonus, this also fixes display of custom headers and error
or warning messages for forms with subsections.

Bug: T180535
Change-Id: I6a88184d302a951be78387490404137acde3fa1a
2017-11-16 12:40:56 +00: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
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
Bartosz Dziewoński
8c1a1a62a1 Avoid duplicate accesskey hints on OOUI widgets
Values returned by `Linker::tooltipAndAccesskeyAttribs()` and
`Linker::titleAttrib( ..., 'withaccess' )` include an accesskey
hint in the title text. This is unnecessary when used for OOjs UI
widgets, since after the changes from T168408 they display an
accesskey hint automatically.

Also fixed some other accesskey bugs in HTMLForm which probably
no one ever ran into.

Bug: T168408
Change-Id: I63285b5bce3341875a6d82eba059623bf105ca62
2017-08-01 20:59:13 +00:00
Amir Sarabadani
8cd74081f7 Do not try to parse empty argument in getErrorsOrWarnings in OOUI
Bug: T167644
Change-Id: I0dcb9bd51ad0cecbdab868fed056b4077d1c9fa8
2017-06-12 16:03:17 +04:30
Derk-Jan Hartman
3188605489 HTMLForm: add errors to html in ooui variants
HTMLForm when using OOUI mode was not adding errors to the resulting
HTML, if depending on message arrays, as previously used before
Status.

This exposed additional problems. Aligned the function a bit closer to
HTMLForm's getErrorsOrWarnings()

Bug: T158492
Change-Id: I8765a025dd441676e35a7c183c67b37036643c1e
2017-04-21 13:58:02 +00:00
Fomafix
464f0c72a5 Remove multiple spaces in PHP files
Change-Id: Id9c26ec5ca730a9536f8fdccb8853eb03cbe87a4
2017-04-12 17:27:19 +02: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
addshore
63dd31cd31 Add access modifiers to htmlform classes
Change-Id: Id8c0f0676b3200993af3cec493efc99839211bcc
2016-11-04 11:40:42 +01:00
Amir Sarabadani
9850c542c6 Clean up array() syntax in docs, part VII
Last part

Change-Id: I38f015e2122ef4fd2d2141718bd889794c29f06c
2016-09-27 06:53:25 +03:30
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
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
Matthew Flaschen
239d68b48d OOUI HTMLForm: Allow specifying whether buttons are framed
Bug: T136361
Change-Id: Ic31f857c749d62a32cafae68dc3f1cbd86e1e382
2016-05-27 17:04:01 -07:00
Florian
8e5912aac3 OOUIHTMLForm: Don't output an empty hidden LabelWidget if not needed
The hidden element is only needed if either a header is set or the form
has errors. If both does not apply, the element isn't needed and should
be omitted instead of hidden with `display:none`.

It's also not needed to add a LabelWidget for the header, if the form has
errors, only, but no header (which would result in an empty space between
the header and the fieldset legend).

Follow up: Ifbf38878d41906184f97169b22002f788711a311

Change-Id: I4ffefdc50d435590d25a7dfc202228920dd801ae
2016-05-13 21:30:22 +02:00
jenkins-bot
46deecce89 Merge "Unify HTMLForm message handling" 2016-05-02 20:52:46 +00:00
Gergő Tisza
dab874cc22 Unify HTMLForm message handling
Improves Ida647973a which unified message handling for form fields
but did not make the functionality available to HTMLForm itself.

Change-Id: I2e6195ba13afbd8b993acb47409fab1be91c547e
2016-05-02 19:48:28 +00:00
Bartosz Dziewoński
cba7952e31 HTMLForm: Don't render 'mw-htmlform-submit-buttons' if there aren't any buttons
Visually, this only affects OOUIHTMLForm, in other kinds of forms
the element has no height anyway.

Change-Id: I90e73c49fbefec23532368848bb30b2e7b69075c
2016-04-22 14:49:51 +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
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
Timo Tijhof
41b5aa343f Remove redundant escaping for namespace references in documentation
Follows-up b264cee. No longer needed as of 0c9e9cc.

Change-Id: I31745f55885eeec2bb8cf2c9ffe9e98242cd5baa
2015-11-23 23:02:32 +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
Florian
64c2de5192 Change Special:ChangePassword to use OOUI
In order to work with OOUI properly, SpecialChangePassword::attemptReset() doesn't
throw PasswordErrors anymore. It now returns a Status object which
is set to fatal, if some requirement doesn't meet.

In OOUIHTMLForm: Handle Message objects as errors correctly. It's a valid parameter
for fatal to use a Message object instead of a message key, so OOUIHTMLForm needs
to handle Mesage objects as Message objects (can be parsed directly) instead of using
it as a message key (which usually doesn't exist).

Bug: T78373
Change-Id: Id768833bbd966cdeadd5a13fdb64b636ea2062ef
2015-11-03 16:06:22 +01:00
Siebrand Mazeland
950910dc99 Fix PHPCS warnings in includes/htmlform/
Change-Id: Ifbf050c92a84d6af59709632965f48f3d567c0da
2015-09-28 13:35:28 +02:00
Kunal Mehta
71c67c48f3 OOUIHTMLForm: s/else if/elseif/
Spotted by phpcs.

Change-Id: I1a0b7a08a17849b270a262063744198d81d36de1
2015-09-23 13:29:30 -07:00
Bartosz Dziewoński
63ac28b436 OOUIHTMLForm: Display errors in a nicer way, part 2
Now we also handle the form-wide errors, putting them in the FieldLayout
that contains the form's header.

Follow-up to I860a96858c4fcac62d63b46e35a9153f22c0a9c9.

Bug: T98894
Change-Id: Ifbf38878d41906184f97169b22002f788711a311
2015-08-21 18:50:13 +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
4ea3974e0c OOUIHTMLForm: Display errors in a nicer way, part 1
Depends on Ie14a35fac70d62ff7d102caaa56654ebde11d7dd in OOUI.

Part 2 follows after some cleanup in intermediary commits
in Ifbf38878d41906184f97169b22002f788711a311.

As a bonus, HTMLFormField::getOOUI() now always produces a
OOUI\FieldLayout in OOUI mode. This will let us clean up some code
where we had to take errors HTML from HTMLForm
(I91af6efa8762e9676efea532381292e221255862).

Bug: T98894
Change-Id: I860a96858c4fcac62d63b46e35a9153f22c0a9c9
2015-08-21 18:29:06 +00: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
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
Roan Kattouw
7fea174c83 Automatically infuse any infusable OOUI widgets present on the page
Change-Id: I931df032c3d8dc5807c7590a763b8d9060c5ee87
2015-06-30 16:07:22 +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
Kunal Mehta
f78470de93 OOUIHTMLForm: Make the submit button infusable
So people can do things to it like adding click handlers.

Change-Id: Ia51d3aca055709d5205eea1922a2985d1623ed8d
2015-06-27 00:55:24 -07:00
Kunal Mehta
fbf72b866c OOUIHTMLForm: Access context after parent constructor is called
This avoids "ContextSource::getContext (OOUIHTMLForm): called and $context
is null. Using RequestContext::getMain() for sanity"

Change-Id: I20c2bb58b3a0e5e259241a3715ee8fdf4b57e148
2015-05-27 23:02:58 -07:00