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