Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -1441,6 +1441,11 @@ |
1442 | 1442 | 'importnosources', |
1443 | 1443 | 'importnofile', |
1444 | 1444 | 'importuploaderror', |
| 1445 | + 'import-parse-failure', |
| 1446 | + 'import-articlename', |
| 1447 | + 'import-noarticle', |
| 1448 | + 'import-nonewrevisions', |
| 1449 | + 'xml-error-string', |
1445 | 1450 | ), |
1446 | 1451 | 'importlog' => array( |
1447 | 1452 | 'importlogpage', |
Index: trunk/phase3/includes/SpecialImport.php |
— | — | @@ -30,12 +30,14 @@ |
31 | 31 | global $wgImportTargetNamespace; |
32 | 32 | |
33 | 33 | $interwiki = false; |
| 34 | + $articleName = ''; |
34 | 35 | $namespace = $wgImportTargetNamespace; |
35 | 36 | $frompage = ''; |
36 | 37 | $history = true; |
37 | 38 | |
38 | 39 | if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') { |
39 | 40 | $isUpload = false; |
| 41 | + $articleName = htmlspecialchars( $wgRequest->getText( 'articlename' ) ); |
40 | 42 | $namespace = $wgRequest->getIntOrNull( 'namespace' ); |
41 | 43 | |
42 | 44 | switch( $wgRequest->getVal( "source" ) ) { |
— | — | @@ -61,7 +63,7 @@ |
62 | 64 | } |
63 | 65 | |
64 | 66 | if( WikiError::isError( $source ) ) { |
65 | | - $wgOut->addWikiText( wfEscapeWikiText( $source->getMessage() ) ); |
| 67 | + $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $source->getMessage() ) ) . '</p>' ); |
66 | 68 | } else { |
67 | 69 | $wgOut->addWikiText( wfMsg( "importstart" ) ); |
68 | 70 | |
— | — | @@ -69,19 +71,26 @@ |
70 | 72 | if( !is_null( $namespace ) ) { |
71 | 73 | $importer->setTargetNamespace( $namespace ); |
72 | 74 | } |
| 75 | + if( !is_null( $articleName ) ) { |
| 76 | + $importer->setTargetArticleName( $articleName ); |
| 77 | + } |
73 | 78 | $reporter = new ImportReporter( $importer, $isUpload, $interwiki ); |
74 | 79 | |
75 | 80 | $reporter->open(); |
76 | 81 | $result = $importer->doImport(); |
77 | | - $reporter->close(); |
| 82 | + $resultCount = $reporter->close(); |
78 | 83 | |
79 | 84 | if( WikiError::isError( $result ) ) { |
80 | | - $wgOut->addWikiText( wfMsg( "importfailed", |
81 | | - wfEscapeWikiText( $result->getMessage() ) ) ); |
| 85 | + # No source or XML parse error |
| 86 | + $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $result->getMessage() ) ) . '</p>' ); |
| 87 | + } elseif( WikiError::isError( $resultCount ) ) { |
| 88 | + # Zero revisions |
| 89 | + $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $resultCount->getMessage() ) ) . '</p>' ); |
82 | 90 | } else { |
83 | 91 | # Success! |
84 | 92 | $wgOut->addWikiText( wfMsg( "importsuccess" ) ); |
85 | 93 | } |
| 94 | + $wgOut->addWikiText( '<hr />' ); |
86 | 95 | } |
87 | 96 | } |
88 | 97 | |
— | — | @@ -89,18 +98,17 @@ |
90 | 99 | |
91 | 100 | if( $wgUser->isAllowed( 'importupload' ) ) { |
92 | 101 | $wgOut->addWikiText( wfMsg( "importtext" ) ); |
93 | | - $wgOut->addHTML( " |
94 | | -<fieldset> |
95 | | - <legend>" . wfMsgHtml('upload') . "</legend> |
96 | | - <form enctype='multipart/form-data' method='post' action=\"$action\"> |
97 | | - <input type='hidden' name='action' value='submit' /> |
98 | | - <input type='hidden' name='source' value='upload' /> |
99 | | - <input type='hidden' name='MAX_FILE_SIZE' value='2000000' /> |
100 | | - <input type='file' name='xmlimport' value='' size='30' /> |
101 | | - <input type='submit' value=\"" . wfMsgHtml( "uploadbtn" ) . "\" /> |
102 | | - </form> |
103 | | -</fieldset> |
104 | | -" ); |
| 102 | + $wgOut->addHTML( |
| 103 | + Xml::openElement( 'fieldset' ). |
| 104 | + Xml::element( 'legend', null, wfMsg( 'upload' ) ) . |
| 105 | + Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) . |
| 106 | + Xml::hidden( 'action', 'submit' ) . |
| 107 | + Xml::hidden( 'source', 'upload' ) . |
| 108 | + Xml::hidden( 'MAX_FILE_SIZE', '2000000' ) . |
| 109 | + "<input type='file' name='xmlimport' value='' size='30' />" . // No Xml function for type=file? Todo? |
| 110 | + Xml::submitButton( wfMsg( 'uploadbtn' ) ) . |
| 111 | + Xml::closeElement( 'form' ) . |
| 112 | + Xml::closeElement( 'fieldset' ) ); |
105 | 113 | } else { |
106 | 114 | if( empty( $wgImportSources ) ) { |
107 | 115 | $wgOut->addWikiText( wfMsg( 'importnosources' ) ); |
— | — | @@ -108,53 +116,57 @@ |
109 | 117 | } |
110 | 118 | |
111 | 119 | if( !empty( $wgImportSources ) ) { |
112 | | - $wgOut->addHTML( " |
113 | | -<fieldset> |
114 | | - <legend>" . wfMsgHtml('importinterwiki') . "</legend> |
115 | | - <form method='post' action=\"$action\">" . |
116 | | - $wgOut->parse( wfMsg( 'import-interwiki-text' ) ) . " |
117 | | - <input type='hidden' name='action' value='submit' /> |
118 | | - <input type='hidden' name='source' value='interwiki' /> |
119 | | - <table> |
120 | | - <tr> |
121 | | - <td> |
122 | | - <select name='interwiki'>" ); |
| 120 | + $wgOut->addHTML( |
| 121 | + Xml::openElement( 'fieldset' ) . |
| 122 | + Xml::element( 'legend', null, wfMsg( 'importinterwiki' ) ) . |
| 123 | + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) . |
| 124 | + wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) . |
| 125 | + Xml::hidden( 'action', 'submit' ) . |
| 126 | + Xml::hidden( 'source', 'interwiki' ) . |
| 127 | + Xml::openElement( 'table' ) . |
| 128 | + "<tr> |
| 129 | + <td>" . |
| 130 | + Xml::openElement( 'select', array( 'name' => 'interwiki' ) ) ); |
123 | 131 | foreach( $wgImportSources as $prefix ) { |
124 | 132 | $iw = htmlspecialchars( $prefix ); |
125 | 133 | $selected = ($interwiki === $prefix) ? ' selected="selected"' : ''; |
126 | | - $wgOut->addHTML( "<option value=\"$iw\"$selected>$iw</option>\n" ); |
| 134 | + $wgOut->addHTML( Xml::option( $iw, $iw, $selected ) ); |
127 | 135 | } |
128 | | - $wgOut->addHTML( " |
129 | | - </select> |
130 | | - </td> |
| 136 | + $wgOut->addHTML( |
| 137 | + Xml::closeElement( 'select' ) . |
| 138 | + "</td> |
131 | 139 | <td>" . |
132 | | - wfInput( 'frompage', 50, $frompage ) . |
| 140 | + Xml::input( 'frompage', 50, $frompage ) . |
133 | 141 | "</td> |
134 | 142 | </tr> |
135 | 143 | <tr> |
136 | 144 | <td></td> |
137 | 145 | <td>" . |
138 | | - wfCheckLabel( wfMsg( 'import-interwiki-history' ), |
139 | | - 'interwikiHistory', 'interwikiHistory', $history ) . |
| 146 | + Xml::checkLabel( wfMsg( 'import-interwiki-history' ), 'interwikiHistory', 'interwikiHistory', $history ) . |
140 | 147 | "</td> |
141 | 148 | </tr> |
142 | 149 | <tr> |
143 | 150 | <td></td> |
144 | | - <td> |
145 | | - " . wfMsgHtml( 'import-interwiki-namespace' ) . " " . |
146 | | - HTMLnamespaceselector( $namespace, '' ) . " |
147 | | - </td> |
| 151 | + <td>" . |
| 152 | + Xml::inputLabel( wfMsg( 'import-articlename' ), 'articlename', 'articlename', 50, $articleName ) . |
| 153 | + "</td> |
148 | 154 | </tr> |
149 | 155 | <tr> |
150 | 156 | <td></td> |
151 | 157 | <td>" . |
152 | | - wfSubmitButton( wfMsg( 'import-interwiki-submit' ) ) . |
| 158 | + Xml::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) . |
| 159 | + Xml::namespaceSelector( $namespace, '' ) . |
153 | 160 | "</td> |
154 | 161 | </tr> |
155 | | - </table> |
156 | | - </form> |
157 | | -</fieldset> |
158 | | -" ); |
| 162 | + <tr> |
| 163 | + <td></td> |
| 164 | + <td>" . |
| 165 | + Xml::submitButton( wfMsg( 'import-interwiki-submit' ) ) . |
| 166 | + "</td> |
| 167 | + </tr>" . |
| 168 | + Xml::closeElement( 'table' ). |
| 169 | + Xml::closeElement( 'form' ) . |
| 170 | + Xml::closeElement( 'fieldset' ) ); |
159 | 171 | } |
160 | 172 | } |
161 | 173 | |
— | — | @@ -185,12 +197,12 @@ |
186 | 198 | $localCount = $wgLang->formatNum( $successCount ); |
187 | 199 | $contentCount = $wgContLang->formatNum( $successCount ); |
188 | 200 | |
189 | | - $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) . |
190 | | - " " . |
191 | | - wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) . |
192 | | - "</li>\n" ); |
| 201 | + if( $successCount > 0 ) { |
| 202 | + $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) . |
| 203 | + " " . |
| 204 | + wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) . |
| 205 | + "</li>\n" ); |
193 | 206 | |
194 | | - if( $successCount > 0 ) { |
195 | 207 | $log = new LogPage( 'import' ); |
196 | 208 | if( $this->mIsUpload ) { |
197 | 209 | $detail = wfMsgForContent( 'import-logentry-upload-detail', |
— | — | @@ -209,15 +221,21 @@ |
210 | 222 | $nullRevision = Revision::newNullRevision( |
211 | 223 | $dbw, $title->getArticleId(), $comment, true ); |
212 | 224 | $nullRevision->insertOn( $dbw ); |
| 225 | + } else { |
| 226 | + $wgOut->addHtml( '<li>' . wfMsgExt( 'import-nonewrevisions', array( 'parse', ) ) . '</li>' ); |
213 | 227 | } |
| 228 | + |
214 | 229 | } |
215 | 230 | |
216 | 231 | function close() { |
217 | 232 | global $wgOut; |
218 | 233 | if( $this->mPageCount == 0 ) { |
219 | | - $wgOut->addHtml( "<li>" . wfMsgHtml( 'importnopages' ) . "</li>\n" ); |
| 234 | + $wgOut->addHtml( "</ul>\n" ); |
| 235 | + return new WikiErrorMsg( "importnopages" ); |
220 | 236 | } |
221 | 237 | $wgOut->addHtml( "</ul>\n" ); |
| 238 | + |
| 239 | + return $this->mPageCount; |
222 | 240 | } |
223 | 241 | } |
224 | 242 | |
— | — | @@ -393,6 +411,7 @@ |
394 | 412 | var $mPageOutCallback = null; |
395 | 413 | var $mRevisionCallback = null; |
396 | 414 | var $mTargetNamespace = null; |
| 415 | + var $mTargetArticleName = null; |
397 | 416 | var $lastfield; |
398 | 417 | |
399 | 418 | function WikiImporter( $source ) { |
— | — | @@ -425,7 +444,7 @@ |
426 | 445 | $chunk = $this->mSource->readChunk(); |
427 | 446 | if( !xml_parse( $parser, $chunk, $this->mSource->atEnd() ) ) { |
428 | 447 | wfDebug( "WikiImporter::doImport encountered XML parsing error\n" ); |
429 | | - return new WikiXmlError( $parser, 'XML import parse failure', $chunk, $offset ); |
| 448 | + return new WikiXmlError( $parser, wfMsgHtml( 'import-parse-failure' ), $chunk, $offset ); |
430 | 449 | } |
431 | 450 | $offset += strlen( $chunk ); |
432 | 451 | } while( $chunk !== false && !$this->mSource->atEnd() ); |
— | — | @@ -501,6 +520,13 @@ |
502 | 521 | } |
503 | 522 | |
504 | 523 | /** |
| 524 | + * Set a target articlename to override the defaults |
| 525 | + */ |
| 526 | + function setTargetArticleName( $articleName ) { |
| 527 | + $this->mTargetArticleName = is_null( $articleName ) ? null : $articleName; |
| 528 | + } |
| 529 | + |
| 530 | + /** |
505 | 531 | * Default per-revision callback, performs the import. |
506 | 532 | * @param WikiRevision $revision |
507 | 533 | * @private |
— | — | @@ -677,6 +703,11 @@ |
678 | 704 | switch( $this->appendfield ) { |
679 | 705 | case "title": |
680 | 706 | $this->workTitle = $this->appenddata; |
| 707 | + |
| 708 | + if( $this->mTargetArticleName != '' ) { |
| 709 | + // Import article with a different target article name |
| 710 | + $this->workTitle = $this->mTargetArticleName; |
| 711 | + } |
681 | 712 | $this->origTitle = Title::newFromText( $this->workTitle ); |
682 | 713 | if( !is_null( $this->mTargetNamespace ) && !is_null( $this->origTitle ) ) { |
683 | 714 | $this->pageTitle = Title::makeTitle( $this->mTargetNamespace, |
— | — | @@ -876,6 +907,9 @@ |
877 | 908 | } |
878 | 909 | |
879 | 910 | public static function newFromInterwiki( $interwiki, $page, $history=false ) { |
| 911 | + if( $page == '' ) { |
| 912 | + return new WikiErrorMsg( 'import-noarticle' ); |
| 913 | + } |
880 | 914 | $link = Title::newFromText( "$interwiki:Special:Export/$page" ); |
881 | 915 | if( is_null( $link ) || $link->getInterwiki() == '' ) { |
882 | 916 | return new WikiErrorMsg( 'importbadinterwiki' ); |
Index: trunk/phase3/includes/WikiError.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | |
103 | 103 | /** @return string */ |
104 | 104 | function getMessage() { |
105 | | - return sprintf( '%s at line %d, col %d (byte %d%s): %s', |
| 105 | + return sprintf( wfMsgHtml( 'xml-error-string', '%s', '%d', '%d', '%d%s', '%s' ), |
106 | 106 | $this->mMessage, |
107 | 107 | $this->mLine, |
108 | 108 | $this->mColumn, |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -2158,11 +2158,16 @@ |
2159 | 2159 | 'importcantopen' => "Couldn't open import file", |
2160 | 2160 | 'importbadinterwiki' => 'Bad interwiki link', |
2161 | 2161 | 'importnotext' => 'Empty or no text', |
2162 | | -'importsuccess' => 'Import succeeded!', |
| 2162 | +'importsuccess' => 'Import finished!', |
2163 | 2163 | 'importhistoryconflict' => 'Conflicting history revision exists (may have imported this page before)', |
2164 | 2164 | 'importnosources' => 'No transwiki import sources have been defined and direct history uploads are disabled.', |
2165 | 2165 | 'importnofile' => 'No import file was uploaded.', |
2166 | 2166 | 'importuploaderror' => 'Upload of import file failed; perhaps the file is bigger than the allowed upload size.', |
| 2167 | +'import-parse-failure' => 'XML import parse failure', |
| 2168 | +'import-articlename' => 'New article name:', |
| 2169 | +'import-noarticle' => 'No article to import!', |
| 2170 | +'import-nonewrevisions' => 'All revisions were previously imported.', |
| 2171 | +'xml-error-string' => '$1 at line $2, col $3 (byte $4): $5', |
2167 | 2172 | |
2168 | 2173 | # Import log |
2169 | 2174 | 'importlogpage' => 'Import log', |
Index: trunk/phase3/languages/messages/MessagesDe.php |
— | — | @@ -1726,19 +1726,24 @@ |
1727 | 1727 | 'import-interwiki-submit' => 'Import', |
1728 | 1728 | 'import-interwiki-namespace' => 'Importiere die Seite in den Namensraum:', |
1729 | 1729 | 'importtext' => 'Auf dieser Spezialseite können über [[{{ns:special}}:Export]] exportierte Seiten in dieses Wiki importiert werden.', |
1730 | | -'importstart' => 'Importiere Seiten …', |
| 1730 | +'importstart' => 'Importiere Seite …', |
1731 | 1731 | 'import-revision-count' => '– {{PLURAL:$1|1 Version|$1 Versionen}}', |
1732 | | -'importnopages' => 'Keine Seiten zum Importieren vorhanden.', |
| 1732 | +'importnopages' => 'Keine Seite zum Importieren vorhanden.', |
1733 | 1733 | 'importfailed' => 'Import fehlgeschlagen: $1', |
1734 | 1734 | 'importunknownsource' => 'Unbekannte Importquelle', |
1735 | 1735 | 'importcantopen' => 'Importdatei konnte nicht geöffnet werden', |
1736 | 1736 | 'importbadinterwiki' => 'Falscher Interwiki-Link', |
1737 | 1737 | 'importnotext' => 'Leer oder kein Text', |
1738 | | -'importsuccess' => 'Import erfolgreich!', |
| 1738 | +'importsuccess' => 'Import abgeschlossen!', |
1739 | 1739 | 'importhistoryconflict' => 'Es existieren bereits ältere Versionen, welche mit diesen kollidieren. Möglicherweise wurde die Seite bereits vorher importiert.', |
1740 | 1740 | 'importnosources' => 'Für den Transwiki-Import sind keine Quellen definiert. Das direkte Hochladen von Versionen ist gesperrt.', |
1741 | 1741 | 'importnofile' => 'Es ist keine Importdatei ausgewählt worden!', |
1742 | 1742 | 'importuploaderror' => 'Das Hochladen der Importdatei ist fehlgeschlagen. Vielleicht ist die Datei größer als erlaubt.', |
| 1743 | +'import-parse-failure' => 'Fehler beim XML-Import:', |
| 1744 | +'import-articlename' => 'Neuer Artikelname:', |
| 1745 | +'import-noarticle' => 'Es wurde kein zu importierender Artikel angegeben!', |
| 1746 | +'import-nonewrevisions' => 'Es sind keine neuen Versionen zum Import vorhanden, alle Versionen wurden bereits früher importiert.', |
| 1747 | +'xml-error-string' => '$1 Zeile $2, Spalte $3, (Byte $4): $5' , |
1743 | 1748 | |
1744 | 1749 | # Import log |
1745 | 1750 | 'importlogpage' => 'Import-Logbuch', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -152,6 +152,8 @@ |
153 | 153 | inline, as in most browsers |
154 | 154 | * Pass the user as an argument to 'isValidPassword' hook callbacks; see |
155 | 155 | docs/hooks.txt for more information |
| 156 | +* (bug 6808) Allow import to different page name |
| 157 | +* (bug 6436) Localization of Special:Import XML parser Error message(s). |
156 | 158 | |
157 | 159 | == Bugfixes since 1.10 == |
158 | 160 | |