WatchAction::onSubmit return correct value, not always true
[lhc/web/wiklou.git] / includes / actions / WatchAction.php
index 23505c0..aaccc0c 100644 (file)
@@ -35,17 +35,12 @@ class WatchAction extends FormAction {
                return false;
        }
 
-       /**
-        * @return string HTML
-        */
        protected function getDescription() {
-               return $this->msg( 'addwatch' )->escaped();
+               return '';
        }
 
        public function onSubmit( $data ) {
-               self::doWatch( $this->getTitle(), $this->getUser() );
-
-               return true;
+               return self::doWatch( $this->getTitle(), $this->getUser() );
        }
 
        protected function checkCanExecute( User $user ) {
@@ -57,22 +52,32 @@ class WatchAction extends FormAction {
                parent::checkCanExecute( $user );
        }
 
+       protected function usesOOUI() {
+               return true;
+       }
+
+       protected function getFormFields() {
+               return [
+                       'intro' => [
+                               'type' => 'info',
+                               'vertical-label' => true,
+                               'raw' => true,
+                               'default' => $this->msg( 'confirm-watch-top' )->parse()
+                       ]
+               ];
+       }
+
        protected function alterForm( HTMLForm $form ) {
+               $form->setWrapperLegendMsg( 'addwatch' );
                $form->setSubmitTextMsg( 'confirm-watch-button' );
                $form->setTokenSalt( 'watch' );
        }
 
-       protected function preText() {
-               return $this->msg( 'confirm-watch-top' )->parse();
-       }
-
        public function onSuccess() {
                $msgKey = $this->getTitle()->isTalkPage() ? 'addedwatchtext-talk' : 'addedwatchtext';
                $this->getOutput()->addWikiMsg( $msgKey, $this->getTitle()->getPrefixedText() );
        }
 
-       /* Static utility methods */
-
        /**
         * Watch or unwatch a page
         * @since 1.22
@@ -176,8 +181,10 @@ class WatchAction extends FormAction {
         * @param string $action Optionally override the action to 'watch'
         * @return string Token
         * @since 1.18
+        * @deprecated since 1.32 Use WatchAction::getWatchToken() with action 'unwatch' directly.
         */
        public static function getUnwatchToken( Title $title, User $user, $action = 'unwatch' ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return self::getWatchToken( $title, $user, $action );
        }