From 639cecc8e0c5790032221a96f7b866f489d3e0a4 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 5 Jul 2005 00:18:01 +0000 Subject: [PATCH] * (bug 2674) Include some site configuration info in export data: namespaces definitions, case-sensitivity, site name, version. * Use xml:space="preserve" hint on export elements --- RELEASE-NOTES | 3 ++ includes/SpecialExport.php | 72 ++++++++++++++++++++++++++++++++++---- 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8b27ea16c8..a37314ac95 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 elements === Caveats === diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index 1d517ca762..b04edb0123 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -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 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 "\n"; + foreach( $info as $item ) { + print " $item\n"; + } + print "\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 = "\n"; + foreach( $wgContLang->getNamespaces() as $ns => $title ) { + $spaces .= ' ' . wfElement( 'namespace', + array( 'key' => $ns ), + str_replace( '_', ' ', $title ) ) . "\n"; + } + $spaces .= " "; + 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 " \n"; wfProfileOut( $fname ); -- 2.20.1