ApiQuery Class Reference
[API]

This is the main query class. More...

Inherits ApiBase.

List of all members.

Public Member Functions

 __construct ($main, $action)
 getDB ()
 Gets a default slave database connection object.
 getNamedDB ($name, $db, $groups)
 Get the query database connection with the given name.
 getPageSet ()
 Gets the set of pages the user has requested (or generated).
 getModules ()
 Get the array mapping module names to class names.
 getCustomPrinter ()
 If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.
 execute ()
 Query execution happens in the following steps: #1 Create a PageSet object with any pages requested by the user #2 If using a generator, execute it to get a new ApiPageSet object #3 Instantiate all requested modules.
 getAllowedParams ()
 Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.
 makeHelpMsg ()
 Override the parent to generate help messages for all available query modules.
 makeHelpMsgParameters ()
 Override to add extra parameters from PageSet.
 shouldCheckMaxlag ()
 Indicates if this module needs maxlag to be checked.
 getParamDescription ()
 Returns an array of parameter descriptions.
 getDescription ()
 Returns the description string for this module.
 getVersion ()
 Returns a string that identifies the version of the extending class.

Protected Member Functions

 executeGeneratorModule ($generatorName, $modules)
 For generator mode, execute generator, and use its output as new ApiPageSet.
 getExamples ()
 Returns usage examples for this module.

Private Member Functions

 addCustomFldsToPageSet ($modules, $pageSet)
 Query modules may optimize data requests through the $this->getPageSet() object by adding extra fields from the page table.
 InstantiateModules (&$modules, $param, $moduleList)
 Create instances of all modules requested by the client.
 outputGeneralPageInfo ()
 Appends an element for each page in the current pageSet with the most general information (id, title), plus any title normalizations and missing or invalid title/pageids/revids.
 makeHelpMsgHelper ($moduleList, $paramName)
 For all modules in $moduleList, generate help messages and join them together.

Static Private Member Functions

static appendUserModules (&$modules, $newModules)
 Helper function to append any add-in modules to the list.

Private Attributes

 $mPropModuleNames
 $mListModuleNames
 $mMetaModuleNames
 $mPageSet
 $params
 $redirect
 $mQueryPropModules
 $mQueryListModules
 $mQueryMetaModules
 $mSlaveDB = null
 $mNamedDB = array()


Detailed Description

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 ApiPageSet object), instantiate and execute various property/list/meta modules, and assemble all resulting data into a single ApiResult object.

In generator mode, a generator will be executed first to populate a second ApiPageSet object, and that object will be used for all subsequent modules.

Definition at line 42 of file ApiQuery.php.


Constructor & Destructor Documentation

ApiQuery::__construct ( main,
action 
)


Member Function Documentation

ApiQuery::addCustomFldsToPageSet ( modules,
pageSet 
) [private]

Query modules may optimize data requests through the $this->getPageSet() object by adding extra fields from the page table.

This function will gather all the extra request fields from the modules.

Parameters:
$modules array of module objects
$pageSet ApiPageSet

Definition at line 246 of file ApiQuery.php.

Referenced by execute(), and executeGeneratorModule().

static ApiQuery::appendUserModules ( &$  modules,
newModules 
) [static, private]

Helper function to append any add-in modules to the list.

Parameters:
$modules array Module array
$newModules array Module array to add to $modules

Definition at line 118 of file ApiQuery.php.

Referenced by __construct().

ApiQuery::execute (  ) 

Query execution happens in the following steps: #1 Create a PageSet object with any pages requested by the user #2 If using a generator, execute it to get a new ApiPageSet object #3 Instantiate all requested modules.

This way the PageSet object will know what shared data is required, and minimize DB calls. #4 Output all normalization and redirect resolution information #5 Execute all requested modules

Reimplemented from ApiBase.

Definition at line 194 of file ApiQuery.php.

References addCustomFldsToPageSet(), executeGeneratorModule(), ApiBase::extractRequestParams(), InstantiateModules(), outputGeneralPageInfo(), and wfRunHooks().

ApiQuery::executeGeneratorModule ( generatorName,
modules 
) [protected]

