Index: trunk/phase3/includes/SpecialExport.php |
— | — | @@ -126,6 +126,14 @@ |
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
| 130 | + * Returns the export schema version. |
| 131 | + * @return string |
| 132 | + */ |
| 133 | + function schemaVersion() { |
| 134 | + return "0.3"; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
130 | 138 | * Opens the XML output stream's root <mediawiki> element. |
131 | 139 | * This does not include an xml directive, so is safe to include |
132 | 140 | * as a subelement in a larger XML stream. Namespace and XML Schema |
— | — | @@ -136,16 +144,66 @@ |
137 | 145 | */ |
138 | 146 | function openStream() { |
139 | 147 | global $wgContLanguageCode; |
| 148 | + $ver = $this->schemaVersion(); |
140 | 149 | 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, |
146 | 155 | 'xml:lang' => $wgContLanguageCode ), |
147 | 156 | null ) . "\n"; |
| 157 | + $this->siteInfo(); |
148 | 158 | } |
149 | 159 | |
| 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 | + |
150 | 208 | /** |
151 | 209 | * Closes the output stream with the closing root element. |
152 | 210 | * Call when finished dumping things. |
— | — | @@ -331,7 +389,9 @@ |
332 | 390 | } |
333 | 391 | |
334 | 392 | $text = Revision::getRevisionText( $row ); |
335 | | - print " " . wfElementClean( 'text', array(), $text ) . "\n"; |
| 393 | + print " " . wfElementClean( 'text', |
| 394 | + array( 'xml:space' => 'preserve' ), $text ) . "\n"; |
| 395 | + |
336 | 396 | print " </revision>\n"; |
337 | 397 | |
338 | 398 | wfProfileOut( $fname ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -470,6 +470,9 @@ |
471 | 471 | * (bug 2640) Include width and height attributes on unscaled images |
472 | 472 | * Workaround for mysterious problem with bogus epoch If-Last-Modified reqs |
473 | 473 | * (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 |
474 | 477 | |
475 | 478 | |
476 | 479 | === Caveats === |