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    /**
18     * @return string
19     */
20    public function getHtml( ImportPlan $importPlan ) {
21        // Try showing the user provided value first if present
22        $wikitext = $importPlan->getRequest()->getIntendedText() ?? $importPlan->getFileInfoText();
23
24        return Html::openElement(
25            'form',
26            [
27                'action' => $this->getPageTitle()->getLocalURL(),
28                'method' => 'POST',
29            ]
30        ) .
31        ( new WikitextEditor( $this ) )->getHtml( $importPlan->getTitle(), $wikitext ) .
32        ( new ImportIdentityFormSnippet( [
33            'clientUrl' => $importPlan->getRequest()->getUrl(),
34            'intendedFileName' => $importPlan->getFileName(),
35            'intendedRevisionSummary' => $importPlan->getRequest()->getIntendedSummary(),
36            'actionStats' => json_encode( $importPlan->getActionStats() ),
37            'validationWarnings' => json_encode( $importPlan->getValidationWarnings() ),
38            'importDetailsHash' => $importPlan->getRequest()->getImportDetailsHash(),
39            'automateSourceWikiCleanup' => $importPlan->getAutomateSourceWikiCleanUp(),
40            'automateSourceWikiDelete' => $importPlan->getAutomateSourceWikiDelete(),
41        ] ) )->getHtml() .
42        new ButtonInputWidget(
43            [
44                'classes' => [ 'mw-importfile-backButton' ],
45                'label' => $this->msg( 'fileimporter-submit-fileinfo' )->plain(),
46                'type' => 'submit',
47                'flags' => [ 'primary', 'progressive' ],
48                'tabIndex' => 2,
49            ]
50        ) .
51        Html::closeElement( 'form' );
52    }
53
54}