Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 18
ErrorPage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 18
 getHtml
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 18
<?php
namespace FileImporter\Html;
use Html;
use OOUI\ButtonWidget;
/**
 * @license GPL-2.0-or-later
 * @author Andrew Kostka <andrew.kostka@wikimedia.de>
 */
class ErrorPage extends SpecialPageHtmlFragment {
    /**
     * @param string $errorMessage HTML
     * @param string|null $url
     * @param string $type Either "error" (default), or "warning"
     *
     * @return string
     */
    public function getHtml( $errorMessage, $url, $type = 'error' ) {
        $output = ( new HelpBanner( $this ) )->getHtml();
        $output .= Html::rawElement(
            'div',
            [ 'class' => "mw-importfile-error-banner ${type}box" ],
            Html::rawElement( 'p', [], $errorMessage )
        );
        if ( $url !== null ) {
            $output .= '<br>' . new ButtonWidget(
                [
                    'label' => $this->msg( 'fileimporter-go-to-original-file-button' )->plain(),
                    'href' => $url,
                    'classes' => [ 'mw-importfile-error-back-button' ],
                    'flags' => [ 'primary', 'progressive' ]
                ]
            );
        }
        return $output;
    }
}