r9914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9913‎ | r9914 | r9915 >
Date:00:18, 5 July 2005
Author:vibber
Status:old
Tags:
Comment:
* (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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialExport.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialExport.php
@@ -126,6 +126,14 @@
127127 }
128128
129129 /**
 130+ * Returns the export schema version.
 131+ * @return string
 132+ */
 133+ function schemaVersion() {
 134+ return "0.3";
 135+ }
 136+
 137+ /**
130138 * Opens the XML output stream's root <mediawiki> element.
131139 * This does not include an xml directive, so is safe to include
132140 * as a subelement in a larger XML stream. Namespace and XML Schema
@@ -136,16 +144,66 @@
137145 */
138146 function openStream() {
139147 global $wgContLanguageCode;
 148+ $ver = $this->schemaVersion();
140149 print wfElement( 'mediawiki', array(
141 - 'xmlns' => 'http://www.mediawiki.org/xml/export-0.1/',
142 - 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
143 - 'xsi:schemaLocation' => 'http://www.mediawiki.org/xml/export-0.1/ ' .
144 - 'http://www.mediawiki.org/xml/export-0.1.xsd',
145 - 'version' => '0.1',
 150+ 'xmlns' => "http://www.mediawiki.org/xml/export-$ver/",
 151+ 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
 152+ 'xsi:schemaLocation' => "http://www.mediawiki.org/xml/export-$ver/ " .
 153+ "http://www.mediawiki.org/xml/export-$ver.xsd",
 154+ 'version' => $ver,
146155 'xml:lang' => $wgContLanguageCode ),
147156 null ) . "\n";
 157+ $this->siteInfo();
148158 }
149159
 160+ function siteInfo() {
 161+ $info = array(
 162+ $this->sitename(),
 163+ $this->homelink(),
 164+ $this->generator(),
 165+ $this->caseSetting(),
 166+ $this->namespaces() );
 167+ print "<siteinfo>\n";
 168+ foreach( $info as $item ) {
 169+ print " $item\n";
 170+ }
 171+ print "</siteinfo>\n";
 172+ }
 173+
 174+ function sitename() {
 175+ global $wgSitename;
 176+ return wfElement( 'sitename', array(), $wgSitename );
 177+ }
 178+
 179+ function generator() {
 180+ global $wgVersion;
 181+ return wfElement( 'generator', array(), "MediaWiki $wgVersion" );
 182+ }
 183+
 184+ function homelink() {
 185+ $page = Title::newFromText( wfMsgForContent( 'mainpage' ) );
 186+ return wfElement( 'base', array(), $page->getFullUrl() );
 187+ }
 188+
 189+ function caseSetting() {
 190+ global $wgCapitalLinks;
 191+ // "case-insensitive" option is reserved for future
 192+ $sensitivity = $wgCapitalLinks ? 'first-letter' : 'case-sensitive';
 193+ return wfElement( 'case', array(), $sensitivity );
 194+ }
 195+
 196+ function namespaces() {
 197+ global $wgContLang;
 198+ $spaces = "<namespaces>\n";
 199+ foreach( $wgContLang->getNamespaces() as $ns => $title ) {
 200+ $spaces .= ' ' . wfElement( 'namespace',
 201+ array( 'key' => $ns ),
 202+ str_replace( '_', ' ', $title ) ) . "\n";
 203+ }
 204+ $spaces .= " </namespaces>";
 205+ return $spaces;
 206+ }
 207+
150208 /**
151209 * Closes the output stream with the closing root element.
152210 * Call when finished dumping things.
@@ -331,7 +389,9 @@
332390 }
333391
334392 $text = Revision::getRevisionText( $row );
335 - print " " . wfElementClean( 'text', array(), $text ) . "\n";
 393+ print " " . wfElementClean( 'text',
 394+ array( 'xml:space' => 'preserve' ), $text ) . "\n";
 395+
336396 print " </revision>\n";
337397
338398 wfProfileOut( $fname );
Index: trunk/phase3/RELEASE-NOTES
@@ -470,6 +470,9 @@
471471 * (bug 2640) Include width and height attributes on unscaled images
472472 * Workaround for mysterious problem with bogus epoch If-Last-Modified reqs
473473 * (bug 1109) Suppress compressed output on 304 responses
 474+* (bug 2674) Include some site configuration info in export data:
 475+ namespaces definitions, case-sensitivity, site name, version.
 476+* Use xml:space="preserve" hint on export <text> elements
474477
475478
476479 === Caveats ===

Status & tagging log