Use protocol-relative URL for link to MediaWiki.org (as with the footer logo on each...
[lhc/web/wiklou.git] / includes / specials / SpecialImport.php
index 165e337..e8c5762 100644 (file)
@@ -60,10 +60,6 @@ class SpecialImport extends SpecialPage {
                        throw new PermissionsError( 'import' );
                }
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
-
                # @todo Allow Title::getUserPermissionsErrors() to take an array
                # @todo FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
                # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
@@ -78,11 +74,12 @@ class SpecialImport extends SpecialPage {
                        )
                );
 
-               if( $errors ){
-                       $this->getOutput()->showPermissionsErrorPage( $errors );
-                       return;
+               if ( $errors ) {
+                       throw new PermissionsError( 'import', $errors );
                }
 
+               $this->checkReadOnly();
+
                $request = $this->getRequest();
                if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) {
                        $this->doImport();
@@ -112,11 +109,11 @@ class SpecialImport extends SpecialPage {
                        if( $user->isAllowed( 'importupload' ) ) {
                                $source = ImportStreamSource::newFromUpload( "xmlimport" );
                        } else {
-                               return $this->getOutput()->permissionRequired( 'importupload' );
+                               throw new PermissionsError( 'importupload' );
                        }
                } elseif ( $sourceName == "interwiki" ) {
                        if( !$user->isAllowed( 'import' ) ){
-                               return $this->getOutput()->permissionRequired( 'import' );
+                               throw new PermissionsError( 'import' );
                        }
                        $this->interwiki = $request->getVal( 'interwiki' );
                        if ( !in_array( $this->interwiki, $wgImportSources ) ) {
@@ -213,7 +210,7 @@ class SpecialImport extends SpecialPage {
                                        "</td>
                                </tr>" .
                                Xml::closeElement( 'table' ).
-                               Html::hidden( 'editToken', $user->editToken() ) .
+                               Html::hidden( 'editToken', $user->getEditToken() ) .
                                Xml::closeElement( 'form' ) .
                                Xml::closeElement( 'fieldset' )
                        );
@@ -243,7 +240,7 @@ class SpecialImport extends SpecialPage {
                                wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) .
                                Html::hidden( 'action', 'submit' ) .
                                Html::hidden( 'source', 'interwiki' ) .
-                               Html::hidden( 'editToken', $user->editToken() ) .
+                               Html::hidden( 'editToken', $user->getEditToken() ) .
                                Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) .
                                "<tr>
                                        <td class='mw-label'>" .
@@ -357,7 +354,7 @@ class ImportReporter extends ContextSource {
 
                $this->mPageCount++;
 
-               $localCount = $this->getLang()->formatNum( $successCount );
+               $localCount = $this->getLanguage()->formatNum( $successCount );
                $contentCount = $wgContLang->formatNum( $successCount );
 
                if( $successCount > 0 ) {
@@ -391,10 +388,10 @@ class ImportReporter extends ContextSource {
                        $nullRevision = Revision::newNullRevision( $dbw, $title->getArticleId(), $comment, true );
                        if (!is_null($nullRevision)) {
                                $nullRevision->insertOn( $dbw );
-                               $article = new Article( $title );
+                               $page = WikiPage::factory( $title );
                                # Update page record
-                               $article->updateRevisionOn( $dbw, $nullRevision );
-                               wfRunHooks( 'NewRevisionFromEditComplete', array( $article, $nullRevision, $latest, $this->getUser() ) );
+                               $page->updateRevisionOn( $dbw, $nullRevision );
+                               wfRunHooks( 'NewRevisionFromEditComplete', array( $page, $nullRevision, $latest, $this->getUser() ) );
                        }
                } else {
                        $this->getOutput()->addHTML( "<li>" . Linker::linkKnown( $title ) . " " .
@@ -406,7 +403,7 @@ class ImportReporter extends ContextSource {
                $out = $this->getOutput();
                if ( $this->mLogItemCount > 0 ) {
                        $msg = wfMsgExt( 'imported-log-entries', 'parseinline',
-                                               $this->getLang()->formatNum( $this->mLogItemCount ) );
+                                               $this->getLanguage()->formatNum( $this->mLogItemCount ) );
                        $out->addHTML( Xml::tags( 'li', null, $msg ) );
                } elseif( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
                        $out->addHTML( "</ul>\n" );