Merge "Restructure /resources/src/mediawiki.page/"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 29 Sep 2015 04:12:03 +0000 (04:12 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 29 Sep 2015 04:12:03 +0000 (04:12 +0000)
includes/actions/FormAction.php
includes/actions/PurgeAction.php
includes/actions/WatchAction.php

index 9decf90..aa201d7 100644 (file)
@@ -31,7 +31,10 @@ abstract class FormAction extends Action {
         * Get an HTMLForm descriptor array
         * @return array
         */
-       abstract protected function getFormFields();
+       protected function getFormFields() {
+               // Default to an empty form with just a submit button
+               return array();
+       }
 
        /**
         * Add pre- or post-text to the form
@@ -75,7 +78,9 @@ abstract class FormAction extends Action {
                        $this->getRequest()->getQueryValues(),
                        array( 'action' => null, 'title' => null )
                );
-               $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) );
+               if ( $params ) {
+                       $form->addHiddenField( 'redirectparams', wfArrayToCgi( $params ) );
+               }
 
                $form->addPreText( $this->preText() );
                $form->addPostText( $this->postText() );
@@ -88,9 +93,10 @@ abstract class FormAction extends Action {
        }
 
        /**
-        * Process the form on POST submission.  If you return false from getFormFields(),
-        * this will obviously never be reached.  If you don't want to do anything with the
-        * form, just return false here
+        * Process the form on POST submission.
+        *
+        * If you don't want to do anything with the form, just return false here.
+        *
         * @param array $data
         * @return bool|array True for success, false for didn't-try, array of errors on failure
         */
index ed0bff7..e5da172 100644 (file)
@@ -44,14 +44,6 @@ class PurgeAction extends FormAction {
                return '';
        }
 
-       /**
-        * Just get an empty form with a single submit button
-        * @return array
-        */
-       protected function getFormFields() {
-               return array();
-       }
-
        public function onSubmit( $data ) {
                return $this->page->doPurge();
        }
index 51108c0..30b83d7 100644 (file)
@@ -42,36 +42,12 @@ class WatchAction extends FormAction {
                return $this->msg( 'addwatch' )->escaped();
        }
 
-       /**
-        * Just get an empty form with a single submit button
-        * @return array
-        */
-       protected function getFormFields() {
-               return array();
-       }
-
        public function onSubmit( $data ) {
                self::doWatch( $this->getTitle(), $this->getUser() );
 
                return true;
        }
 
-       /**
-        * This can be either formed or formless depending on the session token given
-        */
-       public function show() {
-               $this->setHeaders();
-
-               $user = $this->getUser();
-               // This will throw exceptions if there's a problem
-               $this->checkCanExecute( $user );
-
-               $form = $this->getForm();
-               if ( $form->show() ) {
-                       $this->onSuccess();
-               }
-       }
-
        protected function checkCanExecute( User $user ) {
                // Must be logged in
                if ( $user->isAnon() ) {