Revision: 43816
Author:   catrope
Date:     2008-11-21 13:55:27 +0000 (Fri, 21 Nov 2008)

Log Message:
-----------
API: (bug 16408) Added DOM tree generation (rvgeneratexml) to prop=revisions. 
Looks kind of ugly in XML, but bots don't care about that, and people should 
use less crappy-looking formats anyway.

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/api/ApiQueryRevisions.php

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2008-11-21 13:40:08 UTC (rev 43815)
+++ trunk/phase3/RELEASE-NOTES  2008-11-21 13:55:27 UTC (rev 43816)
@@ -450,6 +450,7 @@
 * (bug 12760) meta=userinfo&uiprop=ratelimits doesn't list group-specific rate
   limits
 * (bug 16398) meta=userinfo&uiprop=rights lists some rights twice in some cases
+* (bug 16408) Added rvgeneratexml to prop=revisions
 
 === Languages updated in 1.14 ===
 

Modified: trunk/phase3/includes/api/ApiQueryRevisions.php
===================================================================
--- trunk/phase3/includes/api/ApiQueryRevisions.php     2008-11-21 13:40:08 UTC 
(rev 43815)
+++ trunk/phase3/includes/api/ApiQueryRevisions.php     2008-11-21 13:55:27 UTC 
(rev 43816)
@@ -74,7 +74,7 @@
        }
 
        public function execute() {
-               $limit = $startid = $endid = $start = $end = $dir = $prop = 
$user = $excludeuser = $expandtemplates = $section = $token = null;
+               $limit = $startid = $endid = $start = $end = $dir = $prop = 
$user = $excludeuser = $expandtemplates = $generatexml = $section = $token = 
null;
                extract($this->extractRequestParams(false));
 
                // If any of those parameters are used, work in 'enumeration' 
mode.
@@ -115,7 +115,7 @@
                $this->fld_user = isset ($prop['user']);
                $this->token = $token;
 
-               if ( !is_null($this->token) || ( $this->fld_content && 
$this->expandTemplates ) || $pageCount > 0) {
+               if ( !is_null($this->token) || $pageCount > 0) {
                        $this->addFields( Revision::selectPageFields() );
                }
 
@@ -137,6 +137,7 @@
                        $this->fld_content = true;
 
                        $this->expandTemplates = $expandtemplates;
+                       $this->generateXML = $generatexml;
                        if(isset($section))
                                $this->section = $section;
                        else
@@ -319,6 +320,17 @@
                                if($text === false)
                                        $this->dieUsage("There is no section 
{$this->section} in r".$revision->getId(), 'nosuchsection');
                        }
+                       if ($this->generateXML) {
+                               $wgParser->startExternalParse( $title, new 
ParserOptions(), OT_PREPROCESS );
+                               $dom = $wgParser->preprocessToDom( $text );
+                               if ( is_callable( array( $dom, 'saveXML' ) ) ) {
+                                       $xml = $dom->saveXML();
+                               } else {
+                                       $xml = $dom->__toString();
+                               }
+                               $vals['parsetree'] = $xml;
+                               
+                       }
                        if ($this->expandTemplates) {
                                $text = $wgParser->preprocess( $text, $title, 
new ParserOptions() );
                        }
@@ -373,8 +385,8 @@
                        'excludeuser' => array(
                                ApiBase :: PARAM_TYPE => 'user'
                        ),
-
                        'expandtemplates' => false,
+                       'generatexml' => false,
                        'section' => array(
                                ApiBase :: PARAM_TYPE => 'integer'
                        ),
@@ -397,6 +409,7 @@
                        'user' => 'only include revisions made by user',
                        'excludeuser' => 'exclude revisions made by user',
                        'expandtemplates' => 'expand templates in revision 
content',
+                       'generatexml' => 'generate XML parse tree for revision 
content',
                        'section' => 'only retrieve the content of this 
section',
                        'token' => 'Which tokens to obtain for each revision',
                );



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to