From 3263900481a716913fbd2b59ae855416dc3dfac4 Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 7 Aug 2014 01:40:35 +0100 Subject: [PATCH] Split UnwatchAction into own class Change-Id: Ief650c115237214345bef7733d33967f0e042521 --- includes/AutoLoader.php | 2 +- includes/actions/UnwatchAction.php | 57 ++++++++++++++++++++++++++++++ includes/actions/WatchAction.php | 38 +------------------- 3 files changed, 59 insertions(+), 38 deletions(-) create mode 100644 includes/actions/UnwatchAction.php diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index d7dda6f4bb..b84feb20c4 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -217,7 +217,7 @@ $wgAutoloadLocalClasses = array( 'RollbackAction' => 'includes/actions/RollbackAction.php', 'SubmitAction' => 'includes/actions/EditAction.php', 'UnprotectAction' => 'includes/actions/UnprotectAction.php', - 'UnwatchAction' => 'includes/actions/WatchAction.php', + 'UnwatchAction' => 'includes/actions/UnwatchAction.php', 'ViewAction' => 'includes/actions/ViewAction.php', 'WatchAction' => 'includes/actions/WatchAction.php', diff --git a/includes/actions/UnwatchAction.php b/includes/actions/UnwatchAction.php new file mode 100644 index 0000000000..e2e5a1d843 --- /dev/null +++ b/includes/actions/UnwatchAction.php @@ -0,0 +1,57 @@ +msg( 'removewatch' )->escaped(); + } + + public function onSubmit( $data ) { + wfProfileIn( __METHOD__ ); + self::doUnwatch( $this->getTitle(), $this->getUser() ); + wfProfileOut( __METHOD__ ); + + return true; + } + + protected function alterForm( HTMLForm $form ) { + $form->setSubmitTextMsg( 'confirm-unwatch-button' ); + } + + protected function preText() { + return $this->msg( 'confirm-unwatch-top' )->parse(); + } + + public function onSuccess() { + $this->getOutput()->addWikiMsg( 'removedwatchtext', $this->getTitle()->getPrefixedText() ); + } +} diff --git a/includes/actions/WatchAction.php b/includes/actions/WatchAction.php index 2c7502e574..a54b7c57cd 100644 --- a/includes/actions/WatchAction.php +++ b/includes/actions/WatchAction.php @@ -1,6 +1,6 @@ getOutput()->addWikiMsg( 'addedwatchtext', $this->getTitle()->getPrefixedText() ); } } - -/** - * Page removal from a user's watchlist - * - * @ingroup Actions - */ -class UnwatchAction extends WatchAction { - - public function getName() { - return 'unwatch'; - } - - protected function getDescription() { - return $this->msg( 'removewatch' )->escaped(); - } - - public function onSubmit( $data ) { - wfProfileIn( __METHOD__ ); - self::doUnwatch( $this->getTitle(), $this->getUser() ); - wfProfileOut( __METHOD__ ); - - return true; - } - - protected function alterForm( HTMLForm $form ) { - $form->setSubmitTextMsg( 'confirm-unwatch-button' ); - } - - protected function preText() { - return $this->msg( 'confirm-unwatch-top' )->parse(); - } - - public function onSuccess() { - $this->getOutput()->addWikiMsg( 'removedwatchtext', $this->getTitle()->getPrefixedText() ); - } -} -- 2.20.1