<?php
/**
- *
- *
- * Created on Feb 4, 2009
- *
* Copyright © 2009 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
$params['fullhistory'],
$params['templates']
);
+ $usernamePrefix = $params['interwikisource'];
} else {
$isUpload = true;
if ( !$user->isAllowed( 'importupload' ) ) {
$this->dieWithError( 'apierror-cantimport-upload' );
}
$source = ImportStreamSource::newFromUpload( 'xml' );
+ $usernamePrefix = (string)$params['interwikiprefix'];
+ if ( $usernamePrefix === '' ) {
+ $encParamName = $this->encodeParamName( 'interwikiprefix' );
+ $this->dieWithError( [ 'apierror-missingparam', $encParamName ] );
+ }
}
if ( !$source->isOK() ) {
$this->dieStatus( $source );
}
+ // Check if user can add the log entry tags which were requested
+ if ( $params['tags'] ) {
+ $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user );
+ if ( !$ableToTag->isOK() ) {
+ $this->dieStatus( $ableToTag );
+ }
+ }
+
$importer = new WikiImporter( $source->value, $this->getConfig() );
if ( isset( $params['namespace'] ) ) {
$importer->setTargetNamespace( $params['namespace'] );
$this->dieStatus( $statusRootPage );
}
}
+ $importer->setUsernamePrefix( $usernamePrefix, $params['assignknownusers'] );
$reporter = new ApiImportReporter(
$importer,
$isUpload,
$params['interwikisource'],
$params['summary']
);
+ if ( $params['tags'] ) {
+ $reporter->setChangeTags( $params['tags'] );
+ }
try {
$importer->doImport();
'xml' => [
ApiBase::PARAM_TYPE => 'upload',
],
+ 'interwikiprefix' => [
+ ApiBase::PARAM_TYPE => 'string',
+ ],
'interwikisource' => [
ApiBase::PARAM_TYPE => $this->getAllowedImportSources(),
],
'namespace' => [
ApiBase::PARAM_TYPE => 'namespace'
],
+ 'assignknownusers' => false,
'rootpage' => null,
+ 'tags' => [
+ ApiBase::PARAM_TYPE => 'tags',
+ ApiBase::PARAM_ISMULTI => true,
+ ],
];
}
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Import';
+ return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Import';
}
}