From: jdlrobson Date: Mon, 1 Sep 2014 19:36:06 +0000 (+0100) Subject: Correct button colours of preference page when $wgUseMediaWikiUIEverywhere is enabled X-Git-Tag: 1.31.0-rc.0~13988^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=274978205c0ef8e06f2de183660331004dd5fd41;p=lhc%2Fweb%2Fwiklou.git 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 --- 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();