Merge "Followup I888c616e: Keep IRC line format unchanged."
[lhc/web/wiklou.git] / includes / api / ApiImport.php
index 15eac33..9657e12 100644 (file)
  */
 class ApiImport extends ApiBase {
 
-       public function __construct( $main, $action ) {
-               parent::__construct( $main, $action );
-       }
-
        public function execute() {
                $user = $this->getUser();
                $params = $this->extractRequestParams();
@@ -68,6 +64,12 @@ class ApiImport extends ApiBase {
                if ( isset( $params['namespace'] ) ) {
                        $importer->setTargetNamespace( $params['namespace'] );
                }
+               if ( isset( $params['rootpage'] ) ) {
+                       $statusRootPage = $importer->setTargetRootPage( $params['rootpage'] );
+                       if( !$statusRootPage->isGood() ) {
+                               $this->dieUsageMsg( $statusRootPage->getErrorsArray() );
+                       }
+               }
                $reporter = new ApiImportReporter(
                        $importer,
                        $isUpload,
@@ -98,7 +100,10 @@ class ApiImport extends ApiBase {
        public function getAllowedParams() {
                global $wgImportSources;
                return array(
-                       'token' => null,
+                       'token' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
                        'summary' => null,
                        'xml' => null,
                        'interwikisource' => array(
@@ -109,7 +114,8 @@ class ApiImport extends ApiBase {
                        'templates' => false,
                        'namespace' => array(
                                ApiBase::PARAM_TYPE => 'namespace'
-                       )
+                       ),
+                       'rootpage' => null,
                );
        }
 
@@ -123,6 +129,7 @@ class ApiImport extends ApiBase {
                        'fullhistory' => 'For interwiki imports: import the full history, not just the current version',
                        'templates' => 'For interwiki imports: import all included templates as well',
                        'namespace' => 'For interwiki imports: import to this namespace',
+                       'rootpage' => 'Import as subpage of this page',
                );
        }
 
@@ -152,6 +159,8 @@ class ApiImport extends ApiBase {
                        array( 'cantimport-upload' ),
                        array( 'import-unknownerror', 'source' ),
                        array( 'import-unknownerror', 'result' ),
+                       array( 'import-rootpage-nosubpage', 'namespace' ),
+                       array( 'import-rootpage-invalid' ),
                ) );
        }
 
@@ -173,10 +182,6 @@ class ApiImport extends ApiBase {
        public function getHelpUrls() {
                return 'https://www.mediawiki.org/wiki/API:Import';
        }
-
-       public function getVersion() {
-               return __CLASS__ . ': $Id$';
-       }
 }
 
 /**