* (bug 38231) Add xml parse tree to action=parse.
authorReedy <reedy@wikimedia.org>
Sat, 7 Jul 2012 15:07:29 +0000 (16:07 +0100)
committerCatrope <roan.kattouw@gmail.com>
Thu, 2 Aug 2012 19:49:42 +0000 (12:49 -0700)
Change-Id: I4db3950c937e6299c6f3adc9b90137ac642c607c

RELEASE-NOTES-1.20
includes/api/ApiParse.php

index df7568d..50f2673 100644 (file)
@@ -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 ===
 
index 875684e..f64b3e5 100644 (file)
@@ -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',
                );
        }