Merge "Convert various FormActions to OOUI"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 16 Apr 2017 19:30:55 +0000 (19:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 16 Apr 2017 19:30:55 +0000 (19:30 +0000)
includes/actions/FormAction.php
includes/actions/PurgeAction.php
includes/actions/RevertAction.php
includes/actions/UnwatchAction.php
includes/actions/WatchAction.php
languages/i18n/en.json
languages/i18n/qqq.json

index e94a188..0141b9e 100644 (file)
@@ -58,6 +58,14 @@ abstract class FormAction extends Action {
        protected function alterForm( HTMLForm $form ) {
        }
 
+       /**
+        * Whether the form should use OOUI
+        * @return bool
+        */
+       protected function usesOOUI() {
+               return false;
+       }
+
        /**
         * Get the HTMLForm to control behavior
         * @return HTMLForm|null
@@ -68,7 +76,11 @@ abstract class FormAction extends Action {
                // Give hooks a chance to alter the form, adding extra fields or text etc
                Hooks::run( 'ActionModifyFormFields', [ $this->getName(), &$this->fields, $this->page ] );
 
-               $form = new HTMLForm( $this->fields, $this->getContext(), $this->getName() );
+               if ( $this->usesOOUI() ) {
+                       $form = HTMLForm::factory( 'ooui', $this->fields, $this->getContext(), $this->getName() );
+               } else {
+                       $form = new HTMLForm( $this->fields, $this->getContext(), $this->getName() );
+               }
                $form->setSubmitCallback( [ $this, 'onSubmit' ] );
 
                $title = $this->getTitle();
index b2002ff..904c6e2 100644 (file)
@@ -75,12 +75,24 @@ class PurgeAction extends FormAction {
                }
        }
 
-       protected function alterForm( HTMLForm $form ) {
-               $form->setSubmitTextMsg( 'confirm_purge_button' );
+       protected function usesOOUI() {
+               return true;
        }
 
-       protected function preText() {
-               return $this->msg( 'confirm-purge-top' )->parse();
+       protected function getFormFields() {
+               return [
+                       'intro' => [
+                               'type' => 'info',
+                               'vertical-label' => true,
+                               'raw' => true,
+                               'default' => $this->msg( 'confirm-purge-top' )->parse()
+                       ]
+               ];
+       }
+
+       protected function alterForm( HTMLForm $form ) {
+               $form->setWrapperLegendMsg( 'confirm-purge-title' );
+               $form->setSubmitTextMsg( 'confirm_purge_button' );
        }
 
        protected function postText() {
index e466e65..a914c9b 100644 (file)
@@ -66,6 +66,10 @@ class RevertAction extends FormAction {
                }
        }
 
+       protected function usesOOUI() {
+               return true;
+       }
+
        protected function alterForm( HTMLForm $form ) {
                $form->setWrapperLegendMsg( 'filerevert-legend' );
                $form->setSubmitTextMsg( 'filerevert-submit' );
index 7f043e4..aa17b89 100644 (file)
@@ -31,22 +31,27 @@ class UnwatchAction extends WatchAction {
                return 'unwatch';
        }
 
-       protected function getDescription() {
-               return $this->msg( 'removewatch' )->escaped();
-       }
-
        public function onSubmit( $data ) {
                self::doUnwatch( $this->getTitle(), $this->getUser() );
 
                return true;
        }
 
-       protected function alterForm( HTMLForm $form ) {
-               $form->setSubmitTextMsg( 'confirm-unwatch-button' );
+       protected function getFormFields() {
+               return [
+                       'intro' => [
+                               'type' => 'info',
+                               'vertical-label' => true,
+                               'raw' => true,
+                               'default' => $this->msg( 'confirm-unwatch-top' )->parse()
+                       ]
+               ];
        }
 
-       protected function preText() {
-               return $this->msg( 'confirm-unwatch-top' )->parse();
+       protected function alterForm( HTMLForm $form ) {
+               parent::alterForm( $form );
+               $form->setWrapperLegendMsg( 'removewatch' );
+               $form->setSubmitTextMsg( 'confirm-unwatch-button' );
        }
 
        public function onSuccess() {
index 23505c0..e12a727 100644 (file)
@@ -35,11 +35,8 @@ class WatchAction extends FormAction {
                return false;
        }
 
-       /**
-        * @return string HTML
-        */
        protected function getDescription() {
-               return $this->msg( 'addwatch' )->escaped();
+               return '';
        }
 
        public function onSubmit( $data ) {
@@ -57,15 +54,27 @@ 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() );
index a003a10..9ab562b 100644 (file)
        "confirmrecreate-noreason": "User [[User:$1|$1]] ([[User talk:$1|talk]]) {{GENDER:$1|deleted}} this page after you started editing. Please confirm that you really want to recreate this page.",
        "recreate": "Recreate",
        "unit-pixel": "px",
+       "confirm-purge-title": "Purge this page",
        "confirm_purge_button": "OK",
        "confirm-purge-top": "Clear the cache of this page?",
        "confirm-purge-bottom": "Purging a page clears the cache and forces the most current revision to appear.",
index 698249a..b0e1d74 100644 (file)
        "confirmrecreate-noreason": "Followed by the checkbox which has the label {{msg-mw|Recreate}}.\n\nParameters:\n* $1 - username, also used for GENDER support\n* $2 - (Unused) reason\nSee also:\n* {{msg-mw|Confirmrecreate}}",
        "recreate": "Text shown when the editor fails to save the page due to it having been deleted since they opened VE. $1 is the message {{msg-mw|ooui-dialog-process-continue}}.",
        "unit-pixel": "{{optional}}\npx is the abbreviation for \"pixel\".",
+       "confirm-purge-title": "Title for the confirmation form that appears when the user is about to purge the page.",
        "confirm_purge_button": "Used as Submit button text.\n{{Identical|OK}}",
        "confirm-purge-top": "Used as confirmation message.",
        "confirm-purge-bottom": "Additional description for Purge form.",