From: Brion Vibber Date: Tue, 27 Jun 2006 20:12:18 +0000 (+0000) Subject: * (bug 2482) Log and RC entries for Special:Import events X-Git-Tag: 1.31.0-rc.0~56569 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=bcacaef83408c49b729214bcf24ad222981c80a6;p=lhc%2Fweb%2Fwiklou.git * (bug 2482) Log and RC entries for Special:Import events --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fce55fe2a6..e73ee37e5c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -575,6 +575,7 @@ Some default configuration options have changed: * dumpBackup can optionally compress via dbzip2 * (bug 2483) Run link updates on change via XML import * (bug 2481) List imported pages during Special:Import +* (bug 2482) Log and RC entries for Special:Import events == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index b5ec472b19..eb2b07bd6e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1802,7 +1802,14 @@ $wgHooks = array(); * an action, which is a specific kind of event that can exist in that * log type. */ -$wgLogTypes = array( '', 'block', 'protect', 'rights', 'delete', 'upload', 'move' ); +$wgLogTypes = array( '', + 'block', + 'protect', + 'rights', + 'delete', + 'upload', + 'move', + 'import' ); /** * Lists the message key string for each log type. The localized messages @@ -1817,7 +1824,8 @@ $wgLogNames = array( 'rights' => 'rightslog', 'delete' => 'dellogpage', 'upload' => 'uploadlogpage', - 'move' => 'movelogpage' ); + 'move' => 'movelogpage', + 'import' => 'importlogpage' ); /** * Lists the message key string for descriptive text to be shown at the @@ -1832,7 +1840,8 @@ $wgLogHeaders = array( 'rights' => 'rightslogtext', 'delete' => 'dellogpagetext', 'upload' => 'uploadlogpagetext', - 'move' => 'movelogpagetext' ); + 'move' => 'movelogpagetext', + 'import' => 'importlogpagetext', ); /** * Lists the message key string for formatting individual events of each @@ -1852,7 +1861,9 @@ $wgLogActions = array( 'upload/upload' => 'uploadedimage', 'upload/revert' => 'uploadedimage', 'move/move' => '1movedto2', - 'move/move_redir' => '1movedto2_redir' ); + 'move/move_redir' => '1movedto2_redir', + 'import/upload' => 'import-logentry-upload', + 'import/interwiki' => 'import-logentry-interwiki' ); /** * Experimental preview feature to fetch rendered text diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index f19e0f4f8b..87fbd7ebb4 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -35,8 +35,12 @@ function wfSpecialImport( $page = '' ) { ### if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') { + $isUpload = false; + $interwiki = false; + switch( $wgRequest->getVal( "source" ) ) { case "upload": + $isUpload = true; if( $wgUser->isAllowed( 'importupload' ) ) { $source = ImportStreamSource::newFromUpload( "xmlimport" ); } else { @@ -44,8 +48,9 @@ function wfSpecialImport( $page = '' ) { } break; case "interwiki": + $interwiki = $wgRequest->getVal( "interwiki" ); $source = ImportStreamSource::newFromInterwiki( - $wgRequest->getVal( "interwiki" ), + $interwiki, $wgRequest->getText( "frompage" ) ); break; default: @@ -56,11 +61,14 @@ function wfSpecialImport( $page = '' ) { $wgOut->addWikiText( wfEscapeWikiText( $source->getMessage() ) ); } else { $wgOut->addWikiText( wfMsg( "importstart" ) ); + $importer = new WikiImporter( $source ); - $reporter = new ImportReporter( $importer ); + $reporter = new ImportReporter( $importer, $isUpload, $interwiki ); + $reporter->open(); $result = $importer->doImport(); $reporter->close(); + if( WikiError::isError( $result ) ) { $wgOut->addWikiText( wfMsg( "importfailed", wfEscapeWikiText( $result->getMessage() ) ) ); @@ -120,9 +128,11 @@ function wfSpecialImport( $page = '' ) { * Reporting callback */ class ImportReporter { - function __construct( $importer ) { + function __construct( $importer, $upload, $interwiki ) { $importer->setPageCallback( array( $this, 'reportPage' ) ); - $this->pageCount = 0; + $this->mPageCount = 0; + $this->mIsUpload = $upload; + $this->mInterwiki = $interwiki; } function open() { @@ -134,13 +144,24 @@ class ImportReporter { global $wgOut, $wgUser; $skin = $wgUser->getSkin(); $title = Title::newFromText( $pageName ); + $this->mPageCount++; + $wgOut->addHtml( "
  • " . $skin->makeKnownLinkObj( $title ) . "
  • \n" ); - $this->pageCount++; + + $log = new LogPage( 'import' ); + if( $this->mIsUpload ) { + $log->addEntry( 'upload', $title, '' ); + } else { + $interwiki = '[[:' . $this->mInterwiki . ':' . + $title->getPrefixedText() . ']]'; + $log->addEntry( 'interwiki', $title, + wfMsg( 'import-logentry-interwiki-source', $interwiki ) ); + } } function close() { global $wgOut; - if( $this->pageCount == 0 ) { + if( $this->mPageCount == 0 ) { $wgOut->addHtml( "
  • " . wfMsgHtml( 'importnopages' ) . "
  • \n" ); } $wgOut->addHtml( "\n" ); diff --git a/languages/Messages.php b/languages/Messages.php index dd12c83839..06c9aba8a7 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -1468,6 +1468,14 @@ In the latter case you can also use a link, e.g. [[{{ns:Special}}:Export/{{int:m 'importnofile' => 'No import file was uploaded.', 'importuploaderror' => 'Upload of import file failed; perhaps the file is bigger than the allowed upload size.', +# import log +'importlogpage' => 'Import log', +'importlogpagetext' => 'Administrative imports of pages with edit history from other wikis.', +'import-logentry-upload' => 'imported $1 by file upload', +'import-logentry-interwiki' => 'transwikied $1', +'import-logentry-interwiki-source' => 'from $1', + + # Keyboard access keys for power users 'accesskey-search' => 'f', 'accesskey-minoredit' => 'i',