* (bug 2674) Include some site configuration info in export data:
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Jul 2005 00:18:01 +0000 (00:18 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Jul 2005 00:18:01 +0000 (00:18 +0000)
  namespaces definitions, case-sensitivity, site name, version.
* Use xml:space="preserve" hint on export <text> elements

RELEASE-NOTES
includes/SpecialExport.php

index 8b27ea1..a37314a 100644 (file)
@@ -470,6 +470,9 @@ of MediaWiki:Newpagetext) to &action=edit, if page is new.
 * (bug 2640) Include width and height attributes on unscaled images
 * Workaround for mysterious problem with bogus epoch If-Last-Modified reqs
 * (bug 1109) Suppress compressed output on 304 responses
+* (bug 2674) Include some site configuration info in export data:
+  namespaces definitions, case-sensitivity, site name, version.
+* Use xml:space="preserve" hint on export <text> elements
 
 
 === Caveats ===
index 1d517ca..b04edb0 100644 (file)
@@ -125,6 +125,14 @@ class WikiExporter {
                $this->revCallback = $callback;
        }
        
+       /**
+        * Returns the export schema version.
+        * @return string
+        */
+       function schemaVersion() {
+               return "0.3";
+       }
+       
        /**
         * Opens the XML output stream's root <mediawiki> element.
         * This does not include an xml directive, so is safe to include
@@ -136,14 +144,64 @@ class WikiExporter {
         */
        function openStream() {
                global $wgContLanguageCode;
+               $ver = $this->schemaVersion();
                print wfElement( 'mediawiki', array(
-                       'xmlns'              => 'http://www.mediawiki.org/xml/export-0.1/',
-                       'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
-                       'xsi:schemaLocation' => 'http://www.mediawiki.org/xml/export-0.1/ ' .
-                                               'http://www.mediawiki.org/xml/export-0.1.xsd',
-                       'version'            => '0.1',
+                       'xmlns'              => "http://www.mediawiki.org/xml/export-$ver/",
+                       'xmlns:xsi'          => "http://www.w3.org/2001/XMLSchema-instance",
+                       'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
+                                               "http://www.mediawiki.org/xml/export-$ver.xsd",
+                       'version'            => $ver,
                        'xml:lang'           => $wgContLanguageCode ),
                        null ) . "\n";
+               $this->siteInfo();
+       }
+       
+       function siteInfo() {
+               $info = array(
+                       $this->sitename(),
+                       $this->homelink(),
+                       $this->generator(),
+                       $this->caseSetting(),
+                       $this->namespaces() );
+               print "<siteinfo>\n";
+               foreach( $info as $item ) {
+                       print "  $item\n";
+               }
+               print "</siteinfo>\n";
+       }
+       
+       function sitename() {
+               global $wgSitename;
+               return wfElement( 'sitename', array(), $wgSitename );
+       }
+       
+       function generator() {
+               global $wgVersion;
+               return wfElement( 'generator', array(), "MediaWiki $wgVersion" );
+       }
+       
+       function homelink() {
+               $page = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+               return wfElement( 'base', array(), $page->getFullUrl() );
+       }
+       
+       function caseSetting() {
+               global $wgCapitalLinks;
+               // "case-insensitive" option is reserved for future
+               $sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
+               return wfElement( 'case', array(), $sensitivity );
+       }
+       
+       function namespaces() {
+               global $wgContLang;
+               $spaces = "<namespaces>\n";
+               foreach( $wgContLang->getNamespaces() as $ns => $title ) {
+                       $spaces .= '    ' . wfElement( 'namespace',
+                               array( 'key' => $ns ),
+                               str_replace( '_', ' ', $title ) ) . "\n";
+               }
+               $spaces .= "  </namespaces>";
+               return $spaces;
        }
        
        /**
@@ -331,7 +389,9 @@ class WikiExporter {
                }
        
                $text = Revision::getRevisionText( $row );
-               print "      " . wfElementClean( 'text', array(), $text ) . "\n";
+               print "      " . wfElementClean( 'text',
+                       array( 'xml:space' => 'preserve' ), $text ) . "\n";
+               
                print "    </revision>\n";
                
                wfProfileOut( $fname );