From a9d154b92a5df7db97ed57def3467b8af7f258d1 Mon Sep 17 00:00:00 2001 From: Reedy Date: Sat, 7 Jul 2012 16:07:29 +0100 Subject: [PATCH] * (bug 38231) Add xml parse tree to action=parse. Change-Id: I4db3950c937e6299c6f3adc9b90137ac642c607c --- RELEASE-NOTES-1.20 | 1 + includes/api/ApiParse.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index df7568d7b3..50f2673010 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -218,6 +218,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * (bug 38190) Add "required" flag to some token params for hint in api docs. * (bug 27567) Add file repo support to prop=duplicatefiles. * (bug 27610) Add archivename for non-latest image version to list=filearchive +* (bug 38231) Add xml parse tree to action=parse. === Languages updated in 1.20 === diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 875684e1dd..f64b3e5b61 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -289,6 +289,18 @@ class ApiParse extends ApiBase { $result_array['properties'] = $this->formatProperties( $p_result->getProperties() ); } + if ( $params['generatexml'] ) { + $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS ); + $dom = $wgParser->preprocessToDom( $this->text ); + if ( is_callable( array( $dom, 'saveXML' ) ) ) { + $xml = $dom->saveXML(); + } else { + $xml = $dom->__toString(); + } + $result_array['parsetree'] = array(); + $result->setContent( $result_array['parsetree'], $xml ); + } + $result_mapping = array( 'redirects' => 'r', 'langlinks' => 'll', @@ -541,6 +553,7 @@ class ApiParse extends ApiBase { 'uselang' => null, 'section' => null, 'disablepp' => false, + 'generatexml' => false, ); } @@ -585,6 +598,7 @@ class ApiParse extends ApiBase { 'uselang' => 'Which language to parse the request in', 'section' => 'Only retrieve the content of this section number', 'disablepp' => 'Disable the PP Report from the parser output', + 'generatexml' => 'Generate XML parse tree', ); } -- 2.20.1