Commit graph

186 commits

Author SHA1 Message Date
Timo Tijhof
f34ea0830a widget: Remove outdated try/catch wrapper from SpinnerWidget
== What ==

This method was "Copied from OOUI\Tag", which no longer does this
since last year (I42c7a7b4d, 6e4e1a1796). Apply the same change here.

== Why now ==

Triggering E_USER_ERROR is deprecated in PHP 8.4+.

Bug: T381341
Bug: T379445
Change-Id: I1bac121caf746c30996dccd7fb95c4c240742951
(cherry picked from commit 751eca89fe473cc4a649e47dd54e9ab38f7c1957)
2025-06-14 10:42:05 +00:00
Jamie Kuppens
2537859104 Update user widgets to support named and temp account exclusion
* This change introduces two new optional parameters to the 'allusers'
  API call named 'excludenamed' and 'excludetemp' that allows filtering
  accounts based on whether they're named accounts or temporary
  accounts. This is tested by using the temporary matchPattern
  configured with $wgAutoCreateTempUser.

* User widgets that call 'allusers' have been updated so that
  'excludenamed' and 'excludetemp' can be optionally set so that named
  or temporary accounts may not returned with user suggestions.

Bug: T332030
Change-Id: I6563ae610017fd1cd35c36ba65906041f7f68c4b
2024-09-16 08:45:58 -07:00
Umherirrender
aed646001c htmlform: Add missing documentation to class properties
Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Change-Id: I1f306a3925d6768209a06e70082598b2f70cd319
2024-09-14 11:49:05 +00:00
Bartosz Dziewoński
ccd423225f Add "implements Stringable" to every class with "function __toString()"
In PHP 8, but not in PHP 7.4, every class with a __toString() function
implicitly implements the Stringable interface. Therefore, the
behavior of checks like "instanceof Stringable" differs between these
PHP versions when such classes are involved. Make every such class
implement the interface so that the behavior will be consistent.

The PHP 7.4 fallback for the Stringable interface is provided by
symfony/polyfill-php80.

Change-Id: I3f0330c2555c7d3bf99b654ed3c0b0303e257ea1
2024-06-13 00:23:39 +00:00
Dogu
bbc74d93b0 Refactor widget classes to use cleaner namespacing
This patch refactors various widget classes in the includes/widget
directory to use cleaner namespacing. The patches remove redundant backslash
prefixes in class extending statements and add use statements for OOUI classes
and other MediaWiki-specific classes. This patch improves readability and
maintainability of the code by following the MediaWiki coding conventions and
leverages the benefits of PHP's namespacing system.

List of affected classes:
- CheckMatrixWidget
- DateInputWidget
- DateTimeInputWidget
- NamespaceInputWidget
- SearchInputWidget
- SelectWithInputWidget
- SizeFilterWidget
- SpinnerWidget
- TagMultiselectWidget
- TitleInputWidget
- UserInputWidget

Additionally, the code now correctly documents exceptions thrown by
constructors where missing, enforcing clearer developer expectations.

Change-Id: I0fdaf68a412a1c3b7049a79222f4dbeaa95a6bbc
2024-01-02 23:24:56 +00:00
Dogu
c67060841c Refactor ComplexNamespaceInputWidget to use namespaced OOUI classes
This patch refactors the ComplexNamespaceInputWidget class to use
fully qualified class names for OOUI components. It removes the manual
specification of the OOUI namespace within the class and instead relies
on the `use` declarations at the top of the PHP file. Additionally,
it adds the Exception class to the list of used namespaced classes,
preparing for explicit exception handling.

Change-Id: I3fe255f491979b63b5361da69a87c32b4fa65b5f
2024-01-02 19:01:20 +01:00
Gergő Tisza
de18cff244 htmlform: Support HTML tooltips in checkmatrix
Bug: T290790
Bug: T254222
Change-Id: I69e8217c408acca6bd7f19e7e274b255336dccd2
2023-11-06 23:24:51 +00:00
Func
942d288f52 Implement HTMLToggleSwitchField for mobile layout of preferences
This is the more native way of doing things, which avoids syncing
different states between the toggle and the hidden widget.
The DOM structure is also better and don't confuse screen readers.

