From d82a031ebafbbb6c40c6ae3d18eaa5a06244bb7a Mon Sep 17 00:00:00 2001 From: Ariel Glenn Date: Fri, 5 Dec 2008 02:14:11 +0000 Subject: [PATCH] log comment for imports (bug #12728) --- includes/specials/SpecialImport.php | 43 +++++++++++++++++++++++++++-- languages/messages/MessagesEn.php | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 1af028d360..0859721127 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -28,6 +28,7 @@ class SpecialImport extends SpecialPage { private $interwiki = false; private $namespace; private $frompage = ''; + private $logcomment= false; private $history = true; /** @@ -69,6 +70,8 @@ class SpecialImport extends SpecialPage { $this->namespace = $wgRequest->getIntOrNull( 'namespace' ); $sourceName = $wgRequest->getVal( "source" ); + $this->logcomment = $wgRequest->getText( 'log-comment' ); + if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) { $source = new WikiErrorMsg( 'import-token-mismatch' ); } elseif ( $sourceName == 'upload' ) { @@ -103,7 +106,7 @@ class SpecialImport extends SpecialPage { if( !is_null( $this->namespace ) ) { $importer->setTargetNamespace( $this->namespace ); } - $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki ); + $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment); $reporter->open(); $result = $importer->doImport(); @@ -135,9 +138,26 @@ class SpecialImport extends SpecialPage { Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) . Xml::hidden( 'action', 'submit' ) . Xml::hidden( 'source', 'upload' ) . + Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) . + + " + " . Xml::input( 'xmlimport', 50, '', array( 'type' => 'file' ) ) . ' ' . - Xml::hidden( 'editToken', $wgUser->editToken() ) . + " + + + " . + Xml::label( wfMsg('import-upload-comment'), 'comment' ) . + Xml::input( 'log-comment', 50, '', array( 'type' => 'text' ) ) . ' ' . + " + + + " . Xml::submitButton( wfMsg( 'uploadbtn' ) ) . + " + " . + Xml::closeElement( 'table' ). + Xml::hidden( 'editToken', $wgUser->editToken() ) . Xml::closeElement( 'form' ) . Xml::closeElement( 'fieldset' ) ); @@ -187,6 +207,14 @@ class SpecialImport extends SpecialPage { Xml::namespaceSelector( $this->namespace, '' ) . " + + " . + Xml::label( wfMsg( 'import-comment' ), 'comment' ) . + " + " . + Xml::input( 'log-comment', 50, '', array( 'type' => 'text' ) ) . ' ' . + " + @@ -207,11 +235,14 @@ class SpecialImport extends SpecialPage { * @ingroup SpecialPage */ class ImportReporter { - function __construct( $importer, $upload, $interwiki ) { + private $reason=false; + + function __construct( $importer, $upload, $interwiki , $reason=false ) { $importer->setPageOutCallback( array( $this, 'reportPage' ) ); $this->mPageCount = 0; $this->mIsUpload = $upload; $this->mInterwiki = $interwiki; + $this->reason = $reason; } function open() { @@ -239,12 +270,18 @@ class ImportReporter { if( $this->mIsUpload ) { $detail = wfMsgExt( 'import-logentry-upload-detail', array( 'content', 'parsemag' ), $contentCount ); + if ($this->reason) { + $detail .= ' (' . $this->reason .')'; + } $log->addEntry( 'upload', $title, $detail ); } else { $interwiki = '[[:' . $this->mInterwiki . ':' . $origTitle->getPrefixedText() . ']]'; $detail = wfMsgExt( 'import-logentry-interwiki-detail', array( 'content', 'parsemag' ), $contentCount, $interwiki ); + if ($this->reason) { + $detail .= ' (' . $this->reason .')'; + } $log->addEntry( 'interwiki', $title, $detail ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 44b22d272a..b5343842fc 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -2790,6 +2790,8 @@ All transwiki import actions are logged at the [[Special:Log/import|import log]] 'import-interwiki-history' => 'Copy all history versions for this page', 'import-interwiki-submit' => 'Import', 'import-interwiki-namespace' => 'Transfer pages into namespace:', +'import-upload-comment' => 'Comment:', +'import-comment' => 'Comment:', 'importtext' => 'Please export the file from the source wiki using the [[Special:Export|export utility]]. Save it to your computer and upload it here.', 'importstart' => 'Importing pages...', -- 2.20.1