*/
protected $tabIndex = 1;
+ /**
+ * Numeric index of the help box
+ *
+ * @var int
+ */
+ protected $helpBoxId = 1;
+
/**
* Name of the page we're on
*
// Add parser hooks
$parser = MediaWikiServices::getInstance()->getParser();
- $parser->setHook( 'downloadlink', [ $this, 'downloadLinkHook' ] );
$parser->setHook( 'doclink', [ $this, 'docLink' ] );
}
* Show an error message in a box. Parameters are like wfMessage(), or
* alternatively, pass a Message object in.
* @param string|Message $msg
+ * @param mixed ...$params
*/
- public function showError( $msg /*...*/ ) {
+ public function showError( $msg, ...$params ) {
if ( !( $msg instanceof Message ) ) {
- $args = func_get_args();
- array_shift( $args );
- $args = array_map( 'htmlspecialchars', $args );
- $msg = wfMessage( $msg, $args );
+ $msg = wfMessage(
+ $msg,
+ array_map( 'htmlspecialchars', $params )
+ );
}
$text = $msg->useDatabase( false )->plain();
$this->output->addHTML( $this->getErrorBox( $text ) );
}
/**
- * Get HTML for an info box with an icon.
+ * Get HTML for an information message box with an icon.
*
- * @param string $text Wikitext, get this with wfMessage()->plain()
+ * @param string|HtmlArmor $text Wikitext to be parsed (from Message::plain) or raw HTML.
* @param string|bool $icon Icon name, file in mw-config/images. Default: false
* @param string|bool $class Additional class name to add to the wrapper div. Default: false.
- *
- * @return string
+ * @return string HTML
*/
public function getInfoBox( $text, $icon = false, $class = false ) {
- $text = $this->parse( $text, true );
+ $html = ( $text instanceof HtmlArmor ) ?
+ HtmlArmor::getHtml( $text ) :
+ $this->parse( $text, true );
$icon = ( $icon == false ) ?
'images/info-32.png' :
'images/' . $icon;
$alt = wfMessage( 'config-information' )->text();
- return Html::infoBox( $text, $icon, $alt, $class );
+ return Html::infoBox( $html, $icon, $alt, $class );
}
/**
* @param string $msg
* @return string
*/
- public function getHelpBox( $msg /*, ... */ ) {
- $args = func_get_args();
- array_shift( $args );
+ public function getHelpBox( $msg, ...$args ) {
$args = array_map( 'htmlspecialchars', $args );
$text = wfMessage( $msg, $args )->useDatabase( false )->plain();
$html = $this->parse( $text, true );
+ $id = 'helpBox-' . $this->helpBoxId++;
return "<div class=\"config-help-field-container\">\n" .
- "<span class=\"config-help-field-hint\" title=\"" .
+ "<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
+ "<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
- wfMessage( 'config-help' )->escaped() . "</span>\n" .
+ wfMessage( 'config-help' )->escaped() . "</label>\n" .
"<div class=\"config-help-field-data\">" . $html . "</div>\n" .
"</div>\n";
}
/**
* Output a help box.
* @param string $msg Key for wfMessage()
+ * @param mixed ...$params
*/
- public function showHelpBox( $msg /*, ... */ ) {
- $args = func_get_args();
- $html = $this->getHelpBox( ...$args );
+ public function showHelpBox( $msg, ...$params ) {
+ $html = $this->getHelpBox( $msg, ...$params );
$this->output->addHTML( $html );
}
* Output looks like a list.
*
* @param string $msg
+ * @param mixed ...$params
*/
- public function showMessage( $msg /*, ... */ ) {
- $args = func_get_args();
- array_shift( $args );
+ public function showMessage( $msg, ...$params ) {
$html = '<div class="config-message">' .
- $this->parse( wfMessage( $msg, $args )->useDatabase( false )->plain() ) .
+ $this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) .
"</div>\n";
$this->output->addHTML( $html );
}
/**
* Helper for Installer::docLink()
*
+ * @internal For use by WebInstallerOutput
* @param string $page
- *
* @return string
*/
- protected function getDocUrl( $page ) {
+ public function getDocUrl( $page ) {
$query = [ 'page' => $page ];
if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
}
/**
- * Helper for "Download LocalSettings" link on WebInstall_Complete
+ * Helper for sidebar links.
*
- * @param string $text Unused
- * @param string[] $attribs Unused
- * @param Parser $parser Unused
+ * @internal For use in WebInstallerOutput class
+ * @param string $url
+ * @param string $linkText
+ * @return string HTML
+ */
+ public function makeLinkItem( $url, $linkText ) {
+ return Html::rawElement( 'li', [],
+ Html::element( 'a', [ 'href' => $url ], $linkText )
+ );
+ }
+
+ /**
+ * Helper for "Download LocalSettings" link.
*
+ * @internal For use in WebInstallerComplete class
* @return string Html for download link
*/
- public function downloadLinkHook( $text, $attribs, $parser ) {
+ public function makeDownloadLinkHtml() {
$anchor = Html::rawElement( 'a',
[ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
wfMessage( 'config-download-localsettings' )->parse()