From 274978205c0ef8e06f2de183660331004dd5fd41 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Mon, 1 Sep 2014 20:36:06 +0100 Subject: [PATCH] Correct button colours of preference page when $wgUseMediaWikiUIEverywhere is enabled * Apply mw-ui-destructive to Special:Preferences/Reset when $wgUseMediaWikiUIEverywhere is enabled Introduces HTMLForm->setSubmitDestructive() Bug: 65317 Change-Id: I1d6691dce3e7dab662bda9a718e16c5caee6c041 --- includes/Preferences.php | 6 +++++- includes/htmlform/HTMLForm.php | 11 ++++++++++- includes/specials/SpecialPreferences.php | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/Preferences.php b/includes/Preferences.php index e0d5ed70a1..cb978b1d10 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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 ); } diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 5fda7bd62a..d582da3b9d 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -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 diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 4cfd445f9f..cea00fa6e0 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -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(); -- 2.20.1