* (bug 2482) Log and RC entries for Special:Import events
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jun 2006 20:12:18 +0000 (20:12 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jun 2006 20:12:18 +0000 (20:12 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/SpecialImport.php
languages/Messages.php

index fce55fe..e73ee37 100644 (file)
@@ -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 ==
index b5ec472..eb2b07b 100644 (file)
@@ -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
index f19e0f4..87fbd7e 100644 (file)
@@ -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( "<li>" . $skin->makeKnownLinkObj( $title ) . "</li>\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( "<li>" . wfMsgHtml( 'importnopages' ) . "</li>\n" );
                }
                $wgOut->addHtml( "</ul>\n" );
index dd12c83..06c9aba 100644 (file)
@@ -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',