Bug: T333496
Bug: T334705
Bug: T336107
Change-Id: I47de69459b96f172153065094eb4113584bb435a
2023-05-18 02:23:28 +08:00
jenkins-bot
0d67e2572c Merge "Set autocapitalize on Special:Search input" 2023-05-16 16:55:55 +00:00
Erik Bernhardson
600521d3fe Set autocapitalize on Special:Search input
Capitals are meaningful on some wikis, and they call it out with
$wgCapitalLinks. Match the autocapitalization behaviour with this.
This is mimicing the same functionality as applied to the skin
autocomplete, found in SkinComponentSearch.

Bug: T335551
Change-Id: I98c39061cd7a3d601f5380edd9730bf61f8339fd
2023-05-08 11:34:31 -07:00
Thalia
cd3c40095c Pass allowEditTags config through to multiselect widgets
TitlesMultiselectWidget and NamespacesMultiselectWidget both default
to false, meaning click-to-edit on the tags is disabled. Allow this
to be overridden from the corresponding PHP form fields.

This helps to provide a workaround for the related bug: T334711

Change-Id: I4014c5ba7fea0647da6ec6c420342a41ac90518b
2023-04-18 18:49:43 +01:00
Thalia
ac9cdf8804 TagMultiselectWidget: Set rows to max number of tags if below 10
Bug: T333581
Change-Id: I28dafd8894bb6073e5ef1b4419b6777bd6b2580a
2023-03-30 17:07:41 +01:00
Amir Sarabadani
7d8768e931 Reorg: Move HTML-related classes out of includes/ to Html/
Bug: T321882
Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
2023-02-16 20:40:01 +01:00
tacsipacsi
ce8e8894bd Allow setting min/max on DateInputWidget
This is required for HTMLDateTimeField to be compatible it:
HTMLDateTimeField filters out mustBeAfter/mustBeBefore, while
DateInputWidget didn’t understand min/max until now. Since moment.js
(used by the JavaScript side of the widget) seems to better like the
mustBeAfter/mustBeBefore semantics (strictly larger/smaller than) than
the min/max one (larger/smaller than or equal to), I decided to
internally keep mustBeAfter/mustBeBefore.

Bug: T219633
Change-Id: I487363e40d1e4f74780ed7146c8a6770bfc61fae
2022-10-21 17:51:59 +00:00
Thiemo Kreuz
e23b070b45 Make use of ?? and ?: operators where it makes sense
Change-Id: I1d9d62d80b17d1a05222c6e82f631cb801c311a8
2022-08-04 21:43:12 +02:00
Bartosz Dziewoński
fd5357d049 Support namespace dropdown 'in-user-lang' option in HTMLForm and OOUI widget
Change-Id: I3dbb2ec9d3989a1278151090ad81c7fabd3afbde
2022-05-13 20:29:44 +00:00
Matěj Suchánek
e47c441078 Fix many typos in comments
Found using IntelliJ's "Typo" code inspection.

Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
2022-05-10 12:46:11 +00:00
Thiemo Kreuz
b4c63c64ae Remove some more comments that literally repeat the code
Nothing to learn from these.

You can find a longer explanation in the comments in I93751e6.

Change-Id: I195aae70fc282b58be5b18160783f27d38605d15
2021-12-09 19:01:36 +01:00
Umherirrender
a7bb7cc5c5 Remove unreachable code after exception/die/exit
Change-Id: Ia81903fb2a8157625fbe63115097eccc1161b5db
2021-09-03 23:14:28 +00:00
DannyS712
c80841f58b Remove comments that repeat the code
Don't provide any addition information

Change-Id: I4f474537056e34bac74b0d0cd5b4beb800664f90
2021-06-02 08:03:09 +00:00
STran
ee93d068d2 Add HTMLTagMultiselectField
Implements HTMLTagMultiselectField, a form field that instantiates
TagMultiselectWidget, the PHP representation of the OOUI's js-based
widget of the same name with the implemented parameters:
* allowArbitrary
* allowedValues

