r44245 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44244‎ | r44245 | r44246 >
Date:02:14, 5 December 2008
Author:ariel
Status:ok (Comments)
Tags:
Comment:
log comment for imports (bug #12728)
Modified paths:
  • /trunk/phase3/includes/specials/SpecialImport.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialImport.php
@@ -28,6 +28,7 @@
2929 private $interwiki = false;
3030 private $namespace;
3131 private $frompage = '';
 32+ private $logcomment= false;
3233 private $history = true;
3334
3435 /**
@@ -69,6 +70,8 @@
7071 $this->namespace = $wgRequest->getIntOrNull( 'namespace' );
7172 $sourceName = $wgRequest->getVal( "source" );
7273
 74+ $this->logcomment = $wgRequest->getText( 'log-comment' );
 75+
7376 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) {
7477 $source = new WikiErrorMsg( 'import-token-mismatch' );
7578 } elseif ( $sourceName == 'upload' ) {
@@ -103,7 +106,7 @@
104107 if( !is_null( $this->namespace ) ) {
105108 $importer->setTargetNamespace( $this->namespace );
106109 }
107 - $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki );
 110+ $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment);
108111
109112 $reporter->open();
110113 $result = $importer->doImport();
@@ -135,9 +138,26 @@
136139 Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) .
137140 Xml::hidden( 'action', 'submit' ) .
138141 Xml::hidden( 'source', 'upload' ) .
 142+ Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) .
 143+
 144+ "<tr>
 145+ <td>" .
139146 Xml::input( 'xmlimport', 50, '', array( 'type' => 'file' ) ) . ' ' .
 147+ "</td>
 148+ </tr>
 149+ <tr>
 150+ <td>" .
 151+ Xml::label( wfMsg('import-upload-comment'), 'comment' ) .
 152+ Xml::input( 'log-comment', 50, '', array( 'type' => 'text' ) ) . ' ' .
 153+ "</td>
 154+ </tr>
 155+ <tr>
 156+ <td>" .
 157+ Xml::submitButton( wfMsg( 'uploadbtn' ) ) .
 158+ "</td>
 159+ </tr>" .
 160+ Xml::closeElement( 'table' ).
140161 Xml::hidden( 'editToken', $wgUser->editToken() ) .
141 - Xml::submitButton( wfMsg( 'uploadbtn' ) ) .
142162 Xml::closeElement( 'form' ) .
143163 Xml::closeElement( 'fieldset' )
144164 );
@@ -188,6 +208,14 @@
189209 "</td>
190210 </tr>
191211 <tr>
 212+ <td>" .
 213+ Xml::label( wfMsg( 'import-comment' ), 'comment' ) .
 214+ "</td>
 215+ <td>" .
 216+ Xml::input( 'log-comment', 50, '', array( 'type' => 'text' ) ) . ' ' .
 217+ "</td>
 218+ </tr>
 219+ <tr>
192220 <td>
193221 </td>
194222 <td>" .
@@ -207,11 +235,14 @@
208236 * @ingroup SpecialPage
209237 */
210238 class ImportReporter {
211 - function __construct( $importer, $upload, $interwiki ) {
 239+ private $reason=false;
 240+
 241+ function __construct( $importer, $upload, $interwiki , $reason=false ) {
212242 $importer->setPageOutCallback( array( $this, 'reportPage' ) );
213243 $this->mPageCount = 0;
214244 $this->mIsUpload = $upload;
215245 $this->mInterwiki = $interwiki;
 246+ $this->reason = $reason;
216247 }
217248
218249 function open() {
@@ -239,12 +270,18 @@
240271 if( $this->mIsUpload ) {
241272 $detail = wfMsgExt( 'import-logentry-upload-detail', array( 'content', 'parsemag' ),
242273 $contentCount );
 274+ if ($this->reason) {
 275+ $detail .= ' (' . $this->reason .')';
 276+ }
243277 $log->addEntry( 'upload', $title, $detail );
244278 } else {
245279 $interwiki = '[[:' . $this->mInterwiki . ':' .
246280 $origTitle->getPrefixedText() . ']]';
247281 $detail = wfMsgExt( 'import-logentry-interwiki-detail', array( 'content', 'parsemag' ),
248282 $contentCount, $interwiki );
 283+ if ($this->reason) {
 284+ $detail .= ' (' . $this->reason .')';
 285+ }
249286 $log->addEntry( 'interwiki', $title, $detail );
250287 }
251288
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2790,6 +2790,8 @@
27912791 'import-interwiki-history' => 'Copy all history versions for this page',
27922792 'import-interwiki-submit' => 'Import',
27932793 'import-interwiki-namespace' => 'Transfer pages into namespace:',
 2794+'import-upload-comment' => 'Comment:',
 2795+'import-comment' => 'Comment:',
27942796 'importtext' => 'Please export the file from the source wiki using the [[Special:Export|export utility]].
27952797 Save it to your computer and upload it here.',
27962798 'importstart' => 'Importing pages...',

Follow-up revisions

RevisionCommit summaryAuthorDate
r44247Follow up on r44245:...siebrand02:29, 5 December 2008
r44425Follow-up to r44245, r44250 (comment field on Special:Import)...brion22:31, 10 December 2008

Comments

#Comment by Brion VIBBER (talk | contribs)   22:45, 5 December 2008

Looks like it's working good!

I'd recommend a couple minor changes here...

  1. Append the reason with a colon rather than wrapping in parens. I think this'll be more consistent with other usage, and avoids the double-parentheses in history and recentchanges lists (since the whole comment gets wrapped in parens)
  2. Rearrange the file-upload portion of the Special:Import form a bit. Probably the text-box portion of the upload field should line up with the text-box for the comment, and the submit button.

I might also consider just using one message for the comment field since it'll be identical in both parts of the form; never any need to translate it differently.

#Comment by Raymond (talk | contribs)   15:25, 9 December 2008

Done in r44341

#Comment by Brion VIBBER (talk | contribs)   22:32, 10 December 2008

Follow-ups r44250, r44425 adjusting labels on comment fields.

Status & tagging log