$pages = explode( "\n", $page );
$xml = pages2xml( $pages, $curonly );
echo $xml;
- # exit(1) actually prints 1 in some PHP versions
- exit("");
+ wfAbruptExit();
}
$wgOut->addWikiText( wfMsg( "exporttext" ) );
function pages2xml( $pages, $curonly = false ) {
global $wgLanguageCode, $wgInputEncoding, $wgLang;
- $xml = "<mediawiki version=\"0.1\" xml:ns=\"$wgLanguageCode\">\n";
+ $xml = "<" . "?xml version=\"1.0\" encoding=\"UTF-8\" ?" . ">\n" .
+ "<mediawiki version=\"0.1\" xml:lang=\"$wgLanguageCode\">\n";
foreach( $pages as $page ) {
$xml .= page2xml( $page, $curonly );
}
function page2xml( $page, $curonly, $full = false ) {
global $wgInputCharset, $wgLang;
$title = Title::NewFromText( $page );
+ if( !$title ) return "";
$t = wfStrencode( $title->getDBKey() );
$ns = $title->getNamespace();
$sql = "SELECT cur_id as id,cur_timestamp as timestamp,cur_user as user,cur_user_text as user_text," .
}
if( !$curonly ) {
$sql = "SELECT old_id as id,old_timestamp as timestamp, old_user as user, old_user_text as user_text," .
- "old_comment as comment, old_text as text FROM old " .
+ "old_comment as comment, old_text as text, old_flags as flags FROM old " .
"WHERE old_namespace=$ns AND old_title='$t' ORDER BY old_timestamp";
$res = wfQuery( $sql, DB_READ );
- while( $s = wfFetchObject( $res ) ) {
- $xml .= revision2xml( $s, $full, false );
+ while( $s2 = wfFetchObject( $res ) ) {
+ $xml .= revision2xml( $s2, $full, false );
}
}
$xml .= revision2xml( $s, $full, true );
$c = htmlspecialchars( $s->comment );
$xml .= " <comment>$c</comment>\n";
}
- $t = htmlspecialchars( $s->text );
+ $t = htmlspecialchars( Article::getRevisionText( $s, "" ) );
$xml .= " <text>$t</text>\n";
$xml .= " </revision>\n";
return $xml;