Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
DuplicateFilesErrorPage | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
getHtml | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace FileImporter\Html; |
4 | |
5 | use File; |
6 | use MediaWiki\Html\Html; |
7 | use OOUI\ButtonWidget; |
8 | use OOUI\MessageWidget; |
9 | |
10 | /** |
11 | * Html showing a list of duplicate files. |
12 | * |
13 | * @license GPL-2.0-or-later |
14 | * @author Addshore |
15 | */ |
16 | class DuplicateFilesErrorPage extends SpecialPageHtmlFragment { |
17 | |
18 | /** |
19 | * @param File[] $files |
20 | * @param string|null $url |
21 | */ |
22 | public function getHtml( array $files, ?string $url ): string { |
23 | $output = new MessageWidget( [ |
24 | 'label' => $this->msg( 'fileimporter-duplicatefilesdetected' )->plain(), |
25 | 'type' => 'error', |
26 | ] ); |
27 | |
28 | $output .= Html::rawElement( 'p', [], Html::element( 'strong', [], |
29 | $this->msg( 'fileimporter-duplicatefilesdetected-prefix' )->plain() |
30 | ) ); |
31 | |
32 | $duplicateFilesList = ''; |
33 | foreach ( $files as $file ) { |
34 | $duplicateFilesList .= Html::rawElement( 'li', [], Html::element( |
35 | 'a', |
36 | [ 'href' => $file->getTitle()->getInternalURL() ], |
37 | $file->getTitle() |
38 | ) ); |
39 | } |
40 | |
41 | $output .= Html::rawElement( 'ul', [], $duplicateFilesList ); |
42 | |
43 | if ( $url ) { |
44 | $output .= Html::element( 'br' ) . |
45 | new ButtonWidget( |
46 | [ |
47 | 'label' => $this->msg( 'fileimporter-go-to-original-file-button' )->plain(), |
48 | 'href' => $url, |
49 | 'classes' => [ 'mw-importfile-error-back-button' ], |
50 | 'flags' => [ 'primary', 'progressive' ] |
51 | ] |
52 | ); |
53 | } |
54 | |
55 | return $output; |
56 | } |
57 | |
58 | } |