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