r78289 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78288‎ | r78289 | r78290 >
Date:00:33, 13 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Transferred most HTML printouts to use DTUtils functions; added handling for pag
es that already exist
Modified paths:
  • /trunk/extensions/DataTransfer/specials/DT_ImportCSV.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/specials/DT_ImportCSV.php
@@ -71,8 +71,8 @@
7272 }
7373
7474 if ( $wgRequest->getCheck( 'import_file' ) ) {
75 - $text = "<p>" . wfMsg( 'dt_import_importing' ) . "</p>\n";
76 - $source = ImportStreamSource::newFromUpload( "csv_file" );
 75+ $text = DTUtils::printImportingMessage();
 76+ $source = ImportStreamSource::newFromUpload( "file_name" );
7777 if ( !$source->isOK() ) {
7878 $text .= $wgOut->parse( $source->getWikiText() );
7979 } else {
@@ -83,30 +83,35 @@
8484 $text .= $error_msg;
8585 } else {
8686 $importSummary = $wgRequest->getVal( 'import_summary' );
87 - $text .= self::modifyPages( $pages, $importSummary );
 87+ $forPagesThatExist = $wgRequest->getVal( 'pagesThatExist' );
 88+ $text .= self::modifyPages( $pages, $importSummary, $forPagesThatExist );
8889 }
8990 }
9091 } else {
91 - $select_file_label = wfMsg( 'dt_import_selectfile', 'CSV' );
92 - $encoding_type_label = wfMsg( 'dt_import_encodingtype' );
93 - $import_summary_label = wfMsg( 'dt_import_summarydesc' );
94 - $default_summary = wfMsgForContent( 'dt_import_editsummary', 'CSV' );
95 - $import_button = wfMsg( 'import-interwiki-submit' );
96 - $text = <<<END
97 - <p>$select_file_label</p>
98 - <form enctype="multipart/form-data" action="" method="post">
99 - <p><input type="file" name="csv_file" size="25" /></p>
100 - <p>$encoding_type_label: <select name="encoding">
101 - <option selected value="utf8">UTF-8</option>
102 - <option value="utf16">UTF-16</option>
103 - </select></p>
104 - <p>$import_summary_label
105 - <input type="text" id="wpSummary" class="mw-summary" name="import_summary" value="$default_summary" />
106 - </p>
107 - <p><input type="Submit" name="import_file" value="$import_button"></p>
108 - </form>
109 -
110 -END;
 92+ $formText = DTUtils::printFileSelector( 'CSV' );
 93+ $utf8OptionText = "\t" . Xml::element( 'option',
 94+ array(
 95+ 'selected' => 'selected',
 96+ 'value' => 'utf8'
 97+ ), 'UTF-8' ) . "\n";
 98+ $utf16OptionText = "\t" . Xml::element( 'option',
 99+ array(
 100+ 'value' => 'utf16'
 101+ ), 'UTF-16' ) . "\n";
 102+ $encodingSelectText = Xml::tags( 'select',
 103+ array( 'name' => 'encoding' ),
 104+ "\n" . $utf8OptionText . $utf16OptionText. "\t" ) . "\n\t";
 105+ $formText .= "\t" . Xml::tags( 'p', null, wfMsg( 'dt_import_encodingtype', 'CSV' ) . " " . $encodingSelectText ) . "\n";
 106+ $formText .= "\t" . '<hr style="margin: 10px 0 10px 0" />' . "\n";
 107+ $formText .= DTUtils::printExistingPagesHandling();
 108+ $formText .= DTUtils::printImportSummaryInput( 'CSV' );
 109+ $formText .= DTUtils::printSubmitButton();
 110+ $text = "\t" . Xml::tags( 'form',
 111+ array(
 112+ 'enctype' => 'multipart/form-data',
 113+ 'action' => '',
 114+ 'method' => 'post'
 115+ ), $formText ) . "\n";
111116 }
112117
113118 $wgOut->addHTML( $text );
@@ -167,7 +172,7 @@
168173 }
169174 }
170175
171 - function modifyPages( $pages, $editSummary ) {
 176+ function modifyPages( $pages, $editSummary, $forPagesThatExist ) {
172177 global $wgUser, $wgLang;
173178
174179 $text = "";
@@ -175,6 +180,7 @@
176181 $jobParams = array();
177182 $jobParams['user_id'] = $wgUser->getId();
178183 $jobParams['edit_summary'] = $editSummary;
 184+ $jobParams['for_pages_that_exist'] = $forPagesThatExist;
179185 foreach ( $pages as $page ) {
180186 $title = Title::newFromText( $page->getName() );
181187 if ( is_null( $title ) ) {

Status & tagging log