API: documentation and cleanup.

This commit is contained in:
Yuri Astrakhan 2007-05-20 23:31:44 +00:00
parent afbf57e163
commit cb38c11c84
30 changed files with 95 additions and 33 deletions

View file

@ -4,7 +4,7 @@
/**
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -200,7 +200,14 @@ abstract class ApiBase {
$prompt = 'One value: ';
if (is_array($type)) {
$desc .= $paramPrefix . $prompt . implode(', ', $type);
$choices = array();
$nothingPrompt = false;
foreach ($type as $t)
if ($t=='')
$nothingPrompt = 'Can be empty, or ';
else
$choices[] = $t;
$desc .= $paramPrefix . $nothingPrompt . $prompt . implode(', ', $choices);
} else {
switch ($type) {
case 'namespace':

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This is a simple class to handle action=help
*
* @addtogroup API
*/
class ApiHelp extends ApiBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -327,7 +327,7 @@ class ApiMain extends ApiBase {
*/
protected function getCredits() {
return array(
'This API is being implemented by Yuri Astrakhan [[User:Yurik]] / <FirstnameLastname>@gmail.com',
'This API is being implemented by Yuri Astrakhan [[User:Yurik]] / <Firstname><Lastname>@gmail.com',
'Please leave your comments and suggestions at http://www.mediawiki.org/wiki/API'
);
}

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,15 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This class contains a list of pages that the client has requested.
* Initially, when the client passes in titles=, pageids=, or revisions= parameter,
* an instance of the ApiPageSet class will normalize titles,
* determine if the pages/revisions exist, and prefetch any additional data page data requested.
*
* When generator is used, the result of the generator will become the input for the
* second instance of this class, and all subsequent actions will go use the second instance
* for all their work.
*
* @addtogroup API
*/
class ApiPageSet extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,14 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This is the main query class. It behaves similar to ApiMain: based on the parameters given,
* it will create a list of titles to work on (an instance of the ApiPageSet object)
* instantiate and execute various property/list/meta modules,
* and assemble all resulting data into a single ApiResult object.
*
* In the generator mode, a generator will be first executed to populate a second ApiPageSet object,
* and that object will be used for all subsequent modules.
*
* @addtogroup API
*/
class ApiQuery extends ApiBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* Query module to enumerate all available pages.
*
* @addtogroup API
*/
class ApiQueryAllpages extends ApiQueryGeneratorBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,11 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This is three-in-one module to query:
* * backlinks - links pointing to the given page,
* * embeddedin - what pages transclude the given page within themselves,
* * imageusage - what pages use the given image
*
* @addtogroup API
*/
class ApiQueryBacklinks extends ApiQueryGeneratorBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,9 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This is a base class for all Query modules.
* It provides some common functionality such as constructing various SQL queries.
*
* @addtogroup API
*/
abstract class ApiQueryBase extends ApiBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query module to enumerate categories the set of pages belong to.
*
* @addtogroup API
*/
class ApiQueryCategories extends ApiQueryGeneratorBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query module to list all external URLs found on a given set of pages.
*
* @addtogroup API
*/
class ApiQueryExternalLinks extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This query adds <images> subelement to all pages with the list of images embedded into those pages.
*
* @addtogroup API
*/
class ApiQueryImages extends ApiQueryGeneratorBase {
@ -109,7 +111,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
}
protected function getDescription() {
return 'Returns all links from the given page(s)';
return 'Returns all images contained on the given page(s)';
}
protected function getExamples() {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query module to show basic page information.
*
* @addtogroup API
*/
class ApiQueryInfo extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query module to list all langlinks (links to correspanding foreign language pages).
*
* @addtogroup API
*/
class ApiQueryLangLinks extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query module to list all wiki links on a given set of pages.
*
* @addtogroup API
*/
class ApiQueryLinks extends ApiQueryGeneratorBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* Query action to List the log events, with optional filtering by various parameters.
*
* @addtogroup API
*/
class ApiQueryLogEvents extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,9 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query action to enumerate the recent changes that were done to the wiki.
* Various filters are supported.
*
* @addtogroup API
*/
class ApiQueryRecentChanges extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,10 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query action to enumerate revisions of a given page, or show top revisions of multiple pages.
* Various pieces of information may be shown - flags, comments, and the actual wiki markup of the rev.
* In the enumeration mode, ranges of revisions may be requested and filtered.
*
* @addtogroup API
*/
class ApiQueryRevisions extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,8 @@ if (!defined('MEDIAWIKI')) {
}
/**
* A query action to return meta information about the wiki site.
*
* @addtogroup API
*/
class ApiQuerySiteinfo extends ApiQueryBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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
@ -29,6 +29,9 @@ if (!defined('MEDIAWIKI')) {
}
/**
* This query action allows clients to retrieve a list of recently modified pages
* that are part of the logged-in user's watchlist.
*
* @addtogroup API
*/
class ApiQueryWatchlist extends ApiQueryGeneratorBase {

View file

@ -5,7 +5,7 @@
*
* API for MediaWiki 1.8+
*
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
* Copyright (C) 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