Go to the documentation of this file.
38 if ( isset( $params[
'interwikisource'] ) ) {
42 if ( !isset( $params[
'interwikipage'] ) ) {
43 $this->
dieWithError( [
'apierror-missingparam',
'interwikipage' ] );
46 $params[
'interwikisource'],
47 $params[
'interwikipage'],
48 $params[
'fullhistory'],
51 $usernamePrefix = $params[
'interwikisource'];
58 $usernamePrefix = (string)$params[
'interwikiprefix'];
59 if ( $usernamePrefix ===
'' ) {
61 $this->
dieWithError( [
'apierror-missingparam', $encParamName ] );
69 if ( $params[
'tags'] ) {
71 if ( !$ableToTag->isOK() ) {
77 if ( isset( $params[
'namespace'] ) ) {
79 } elseif ( isset( $params[
'rootpage'] ) ) {
80 $statusRootPage = $importer->setTargetRootPage( $params[
'rootpage'] );
81 if ( !$statusRootPage->isGood() ) {
85 $importer->setUsernamePrefix( $usernamePrefix, $params[
'assignknownusers'] );
89 $params[
'interwikisource'],
92 if ( $params[
'tags'] ) {
93 $reporter->setChangeTags( $params[
'tags'] );
97 $importer->doImport();
98 }
catch ( Exception $e ) {
102 $resultData = $reporter->getData();
105 $result->addValue(
null, $this->
getModuleName(), $resultData );
116 $importSources = $this->
getConfig()->get(
'ImportSources' );
117 Hooks::run(
'ImportSources', [ &$importSources ] );
120 foreach ( $importSources as $key => $value ) {
121 if ( is_int( $key ) ) {
124 foreach ( $value as $subproject ) {
125 $result[] =
"$key:$subproject";
146 'interwikiprefix' => [
149 'interwikisource' => [
152 'interwikipage' =>
null,
153 'fullhistory' =>
false,
154 'templates' =>
false,
158 'assignknownusers' =>
false,
173 'action=import&interwikisource=meta&interwikipage=Help:ParserFunctions&' .
174 'namespace=100&fullhistory=&token=123ABC'
175 =>
'apihelp-import-example-import',
180 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Import';
XML file reader for the page data importer.
mustBePosted()
Indicates whether this module must be called with a POST request.
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
getAllowedImportSources()
Returns a list of interwiki prefixes corresponding to each defined import source.
This abstract class implements many basic API functions, and is the base of all API classes.
needsToken()
Returns the token type this module requires in order to execute.
dieWithException( $exception, array $options=[])
Abort execution with an error derived from an exception.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getHelpUrls()
Return links to more detailed help pages about the module.
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
getExamplesMessages()
Returns usage examples for this module.
getPermissionManager()
Obtain a PermissionManager instance that subclasses may use in their authorization checks.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
isWriteMode()
Indicates whether this module requires write mode.
API module that imports an XML file like Special:Import does.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
setTargetNamespace( $namespace)
Set a target namespace to override the defaults.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Import reporter for the API.
static newFromUpload( $fieldname="xmlimport")