r78290 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78289‎ | r78290 | r78291 >
Date:00:35, 13 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Transferred most HTML printouts to use DTUtils functions; added handling for pages that already exist; fix for MW 1.17+
Modified paths:
  • /trunk/extensions/DataTransfer/specials/DT_ImportXML.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/specials/DT_ImportXML.php
@@ -29,26 +29,35 @@
3030 }
3131
3232 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 );
3644 } 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";
4555
46 -END;
4756 }
4857
4958 $wgOut->addHTML( $text );
5059 }
5160
52 - function modifyPages( $source ) {
 61+ function modifyPages( $source, $editSummary, $forPagesThatExist ) {
5362 $text = "";
5463 $xml_parser = new DTXMLParser( $source );
5564 $xml_parser->doParse();
@@ -56,7 +65,8 @@
5766 $job_params = array();
5867 global $wgUser;
5968 $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;
6171
6272 foreach ( $xml_parser->mPages as $page ) {
6373 $title = Title::newFromText( $page->getName() );

Status & tagging log