Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ErrorPage | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
getHtml | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace FileImporter\Html; |
4 | |
5 | use MediaWiki\Html\Html; |
6 | use OOUI\ButtonWidget; |
7 | |
8 | /** |
9 | * @license GPL-2.0-or-later |
10 | * @author Andrew Kostka <andrew.kostka@wikimedia.de> |
11 | */ |
12 | class ErrorPage extends SpecialPageHtmlFragment { |
13 | |
14 | /** |
15 | * @param string $errorMessage HTML |
16 | * @param string|null $url |
17 | * @param string $type Either "error" (default), or "warning" |
18 | */ |
19 | public function getHtml( string $errorMessage, ?string $url, string $type = 'error' ): string { |
20 | $output = ( new HelpBanner( $this ) )->getHtml(); |
21 | |
22 | if ( $type === 'error' ) { |
23 | $output .= Html::errorBox( $errorMessage, '', 'mw-importfile-error-banner' ); |
24 | } else { |
25 | $output .= Html::warningBox( $errorMessage, 'mw-importfile-error-banner' ); |
26 | } |
27 | |
28 | if ( $url !== null ) { |
29 | $output .= '<br>' . new ButtonWidget( |
30 | [ |
31 | 'label' => $this->msg( 'fileimporter-go-to-original-file-button' )->plain(), |
32 | 'href' => $url, |
33 | 'classes' => [ 'mw-importfile-error-back-button' ], |
34 | 'flags' => [ 'primary', 'progressive' ] |
35 | ] |
36 | ); |
37 | } |
38 | |
39 | return $output; |
40 | } |
41 | |
42 | } |