Bug: T278317
Change-Id: I3a6a30506d493be4185f917c577b3837fffd8ae1
2021-03-26 08:15:38 -07:00
Matěj Suchánek
51642e0aae Replace tabs with spaces
Change-Id: Id034c34a294585f58dba58c26db466e0e39cb557
2020-09-04 18:04:07 +02:00
Gergő Tisza
bf08948bbe
Clarify documentation of TitlesMultiselectWidget::$showMissing
Bug: T254357
Change-Id: Iea2dd47f95bc3b84e8f29dff97d38fb1d989b9c7
2020-06-03 16:24:36 +02:00
Ed Sanders
7690bd6f25 Create a PHP version of jquery.spinner
Change-Id: I7622b08ec89525d24a4a1a755ffeee1aace9d382
2020-03-13 18:06:29 +01:00
James D. Forrester
3a9a542e1d widgets: Split out SearchWidgets into their own tree
Expecting people to magically know that MediaWiki\Widget\SearchInputWidget is
generic and for use on random pages, but MediaWiki\Widget\SearchResultWidget
is super-specialised, based on bespoke technologies, and only for use on
Special:Search, is not great.

None of these are used outside the MediaWiki core codebase and so this change
whilst it would otherwise be technically breaking is fine.

Change-Id: I16d21dd5e1ac3aa9893863df272d1bbb4788066f
2020-02-11 14:37:27 -08:00
Peter Ovchyn
61e0908fa2 languages: Introduce LanguageConverterFactory
Done:
* Replace LanguageConverter::newConverter by LanguageConverterFactory::getLanguageConverter
* Remove LanguageConverter::newConverter from all subclasses
* Add LanguageConverterFactory integration tests which covers all languages by their code.
* Caching of LanguageConverters in factory
* Make all tests running (hope that's would be enough)
* Uncomment  the deprecated functions.
* Rename FakeConverter to TrivialLanguageConverter
* Create ILanguageConverter to have shared ancestor
* Make the LanguageConverter class abstract.
* Create table with mapping between lang code and converter instead of using name convention
* ILanguageConverter @internal
* Clean up code

Change-Id: I0e4d77de0f44e18c19956a1ffd69d30e63cf51bf
Bug: T226833, T243332
2020-02-03 11:38:03 +02:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
jenkins-bot
cab00f54ab Merge "Return HtmlArmor for Search ResultSet snippets" 2019-12-13 08:27:35 +00:00
Erik Bernhardson
0c8289e5db Return HtmlArmor for Search ResultSet snippets
Passing around strings that are expected to be safe html and are
known to be based on user input is a fairly unsafe operation. Make
it harder to do the wrong thing by requiring HtmlArmor to be returned
from the ResultSet snippets. This does not address the snippets on
individual result objects as the api surface is larger and requires
more bc handling.

Change-Id: I76231d6fc53c4982eb4cd174d2e6a75eb2740497
2019-12-12 10:14:50 -08:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
Thiemo Kreuz
78ca9eff4a Remove duplicate variable name from class property PHPDocs
Repeating the variable name doesn't do anything. Documentation
generators don't need it. It's more stuff to read that doesn't add new
information. And it can become outdated.

Note there are two types of @var docs. When used inline (and not on a
class property) the variable name is needed.

Change-Id: If5a520405efacd8cefd90b878c999b842b91ac61
2019-12-02 12:58:29 +00:00
Umherirrender
c7ad21c25f Improve param docs
Change-Id: I746a69f6ed01c3ff000da125457df62b02d13b34
2019-11-28 19:08:59 +01:00
Thalia
16555e6f65 Add option for showing valid IPs in UsersMultiselectWidget menu
Pass through config options from HTMLUserTextField that allow the
field to accept an IP address and/or range, and specify the maximum
allowed range size.

Bug: T238277
Change-Id: I0e0f6b6fd6801d5cd561def28917e81a81b3f7d4
2019-11-15 21:42:32 +00:00
Umherirrender
ba4adc3fc9 phpcs: Enable PSR12.Files.ImportStatement.LeadingSlash and make pass
Change-Id: Ifaa7bef925cc4e1b3f1751bb66abdda7fe6763d8
2019-10-11 20:01:32 +02:00
jenkins-bot
4771c10b8a Merge "Fixup phan warning toomanyparams (part 2)" 2019-10-10 19:40:59 +00:00
Daimona Eaytoy
8ba620b15a Fixup phan warning toomanyparams (part 2)
Bug: T231636
Change-Id: Idde7a766bb0d084d6b67bb0c940d7ad704847ad2
2019-10-10 12:52:01 +00:00
Daimona Eaytoy
e3412efac3 Unsuppress PhanParamReqAfterOpt, use PHP71 nullable types
These were all checked with codesearch to ensure nothing is overriding
these methods.
For the most part, I've updated the signature to use nullable types; for
two Pager's, I've just made all parameters non-optional, because you're
already forced to pass them with a required parameter at the end.

Bug: T231636
Change-Id: Ie047891f55fcd322039194cfa9a8549e4f1f6f14
2019-10-10 11:53:58 +02:00
Daimona Eaytoy
1f17cc238a widget: Improve properties documentation
Explicitly declare all dynamic properties. Add docblocks for several
props. Remove the defaults when they're already set in the constructor.
Make TagMultiselectWidget use ?? like other widgets.

Change-Id: I889bf6f9e1bbe381f5bffb8ce1370c9e2e863520
2019-09-10 14:05:14 +02:00
Daimona Eaytoy
327e8ea416 Unsuppress phan issues part 6
Bug: T231636
Depends-On: I50377746f01749b058c39fd8229f9d566224cc43
Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
2019-09-01 09:48:45 +00:00
Daimona Eaytoy
e70b5b3309 Unsuppress other phan issues (part 4)
Bug: T231636
Depends-On: I58e67c2b38389df874438deada4239510d21654f
Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
2019-08-31 17:13:39 +00:00
jenkins-bot
4306994b79 Merge "Allow SelectWithInput to be marked as required and handle that dynamically" 2019-07-31 13:28:54 +00:00
David Barratt
8a1f1ec631
Allow SelectWithInput to be marked as required and handle that dynamically
Alters the SelectWithInput to allow a required config to be passed from a
parent widget. Also handles the required state dynamically. If the widget is
an OR widget, then only the select dropdown is required. The text input will
be required when the other option is selected. If the widget is an AND widget
then both the select dropdown and the text input will be required.

Bug: T220533
Change-Id: I8479743126756f2b1bd7bcd53b100a0134f34d07
2019-07-30 16:33:02 -04:00
David Causse
6af636fb03 Add ISearchResultSet
Bug: T228626
Change-Id: I3306bf6107c97dd58adf578fd965bd11a422627d
2019-07-22 18:27:39 +00:00
David Causse
9b30a0d77d Fix bad method call to \MediaWiki\Widget\Search\SearchResultWidget::render
Change-Id: I6b3a65ba62a9686bdc65110cba9d61362e584051
2019-07-22 18:05:21 +02:00
David Causse
92c20832f1 Deprecate SearchResult::termMatches()
And start indicating that hooks relying on this data might become
unreliable as this data is only populated by SearchDatabase search
engines.

This information was only populated by SearchDatabase implementations
and due to bad initial design of SearchResult[Set] (now fixed) it forced
users of these classes to carry this information for the sole purpose of
highlighting.
Because SearchEngine can now own their SearchResult[Set] implementations
nothing that is engine specific should be exposed outside of these
specific implementations.
If there are some logic that still requires access to such list of terms
they should be made engine specific by guarding their code against
instanceof SqlSearchResult.

Change-Id: I38b82c5e4c35309ee447edc3ded60ca6a18b247a
Depends-On: I53fe37c65c7940f696c1e184125e01e592a976e4
2019-06-27 08:44:06 -07:00
jenkins-bot
8ffabe23a1 Merge "Fix param type of search terms in search related classes" 2019-06-17 07:54:27 +00:00
Umherirrender
9421f6f52f Fix param type of search terms in search related classes
Change-Id: I036434268f1e7992f7f9f23d2c1c0fcd399823c8
2019-06-14 19:50:12 +02:00
jenkins-bot
61544d6eb2 Merge "Migrate remaining usages of Title::userCan() to PermissionManager" 2019-06-14 11:19:47 +00:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Máté Szabó
6420c79320 Migrate remaining usages of Title::userCan() to PermissionManager
T208768 introduced the PermissionManager service that can now be used
for page specific permission checks. This change replaces remaining calls
to Title::userCan() with the new service in MediaWiki core.

Bug: T220191
Change-Id: Ie45e0cb6aa49a8c66147b470946161fc18160fc1
2019-06-03 13:03:46 +02:00