Replace infobox usages and extend successbox, warningbox and errorbox
Adding optional $className parameter to provide additional styling options. Optional parameter $heading was introduced for MobileFrontend. Therefore leaving inconsistent parameter order is necessary for the time being. Bug: T232903 Change-Id: I5857b2c58a47a83156c32f086a73fe2bd48ab0c8
This commit is contained in:
parent
eda773a437
commit
a9252abb1c
6 changed files with 23 additions and 16 deletions
|
|
@ -704,7 +704,7 @@ class Html {
|
|||
* Return the HTML for a message box.
|
||||
* @since 1.31
|
||||
* @param string $html of contents of box
|
||||
* @param string $className corresponding to box
|
||||
* @param string|array $className corresponding to box
|
||||
* @param string $heading (optional)
|
||||
* @return string of HTML representing a box.
|
||||
*/
|
||||
|
|
@ -718,32 +718,38 @@ class Html {
|
|||
/**
|
||||
* Return a warning box.
|
||||
* @since 1.31
|
||||
* @since 1.34 $className optional parameter added
|
||||
* @param string $html of contents of box
|
||||
* @param string $className (optional) corresponding to box
|
||||
* @return string of HTML representing a warning box.
|
||||
*/
|
||||
public static function warningBox( $html ) {
|
||||
return self::messageBox( $html, 'warningbox' );
|
||||
public static function warningBox( $html, $className = '' ) {
|
||||
return self::messageBox( $html, [ 'warningbox', $className ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an error box.
|
||||
* @since 1.31
|
||||
* @since 1.34 $className optional parameter added
|
||||
* @param string $html of contents of error box
|
||||
* @param string $heading (optional)
|
||||
* @param string $className (optional) corresponding to box
|
||||
* @return string of HTML representing an error box.
|
||||
*/
|
||||
public static function errorBox( $html, $heading = '' ) {
|
||||
return self::messageBox( $html, 'errorbox', $heading );
|
||||
public static function errorBox( $html, $heading = '', $className = '' ) {
|
||||
return self::messageBox( $html, [ 'errorbox', $className ], $heading );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a success box.
|
||||
* @since 1.31
|
||||
* @since 1.34 $className optional parameter added
|
||||
* @param string $html of contents of box
|
||||
* @param string $className (optional) corresponding to box
|
||||
* @return string of HTML representing a success box.
|
||||
*/
|
||||
public static function successBox( $html ) {
|
||||
return self::messageBox( $html, 'successbox' );
|
||||
public static function successBox( $html, $className = '' ) {
|
||||
return self::messageBox( $html, [ 'successbox', $className ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -690,7 +690,7 @@ abstract class DatabaseInstaller {
|
|||
$this->getPasswordBox( 'wgDBpassword', 'config-db-password' ) .
|
||||
$this->parent->getHelpBox( 'config-db-web-help' );
|
||||
if ( $noCreateMsg ) {
|
||||
$s .= $this->parent->getWarningBox( wfMessage( $noCreateMsg )->plain() );
|
||||
$s .= Html::warningBox( wfMessage( $noCreateMsg )->plain(), 'config-warning-box' );
|
||||
} else {
|
||||
$s .= $this->getCheckBox( '_CreateDBAccount', 'config-db-web-create' );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,7 +390,8 @@ class WebInstaller extends Installer {
|
|||
);
|
||||
}
|
||||
$text = $msg->useDatabase( false )->plain();
|
||||
$this->output->addHTML( $this->getErrorBox( $text ) );
|
||||
$box = Html::errorBox( $text, '', 'config-error-box' );
|
||||
$this->output->addHTML( $box );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1046,9 +1047,9 @@ class WebInstaller extends Installer {
|
|||
$text = $status->getWikiText();
|
||||
|
||||
if ( $status->isOK() ) {
|
||||
$box = $this->getWarningBox( $text );
|
||||
$box = Html::warningBox( $text, 'config-warning-box' );
|
||||
} else {
|
||||
$box = $this->getErrorBox( $text );
|
||||
$box = Html::errorBox( $text, '', 'config-error-box' );
|
||||
}
|
||||
|
||||
$this->output->addHTML( $box );
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class WebInstallerOptions extends WebInstallerPage {
|
|||
}
|
||||
} else {
|
||||
$skinHtml .=
|
||||
$this->parent->getWarningBox( wfMessage( 'config-skins-missing' )->plain() ) .
|
||||
Html::warningBox( wfMessage( 'config-skins-missing' )->plain(), 'config-warning-box' ) .
|
||||
Html::hidden( 'config_wgDefaultSkin', $chosenSkinName );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class WebInstallerRestart extends WebInstallerPage {
|
|||
}
|
||||
|
||||
$this->startForm();
|
||||
$s = $this->parent->getWarningBox( wfMessage( 'config-help-restart' )->plain() );
|
||||
$s = Html::warningBox( wfMessage( 'config-help-restart' )->plain(), '', 'config-warning-box' );
|
||||
$this->addHTML( $s );
|
||||
$this->endForm( 'restart' );
|
||||
|
||||
|
|
|
|||
|
|
@ -566,11 +566,11 @@ class HtmlTest extends MediaWikiTestCase {
|
|||
'<div class="errorbox">err</div>'
|
||||
);
|
||||
$this->assertEquals(
|
||||
Html::errorBox( 'err', 'heading' ),
|
||||
'<div class="errorbox"><h2>heading</h2>err</div>'
|
||||
Html::errorBox( 'err', 'heading', 'errorbox-custom-class' ),
|
||||
'<div class="errorbox errorbox-custom-class"><h2>heading</h2>err</div>'
|
||||
);
|
||||
$this->assertEquals(
|
||||
Html::errorBox( 'err', '0' ),
|
||||
Html::errorBox( 'err', '0', '' ),
|
||||
'<div class="errorbox"><h2>0</h2>err</div>'
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue