MediaWiki
master
UnwatchAction.php
Go to the documentation of this file.
1
<?php
23
use
MediaWiki\Context\IContextSource
;
24
use
MediaWiki\HTMLForm\HTMLForm
;
25
use
MediaWiki\Watchlist\WatchedItemStore
;
26
use
MediaWiki\Watchlist\WatchlistManager
;
27
33
class
UnwatchAction
extends
WatchAction
{
34
35
private
WatchlistManager
$watchlistManager;
36
43
public
function
__construct
(
44
Article
$article,
45
IContextSource
$context,
46
WatchlistManager
$watchlistManager,
47
WatchedItemStore
$watchedItemStore
48
) {
49
parent::__construct( $article, $context, $watchlistManager, $watchedItemStore );
50
$this->watchlistManager = $watchlistManager;
51
}
52
53
public
function
getName
() {
54
return
'unwatch'
;
55
}
56
57
public
function
onSubmit
( $data ) {
58
$this->watchlistManager->removeWatch(
59
$this->
getAuthority
(),
60
$this->
getTitle
()
61
);
62
63
return
true
;
64
}
65
66
protected
function
getFormFields
() {
67
return
[
68
'intro'
=> [
69
'type'
=>
'info'
,
70
'raw'
=>
true
,
71
'default'
=> $this->
msg
(
'confirm-unwatch-top'
)->parse()
72
]
73
];
74
}
75
76
protected
function
alterForm
(
HTMLForm
$form ) {
77
parent::alterForm( $form );
78
$form->
setWrapperLegendMsg
(
'removewatch'
);
79
$form->
setSubmitTextMsg
(
'confirm-unwatch-button'
);
80
}
81
82
public
function
onSuccess
() {
83
$msgKey = $this->
getTitle
()->isTalkPage() ?
'removedwatchtext-talk'
:
'removedwatchtext'
;
84
$this->
getOutput
()->addWikiMsg( $msgKey, $this->
getTitle
()->getPrefixedText() );
85
}
86
87
public
function
doesWrites
() {
88
return
true
;
89
}
90
}
getAuthority
getAuthority()
getTitle
getTitle()
Definition
RevisionSearchResultTrait.php:82
Action\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition
Action.php:141
Action\msg
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition
Action.php:223
Article
Legacy class representing an editable page and handling UI for some page actions.
Definition
Article.php:70
MediaWiki\HTMLForm\HTMLForm
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition
HTMLForm.php:208
MediaWiki\HTMLForm\HTMLForm\setWrapperLegendMsg
setWrapperLegendMsg( $msg)
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
Definition
HTMLForm.php:1890
MediaWiki\HTMLForm\HTMLForm\setSubmitTextMsg
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
Definition
HTMLForm.php:1681
MediaWiki\Watchlist\WatchedItemStore
Storage layer class for WatchedItems.
Definition
WatchedItemStore.php:42
MediaWiki\Watchlist\WatchlistManager
WatchlistManager service.
Definition
WatchlistManager.php:49
UnwatchAction
Page removal from a user's watchlist.
Definition
UnwatchAction.php:33
UnwatchAction\onSubmit
onSubmit( $data)
Process the form on POST submission.
Definition
UnwatchAction.php:57
UnwatchAction\getFormFields
getFormFields()
Get an HTMLForm descriptor array.
Definition
UnwatchAction.php:66
UnwatchAction\__construct
__construct(Article $article, IContextSource $context, WatchlistManager $watchlistManager, WatchedItemStore $watchedItemStore)
Definition
UnwatchAction.php:43
UnwatchAction\doesWrites
doesWrites()
Definition
UnwatchAction.php:87
UnwatchAction\getName
getName()
Return the name of the action this object responds to.
Definition
UnwatchAction.php:53
UnwatchAction\onSuccess
onSuccess()
Show one of 8 possible success messages.
Definition
UnwatchAction.php:82
UnwatchAction\alterForm
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
Definition
UnwatchAction.php:76
WatchAction
Page addition to a user's watchlist.
Definition
WatchAction.php:39
MediaWiki\Context\IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition
IContextSource.php:71
includes
actions
UnwatchAction.php
Generated on Fri Jul 26 2024 22:22:32 for MediaWiki by
1.10.0