Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
SpecialResetTokens.php
Go to the documentation of this file.
1<?php
7namespaceMediaWiki\Specials;
8
9useMediaWiki\Html\Html;
10useMediaWiki\HTMLForm\HTMLForm;
11useMediaWiki\MainConfigNames;
12useMediaWiki\SpecialPage\FormSpecialPage;
13useMediaWiki\SpecialPage\SpecialPage;
14
22classSpecialResetTokensextendsFormSpecialPage {
24private $tokensList;
25
26publicfunction__construct() {
27 parent::__construct('ResetTokens' );
28 }
29
31publicfunctiondoesWrites() {
32returntrue;
33 }
34
36publicfunctionrequiresUnblock() {
37returnfalse;
38 }
39
46protectedfunctiongetTokensList() {
47if ( !$this->tokensList ) {
48 $tokens = [
49 ['preference' =>'watchlisttoken','label-message' =>'resettokens-watchlist-token' ],
50 ];
51 $this->getHookRunner()->onSpecialResetTokensTokens( $tokens );
52
53 $hiddenPrefs = $this->getConfig()->get(MainConfigNames::HiddenPrefs );
54 $tokens = array_filter( $tokens,staticfunction ( $tok ) use ( $hiddenPrefs ) {
55return !in_array( $tok['preference'], $hiddenPrefs );
56 } );
57
58 $this->tokensList = $tokens;
59 }
60
61return $this->tokensList;
62 }
63
65publicfunctionexecute($par ) {
66// This is a preferences page, so no user JS for y'all.
67 $this->getOutput()->disallowUserJs();
68 $this->requireNamedUser();
69
70 parent::execute($par );
71
72 $this->getOutput()->addReturnTo(SpecialPage::getTitleFor('Preferences' ) );
73 }
74
75publicfunctiononSuccess() {
76 $this->getOutput()->wrapWikiMsg(
77 Html::successBox('$1' ),
78'resettokens-done'
79 );
80 }
81
87protectedfunctiongetFormFields() {
88 $user = $this->getUser();
89 $tokens = $this->getTokensList();
90
91if ( $tokens ) {
92 $tokensForForm = [];
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'] ) )
97 ->escaped();
98 $tokensForForm[$label] = $tok['preference'];
99 }
100
101 $desc = [
102'label-message' =>'resettokens-tokens',
103'type' =>'multiselect',
104'options' => $tokensForForm,
105 ];
106 }else {
107 $desc = [
108'label-message' =>'resettokens-no-tokens',
109'type' =>'info',
110 ];
111 }
112
113return [
114'tokens' => $desc,
115 ];
116 }
117
122protectedfunctionalterForm(HTMLForm $form ) {
123 $form->setSubmitDestructive();
124if ( $this->getTokensList() ) {
125 $form->setSubmitTextMsg('resettokens-resetbutton' );
126 }else {
127 $form->suppressDefaultSubmit();
128 }
129 }
130
132protectedfunctiongetDisplayFormat() {
133return'ooui';
134 }
135
137publicfunctiononSubmit( array $formData ) {
138if ( $formData['tokens'] ) {
139 $user = $this->getUser();
140foreach ( $formData['tokens'] as $tokenPref ) {
141 $user->resetTokenFromOption( $tokenPref );
142 }
143 $user->saveSettings();
144
145returntrue;
146 }
147
148returnfalse;
149 }
150
152protectedfunctiongetGroupName() {
153return'login';
154 }
155
157publicfunctionisListed() {
158return (bool)$this->getTokensList();
159 }
160}
161
166class_alias( SpecialResetTokens::class,'SpecialResetTokens' );
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
DefinitionHTMLForm.php:195
MediaWiki\HTMLForm\HTMLForm\suppressDefaultSubmit
suppressDefaultSubmit( $suppressSubmit=true)
Stop a default submit button being shown for this form.
DefinitionHTMLForm.php:1628
MediaWiki\HTMLForm\HTMLForm\setSubmitTextMsg
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
DefinitionHTMLForm.php:1540
MediaWiki\HTMLForm\HTMLForm\setSubmitDestructive
setSubmitDestructive()
Identify that the submit button in the form has a destructive action.
DefinitionHTMLForm.php:1526
MediaWiki\Html\Html
This class is a collection of static functions that serve two purposes:
DefinitionHtml.php:43
MediaWiki\MainConfigNames
A class containing constants representing the names of configuration variables.
DefinitionMainConfigNames.php:22
MediaWiki\MainConfigNames\HiddenPrefs
const HiddenPrefs
Name constant for the HiddenPrefs setting, for use with Config::get()
DefinitionMainConfigNames.php:2661
MediaWiki\SpecialPage\FormSpecialPage
Special page which uses an HTMLForm to handle processing.
DefinitionFormSpecialPage.php:26
MediaWiki\SpecialPage\FormSpecialPage\$par
string null $par
The subpage of the special page.
DefinitionFormSpecialPage.php:31
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
DefinitionSpecialPage.php:51
MediaWiki\SpecialPage\SpecialPage\getTitleFor
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,...
DefinitionSpecialPage.php:139
MediaWiki\SpecialPage\SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
DefinitionSpecialPage.php:884
MediaWiki\SpecialPage\SpecialPage\requireNamedUser
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.
DefinitionSpecialPage.php:439
MediaWiki\SpecialPage\SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
DefinitionSpecialPage.php:949
MediaWiki\SpecialPage\SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
DefinitionSpecialPage.php:985
MediaWiki\SpecialPage\SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
DefinitionSpecialPage.php:874
MediaWiki\SpecialPage\SpecialPage\getHookRunner
getHookRunner()
DefinitionSpecialPage.php:1194
MediaWiki\Specials\SpecialResetTokens
Let users reset tokens like the watchlist token.
DefinitionSpecialResetTokens.php:22
MediaWiki\Specials\SpecialResetTokens\doesWrites
doesWrites()
Indicates whether POST requests to this special page require write access to the wiki....
DefinitionSpecialResetTokens.php:31
MediaWiki\Specials\SpecialResetTokens\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
DefinitionSpecialResetTokens.php:152
MediaWiki\Specials\SpecialResetTokens\requiresUnblock
requiresUnblock()
Whether this action cannot be executed by a blocked user, default to requiresPost()bool
DefinitionSpecialResetTokens.php:36
MediaWiki\Specials\SpecialResetTokens\alterForm
alterForm(HTMLForm $form)
Suppress the submit button if there's nothing to do; provide additional message on it otherwise.
DefinitionSpecialResetTokens.php:122
MediaWiki\Specials\SpecialResetTokens\getTokensList
getTokensList()
Returns the token information list for this page after running the hook and filtering out disabled pr...
DefinitionSpecialResetTokens.php:46
MediaWiki\Specials\SpecialResetTokens\getFormFields
getFormFields()
Display appropriate message if there's nothing to do.
DefinitionSpecialResetTokens.php:87
MediaWiki\Specials\SpecialResetTokens\getDisplayFormat
getDisplayFormat()
Get display format for the form.See HTMLForm documentation for available values.1....
DefinitionSpecialResetTokens.php:132
MediaWiki\Specials\SpecialResetTokens\execute
execute( $par)
Basic SpecialPage workflow: get a form, send it to the user; get some data back,.
DefinitionSpecialResetTokens.php:65
MediaWiki\Specials\SpecialResetTokens\isListed
isListed()
Whether this special page is listed in Special:SpecialPages.to override 1.3 (r3583) bool
DefinitionSpecialResetTokens.php:157
MediaWiki\Specials\SpecialResetTokens\onSubmit
onSubmit(array $formData)
Process the form on submission.bool|string|array|Status As documented for HTMLForm::trySubmit.
DefinitionSpecialResetTokens.php:137
MediaWiki\Specials\SpecialResetTokens\__construct
__construct()
DefinitionSpecialResetTokens.php:26
MediaWiki\Specials\SpecialResetTokens\onSuccess
onSuccess()
Do something exciting on successful processing of the form, most likely to show a confirmation messag...
DefinitionSpecialResetTokens.php:75
MediaWiki\Specials

[8]ページ先頭

©2009-2025 Movatter.jp