Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ChangeFileInfoForm | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| getHtml | |
100.00% |
21 / 21 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace FileImporter\Html; |
| 4 | |
| 5 | use FileImporter\Data\ImportPlan; |
| 6 | use MediaWiki\Html\Html; |
| 7 | use OOUI\ButtonInputWidget; |
| 8 | |
| 9 | /** |
| 10 | * Form allowing the user to change the file info text. |
| 11 | * |
| 12 | * @license GPL-2.0-or-later |
| 13 | * @author Christoph Jauera <christoph.jauera@wikimedia.de> |
| 14 | */ |
| 15 | class ChangeFileInfoForm extends SpecialPageHtmlFragment { |
| 16 | |
| 17 | public function getHtml( ImportPlan $importPlan ): string { |
| 18 | // Try showing the user provided value first if present |
| 19 | $wikitext = $importPlan->getRequest()->getIntendedText() ?? $importPlan->getFileInfoText(); |
| 20 | |
| 21 | return Html::openElement( |
| 22 | 'form', |
| 23 | [ |
| 24 | 'action' => $this->getPageTitle()->getLocalURL(), |
| 25 | 'method' => 'POST', |
| 26 | ] |
| 27 | ) . |
| 28 | ( new WikitextEditor( $this ) )->getHtml( $importPlan->getTitle(), $wikitext ) . |
| 29 | ImportIdentityFormSnippet::newFromImportPlan( $importPlan, [ 'intendedWikitext' ] ) |
| 30 | ->getHtml() . |
| 31 | new ButtonInputWidget( |
| 32 | [ |
| 33 | 'classes' => [ 'mw-importfile-backButton' ], |
| 34 | 'label' => $this->msg( 'fileimporter-submit-fileinfo' )->plain(), |
| 35 | 'type' => 'submit', |
| 36 | 'flags' => [ 'primary', 'progressive' ], |
| 37 | 'tabIndex' => 2, |
| 38 | ] |
| 39 | ) . |
| 40 | Html::closeElement( 'form' ); |
| 41 | } |
| 42 | |
| 43 | } |