From: Magnus Manske Date: Tue, 21 Dec 2004 10:54:28 +0000 (+0000) Subject: Special:Export will now return *real* XML when using XML parser X-Git-Tag: 1.5.0alpha1~1067 X-Git-Url: http://git.cyclocoop.org/url?a=commitdiff_plain;h=4aacdc1d06e0caa5348ab964389287a0bb6ad57b;p=lhc%2Fweb%2Fwiklou.git Special:Export will now return *real* XML when using XML parser --- diff --git a/includes/ParserXML.php b/includes/ParserXML.php index c84fdeec06..2c5661a847 100644 --- a/includes/ParserXML.php +++ b/includes/ParserXML.php @@ -434,24 +434,30 @@ class ParserXML EXTENDS Parser $this->mInPre = false; } - function parse( $text, &$title, $options, $linestart = true, $clearState = true ) { - global $wgWiki2xml ; - $tmpfname = tempnam("/tmp", "FOO"); + /** + * Turns the wikitext into XML by calling the external parser + * + */ + function runXMLparser ( &$text ) { + global $wgWiki2xml ; + $tmpfname = tempnam("/tmp", "FOO"); $handle = fopen($tmpfname, "w"); fwrite($handle, $text); fclose($handle); + exec ( $wgWiki2xml . " < " . $tmpfname , $a ) ; + $text = implode ( "\n" , $a ) ; + unlink($tmpfname); + } - exec ( $wgWiki2xml . " < " . $tmpfname , $a ) ; - $text = implode ( "\n" , $a ) ; - - unlink($tmpfname); - + function parse( $text, &$title, $options, $linestart = true, $clearState = true ) { + $this->runXMLparser ( $text ) ; $nowikicount = 0 ; $w = new xml2php; $result = $w->scanString( $text ); - $text = $result->makeXHTML ( $this ) . "
" . $text ; - $text .= "
" . $result->myPrint(); + + if ( 1 ) $text = $result->makeXHTML ( $this ) ; # No debugging info + else $text = $result->makeXHTML ( $this ) . "
" . $text . "
" . $result->myPrint(); $this->mOutput->setText ( $text ) ; return $this->mOutput; diff --git a/includes/SpecialExport.php b/includes/SpecialExport.php index c8f3052aac..f23493fd7d 100644 --- a/includes/SpecialExport.php +++ b/includes/SpecialExport.php @@ -140,6 +140,8 @@ function revision2xml( $rev, $full ) { $fname = 'revision2xml'; wfProfileIn( $fname ); + global $wgParser , $wgUseXMLparser ; # So we can return *real* XML + $xml = " \n"; if( $full ) $xml .= " " . $rev->getId() . "\n"; @@ -163,7 +165,14 @@ function revision2xml( $rev, $full ) { $c = xmlsafe( $rev->getComment() ); $xml .= " $c\n"; } - $t = xmlsafe( $rev->getText() ); + + $t = $rev->getText() ; + if ( $wgUseXMLparser ) + { + $wgParser->runXMLparser ( $t ) ; + } + $t = xmlsafe( $t ) ; + $xml .= " $t\n"; $xml .= " \n"; wfProfileOut( $fname );