merged master
[lhc/web/wiklou.git] / includes / api / ApiQueryRevisions.php
index 475d212..0bb0d77 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Sep 7, 2006
  *
- * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 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
@@ -161,13 +161,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                $this->token = $params['token'];
 
                if ( !empty( $params['contentformat'] ) ) {
-                       $n = ContentHandler::getContentFormatID( $params['contentformat'] );
-
-                       if ( is_int( $n ) ) {
-                               $this->contentFormat = $n;
-                       } else {
-                               $this->dieUsage( "Unknown format " . $params['contentformat'], 'badformat' );
-                       }
+                       $this->contentFormat = $params['contentformat'];
                }
 
                // Possible indexes used
@@ -516,8 +510,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                                } else {
                                        $this->setWarning( "Conversion to XML is supported for wikitext only, " .
                                                                                $title->getPrefixedDBkey() .
-                                                                               " uses content model #" . $content->getModel() .
-                                                                               " (" . ContentHandler::getContentModelName( $content->getModel() ). ")" );
+                                                                               " uses content model " . $content->getModel() . ")" );
                                }
                        }
 
@@ -530,8 +523,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                                } else {
                                        $this->setWarning( "Template expansion is supported for wikitext only, " .
                                                $title->getPrefixedDBkey() .
-                                               " uses content model #" . $content->getModel() .
-                                               " (" . ContentHandler::getContentModelName( $content->getModel() ). ")" );
+                                               " uses content model " . $content->getModel() . ")" );
 
                                        $text = false;
                                }
@@ -546,15 +538,13 @@ class ApiQueryRevisions extends ApiQueryBase {
 
                                if ( !$content->isSupportedFormat( $format ) ) {
                                        $model = $content->getModel();
-                                       $formatName = ContentHandler::getContentFormatMimeType( $format );
-                                       $modelName = ContentHandler::getContentModelName( $model );
                                        $name = $title->getPrefixedDBkey();
 
-                                       $this->dieUsage( "The requested format #{$this->contentFormat} ($formatName) is not supported for content model #$model ($modelName) used by $name", 'badformat' );
+                                       $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
                                }
 
                                $text = $content->serialize( $format );
-                               $vals['textformat'] = ContentHandler::getContentFormatMimeType( $format );
+                               $vals['contentformat'] = $format;
                        }
 
                        if ( $text !== false ) {
@@ -577,11 +567,9 @@ class ApiQueryRevisions extends ApiQueryBase {
                                        $model = $title->getContentModel();
 
                                        if ( $this->contentFormat && !ContentHandler::getForModelID( $model )->isSupportedFormat( $this->contentFormat ) ) {
-                                               $formatName = ContentHandler::getContentFormatMimeType( $this->contentFormat );
-                                               $modelName = ContentHandler::getContentModelName( $model );
                                                $name = $title->getPrefixedDBkey();
 
-                                               $this->dieUsage( "The requested format #{$this->contentFormat} ($formatName) is not supported for content model #$model ($modelName) used by $name", 'badformat' );
+                                               $this->dieUsage( "The requested format {$this->contentFormat} is not supported for content model $model used by $name", 'badformat' );
                                        }
 
                                        $difftocontent = ContentHandler::makeContent( $this->difftotext, $title, $model, $this->contentFormat );
@@ -680,7 +668,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                        'diffto' => null,
                        'difftotext' => null,
                        'contentformat' => array(
-                               ApiBase::PARAM_TYPE => array_values( $GLOBALS[ 'wgContentFormatMimeTypes' ] ),
+                               ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
                                ApiBase::PARAM_DFLT => null
                        ),
                );
@@ -727,6 +715,66 @@ class ApiQueryRevisions extends ApiQueryBase {
                );
        }
 
+       public function getResultProperties() {
+               $props = array(
+                       '' => array(),
+                       'ids' => array(
+                               'revid' => 'integer',
+                               'parentid' => array(
+                                       ApiBase::PROP_TYPE => 'integer',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'flags' => array(
+                               'minor' => 'boolean'
+                       ),
+                       'user' => array(
+                               'userhidden' => 'boolean',
+                               'user' => 'string',
+                               'anon' => 'boolean'
+                       ),
+                       'userid' => array(
+                               'userhidden' => 'boolean',
+                               'userid' => 'integer',
+                               'anon' => 'boolean'
+                       ),
+                       'timestamp' => array(
+                               'timestamp' => 'timestamp'
+                       ),
+                       'size' => array(
+                               'size' => 'integer'
+                       ),
+                       'sha1' => array(
+                               'sha1' => 'string'
+                       ),
+                       'comment' => array(
+                               'commenthidden' => 'boolean',
+                               'comment' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'parsedcomment' => array(
+                               'commenthidden' => 'boolean',
+                               'parsedcomment' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               )
+                       ),
+                       'content' => array(
+                               '*' => array(
+                                       ApiBase::PROP_TYPE => 'string',
+                                       ApiBase::PROP_NULLABLE => true
+                               ),
+                               'texthidden' => 'boolean'
+                       )
+               );
+
+               self::addTokenProperties( $props, $this->getTokenFunctions() );
+
+               return $props;
+       }
+
        public function getDescription() {
                return array(
                        'Get revision information',