Index: trunk/extensions/DataTransfer/specials/DT_ImportCSV.php |
— | — | @@ -71,8 +71,8 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | 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" ); |
77 | 77 | if ( !$source->isOK() ) { |
78 | 78 | $text .= $wgOut->parse( $source->getWikiText() ); |
79 | 79 | } else { |
— | — | @@ -83,30 +83,35 @@ |
84 | 84 | $text .= $error_msg; |
85 | 85 | } else { |
86 | 86 | $importSummary = $wgRequest->getVal( 'import_summary' ); |
87 | | - $text .= self::modifyPages( $pages, $importSummary ); |
| 87 | + $forPagesThatExist = $wgRequest->getVal( 'pagesThatExist' ); |
| 88 | + $text .= self::modifyPages( $pages, $importSummary, $forPagesThatExist ); |
88 | 89 | } |
89 | 90 | } |
90 | 91 | } 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"; |
111 | 116 | } |
112 | 117 | |
113 | 118 | $wgOut->addHTML( $text ); |
— | — | @@ -167,7 +172,7 @@ |
168 | 173 | } |
169 | 174 | } |
170 | 175 | |
171 | | - function modifyPages( $pages, $editSummary ) { |
| 176 | + function modifyPages( $pages, $editSummary, $forPagesThatExist ) { |
172 | 177 | global $wgUser, $wgLang; |
173 | 178 | |
174 | 179 | $text = ""; |
— | — | @@ -175,6 +180,7 @@ |
176 | 181 | $jobParams = array(); |
177 | 182 | $jobParams['user_id'] = $wgUser->getId(); |
178 | 183 | $jobParams['edit_summary'] = $editSummary; |
| 184 | + $jobParams['for_pages_that_exist'] = $forPagesThatExist; |
179 | 185 | foreach ( $pages as $page ) { |
180 | 186 | $title = Title::newFromText( $page->getName() ); |
181 | 187 | if ( is_null( $title ) ) { |