MediaWiki REL1_40
UnwatchAction.php
Go to the documentation of this file.
1<?php
24
31
33 private $watchlistManager;
34
41 public function __construct(
42 Article $article,
43 IContextSource $context,
44 WatchlistManager $watchlistManager,
45 WatchedItemStore $watchedItemStore
46 ) {
47 parent::__construct( $article, $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->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()
getOutput()
Get the OutputPage being used for this instance.
Definition Action.php:151
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Definition Action.php:233
Legacy class representing an editable page and handling UI for some page actions.
Definition Article.php:56
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:153
setSubmitTextMsg( $msg)
Set the text for the submit button to a message.
setWrapperLegendMsg( $msg)
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
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.
Storage layer class for WatchedItems.
Interface for objects which can provide a MediaWiki context on request.