For generator mode, execute generator, and use its output as new ApiPageSet.

Parameters:
$generatorName string Module name
$modules array of module objects

Definition at line 417 of file ApiQuery.php.

References addCustomFldsToPageSet(), ApiBase::dieDebug(), ApiBase::dieUsage(), and wfRunHooks().

Referenced by execute().

ApiQuery::getAllowedParams (  ) 

Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (array with PARAM_* constants as keys) Don't call this function directly: use getFinalParams() to allow hooks to modify parameters as needed.

Returns:
array

Reimplemented from ApiBase.

Definition at line 456 of file ApiQuery.php.

References ApiBase::PARAM_ISMULTI, and ApiBase::PARAM_TYPE.

ApiQuery::getCustomPrinter (  ) 

If the module may only be used with a certain format module, it should override this method to return an instance of that formatter.

A value of null means the default format will be used.

Returns:
mixed instance of a derived class of ApiFormatBase, or null

Reimplemented from ApiBase.

Definition at line 174 of file ApiQuery.php.

References ApiBase::getMain(), and ApiBase::getParameter().

ApiQuery::getDB (  ) 

Gets a default slave database connection object.

Returns:
Database

Definition at line 130 of file ApiQuery.php.

References ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().

Referenced by outputGeneralPageInfo().

ApiQuery::getDescription (  ) 

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 565 of file ApiQuery.php.

ApiQuery::getExamples (  )  [protected]

Returns usage examples for this module.

Return null if no examples are available.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 573 of file ApiQuery.php.

ApiQuery::getModules (  ) 

Get the array mapping module names to class names.

Returns:
array(modulename => classname)

Definition at line 170 of file ApiQuery.php.

ApiQuery::getNamedDB ( name,
db,
groups 
)

Get the query database connection with the given name.

If no such connection has been requested before, it will be created. Subsequent calls with the same $name will return the same connection as the first, regardless of the values of $db and $groups

Parameters:
$name string Name to assign to the database connection
$db int One of the DB_* constants
$groups array Query groups
Returns:
Database

Definition at line 149 of file ApiQuery.php.

References $db, $name, ApiBase::profileDBIn(), ApiBase::profileDBOut(), and wfGetDB().

ApiQuery::getPageSet (  ) 

Gets the set of pages the user has requested (or generated).

Returns:
ApiPageSet

Definition at line 162 of file ApiQuery.php.

Referenced by outputGeneralPageInfo().

ApiQuery::getParamDescription (  ) 

Returns an array of parameter descriptions.

Don't call this functon directly: use getFinalParamDescription() to allow hooks to modify descriptions as needed.

Returns:
array

Reimplemented from ApiBase.

Definition at line 551 of file ApiQuery.php.

ApiQuery::getVersion (  ) 

Returns a string that identifies the version of the extending class.

Typically includes the class name, the svn revision, timestamp, and last author. Usually done with SVN's Id keyword

Returns:
string

Reimplemented from ApiBase.

Definition at line 580 of file ApiQuery.php.

ApiQuery::InstantiateModules ( &$  modules,
param,
moduleList 
) [private]

Create instances of all modules requested by the client.

Parameters:
$modules array to append instatiated modules to
$param string Parameter name to read modules from
$moduleList array(modulename => classname)

Definition at line 259 of file ApiQuery.php.

Referenced by execute().

ApiQuery::makeHelpMsg (  ) 

Override the parent to generate help messages for all available query modules.

Returns:
string

Reimplemented from ApiBase.

Definition at line 484 of file ApiQuery.php.

References $msg, and makeHelpMsgHelper().

ApiQuery::makeHelpMsgHelper ( moduleList,
paramName 
) [private]

For all modules in $moduleList, generate help messages and join them together.

Parameters:
$moduleList array(modulename => classname)
$paramName string Parameter name
Returns:
string

Definition at line 517 of file ApiQuery.php.

References $msg, and ApiMain::makeHelpMsgHeader().

Referenced by makeHelpMsg().

ApiQuery::makeHelpMsgParameters (  ) 

Override to add extra parameters from PageSet.

