Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
96.15% |
50 / 52 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
ChangeFileNameForm | |
96.15% |
50 / 52 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
getHtml | |
96.15% |
50 / 52 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace FileImporter\Html; |
4 | |
5 | use FileImporter\Data\ImportPlan; |
6 | use MediaWiki\Html\Html; |
7 | use MediaWiki\Title\MalformedTitleException; |
8 | use OOUI\ButtonInputWidget; |
9 | use OOUI\FieldLayout; |
10 | use OOUI\FieldsetLayout; |
11 | use OOUI\TextInputWidget; |
12 | |
13 | /** |
14 | * Form allowing the user to select a new file name. |
15 | * |
16 | * @license GPL-2.0-or-later |
17 | * @author Addshore |
18 | */ |
19 | class ChangeFileNameForm extends SpecialPageHtmlFragment { |
20 | |
21 | /** |
22 | * @return string |
23 | */ |
24 | public function getHtml( ImportPlan $importPlan ) { |
25 | try { |
26 | $filenameValue = $importPlan->getFileName(); |
27 | } catch ( MalformedTitleException $ex ) { |
28 | $filenameValue = $importPlan->getRequest()->getIntendedName(); |
29 | } |
30 | |
31 | return Html::openElement( |
32 | 'form', |
33 | [ |
34 | 'action' => $this->getPageTitle()->getLocalURL(), |
35 | 'method' => 'POST', |
36 | ] |
37 | ) . |
38 | ( new FieldsetLayout( [ |
39 | 'items' => [ new FieldLayout( |
40 | new TextInputWidget( |
41 | [ |
42 | 'name' => 'intendedFileName', |
43 | 'value' => $filenameValue, |
44 | 'suggestions' => false, |
45 | 'autofocus' => true, |
46 | 'required' => true, |
47 | ] |
48 | ), |
49 | [ |
50 | 'align' => 'top', |
51 | 'label' => $this->msg( 'fileimporter-newfilename' )->plain(), |
52 | ] |
53 | ) ] |
54 | ] ) ) . |
55 | // TODO allow changing the case of the file extension |
56 | Html::element( |
57 | 'p', |
58 | [], |
59 | $this->msg( 'fileimporter-extensionlabel' )->plain() . |
60 | ' .' . $importPlan->getFileExtension() |
61 | ) . |
62 | ( new ImportIdentityFormSnippet( [ |
63 | 'clientUrl' => $importPlan->getRequest()->getUrl(), |
64 | 'intendedWikitext' => $importPlan->getFileInfoText(), |
65 | 'actionStats' => json_encode( $importPlan->getActionStats() ), |
66 | 'validationWarnings' => json_encode( $importPlan->getValidationWarnings() ), |
67 | 'importDetailsHash' => $importPlan->getRequest()->getImportDetailsHash(), |
68 | 'intendedRevisionSummary' => $importPlan->getRequest()->getIntendedSummary(), |
69 | 'automateSourceWikiCleanup' => $importPlan->getAutomateSourceWikiCleanUp(), |
70 | 'automateSourceWikiDelete' => $importPlan->getAutomateSourceWikiDelete(), |
71 | ] ) )->getHtml() . |
72 | new ButtonInputWidget( |
73 | [ |
74 | 'classes' => [ 'mw-importfile-backButton' ], |
75 | 'label' => $this->msg( 'fileimporter-submit-title' )->plain(), |
76 | 'type' => 'submit', |
77 | 'flags' => [ 'primary', 'progressive' ], |
78 | ] |
79 | ) . |
80 | Html::closeElement( 'form' ); |
81 | } |
82 | |
83 | } |