Commit graph

15 commits

Author SHA1 Message Date
mainframe98
8b48c99889 Add OOUI for HTMLFormFieldCloner
The JavaScript for the cloner fields has been updated to function
when using OOUI Cloners.

The buttons are packed quite tight together, but there does not
seem to be any CSS that enforced the spacing that I could find.

Bug: T171666
Change-Id: Iba6eed9d6cee922d56855bbe2e836956bfd90f42
2018-10-02 11:50:10 +02: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
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
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
Timo Tijhof
3a2a707546 Clean up remaining get_class() uses
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I1888a1897ecf4548a2e5a67a942e5c080dd7e3d3
2017-03-07 22:03:47 +00:00
Bartosz Dziewoński
a83188d0ab HTMLFormFieldCloner: Set 'formnovalidate' on add/remove field buttons
Otherwise, after we allow HTML5 form validation attributes, these
buttons wouldn't work for non-JS users (unless the whole form was
otherwise valid).

Change-Id: Ia9c16849774c186b991280ea60fc5608ddd4cf42
2016-12-18 12:58:26 +00:00
jenkins-bot
f9e21f91e4 Merge "mw.htmlform: Fields hidden with 'hide-if' should be disabled" 2016-12-18 12:56:11 +00:00
Bartosz Dziewoński
5d5dbc83da mw.htmlform: Fields hidden with 'hide-if' should be disabled
Otherwise, in browsers that support HTML5 form validation, it
would be impossible to submit the form if a field failing
validation was hidden (e.g. because it's marked as required).

Note that disabled fields are not submitted with the form. This
should be okay, as server-side validation ignores them entirely.
(I37e50799ba1f0e0e64a197818b58444f5b056bf0 fixes a corner case.)

For cloner fields, 'hide-if' rules of the parent are now copied
to the children, to make handling such nested fields simpler.

Bug: T145440
Change-Id: I81d04dca6cbb499a15828fd33b01746b68c694da
2016-12-02 19:22:38 +01:00
jenkins-bot
474b445a1d Merge "HTMLFormFieldCloner: Don't try to validate hidden fields" 2016-11-25 18:59:02 +00:00
Bartosz Dziewoński
ae99e67243 HTMLFormFieldCloner: Don't try to validate hidden fields
Follow-up to 788526c2d1.

To test: try to create a SecurePoll of type "Approval vote". Without this
patch, but with I81d04dca6cbb499a15828fd33b01746b68c694da, an invisible
field (only applicable for "Range voting (plurality)") will fail validation.

Change-Id: I37e50799ba1f0e0e64a197818b58444f5b056bf0
2016-11-24 17:50:49 +01: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
Florian Schmidt
ac4f758dee Type hint array for HTMLFormFieldCloner::getInputHTMLForKey()
I was a bit fast with merging I18edfcb62f7b21f2c1990c73944ee6a956fd4901,
because I think, type hinting the type of the parameter would make sense,
too.

Bug: T142912
Change-Id: Id397847c6c078047f3daa84db68ccf3e629ca531
2016-08-15 16:41:20 +02:00
Brad Jorsch
a979689003 HTMLFormFieldCloner: Pass enpty array, not null, to avoid warning
Bug: T142912
Change-Id: I18edfcb62f7b21f2c1990c73944ee6a956fd4901
2016-08-15 10:13:54 -04:00
Bartosz Dziewoński
15692fa6d4 Move HTMLFormField subclasses to a separate directory
It's getting more difficult to navigate the files in includes/htmlform/
with every new field and every new helper class that is being added.

Change-Id: I92ce2356baf6151f17b2440970d5abdf86503820
2016-08-01 07:58:56 +00:00
Renamed from includes/htmlform/HTMLFormFieldCloner.php (Browse further)