Correct button colours of preference page when $wgUseMediaWikiUIEverywhere is enabled
authorjdlrobson <jdlrobson@gmail.com>
Mon, 1 Sep 2014 19:36:06 +0000 (20:36 +0100)
committerJdlrobson <jrobson@wikimedia.org>
Wed, 17 Sep 2014 00:00:38 +0000 (00:00 +0000)
* Apply mw-ui-destructive to Special:Preferences/Reset
  when $wgUseMediaWikiUIEverywhere is enabled

Introduces HTMLForm->setSubmitDestructive()

Bug: 65317
Change-Id: I1d6691dce3e7dab662bda9a718e16c5caee6c041

includes/Preferences.php
includes/htmlform/HTMLForm.php
includes/specials/SpecialPreferences.php

index e0d5ed7..cb978b1 100644 (file)
@@ -1539,6 +1539,9 @@ class PreferencesForm extends HTMLForm {
         * @return string
         */
        function getButtons() {
+               global $wgUseMediaWikiUIEverywhere;
+               $attrs = $wgUseMediaWikiUIEverywhere ? array( 'class' => 'mw-ui-button mw-ui-quiet' ) : array();
+
                if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
                        return '';
                }
@@ -1548,7 +1551,8 @@ class PreferencesForm extends HTMLForm {
                if ( $this->getModifiedUser()->isAllowed( 'editmyoptions' ) ) {
                        $t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
 
-                       $html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped() );
+                       $html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped(),
+                               $attrs );
 
                        $html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html );
                }
index 5fda7bd..d582da3 100644 (file)
@@ -139,6 +139,7 @@ class HTMLForm extends ContextSource {
        protected $mFieldTree;
        protected $mShowReset = false;
        protected $mShowSubmit = true;
+       protected $mSubmitModifierClass = 'mw-ui-constructive';
 
        protected $mSubmitCallback;
        protected $mValidationErrorMessage;
@@ -897,7 +898,7 @@ class HTMLForm extends ContextSource {
                        $attribs['class'] = array( 'mw-htmlform-submit' );
 
                        if ( $this->isVForm() || $useMediaWikiUIEverywhere ) {
-                               array_push( $attribs['class'], 'mw-ui-button', 'mw-ui-constructive' );
+                               array_push( $attribs['class'], 'mw-ui-button', $this->mSubmitModifierClass );
                        }
 
                        if ( $this->isVForm() ) {
@@ -1042,6 +1043,14 @@ class HTMLForm extends ContextSource {
                return $this;
        }
 
+       /**
+        * Identify that the submit button in the form has a destructive action
+        *
+        */
+       public function setSubmitDestructive() {
+               $this->mSubmitModifierClass = 'mw-ui-destructive';
+       }
+
        /**
         * Set the text for the submit button to a message
         * @since 1.19
index 4cfd445..cea00fa 100644 (file)
@@ -73,6 +73,7 @@ class SpecialPreferences extends SpecialPage {
                $htmlForm = new HTMLForm( array(), $context, 'prefs-restore' );
 
                $htmlForm->setSubmitTextMsg( 'restoreprefs' );
+               $htmlForm->setSubmitDestructive();
                $htmlForm->setSubmitCallback( array( $this, 'submitReset' ) );
                $htmlForm->suppressReset();