Returns:
string

Reimplemented from ApiBase.

Definition at line 542 of file ApiQuery.php.

ApiQuery::outputGeneralPageInfo (  )  [private]

Appends an element for each page in the current pageSet with the most general information (id, title), plus any title normalizations and missing or invalid title/pageids/revids.

Definition at line 271 of file ApiQuery.php.

References $result, $title, ApiQueryBase::addTitleInfo(), getDB(), getPageSet(), ApiBase::getResult(), and ApiResult::setContent().

Referenced by execute().

ApiQuery::shouldCheckMaxlag (  ) 

Indicates if this module needs maxlag to be checked.

Returns:
bool

Reimplemented from ApiBase.

Definition at line 547 of file ApiQuery.php.


Member Data Documentation

ApiQuery::$mListModuleNames [private]

Definition at line 44 of file ApiQuery.php.

ApiQuery::$mMetaModuleNames [private]

Definition at line 44 of file ApiQuery.php.

ApiQuery::$mNamedDB = array() [private]

Definition at line 93 of file ApiQuery.php.

ApiQuery::$mPageSet [private]

Definition at line 45 of file ApiQuery.php.

ApiQuery::$mPropModuleNames [private]

Definition at line 44 of file ApiQuery.php.

ApiQuery::$mQueryListModules [private]

Initial value:

 array (
                'allimages' => 'ApiQueryAllimages',
                'allpages' => 'ApiQueryAllpages',
                'alllinks' => 'ApiQueryAllLinks',
                'allcategories' => 'ApiQueryAllCategories',
                'allusers' => 'ApiQueryAllUsers',
                'backlinks' => 'ApiQueryBacklinks',
                'blocks' => 'ApiQueryBlocks',
                'categorymembers' => 'ApiQueryCategoryMembers',
                'deletedrevs' => 'ApiQueryDeletedrevs',
                'embeddedin' => 'ApiQueryBacklinks',
                'imageusage' => 'ApiQueryBacklinks',
                'logevents' => 'ApiQueryLogEvents',
                'recentchanges' => 'ApiQueryRecentChanges',
                'search' => 'ApiQuerySearch',
                'usercontribs' => 'ApiQueryContributions',
                'watchlist' => 'ApiQueryWatchlist',
                'watchlistraw' => 'ApiQueryWatchlistRaw',
                'exturlusage' => 'ApiQueryExtLinksUsage',
                'users' => 'ApiQueryUsers',
                'random' => 'ApiQueryRandom',
                'protectedtitles' => 'ApiQueryProtectedTitles',
        )

Definition at line 62 of file ApiQuery.php.

ApiQuery::$mQueryMetaModules [private]

Initial value:

 array (
                'siteinfo' => 'ApiQuerySiteinfo',
                'userinfo' => 'ApiQueryUserInfo',
                'allmessages' => 'ApiQueryAllmessages',
        )

Definition at line 86 of file ApiQuery.php.

ApiQuery::$mQueryPropModules [private]

Initial value:

 array (
                'info' => 'ApiQueryInfo',
                'revisions' => 'ApiQueryRevisions',
                'links' => 'ApiQueryLinks',
                'langlinks' => 'ApiQueryLangLinks',
                'images' => 'ApiQueryImages',
                'imageinfo' => 'ApiQueryImageInfo',
                'templates' => 'ApiQueryLinks',
                'categories' => 'ApiQueryCategories',
                'extlinks' => 'ApiQueryExternalLinks',
                'categoryinfo' => 'ApiQueryCategoryInfo',
                'duplicatefiles' => 'ApiQueryDuplicateFiles',
        )

Definition at line 48 of file ApiQuery.php.

ApiQuery::$mSlaveDB = null [private]

Definition at line 92 of file ApiQuery.php.

ApiQuery::$params [private]

Definition at line 46 of file ApiQuery.php.

ApiQuery::$redirect [private]

Definition at line 46 of file ApiQuery.php.


The documentation for this class was generated from the following file:

Generated on Sat Sep 5 02:08:31 2009 for MediaWiki by  doxygen 1.5.9