<?php
/**
- * API for MediaWiki 1.8+
+ *
*
* Created on Sep 7, 2006
*
class ApiQueryRevisions extends ApiQueryBase {
private $diffto, $difftotext, $expandTemplates, $generateXML, $section,
- $token;
+ $token, $parseContent;
public function __construct( $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'rv' );
return $this->tokenFunctions;
}
+ /**
+ * @param $pageid
+ * @param $title Title
+ * @param $rev Revision
+ * @return bool|String
+ */
public static function getRollbackToken( $pageid, $title, $rev ) {
global $wgUser;
if ( !$wgUser->isAllowed( 'rollback' ) ) {
$params['diffto'] = 0;
}
if ( ( !ctype_digit( $params['diffto'] ) || $params['diffto'] < 0 )
- && $params['diffto'] != 'prev' && $params['diffto'] != 'next' )
- {
+ && $params['diffto'] != 'prev' && $params['diffto'] != 'next' ) {
$this->dieUsage( 'rvdiffto must be set to a non-negative number, "prev", "next" or "cur"', 'diffto' );
}
// Check whether the revision exists and is readable,
$this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
}
-
if ( !is_null( $this->token ) || $pageCount > 0 ) {
$this->addFields( Revision::selectPageFields() );
}
}
}
- //Bug 24166 - API error when using rvprop=tags
+ // Bug 24166 - API error when using rvprop=tags
$this->addTables( 'revision' );
-
if ( $enumRevMode ) {
// This is mostly to prevent parameter errors (and optimize SQL?)
if ( !is_null( $params['startid'] ) && !is_null( $params['start'] ) ) {
}
if ( $this->fld_parsedcomment ) {
- global $wgUser;
- $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $comment, $title );
+ $vals['parsedcomment'] = Linker::formatComment( $comment, $title );
}
}
}
$text = $wgParser->preprocess( $text, $title, new ParserOptions() );
}
if ( $this->parseContent ) {
- global $wgEnableParserCache;
-
- $popts = new ParserOptions();
- $popts->setTidy( true );
-
- $articleObj = new Article( $title );
-
- $p_result = false;
- $pcache = ParserCache::singleton();
- if ( $wgEnableParserCache ) {
- $p_result = $pcache->get( $articleObj, $popts );
- }
- if ( !$p_result ) {
- $p_result = $wgParser->parse( $text, $title, $popts );
-
- if ( $wgEnableParserCache ) {
- $pcache->save( $p_result, $articleObj, $popts );
- }
- }
-
- $text = $p_result->getText();
+ $text = $wgParser->parse( $text, $title, new ParserOptions() )->getText();
}
ApiResult::setContent( $vals, $text );
} elseif ( $this->fld_content ) {
'endid' => 'Stop revision enumeration on this revid (enum)',
'start' => 'From which revision timestamp to start enumeration (enum)',
'end' => 'Enumerate up to this timestamp (enum)',
- 'dir' => 'Direction of enumeration - towards "newer" or "older" revisions (enum)',
+ 'dir' => $this->getDirectionDescription( $p ),
'user' => 'Only include revisions made by user',
'excludeuser' => 'Exclude revisions made by user',
'expandtemplates' => 'Expand templates in revision content',
public function getDescription() {
return array(
'Get revision information',
- 'This module may be used in several ways:',
+ 'May be used in several ways:',
' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter',
' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params',
' 3) Get data about a set of revisions by setting their IDs with revids parameter',
) );
}
- protected function getExamples() {
+ public function getExamples() {
return array(
'Get data with content for the last revision of titles "API" and "Main Page":',
' api.php?action=query&prop=revisions&titles=API|Main%20Page&rvprop=timestamp|user|comment|content',
);
}
+ public function getHelpUrls() {
+ return 'http://www.mediawiki.org/wiki/API:Properties#revisions_.2F_rv';
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}