Merge "Added more JobRunner docs"
[lhc/web/wiklou.git] / includes / specials / SpecialImport.php
index 891962b..2a3ab64 100644 (file)
@@ -44,12 +44,12 @@ class SpecialImport extends SpecialPage {
         */
        public function __construct() {
                parent::__construct( 'Import', 'import' );
-               global $wgImportTargetNamespace;
-               $this->namespace = $wgImportTargetNamespace;
+               $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
        }
 
        /**
         * Execute
+        * @param string|null $par
         */
        function execute( $par ) {
                $this->setHeaders();
@@ -91,15 +91,15 @@ class SpecialImport extends SpecialPage {
         * Do the actual import
         */
        private function doImport() {
-               global $wgImportSources, $wgExportMaxLinkDepth;
-
                $isUpload = false;
                $request = $this->getRequest();
                $this->namespace = $request->getIntOrNull( 'namespace' );
                $sourceName = $request->getVal( "source" );
 
                $this->logcomment = $request->getText( 'log-comment' );
-               $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull( 'pagelink-depth' );
+               $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0
+                       ? 0
+                       : $request->getIntOrNull( 'pagelink-depth' );
                $this->rootpage = $request->getText( 'rootpage' );
 
                $user = $this->getUser();
@@ -117,7 +117,7 @@ class SpecialImport extends SpecialPage {
                                throw new PermissionsError( 'import' );
                        }
                        $this->interwiki = $request->getVal( 'interwiki' );
-                       if ( !in_array( $this->interwiki, $wgImportSources ) ) {
+                       if ( !in_array( $this->interwiki, $this->getConfig()->get( 'ImportSources' ) ) ) {
                                $source = Status::newFatal( "import-invalid-interwiki" );
                        } else {
                                $this->history = $request->getCheck( 'interwikiHistory' );
@@ -201,11 +201,10 @@ class SpecialImport extends SpecialPage {
        }
 
        private function showForm() {
-               global $wgImportSources, $wgExportMaxLinkDepth;
-
                $action = $this->getPageTitle()->getLocalURL( array( 'action' => 'submit' ) );
                $user = $this->getUser();
                $out = $this->getOutput();
+               $importSources = $this->getConfig()->get( 'ImportSources' );
 
                if ( $user->isAllowed( 'importupload' ) ) {
                        $out->addHTML(
@@ -242,7 +241,10 @@ class SpecialImport extends SpecialPage {
                                </tr>
                                <tr>
                                        <td class='mw-label'>" .
-                                       Xml::label( $this->msg( 'import-interwiki-rootpage' )->text(), 'mw-interwiki-rootpage-upload' ) .
+                                       Xml::label(
+                                               $this->msg( 'import-interwiki-rootpage' )->text(),
+                                               'mw-interwiki-rootpage-upload'
+                                       ) .
                                        "</td>
                                        <td class='mw-input'>" .
                                        Xml::input( 'rootpage', 50, $this->rootpage,
@@ -261,15 +263,15 @@ class SpecialImport extends SpecialPage {
                                        Xml::closeElement( 'fieldset' )
                        );
                } else {
-                       if ( empty( $wgImportSources ) ) {
+                       if ( empty( $importSources ) ) {
                                $out->addWikiMsg( 'importnosources' );
                        }
                }
 
-               if ( $user->isAllowed( 'import' ) && !empty( $wgImportSources ) ) {
+               if ( $user->isAllowed( 'import' ) && !empty( $importSources ) ) {
                        # Show input field for import depth only if $wgExportMaxLinkDepth > 0
                        $importDepth = '';
-                       if ( $wgExportMaxLinkDepth > 0 ) {
+                       if ( $this->getConfig()->get( 'ExportMaxLinkDepth' ) > 0 ) {
                                $importDepth = "<tr>
                                                        <td class='mw-label'>" .
                                        $this->msg( 'export-pagelinks' )->parse() .
@@ -306,7 +308,7 @@ class SpecialImport extends SpecialPage {
                                        )
                        );
 
-                       foreach ( $wgImportSources as $prefix ) {
+                       foreach ( $importSources as $prefix ) {
                                $selected = ( $this->interwiki === $prefix ) ? ' selected="selected"' : '';
                                $out->addHTML( Xml::option( $prefix, $prefix, $selected ) );
                        }
@@ -434,7 +436,9 @@ class ImportReporter extends ContextSource {
        }
 
        function reportNotice( $msg, array $params ) {
-               $this->getOutput()->addHTML( Html::element( 'li', array(), $this->msg( $msg, $params )->text() ) );
+               $this->getOutput()->addHTML(
+                       Html::element( 'li', array(), $this->msg( $msg, $params )->text() )
+               );
        }
 
        function reportLogItem( /* ... */ ) {
@@ -475,7 +479,8 @@ class ImportReporter extends ContextSource {
                                $detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
                                        $successCount )->inContentLanguage()->text();
                                if ( $this->reason ) {
-                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+                                               . $this->reason;
                                }
                                $log->addEntry( 'upload', $title, $detail, array(), $this->getUser() );
                        } else {
@@ -484,7 +489,8 @@ class ImportReporter extends ContextSource {
                                $detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
                                        $successCount )->params( $interwiki )->inContentLanguage()->text();
                                if ( $this->reason ) {
-                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->reason;
+                                       $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
+                                               . $this->reason;
                                }
                                $log->addEntry( 'interwiki', $title, $detail, array(), $this->getUser() );
                        }
@@ -492,13 +498,23 @@ class ImportReporter extends ContextSource {
                        $comment = $detail; // quick
                        $dbw = wfGetDB( DB_MASTER );
                        $latest = $title->getLatestRevID();
-                       $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleID(), $comment, true, $this->getUser() );
+                       $nullRevision = Revision::newNullRevision(
+                               $dbw,
+                               $title->getArticleID(),
+                               $comment,
+                               true,
+                               $this->getUser()
+                       );
+
                        if ( !is_null( $nullRevision ) ) {
                                $nullRevision->insertOn( $dbw );
                                $page = WikiPage::factory( $title );
                                # Update page record
                                $page->updateRevisionOn( $dbw, $nullRevision );
-                               wfRunHooks( 'NewRevisionFromEditComplete', array( $page, $nullRevision, $latest, $this->getUser() ) );
+                               wfRunHooks(
+                                       'NewRevisionFromEditComplete',
+                                       array( $page, $nullRevision, $latest, $this->getUser() )
+                               );
                        }
                } else {
                        $this->getOutput()->addHTML( "<li>" . Linker::linkKnown( $title ) . " " .