From 8d0909f3952544420e3bc6aaed6af553ae339426 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 11 Jan 2005 15:58:45 +0000 Subject: [PATCH] updated XML parser --- includes/ParserXML.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/ParserXML.php b/includes/ParserXML.php index 99e5fa8b2f..2ca2117f4d 100644 --- a/includes/ParserXML.php +++ b/includes/ParserXML.php @@ -525,15 +525,37 @@ class ParserXML EXTENDS Parser * Turns the wikitext into XML by calling the external parser * */ + function html2xml ( &$text ) { + global $wgWiki2xml ; + + # generating html2xml command path + $a = $wgWiki2xml ; + $a = explode ( "/" , $a ) ; + array_pop ( $a ) ; + $a[] = "html2xml" ; + $html2xml = implode ( "/" , $a ) ; + $a = array () ; + + $tmpfname = tempnam("/tmp", "FOO"); + $handle = fopen($tmpfname, "w"); + fwrite($handle, utf8_encode ( $text ) ); + fclose($handle); + exec ( $html2xml . " < " . $tmpfname , $a ) ; + $text = utf8_decode ( implode ( "\n" , $a ) ) ; + unlink($tmpfname); + } + function runXMLparser ( &$text ) { global $wgWiki2xml ; + $this->html2xml ( $text ) ; + $tmpfname = tempnam("/tmp", "FOO"); $handle = fopen($tmpfname, "w"); - fwrite($handle, $text); + fwrite($handle, $text ) ; fclose($handle); exec ( $wgWiki2xml . " < " . $tmpfname , $a ) ; - $text = implode ( "\n" , $a ) ; + $text = utf8_decode ( implode ( "\n" , $a ) ) ; unlink($tmpfname); } -- 2.20.1