Special:Export will now return *real* XML when using XML parser
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 21 Dec 2004 10:54:28 +0000 (10:54 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 21 Dec 2004 10:54:28 +0000 (10:54 +0000)
includes/ParserXML.php
includes/SpecialExport.php

index c84fdee..2c5661a 100644 (file)
@@ -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 ) . "<hr>" . $text ;
-               $text .= "<hr>" . $result->myPrint();
+
+               if ( 1 ) $text = $result->makeXHTML ( $this ) ; # No debugging info
+               else $text = $result->makeXHTML ( $this ) . "<hr>" . $text . "<hr>" . $result->myPrint();
                
                $this->mOutput->setText ( $text ) ;
                return $this->mOutput;
index c8f3052..f23493f 100644 (file)
@@ -140,6 +140,8 @@ function revision2xml( $rev, $full ) {
        $fname = 'revision2xml';
        wfProfileIn( $fname );
        
+       global $wgParser , $wgUseXMLparser ; # So we can return *real* XML
+
        $xml = "    <revision>\n";
        if( $full )
                $xml .= "    <id>" . $rev->getId() . "</id>\n";
@@ -163,7 +165,14 @@ function revision2xml( $rev, $full ) {
                $c = xmlsafe( $rev->getComment() );
                $xml .= "      <comment>$c</comment>\n";
        }
-       $t = xmlsafe( $rev->getText() );
+
+       $t = $rev->getText() ;
+       if ( $wgUseXMLparser )
+          {
+          $wgParser->runXMLparser ( $t ) ;
+          }
+       $t = xmlsafe( $t ) ;
+
        $xml .= "      <text>$t</text>\n";
        $xml .= "    </revision>\n";
        wfProfileOut( $fname );