Spaces to tabs
[lhc/web/wiklou.git] / includes / Export.php
index 23b7849..06e4565 100644 (file)
@@ -1,21 +1,27 @@
 <?php
-# Copyright (C) 2003, 2005, 2006 Brion Vibber <brion@pobox.com>
-# http://www.mediawiki.org/
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-# http://www.gnu.org/copyleft/gpl.html
+/**
+ * Base classes for dumps and export
+ *
+ * Copyright © 2003, 2005, 2006 Brion Vibber <brion@pobox.com>
+ * http://www.mediawiki.org/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ */
 
 /**
  * @defgroup Dump Dump
@@ -124,7 +130,7 @@ class WikiExporter {
        public function pageByName( $name ) {
                $title = Title::newFromText( $name );
                if( is_null( $title ) ) {
-                       return new WikiError( "Can't export invalid title" );
+                       throw new MWException( "Can't export invalid title" );
                } else {
                        return $this->pageByTitle( $title );
                }
@@ -161,7 +167,7 @@ class WikiExporter {
                WHERE page_id=rev_page AND $nothidden AND " . $cond ;
                $result = $this->db->query( $sql, __METHOD__ );
                $resultset = $this->db->resultObject( $result );
-               while( $row = $resultset->fetchObject() ) {
+               foreach ( $resultset as $row ) {
                        $this->author_list .= "<contributor>" .
                                "<username>" .
                                htmlentities( $row->rev_user_text )  .
@@ -245,12 +251,12 @@ class WikiExporter {
                                # One, and only one hook should set this, and return false
                                if( wfRunHooks( 'WikiExporter::dumpStableQuery', array(&$tables,&$opts,&$join) ) ) {
                                        wfProfileOut( __METHOD__ );
-                                       return new WikiError( __METHOD__." given invalid history dump type." );
+                                       throw new MWException( __METHOD__." given invalid history dump type." );
                                }
                        } else {
                                # Uknown history specification parameter?
                                wfProfileOut( __METHOD__ );
-                               return new WikiError( __METHOD__." given invalid history dump type." );
+                               throw new MWException( __METHOD__." given invalid history dump type." );
                        }
                        # Query optimization hacks
                        if( $cond == '' ) {
@@ -348,7 +354,7 @@ class XmlDumpWriter {
         * @return string
         */
        function schemaVersion() {
-               return "0.4";
+               return "0.5";
        }
 
        /**
@@ -505,12 +511,12 @@ class XmlDumpWriter {
                        // Raw text from the database may have invalid chars
                        $text = strval( Revision::getRevisionText( $row ) );
                        $out .= "      " . Xml::elementClean( 'text',
-                               array( 'xml:space' => 'preserve' ),
+                               array( 'xml:space' => 'preserve', 'bytes' => $row->rev_len ),
                                strval( $text ) ) . "\n";
                } else {
                        // Stub output
                        $out .= "      " . Xml::element( 'text',
-                               array( 'id' => $row->rev_text_id ),
+                               array( 'id' => $row->rev_text_id, 'bytes' => $row->rev_len ),
                                "" ) . "\n";
                }