* http://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * * @file * @ingroup SpecialPage */ /** * Constructor */ function wfSpecialImport( $page = '' ) { global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources; global $wgImportTargetNamespace; $interwiki = false; $namespace = $wgImportTargetNamespace; $frompage = ''; $history = true; if ( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') { $isUpload = false; $namespace = $wgRequest->getIntOrNull( 'namespace' ); switch( $wgRequest->getVal( "source" ) ) { case "upload": $isUpload = true; if( $wgUser->isAllowed( 'importupload' ) ) { $source = ImportStreamSource::newFromUpload( "xmlimport" ); } else { return $wgOut->permissionRequired( 'importupload' ); } break; case "interwiki": $interwiki = $wgRequest->getVal( 'interwiki' ); $history = $wgRequest->getCheck( 'interwikiHistory' ); $frompage = $wgRequest->getText( "frompage" ); $source = ImportStreamSource::newFromInterwiki( $interwiki, $frompage, $history ); break; default: $source = new WikiErrorMsg( "importunknownsource" ); } if( WikiError::isError( $source ) ) { $wgOut->wrapWikiMsg( '
$1
', array( 'importfailed', $source->getMessage() ) ); } else { $wgOut->addWikiMsg( "importstart" ); $importer = new WikiImporter( $source ); if( !is_null( $namespace ) ) { $importer->setTargetNamespace( $namespace ); } $reporter = new ImportReporter( $importer, $isUpload, $interwiki ); $reporter->open(); $result = $importer->doImport(); $resultCount = $reporter->close(); if( WikiError::isError( $result ) ) { # No source or XML parse error $wgOut->wrapWikiMsg( '$1
', array( 'importfailed', $result->getMessage() ) ); } elseif( WikiError::isError( $resultCount ) ) { # Zero revisions $wgOut->wrapWikiMsg( '$1
', array( 'importfailed', $resultCount->getMessage() ) ); } else { # Success! $wgOut->addWikiMsg( 'importsuccess' ); } $wgOut->addWikiText( '