Merge "Fix separated login link so that create account and login are always next...
[lhc/web/wiklou.git] / includes / api / ApiParse.php
index dbcd43c..c63ae8a 100644 (file)
@@ -2,7 +2,7 @@
 /**
  * Created on Dec 01, 2007
  *
- * Copyright © 2007 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -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',
@@ -401,7 +413,7 @@ class ApiParse extends ApiBase {
                        return '';
                }
 
-               $s = htmlspecialchars( wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ) );
+               $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() );
 
                $langs = array();
                foreach ( $languages as $l ) {
@@ -413,7 +425,7 @@ class ApiParse extends ApiBase {
                                $text == '' ? $l : $text );
                }
 
-               $s .= implode( htmlspecialchars( wfMsgExt( 'pipe-separator', 'escapenoentities' ) ), $langs );
+               $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
 
                if ( $wgContLang->isRTL() ) {
                        $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s );
@@ -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',
                );
        }