2006-10-20 07:10:18 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Created on Oct 19, 2006
|
|
|
|
|
*
|
|
|
|
|
* API for MediaWiki 1.8+
|
|
|
|
|
*
|
2007-05-20 23:31:44 +00:00
|
|
|
* Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
|
2006-10-20 07:10:18 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!defined('MEDIAWIKI')) {
|
|
|
|
|
// Eclipse helper - will be ignored in production
|
|
|
|
|
require_once ('ApiQueryBase.php');
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 08:55:14 +00:00
|
|
|
/**
|
2007-05-20 23:31:44 +00:00
|
|
|
* A query action to enumerate the recent changes that were done to the wiki.
|
|
|
|
|
* Various filters are supported.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-04-20 08:55:14 +00:00
|
|
|
*/
|
2006-10-20 07:10:18 +00:00
|
|
|
class ApiQueryRecentChanges extends ApiQueryBase {
|
|
|
|
|
|
|
|
|
|
public function __construct($query, $moduleName) {
|
|
|
|
|
parent :: __construct($query, $moduleName, 'rc');
|
|
|
|
|
}
|
|
|
|
|
|
2007-05-21 04:34:48 +00:00
|
|
|
private $fld_comment = false, $fld_user = false, $fld_flags = false,
|
|
|
|
|
$fld_timestamp = false, $fld_title = false, $fld_ids = false,
|
|
|
|
|
$fld_sizes = false;
|
2008-09-04 15:17:51 +00:00
|
|
|
|
|
|
|
|
protected function getTokenFunctions() {
|
|
|
|
|
// tokenname => function
|
|
|
|
|
// function prototype is func($pageid, $title, $rev)
|
|
|
|
|
// should return token or false
|
|
|
|
|
|
|
|
|
|
// Don't call the hooks twice
|
|
|
|
|
if(isset($this->tokenFunctions))
|
|
|
|
|
return $this->tokenFunctions;
|
|
|
|
|
|
|
|
|
|
// If we're in JSON callback mode, no tokens can be obtained
|
|
|
|
|
if(!is_null($this->getMain()->getRequest()->getVal('callback')))
|
|
|
|
|
return array();
|
|
|
|
|
|
|
|
|
|
$this->tokenFunctions = array(
|
|
|
|
|
'patrol' => array( 'ApiQueryRecentChanges', 'getPatrolToken' )
|
|
|
|
|
);
|
|
|
|
|
wfRunHooks('APIQueryRecentChangesTokens', array(&$this->tokenFunctions));
|
|
|
|
|
return $this->tokenFunctions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getPatrolToken($pageid, $title, $rc)
|
|
|
|
|
{
|
|
|
|
|
global $wgUser;
|
2008-10-14 12:46:11 +00:00
|
|
|
if(!$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
|
2008-09-04 15:17:51 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// The patrol token is always the same, let's exploit that
|
|
|
|
|
static $cachedPatrolToken = null;
|
|
|
|
|
if(!is_null($cachedPatrolToken))
|
|
|
|
|
return $cachedPatrolToken;
|
|
|
|
|
|
|
|
|
|
$cachedPatrolToken = $wgUser->editToken();
|
|
|
|
|
return $cachedPatrolToken;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/**
|
|
|
|
|
* Generates and outputs the result of this query based upon the provided parameters.
|
|
|
|
|
*/
|
2006-10-20 07:10:18 +00:00
|
|
|
public function execute() {
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Initialize vars */
|
2008-09-04 15:17:51 +00:00
|
|
|
$limit = $prop = $namespace = $titles = $show = $type = $dir = $start = $end = $token = null;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Get the parameters of the request. */
|
2006-10-20 07:10:18 +00:00
|
|
|
extract($this->extractRequestParams());
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Build our basic query. Namely, something along the lines of:
|
2008-05-10 10:49:26 +00:00
|
|
|
* SELECT * FROM recentchanges WHERE rc_timestamp > $start
|
2008-04-14 07:45:50 +00:00
|
|
|
* AND rc_timestamp < $end AND rc_namespace = $namespace
|
2007-10-12 00:15:21 +00:00
|
|
|
* AND rc_deleted = '0'
|
|
|
|
|
*/
|
2008-04-07 13:27:33 +00:00
|
|
|
$db = $this->getDB();
|
2008-05-10 10:49:26 +00:00
|
|
|
$this->addTables('recentchanges');
|
|
|
|
|
$this->addOption('USE INDEX', array('recentchanges' => 'rc_timestamp'));
|
2006-10-20 07:10:18 +00:00
|
|
|
$this->addWhereRange('rc_timestamp', $dir, $start, $end);
|
|
|
|
|
$this->addWhereFld('rc_namespace', $namespace);
|
2007-06-02 03:47:34 +00:00
|
|
|
$this->addWhereFld('rc_deleted', 0);
|
2008-10-25 14:04:43 +00:00
|
|
|
if($titles)
|
2008-02-27 10:28:03 +00:00
|
|
|
{
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
foreach($titles as $t)
|
|
|
|
|
{
|
|
|
|
|
$obj = Title::newFromText($t);
|
|
|
|
|
$lb->addObj($obj);
|
|
|
|
|
if($obj->getNamespace() < 0)
|
|
|
|
|
{
|
|
|
|
|
// LinkBatch refuses these, but we need them anyway
|
|
|
|
|
if(!array_key_exists($obj->getNamespace(), $lb->data))
|
|
|
|
|
$lb->data[$obj->getNamespace()] = array();
|
|
|
|
|
$lb->data[$obj->getNamespace()][$obj->getDbKey()] = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$where = $lb->constructSet('rc', $this->getDb());
|
|
|
|
|
if($where != '')
|
|
|
|
|
$this->addWhere($where);
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-12 14:03:43 +00:00
|
|
|
if(!is_null($type))
|
|
|
|
|
$this->addWhereFld('rc_type', $this->parseRCType($type));
|
2006-10-20 07:10:18 +00:00
|
|
|
|
2006-11-04 06:53:52 +00:00
|
|
|
if (!is_null($show)) {
|
|
|
|
|
$show = array_flip($show);
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Check for conflicting parameters. */
|
2008-04-14 07:45:50 +00:00
|
|
|
if ((isset ($show['minor']) && isset ($show['!minor']))
|
|
|
|
|
|| (isset ($show['bot']) && isset ($show['!bot']))
|
2008-04-07 13:01:57 +00:00
|
|
|
|| (isset ($show['anon']) && isset ($show['!anon']))
|
2008-05-07 19:30:59 +00:00
|
|
|
|| (isset ($show['redirect']) && isset ($show['!redirect']))
|
|
|
|
|
|| (isset ($show['patrolled']) && isset ($show['!patrolled']))) {
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-11-04 06:53:52 +00:00
|
|
|
$this->dieUsage("Incorrect parameter - mutually exclusive values may not be supplied", 'show');
|
2007-10-12 00:15:21 +00:00
|
|
|
}
|
2008-05-07 19:30:59 +00:00
|
|
|
|
|
|
|
|
// Check permissions
|
|
|
|
|
global $wgUser;
|
2008-10-14 12:46:11 +00:00
|
|
|
if((isset($show['patrolled']) || isset($show['!patrolled'])) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
|
2008-05-07 19:30:59 +00:00
|
|
|
$this->dieUsage("You need the patrol right to request the patrolled flag", 'permissiondenied');
|
2006-11-04 06:53:52 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add additional conditions to query depending upon parameters. */
|
2006-11-04 06:53:52 +00:00
|
|
|
$this->addWhereIf('rc_minor = 0', isset ($show['!minor']));
|
|
|
|
|
$this->addWhereIf('rc_minor != 0', isset ($show['minor']));
|
|
|
|
|
$this->addWhereIf('rc_bot = 0', isset ($show['!bot']));
|
|
|
|
|
$this->addWhereIf('rc_bot != 0', isset ($show['bot']));
|
|
|
|
|
$this->addWhereIf('rc_user = 0', isset ($show['anon']));
|
|
|
|
|
$this->addWhereIf('rc_user != 0', isset ($show['!anon']));
|
2008-05-07 19:30:59 +00:00
|
|
|
$this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
|
|
|
|
|
$this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
|
2008-04-07 13:01:57 +00:00
|
|
|
$this->addWhereIf('page_is_redirect = 1', isset ($show['redirect']));
|
2008-04-07 13:27:33 +00:00
|
|
|
// Don't throw log entries out the window here
|
|
|
|
|
$this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset ($show['!redirect']));
|
2006-10-20 07:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add the fields we're concerned with to out query. */
|
2006-10-20 07:10:18 +00:00
|
|
|
$this->addFields(array (
|
|
|
|
|
'rc_timestamp',
|
|
|
|
|
'rc_namespace',
|
|
|
|
|
'rc_title',
|
2008-09-04 15:17:51 +00:00
|
|
|
'rc_cur_id',
|
2006-10-20 07:10:18 +00:00
|
|
|
'rc_type',
|
|
|
|
|
'rc_moved_to_ns',
|
|
|
|
|
'rc_moved_to_title'
|
|
|
|
|
));
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Determine what properties we need to display. */
|
2006-10-21 08:26:32 +00:00
|
|
|
if (!is_null($prop)) {
|
|
|
|
|
$prop = array_flip($prop);
|
2007-05-21 04:34:48 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Set up internal members based upon params. */
|
2007-05-21 04:34:48 +00:00
|
|
|
$this->fld_comment = isset ($prop['comment']);
|
|
|
|
|
$this->fld_user = isset ($prop['user']);
|
|
|
|
|
$this->fld_flags = isset ($prop['flags']);
|
|
|
|
|
$this->fld_timestamp = isset ($prop['timestamp']);
|
|
|
|
|
$this->fld_title = isset ($prop['title']);
|
|
|
|
|
$this->fld_ids = isset ($prop['ids']);
|
|
|
|
|
$this->fld_sizes = isset ($prop['sizes']);
|
2008-04-07 13:01:57 +00:00
|
|
|
$this->fld_redirect = isset($prop['redirect']);
|
2008-02-24 20:23:33 +00:00
|
|
|
$this->fld_patrolled = isset($prop['patrolled']);
|
2008-09-06 12:18:36 +00:00
|
|
|
$this->fld_loginfo = isset($prop['loginfo']);
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-24 20:23:33 +00:00
|
|
|
global $wgUser;
|
2008-10-14 12:46:11 +00:00
|
|
|
if($this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
|
2008-03-27 16:31:52 +00:00
|
|
|
$this->dieUsage("You need the patrol right to request the patrolled flag", 'permissiondenied');
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Add fields to our query if they are specified as a needed parameter. */
|
2008-04-14 07:45:50 +00:00
|
|
|
$this->addFieldsIf('rc_id', $this->fld_ids);
|
|
|
|
|
$this->addFieldsIf('rc_this_oldid', $this->fld_ids);
|
|
|
|
|
$this->addFieldsIf('rc_last_oldid', $this->fld_ids);
|
|
|
|
|
$this->addFieldsIf('rc_comment', $this->fld_comment);
|
2007-05-21 04:34:48 +00:00
|
|
|
$this->addFieldsIf('rc_user', $this->fld_user);
|
|
|
|
|
$this->addFieldsIf('rc_user_text', $this->fld_user);
|
|
|
|
|
$this->addFieldsIf('rc_minor', $this->fld_flags);
|
|
|
|
|
$this->addFieldsIf('rc_bot', $this->fld_flags);
|
|
|
|
|
$this->addFieldsIf('rc_new', $this->fld_flags);
|
|
|
|
|
$this->addFieldsIf('rc_old_len', $this->fld_sizes);
|
|
|
|
|
$this->addFieldsIf('rc_new_len', $this->fld_sizes);
|
2008-02-24 20:23:33 +00:00
|
|
|
$this->addFieldsIf('rc_patrolled', $this->fld_patrolled);
|
2008-09-06 12:18:36 +00:00
|
|
|
$this->addFieldsIf('rc_logid', $this->fld_loginfo);
|
|
|
|
|
$this->addFieldsIf('rc_log_type', $this->fld_loginfo);
|
|
|
|
|
$this->addFieldsIf('rc_log_action', $this->fld_loginfo);
|
|
|
|
|
$this->addFieldsIf('rc_params', $this->fld_loginfo);
|
2008-04-07 13:01:57 +00:00
|
|
|
if($this->fld_redirect || isset($show['redirect']) || isset($show['!redirect']))
|
|
|
|
|
{
|
2008-05-10 10:49:26 +00:00
|
|
|
$this->addTables('page');
|
2008-05-13 14:56:51 +00:00
|
|
|
$this->addJoinConds(array('page' => array('LEFT JOIN', array('rc_namespace=page_namespace', 'rc_title=page_title'))));
|
2008-04-07 13:01:57 +00:00
|
|
|
$this->addFields('page_is_redirect');
|
|
|
|
|
}
|
2006-10-21 08:26:32 +00:00
|
|
|
}
|
2008-09-04 15:17:51 +00:00
|
|
|
$this->token = $token;
|
2008-04-14 07:45:50 +00:00
|
|
|
/* Specify the limit for our query. It's $limit+1 because we (possibly) need to
|
2007-10-12 00:15:21 +00:00
|
|
|
* generate a "continue" parameter, to allow paging. */
|
2006-10-20 07:10:18 +00:00
|
|
|
$this->addOption('LIMIT', $limit +1);
|
2007-10-12 00:15:21 +00:00
|
|
|
|
2006-10-20 07:10:18 +00:00
|
|
|
$data = array ();
|
|
|
|
|
$count = 0;
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Perform the actual query. */
|
2007-01-22 23:50:42 +00:00
|
|
|
$db = $this->getDB();
|
2006-10-20 07:10:18 +00:00
|
|
|
$res = $this->select(__METHOD__);
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Iterate through the rows, adding data extracted from them to our query result. */
|
2006-10-20 07:10:18 +00:00
|
|
|
while ($row = $db->fetchObject($res)) {
|
|
|
|
|
if (++ $count > $limit) {
|
|
|
|
|
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
|
2007-07-09 05:19:07 +00:00
|
|
|
$this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->rc_timestamp));
|
2006-10-20 07:10:18 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Extract the data from a single row. */
|
2007-05-21 04:34:48 +00:00
|
|
|
$vals = $this->extractRowInfo($row);
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add that row's data to our final output. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if($vals)
|
2006-10-21 08:26:32 +00:00
|
|
|
$data[] = $vals;
|
2006-10-20 07:10:18 +00:00
|
|
|
}
|
2007-10-12 00:15:21 +00:00
|
|
|
|
2006-10-20 07:10:18 +00:00
|
|
|
$db->freeResult($res);
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Format the result */
|
2006-10-20 07:10:18 +00:00
|
|
|
$result = $this->getResult();
|
|
|
|
|
$result->setIndexedTagName($data, 'rc');
|
|
|
|
|
$result->addValue('query', $this->getModuleName(), $data);
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/**
|
|
|
|
|
* Extracts from a single sql row the data needed to describe one recent change.
|
|
|
|
|
*
|
|
|
|
|
* @param $row The row from which to extract the data.
|
|
|
|
|
* @return An array mapping strings (descriptors) to their respective string values.
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
2007-05-21 04:34:48 +00:00
|
|
|
private function extractRowInfo($row) {
|
2007-10-12 00:15:21 +00:00
|
|
|
/* If page was moved somewhere, get the title of the move target. */
|
2007-05-21 04:34:48 +00:00
|
|
|
$movedToTitle = false;
|
2008-10-25 14:04:43 +00:00
|
|
|
if (isset($row->rc_moved_to_title) && $row->rc_moved_to_title !== '')
|
2007-05-21 04:34:48 +00:00
|
|
|
$movedToTitle = Title :: makeTitle($row->rc_moved_to_ns, $row->rc_moved_to_title);
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Determine the title of the page that has been changed. */
|
2007-07-14 19:04:31 +00:00
|
|
|
$title = Title :: makeTitle($row->rc_namespace, $row->rc_title);
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Our output data. */
|
2007-05-21 04:34:48 +00:00
|
|
|
$vals = array ();
|
|
|
|
|
|
2007-10-11 23:59:00 +00:00
|
|
|
$type = intval ( $row->rc_type );
|
|
|
|
|
|
|
|
|
|
/* Determine what kind of change this was. */
|
|
|
|
|
switch ( $type ) {
|
2008-09-04 15:17:51 +00:00
|
|
|
case RC_EDIT: $vals['type'] = 'edit'; break;
|
|
|
|
|
case RC_NEW: $vals['type'] = 'new'; break;
|
|
|
|
|
case RC_MOVE: $vals['type'] = 'move'; break;
|
|
|
|
|
case RC_LOG: $vals['type'] = 'log'; break;
|
|
|
|
|
case RC_MOVE_OVER_REDIRECT: $vals['type'] = 'move over redirect'; break;
|
2007-10-11 23:59:00 +00:00
|
|
|
default: $vals['type'] = $type;
|
|
|
|
|
}
|
2007-05-21 04:34:48 +00:00
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Create a new entry in the result for the title. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_title) {
|
|
|
|
|
ApiQueryBase :: addTitleInfo($vals, $title);
|
|
|
|
|
if ($movedToTitle)
|
2007-07-14 19:04:31 +00:00
|
|
|
ApiQueryBase :: addTitleInfo($vals, $movedToTitle, "new_");
|
2007-05-21 04:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add ids, such as rcid, pageid, revid, and oldid to the change's info. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_ids) {
|
2007-07-15 01:12:54 +00:00
|
|
|
$vals['rcid'] = intval($row->rc_id);
|
2007-05-21 04:34:48 +00:00
|
|
|
$vals['pageid'] = intval($row->rc_cur_id);
|
|
|
|
|
$vals['revid'] = intval($row->rc_this_oldid);
|
|
|
|
|
$vals['old_revid'] = intval( $row->rc_last_oldid );
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add user data and 'anon' flag, if use is anonymous. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_user) {
|
|
|
|
|
$vals['user'] = $row->rc_user_text;
|
|
|
|
|
if(!$row->rc_user)
|
|
|
|
|
$vals['anon'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add flags, such as new, minor, bot. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_flags) {
|
|
|
|
|
if ($row->rc_bot)
|
|
|
|
|
$vals['bot'] = '';
|
|
|
|
|
if ($row->rc_new)
|
|
|
|
|
$vals['new'] = '';
|
|
|
|
|
if ($row->rc_minor)
|
|
|
|
|
$vals['minor'] = '';
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add sizes of each revision. (Only available on 1.10+) */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_sizes) {
|
|
|
|
|
$vals['oldlen'] = intval($row->rc_old_len);
|
|
|
|
|
$vals['newlen'] = intval($row->rc_new_len);
|
|
|
|
|
}
|
2007-10-12 00:15:21 +00:00
|
|
|
|
|
|
|
|
/* Add the timestamp. */
|
2007-05-21 04:34:48 +00:00
|
|
|
if ($this->fld_timestamp)
|
|
|
|
|
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
|
|
|
|
|
|
2007-10-12 00:15:21 +00:00
|
|
|
/* Add edit summary / log summary. */
|
2008-10-25 14:04:43 +00:00
|
|
|
if ($this->fld_comment && isset($row->rc_comment)) {
|
2007-05-21 04:34:48 +00:00
|
|
|
$vals['comment'] = $row->rc_comment;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-07 13:01:57 +00:00
|
|
|
if ($this->fld_redirect)
|
|
|
|
|
if($row->page_is_redirect)
|
|
|
|
|
$vals['redirect'] = '';
|
|
|
|
|
|
2008-02-24 20:23:33 +00:00
|
|
|
/* Add the patrolled flag */
|
|
|
|
|
if ($this->fld_patrolled && $row->rc_patrolled == 1)
|
|
|
|
|
$vals['patrolled'] = '';
|
2008-09-06 12:18:36 +00:00
|
|
|
|
|
|
|
|
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
|
|
|
|
|
$vals['logid'] = $row->rc_logid;
|
|
|
|
|
$vals['logtype'] = $row->rc_log_type;
|
|
|
|
|
$vals['logaction'] = $row->rc_log_action;
|
|
|
|
|
ApiQueryLogEvents::addLogParams($this->getResult(),
|
|
|
|
|
$vals, $row->rc_params,
|
|
|
|
|
$row->rc_log_type);
|
|
|
|
|
}
|
2008-09-04 15:17:51 +00:00
|
|
|
|
|
|
|
|
if(!is_null($this->token))
|
|
|
|
|
{
|
|
|
|
|
$tokenFunctions = $this->getTokenFunctions();
|
|
|
|
|
foreach($this->token as $t)
|
|
|
|
|
{
|
|
|
|
|
$val = call_user_func($tokenFunctions[$t], $row->rc_cur_id,
|
|
|
|
|
$title, RecentChange::newFromRow($row));
|
|
|
|
|
if($val === false)
|
|
|
|
|
$this->setWarning("Action '$t' is not allowed for the current user");
|
|
|
|
|
else
|
|
|
|
|
$vals[$t . 'token'] = $val;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-21 04:34:48 +00:00
|
|
|
|
|
|
|
|
return $vals;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-10-12 14:03:43 +00:00
|
|
|
private function parseRCType($type)
|
|
|
|
|
{
|
|
|
|
|
if(is_array($type))
|
|
|
|
|
{
|
|
|
|
|
$retval = array();
|
|
|
|
|
foreach($type as $t)
|
|
|
|
|
$retval[] = $this->parseRCType($t);
|
|
|
|
|
return $retval;
|
|
|
|
|
}
|
|
|
|
|
switch($type)
|
|
|
|
|
{
|
|
|
|
|
case 'edit': return RC_EDIT;
|
|
|
|
|
case 'new': return RC_NEW;
|
|
|
|
|
case 'log': return RC_LOG;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
}
|
2007-05-21 04:34:48 +00:00
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2006-10-20 07:10:18 +00:00
|
|
|
return array (
|
2006-11-03 06:53:47 +00:00
|
|
|
'start' => array (
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'timestamp'
|
|
|
|
|
),
|
|
|
|
|
'end' => array (
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'timestamp'
|
|
|
|
|
),
|
2006-10-20 07:10:18 +00:00
|
|
|
'dir' => array (
|
|
|
|
|
ApiBase :: PARAM_DFLT => 'older',
|
|
|
|
|
ApiBase :: PARAM_TYPE => array (
|
|
|
|
|
'newer',
|
|
|
|
|
'older'
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'namespace' => array (
|
2006-11-03 06:53:47 +00:00
|
|
|
ApiBase :: PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'namespace'
|
2006-10-20 07:10:18 +00:00
|
|
|
),
|
2008-02-27 10:28:03 +00:00
|
|
|
'titles' => array(
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true
|
|
|
|
|
),
|
2006-10-21 08:26:32 +00:00
|
|
|
'prop' => array (
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true,
|
2007-05-21 04:34:48 +00:00
|
|
|
ApiBase :: PARAM_DFLT => 'title|timestamp|ids',
|
2006-10-21 08:26:32 +00:00
|
|
|
ApiBase :: PARAM_TYPE => array (
|
|
|
|
|
'user',
|
|
|
|
|
'comment',
|
2007-05-21 04:34:48 +00:00
|
|
|
'flags',
|
|
|
|
|
'timestamp',
|
|
|
|
|
'title',
|
|
|
|
|
'ids',
|
2008-02-24 20:23:33 +00:00
|
|
|
'sizes',
|
2008-04-07 13:01:57 +00:00
|
|
|
'redirect',
|
2008-09-06 12:18:36 +00:00
|
|
|
'patrolled',
|
|
|
|
|
'loginfo',
|
2006-10-21 08:26:32 +00:00
|
|
|
)
|
|
|
|
|
),
|
2008-09-04 15:17:51 +00:00
|
|
|
'token' => array(
|
|
|
|
|
ApiBase :: PARAM_TYPE => array_keys($this->getTokenFunctions()),
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true
|
|
|
|
|
),
|
2006-11-04 06:53:52 +00:00
|
|
|
'show' => array (
|
2006-10-20 07:10:18 +00:00
|
|
|
ApiBase :: PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase :: PARAM_TYPE => array (
|
|
|
|
|
'minor',
|
2006-11-04 06:53:52 +00:00
|
|
|
'!minor',
|
|
|
|
|
'bot',
|
|
|
|
|
'!bot',
|
|
|
|
|
'anon',
|
2008-04-07 13:01:57 +00:00
|
|
|
'!anon',
|
|
|
|
|
'redirect',
|
2008-05-07 19:30:59 +00:00
|
|
|
'!redirect',
|
|
|
|
|
'patrolled',
|
|
|
|
|
'!patrolled'
|
2006-10-20 07:10:18 +00:00
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'limit' => array (
|
|
|
|
|
ApiBase :: PARAM_DFLT => 10,
|
|
|
|
|
ApiBase :: PARAM_TYPE => 'limit',
|
|
|
|
|
ApiBase :: PARAM_MIN => 1,
|
2007-05-19 18:08:36 +00:00
|
|
|
ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1,
|
2006-10-20 07:10:18 +00:00
|
|
|
ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2
|
2007-10-12 14:03:43 +00:00
|
|
|
),
|
|
|
|
|
'type' => array (
|
|
|
|
|
ApiBase :: PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase :: PARAM_TYPE => array (
|
|
|
|
|
'edit',
|
2008-04-14 07:45:50 +00:00
|
|
|
'new',
|
2007-10-12 14:03:43 +00:00
|
|
|
'log'
|
|
|
|
|
)
|
2006-10-20 07:10:18 +00:00
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getParamDescription() {
|
2006-10-20 07:10:18 +00:00
|
|
|
return array (
|
|
|
|
|
'start' => 'The timestamp to start enumerating from.',
|
|
|
|
|
'end' => 'The timestamp to end enumerating.',
|
2006-11-03 06:53:47 +00:00
|
|
|
'dir' => 'In which direction to enumerate.',
|
|
|
|
|
'namespace' => 'Filter log entries to only this namespace(s)',
|
2008-02-27 10:28:03 +00:00
|
|
|
'titles' => 'Filter log entries to only these page titles',
|
2006-11-03 06:53:47 +00:00
|
|
|
'prop' => 'Include additional pieces of information',
|
2008-09-04 15:17:51 +00:00
|
|
|
'token' => 'Which tokens to obtain for each change',
|
2006-11-04 06:53:52 +00:00
|
|
|
'show' => array (
|
|
|
|
|
'Show only items that meet this criteria.',
|
|
|
|
|
'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
|
|
|
|
|
),
|
2007-10-12 14:03:43 +00:00
|
|
|
'type' => 'Which types of changes to show.',
|
2008-07-22 13:26:15 +00:00
|
|
|
'limit' => 'How many total changes to return.'
|
2006-10-20 07:10:18 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2006-10-20 07:10:18 +00:00
|
|
|
return 'Enumerate recent changes';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getExamples() {
|
|
|
|
|
return array (
|
2006-11-03 04:56:42 +00:00
|
|
|
'api.php?action=query&list=recentchanges'
|
2006-10-20 07:10:18 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVersion() {
|
2007-12-06 18:33:18 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2006-10-20 07:10:18 +00:00
|
|
|
}
|
|
|
|
|
}
|