Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ChangeFileInfoForm
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 getHtml
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace FileImporter\Html;
4
5use FileImporter\Data\ImportPlan;
6use MediaWiki\Html\Html;
7use 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 */
15class 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        ( new ImportIdentityFormSnippet( [
30            'clientUrl' => $importPlan->getRequest()->getUrl(),
31            'intendedFileName' => $importPlan->getFileName(),
32            'intendedRevisionSummary' => $importPlan->getRequest()->getIntendedSummary(),
33            'actionStats' => json_encode( $importPlan->getActionStats() ),
34            'validationWarnings' => json_encode( $importPlan->getValidationWarnings() ),
35            'importDetailsHash' => $importPlan->getRequest()->getImportDetailsHash(),
36            'automateSourceWikiCleanup' => $importPlan->getAutomateSourceWikiCleanUp(),
37            'automateSourceWikiDelete' => $importPlan->getAutomateSourceWikiDelete(),
38        ] ) )->getHtml() .
39        new ButtonInputWidget(
40            [
41                'classes' => [ 'mw-importfile-backButton' ],
42                'label' => $this->msg( 'fileimporter-submit-fileinfo' )->plain(),
43                'type' => 'submit',
44                'flags' => [ 'primary', 'progressive' ],
45                'tabIndex' => 2,
46            ]
47        ) .
48        Html::closeElement( 'form' );
49    }
50
51}