Merge "(bug 34876) improve $.makeCollapsible performance on the initial collapsing"
[lhc/web/wiklou.git] / includes / specials / SpecialImport.php
index 2ea030e..bed39b2 100644 (file)
@@ -33,6 +33,7 @@ class SpecialImport extends SpecialPage {
 
        private $interwiki = false;
        private $namespace;
+       private $rootpage = '';
        private $frompage = '';
        private $logcomment= false;
        private $history = true;
@@ -100,6 +101,7 @@ class SpecialImport extends SpecialPage {
 
                $this->logcomment = $request->getText( 'log-comment' );
                $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull( 'pagelink-depth' );
+               $this->rootpage = $request->getText( 'rootpage' );\r
 
                $user = $this->getUser();
                if ( !$user->matchEditToken( $request->getVal( 'editToken' ) ) ) {
@@ -137,12 +139,20 @@ class SpecialImport extends SpecialPage {
                if( !$source->isGood() ) {
                        $out->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'importfailed', $source->getWikiText() ) );
                } else {
-                       $out->addWikiMsg( "importstart" );
-
                        $importer = new WikiImporter( $source->value );
                        if( !is_null( $this->namespace ) ) {
                                $importer->setTargetNamespace( $this->namespace );
                        }
+                       if( !is_null( $this->rootpage ) ) {
+                               $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
+                               if( !$statusRootPage->isGood() ) {
+                                       $out->wrapWikiMsg( "<p class=\"error\">\n$1\n</p>", array( 'import-options-wrong', $statusRootPage->getWikiText(), count( $statusRootPage->getErrorsArray() ) ) );
+                                       return;
+                               }
+                       }
+
+                       $out->addWikiMsg( "importstart" );
+
                        $reporter = new ImportReporter( $importer, $isUpload, $this->interwiki , $this->logcomment);
                        $reporter->setContext( $this->getContext() );
                        $exception = false;
@@ -177,21 +187,21 @@ class SpecialImport extends SpecialPage {
                $out = $this->getOutput();
 
                if( $user->isAllowed( 'importupload' ) ) {
-                       $out->addWikiMsg( "importtext" );
                        $out->addHTML(
                                Xml::fieldset( $this->msg( 'import-upload' )->text() ).
                                Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post',
                                        'action' => $action, 'id' => 'mw-import-upload-form' ) ) .
+                               $this->msg( 'importtext' )->parseAsBlock() .
                                Html::hidden( 'action', 'submit' ) .
                                Html::hidden( 'source', 'upload' ) .
-                               Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) .
+                               Xml::openElement( 'table', array( 'id' => 'mw-import-table-upload' ) ) .
 
                                "<tr>
                                        <td class='mw-label'>" .
                                                Xml::label( $this->msg( 'import-upload-filename' )->text(), 'xmlimport' ) .
                                        "</td>
                                        <td class='mw-input'>" .
-                                               Xml::input( 'xmlimport', 50, '', array( 'type' => 'file' ) ) . ' ' .
+                                               Xml::input( 'xmlimport', 50, '', array( 'id' => 'xmlimport', 'type' => 'file' ) ) . ' ' .
                                        "</td>
                                </tr>
                                <tr>
@@ -203,6 +213,15 @@ class SpecialImport extends SpecialPage {
                                                        array( 'id' => 'mw-import-comment', 'type' => 'text' ) ) . ' ' .
                                        "</td>
                                </tr>
+                               <tr>
+                                       <td class='mw-label'>" .
+                                               Xml::label( $this->msg( 'import-interwiki-rootpage' )->text(), 'mw-interwiki-rootpage-upload' ) .
+                                       "</td>
+                                       <td class='mw-input'>" .
+                                               Xml::input( 'rootpage', 50, $this->rootpage,
+                                                       array( 'id' => 'mw-interwiki-rootpage-upload', 'type' => 'text' ) ) . ' ' .
+                                       "</td>
+                               </tr>
                                <tr>
                                        <td></td>
                                        <td class='mw-submit'>" .
@@ -241,13 +260,13 @@ class SpecialImport extends SpecialPage {
                                Html::hidden( 'action', 'submit' ) .
                                Html::hidden( 'source', 'interwiki' ) .
                                Html::hidden( 'editToken', $user->getEditToken() ) .
-                               Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) .
+                               Xml::openElement( 'table', array( 'id' => 'mw-import-table-interwiki' ) ) .
                                "<tr>
                                        <td class='mw-label'>" .
                                                Xml::label( $this->msg( 'import-interwiki-source' )->text(), 'interwiki' ) .
                                        "</td>
                                        <td class='mw-input'>" .
-                                               Xml::openElement( 'select', array( 'name' => 'interwiki' ) )
+                                               Xml::openElement( 'select', array( 'name' => 'interwiki', 'id' => 'interwiki' ) )
                        );
                        foreach( $wgImportSources as $prefix ) {
                                $selected = ( $this->interwiki === $prefix ) ? ' selected="selected"' : '';
@@ -256,7 +275,7 @@ class SpecialImport extends SpecialPage {
 
                        $out->addHTML(
                                                Xml::closeElement( 'select' ) .
-                                               Xml::input( 'frompage', 50, $this->frompage ) .
+                                               Xml::input( 'frompage', 50, $this->frompage, array( 'id' => 'frompage' ) ) .
                                        "</td>
                                </tr>
                                <tr>
@@ -300,6 +319,15 @@ class SpecialImport extends SpecialPage {
                                                        array( 'id' => 'mw-interwiki-comment', 'type' => 'text' ) ) . ' ' .
                                        "</td>
                                </tr>
+                               <tr>
+                                       <td class='mw-label'>" .
+                                               Xml::label( $this->msg( 'import-interwiki-rootpage' )->text(), 'mw-interwiki-rootpage-interwiki' ) .
+                                       "</td>
+                                       <td class='mw-input'>" .
+                                               Xml::input( 'rootpage', 50, $this->rootpage,
+                                                       array( 'id' => 'mw-interwiki-rootpage-interwiki', 'type' => 'text' ) ) . ' ' .
+                                       "</td>
+                               </tr>
                                <tr>
                                        <td>
                                        </td>