Index: trunk/extensions/DataTransfer/specials/DT_ImportXML.php |
— | — | @@ -29,26 +29,35 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | if ( $wgRequest->getCheck( 'import_file' ) ) { |
33 | | - $text = "<p>" . wfMsg( 'dt_import_importing' ) . "</p>\n"; |
34 | | - $source = ImportStreamSource::newFromUpload( "xml_file" ); |
35 | | - $text .= self::modifyPages( $source ); |
| 33 | + $text = DTUtils::printImportingMessage(); |
| 34 | + $uploadResult = ImportStreamSource::newFromUpload( "file_name" ); |
| 35 | + // handling changed in MW 1.17 |
| 36 | + if ( $uploadResult instanceof Status ) { |
| 37 | + $source = $uploadResult->value; |
| 38 | + } else { |
| 39 | + $source = $uploadResult; |
| 40 | + } |
| 41 | + $importSummary = $wgRequest->getVal( 'import_summary' ); |
| 42 | + $forPagesThatExist = $wgRequest->getVal( 'pagesThatExist' ); |
| 43 | + $text .= self::modifyPages( $source, $importSummary, $forPagesThatExist ); |
36 | 44 | } else { |
37 | | - $select_file_label = wfMsg( 'dt_import_selectfile', 'XML' ); |
38 | | - $import_button = wfMsg( 'import-interwiki-submit' ); |
39 | | - $text = <<<END |
40 | | - <p>$select_file_label</p> |
41 | | - <form enctype="multipart/form-data" action="" method="post"> |
42 | | - <p><input type="file" name="xml_file" size="25" /></p> |
43 | | - <p><input type="Submit" name="import_file" value="$import_button"></p> |
44 | | - </form> |
| 45 | + $formText = DTUtils::printFileSelector( 'XML' ); |
| 46 | + $formText .= DTUtils::printExistingPagesHandling(); |
| 47 | + $formText .= DTUtils::printImportSummaryInput( 'XML' ); |
| 48 | + $formText .= DTUtils::printSubmitButton(); |
| 49 | + $text = "\t" . Xml::tags( 'form', |
| 50 | + array( |
| 51 | + 'enctype' => 'multipart/form-data', |
| 52 | + 'action' => '', |
| 53 | + 'method' => 'post' |
| 54 | + ), $formText ) . "\n"; |
45 | 55 | |
46 | | -END; |
47 | 56 | } |
48 | 57 | |
49 | 58 | $wgOut->addHTML( $text ); |
50 | 59 | } |
51 | 60 | |
52 | | - function modifyPages( $source ) { |
| 61 | + function modifyPages( $source, $editSummary, $forPagesThatExist ) { |
53 | 62 | $text = ""; |
54 | 63 | $xml_parser = new DTXMLParser( $source ); |
55 | 64 | $xml_parser->doParse(); |
— | — | @@ -56,7 +65,8 @@ |
57 | 66 | $job_params = array(); |
58 | 67 | global $wgUser; |
59 | 68 | $job_params['user_id'] = $wgUser->getId(); |
60 | | - $job_params['edit_summary'] = wfMsgForContent( 'dt_import_editsummary', 'XML' ); |
| 69 | + $job_params['edit_summary'] = $editSummary; |
| 70 | + $job_params['for_pages_that_exist'] = $forPagesThatExist; |
61 | 71 | |
62 | 72 | foreach ( $xml_parser->mPages as $page ) { |
63 | 73 | $title = Title::newFromText( $page->getName() ); |