Documentation addition/tweaks
[lhc/web/wiklou.git] / includes / Import.php
index 605fd81..533d538 100644 (file)
@@ -1,7 +1,8 @@
 <?php
 /**
  * MediaWiki page data importer
- * Copyright (C) 2003,2005 Brion Vibber <brion@pobox.com>
+ *
+ * Copyright © 2003,2005 Brion Vibber <brion@pobox.com>
  * http://www.mediawiki.org/
  *
  * This program is free software; you can redistribute it and/or modify
@@ -24,7 +25,7 @@
  */
 
 /**
- *
+ * @todo document (e.g. one-sentence class description).
  * @ingroup SpecialPage
  */
 class WikiRevision {
@@ -310,7 +311,6 @@ class WikiRevision {
 
                $file = wfLocalFile( $this->getTitle() );
                if( !$file ) {
-                       var_dump( $file );
                        wfDebug( "IMPORT: Bad file. :(\n" );
                        return false;
                }
@@ -414,27 +414,27 @@ class ImportStreamSource {
        static function newFromFile( $filename ) {
                $file = @fopen( $filename, 'rt' );
                if( !$file ) {
-                       return new WikiErrorMsg( "importcantopen" );
+                       return Status::newFatal( "importcantopen" );
                }
-               return new ImportStreamSource( $file );
+               return Status::newGood( new ImportStreamSource( $file ) );
        }
 
        static function newFromUpload( $fieldname = "xmlimport" ) {
                $upload =& $_FILES[$fieldname];
 
                if( !isset( $upload ) || !$upload['name'] ) {
-                       return new WikiErrorMsg( 'importnofile' );
+                       return Status::newFatal( 'importnofile' );
                }
                if( !empty( $upload['error'] ) ) {
                        switch($upload['error']){
                                case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
-                                       return new WikiErrorMsg( 'importuploaderrorsize' );
+                                       return Status::newFatal( 'importuploaderrorsize' );
                                case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
-                                       return new WikiErrorMsg( 'importuploaderrorsize' );
+                                       return Status::newFatal( 'importuploaderrorsize' );
                                case 3: # The uploaded file was only partially uploaded
-                                       return new WikiErrorMsg( 'importuploaderrorpartial' );
-                               case 6: #Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
-                                       return new WikiErrorMsg( 'importuploaderrortemp' );
+                                       return Status::newFatal( 'importuploaderrorpartial' );
+                               case 6: #Missing a temporary folder.
+                                       return Status::newFatal( 'importuploaderrortemp' );
                                # case else: # Currently impossible
                        }
 
@@ -443,7 +443,7 @@ class ImportStreamSource {
                if( is_uploaded_file( $fname ) ) {
                        return ImportStreamSource::newFromFile( $fname );
                } else {
-                       return new WikiErrorMsg( 'importnofile' );
+                       return Status::newFatal( 'importnofile' );
                }
        }
 
@@ -459,19 +459,19 @@ class ImportStreamSource {
                        fwrite( $file, $data );
                        fflush( $file );
                        fseek( $file, 0 );
-                       return new ImportStreamSource( $file );
+                       return Status::newGood( new ImportStreamSource( $file ) );
                } else {
-                       return new WikiErrorMsg( 'importcantopen' );
+                       return Status::newFatal( 'importcantopen' );
                }
        }
 
        public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
                if( $page == '' ) {
-                       return new WikiErrorMsg( 'import-noarticle' );
+                       return Status::newFatal( 'import-noarticle' );
                }
                $link = Title::newFromText( "$interwiki:Special:Export/$page" );
                if( is_null( $link ) || $link->getInterwiki() == '' ) {
-                       return new WikiErrorMsg( 'importbadinterwiki' );
+                       return Status::newFatal( 'importbadinterwiki' );
                } else {
                        $params = array();
                        if ( $history ) $params['history'] = 1;