r69575 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69574‎ | r69575 | r69576 >
Date:00:51, 20 July 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added input for user to enter edit summary; formatNum() added for display of number of pages
Modified paths:
  • /trunk/extensions/DataTransfer/specials/DT_ImportCSV.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DataTransfer/specials/DT_ImportCSV.php
@@ -79,14 +79,18 @@
8080 $encoding = $wgRequest->getVal( 'encoding' );
8181 $pages = array();
8282 $error_msg = self::getCSVData( $source->mHandle, $encoding, $pages );
83 - if ( ! is_null( $error_msg ) )
 83+ if ( ! is_null( $error_msg ) ) {
8484 $text .= $error_msg;
85 - else
86 - $text .= self::modifyPages( $pages );
 85+ } else {
 86+ $importSummary = $wgRequest->getVal( 'import_summary' );
 87+ $text .= self::modifyPages( $pages, $importSummary );
 88+ }
8789 }
8890 } else {
8991 $select_file_label = wfMsg( 'dt_import_selectfile', 'CSV' );
9092 $encoding_type_label = wfMsg( 'dt_import_encodingtype' );
 93+ $import_summary_label = wfMsg( 'dt_import_summarydesc' );
 94+ $default_summary = wfMsgForContent( 'dt_import_editsummary', 'CSV' );
9195 $import_button = wfMsg( 'import-interwiki-submit' );
9296 $text = <<<END
9397 <p>$select_file_label</p>
@@ -95,7 +99,10 @@
96100 <p>$encoding_type_label: <select name="encoding">
97101 <option selected value="utf8">UTF-8</option>
98102 <option value="utf16">UTF-16</option>
99 - </select>
 103+ </select></p>
 104+ <p>$import_summary_label
 105+ <input type="text" name="import_summary" value="$default_summary" />
 106+ </p>
100107 <p><input type="Submit" name="import_file" value="$import_button"></p>
101108 </form>
102109
@@ -160,24 +167,26 @@
161168 }
162169 }
163170
164 - function modifyPages( $pages ) {
 171+ function modifyPages( $pages, $editSummary ) {
 172+ global $wgUser, $wgLang;
 173+
165174 $text = "";
166175 $jobs = array();
167 - $job_params = array();
168 - global $wgUser;
169 - $job_params['user_id'] = $wgUser->getId();
170 - $job_params['edit_summary'] = wfMsgForContent( 'dt_import_editsummary', 'CSV' );
 176+ $jobParams = array();
 177+ $jobParams['user_id'] = $wgUser->getId();
 178+ $jobParams['edit_summary'] = $editSummary;
171179 foreach ( $pages as $page ) {
172180 $title = Title::newFromText( $page->getName() );
173181 if ( is_null( $title ) ) {
174182 $text .= '<p>' . wfMsg( 'img-auth-badtitle', $page->getName() ) . "</p>\n";
175183 continue;
176184 }
177 - $job_params['text'] = $page->createText();
178 - $jobs[] = new DTImportJob( $title, $job_params );
 185+ $jobParams['text'] = $page->createText();
 186+ $jobs[] = new DTImportJob( $title, $jobParams );
179187 }
180188 Job::batchInsert( $jobs );
181 - $text .= wfMsg( 'dt_import_success', count( $jobs ), 'CSV' );
 189+ $text .= wfMsgExt( 'dt_import_success', array( 'parse' ), $wgLang->formatNum( count( $jobs ) ), 'CSV' );
 190+
182191 return $text;
183192 }
184193

Status & tagging log