X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialImport.php;h=ab5d4d7238524754fa0e1cd87bbb8d611beb22b7;hp=beb454d669f899b6847dc702e35f3b39af620f19;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hpb=d19826aa35b206847a568a4b2c1c9ffaa615fca5 diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index beb454d669..ab5d4d7238 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -24,8 +24,6 @@ * @ingroup SpecialPage */ -use MediaWiki\MediaWikiServices; - /** * MediaWiki page data importer * @@ -45,6 +43,8 @@ class SpecialImport extends SpecialPage { private $includeTemplates = false; private $pageLinkDepth; private $importSources; + private $assignKnownUsers; + private $usernamePrefix; public function __construct() { parent::__construct( 'Import', 'import' ); @@ -112,6 +112,7 @@ class SpecialImport extends SpecialPage { $isUpload = false; $request = $this->getRequest(); $this->sourceName = $request->getVal( "source" ); + $this->assignKnownUsers = $request->getCheck( 'assignKnownUsers' ); $this->logcomment = $request->getText( 'log-comment' ); $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0 @@ -132,6 +133,7 @@ class SpecialImport extends SpecialPage { $source = Status::newFatal( 'import-token-mismatch' ); } elseif ( $this->sourceName === 'upload' ) { $isUpload = true; + $this->usernamePrefix = $this->fullInterwikiPrefix = $request->getVal( 'usernamePrefix' ); if ( $user->isAllowed( 'importupload' ) ) { $source = ImportStreamSource::newFromUpload( "xmlimport" ); } else { @@ -171,6 +173,10 @@ class SpecialImport extends SpecialPage { $source = Status::newFatal( "importunknownsource" ); } + if ( (string)$this->fullInterwikiPrefix === '' ) { + $source->fatal( 'importnoprefix' ); + } + $out = $this->getOutput(); if ( !$source->isGood() ) { $out->addWikiText( "

\n" . @@ -194,6 +200,7 @@ class SpecialImport extends SpecialPage { return; } } + $importer->setUsernamePrefix( $this->fullInterwikiPrefix, $this->assignKnownUsers ); $out->addWikiMsg( "importstart" ); @@ -338,6 +345,28 @@ class SpecialImport extends SpecialPage { Html::input( 'xmlimport', '', 'file', [ 'id' => 'xmlimport' ] ) . ' ' . " + + " . + Xml::label( $this->msg( 'import-upload-username-prefix' )->text(), + 'mw-import-usernamePrefix' ) . + " + " . + Xml::input( 'usernamePrefix', 50, + $this->usernamePrefix, + [ 'id' => 'usernamePrefix', 'type' => 'text' ] ) . ' ' . + " + + + + " . + Xml::checkLabel( + $this->msg( 'import-assign-known-users' )->text(), + 'assignKnownUsers', + 'assignKnownUsers', + $this->assignKnownUsers + ) . + " + " . Xml::label( $this->msg( 'import-comment' )->text(), 'mw-import-comment' ) . @@ -491,6 +520,17 @@ class SpecialImport extends SpecialPage { ) . " + + + " . + Xml::checkLabel( + $this->msg( 'import-assign-known-users' )->text(), + 'assignKnownUsers', + 'assignKnownUsers', + $this->assignKnownUsers + ) . + " + $importDepth " . @@ -524,172 +564,3 @@ class SpecialImport extends SpecialPage { return 'pagetools'; } } - -/** - * Reporting callback - * @ingroup SpecialPage - */ -class ImportReporter extends ContextSource { - private $reason = false; - private $logTags = []; - private $mOriginalLogCallback = null; - private $mOriginalPageOutCallback = null; - private $mLogItemCount = 0; - - /** - * @param WikiImporter $importer - * @param bool $upload - * @param string $interwiki - * @param string|bool $reason - */ - function __construct( $importer, $upload, $interwiki, $reason = false ) { - $this->mOriginalPageOutCallback = - $importer->setPageOutCallback( [ $this, 'reportPage' ] ); - $this->mOriginalLogCallback = - $importer->setLogItemCallback( [ $this, 'reportLogItem' ] ); - $importer->setNoticeCallback( [ $this, 'reportNotice' ] ); - $this->mPageCount = 0; - $this->mIsUpload = $upload; - $this->mInterwiki = $interwiki; - $this->reason = $reason; - } - - /** - * Sets change tags to apply to the import log entry and null revision. - * - * @param array $tags - * @since 1.29 - */ - public function setChangeTags( array $tags ) { - $this->logTags = $tags; - } - - function open() { - $this->getOutput()->addHTML( "

\n" ); - - return Status::newFatal( 'importnopages' ); - } - $out->addHTML( "\n" ); - - return Status::newGood( $this->mPageCount ); - } -}