27 parent::__construct(
'ResetTokens' );
47if ( !$this->tokensList ) {
49 [
'preference' =>
'watchlisttoken',
'label-message' =>
'resettokens-watchlist-token' ],
51 $this->
getHookRunner()->onSpecialResetTokensTokens( $tokens );
54 $tokens = array_filter( $tokens,
staticfunction ( $tok ) use ( $hiddenPrefs ) {
55return !in_array( $tok[
'preference'], $hiddenPrefs );
58 $this->tokensList = $tokens;
61return $this->tokensList;
66// This is a preferences page, so no user JS for y'all. 70 parent::execute(
$par );
77 Html::successBox(
'$1' ),
93foreach ( $tokens as $tok ) {
94 $label = $this->
msg(
'resettokens-token-label' )
95 ->rawParams( $this->
msg( $tok[
'label-message'] )->parse() )
96 ->params( $user->getTokenFromOption( $tok[
'preference'] ) )
98 $tokensForForm[$label] = $tok[
'preference'];
102'label-message' =>
'resettokens-tokens',
103'type' =>
'multiselect',
104'options' => $tokensForForm,
108'label-message' =>
'resettokens-no-tokens',
138if ( $formData[
'tokens'] ) {
140foreach ( $formData[
'tokens'] as $tokenPref ) {
141 $user->resetTokenFromOption( $tokenPref );
143 $user->saveSettings();
166class_alias( SpecialResetTokens::class,
'SpecialResetTokens' );
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
suppressDefaultSubmit( $suppressSubmit=true)
Stop a default submit button being shown for this form.
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
setSubmitDestructive()
Identify that the submit button in the form has a destructive action.
This class is a collection of static functions that serve two purposes:
A class containing constants representing the names of configuration variables.
const HiddenPrefs
Name constant for the HiddenPrefs setting, for use with Config::get()
Special page which uses an HTMLForm to handle processing.
string null $par
The subpage of the special page.
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getUser()
Shortcut to get the User executing this instance.
requireNamedUser( $reasonMsg='exception-nologin-text', $titleMsg='exception-nologin', bool $alwaysRedirectToLoginPage=false)
If the user is not logged in or is a temporary user, throws UserNotLoggedIn.
getConfig()
Shortcut to get main config object.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
Let users reset tokens like the watchlist token.
doesWrites()
Indicates whether POST requests to this special page require write access to the wiki....
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
requiresUnblock()
Whether this action cannot be executed by a blocked user, default to requiresPost()bool
alterForm(HTMLForm $form)
Suppress the submit button if there's nothing to do; provide additional message on it otherwise.
getTokensList()
Returns the token information list for this page after running the hook and filtering out disabled pr...
getFormFields()
Display appropriate message if there's nothing to do.
getDisplayFormat()
Get display format for the form.See HTMLForm documentation for available values.1....
execute( $par)
Basic SpecialPage workflow: get a form, send it to the user; get some data back,.
isListed()
Whether this special page is listed in Special:SpecialPages.to override 1.3 (r3583) bool
onSubmit(array $formData)
Process the form on submission.bool|string|array|Status As documented for HTMLForm::trySubmit.
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...