Go to the documentation of this file.
35 parent::__construct(
$query, $moduleName,
'cm' );
47 $this->
run( $resultPageSet );
54 private function run( $resultPageSet =
null ) {
58 if ( $categoryTitle->getNamespace() !=
NS_CATEGORY ) {
59 $this->
dieUsage(
'The category name you entered is not valid',
'invalidcategory' );
62 $prop = array_flip(
$params[
'prop'] );
63 $fld_ids = isset( $prop[
'ids'] );
64 $fld_title = isset( $prop[
'title'] );
65 $fld_sortkey = isset( $prop[
'sortkey'] );
66 $fld_sortkeyprefix = isset( $prop[
'sortkeyprefix'] );
67 $fld_timestamp = isset( $prop[
'timestamp'] );
68 $fld_type = isset( $prop[
'type'] );
70 if ( is_null( $resultPageSet ) ) {
71 $this->
addFields(
array(
'cl_from',
'cl_sortkey',
'cl_type',
'page_namespace',
'page_title' ) );
73 $this->
addFieldsIf(
'cl_sortkey_prefix', $fld_sortkeyprefix );
75 $this->
addFields( $resultPageSet->getPageTableFields() );
79 $this->
addFieldsIf(
'cl_timestamp', $fld_timestamp ||
$params[
'sort'] ==
'timestamp' );
83 $this->
addWhereFld(
'cl_to', $categoryTitle->getDBkey() );
92 $miser_ns =
$params[
'namespace'];
97 $dir = in_array(
$params[
'dir'],
array(
'asc',
'ascending',
'newer' ) ) ?
'newer' :
'older';
99 if (
$params[
'sort'] ==
'timestamp' ) {
107 if ( !is_null(
$params[
'continue'] ) ) {
108 $cont = explode(
'|',
$params[
'continue'] );
110 $op = (
$dir ===
'newer' ?
'>' :
'<' );
111 $db = $this->
getDB();
112 $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
113 $continueFrom = (int)$cont[1];
115 $this->
addWhere(
"cl_timestamp $op $continueTimestamp OR " .
116 "(cl_timestamp = $continueTimestamp AND " .
117 "cl_from $op= $continueFrom)"
121 $this->
addOption(
'USE INDEX',
'cl_timestamp' );
124 $cont = explode(
'|',
$params[
'continue'], 3 );
128 $contTypeIndex = array_search( $cont[0], $queryTypes );
129 $queryTypes = array_slice( $queryTypes, $contTypeIndex );
133 $escSortkey = $this->
getDB()->addQuotes( pack(
'H*', $cont[1] ) );
134 $from = intval( $cont[2] );
135 $op =
$dir ==
'newer' ?
'>' :
'<';
137 $contWhere =
"cl_sortkey $op $escSortkey OR " .
138 "(cl_sortkey = $escSortkey AND " .
139 "cl_from $op= $from)";
144 $startsortkey =
$params[
'startsortkeyprefix'] !==
null ?
147 $endsortkey =
$params[
'endsortkeyprefix'] !==
null ?
158 $this->
addOption(
'USE INDEX',
'cl_sortkey' );
161 $this->
addWhere(
'cl_from=page_id' );
166 if (
$params[
'sort'] ==
'sortkey' ) {
174 foreach ( $queryTypes
as $type ) {
176 if ( $first && $contWhere ) {
179 $extraConds[] = $contWhere;
182 $rows = array_merge( $rows, iterator_to_array(
$res ) );
183 if ( count( $rows ) >=
$limit + 1 ) {
193 $rows = iterator_to_array(
$res );
198 foreach ( $rows
as $row ) {
204 if (
$params[
'sort'] ==
'timestamp' ) {
207 $sortkey = bin2hex( $row->cl_sortkey );
209 "{$row->cl_type}|$sortkey|{$row->cl_from}"
219 if ( count( $miser_ns ) && !in_array( $row->page_namespace, $miser_ns ) ) {
223 if ( is_null( $resultPageSet ) ) {
226 $vals[
'pageid'] = intval( $row->page_id );
232 if ( $fld_sortkey ) {
233 $vals[
'sortkey'] = bin2hex( $row->cl_sortkey );
235 if ( $fld_sortkeyprefix ) {
236 $vals[
'sortkeyprefix'] = $row->cl_sortkey_prefix;
239 $vals[
'type'] = $row->cl_type;
241 if ( $fld_timestamp ) {
247 if (
$params[
'sort'] ==
'timestamp' ) {
250 $sortkey = bin2hex( $row->cl_sortkey );
252 "{$row->cl_type}|$sortkey|{$row->cl_from}"
258 $resultPageSet->processDbRow( $row );
262 if ( is_null( $resultPageSet ) ) {
263 $result->setIndexedTagName_internal(
288 'namespace' =>
array(
334 'startsortkey' =>
null,
335 'endsortkey' =>
null,
336 'startsortkeyprefix' =>
null,
337 'endsortkeyprefix' =>
null,
345 'title' =>
"Which category to enumerate (required). Must include " .
346 "'Category:' prefix. Cannot be used together with {$p}pageid",
347 'pageid' =>
"Page ID of the category to enumerate. Cannot be used together with {$p}title",
349 'What pieces of information to include',
350 ' ids - Adds the page ID',
351 ' title - Adds the title and namespace ID of the page',
352 ' sortkey - Adds the sortkey used for sorting in the category (hexadecimal string)',
353 ' sortkeyprefix - Adds the sortkey prefix used for sorting in the ' .
354 'category (human-readable part of the sortkey)',
355 ' type - Adds the type that the page has been categorised as (page, subcat or file)',
356 ' timestamp - Adds the timestamp of when the page was included',
358 'namespace' =>
'Only include pages in these namespaces',
359 'type' =>
"What type of category members to include. Ignored when {$p}sort=timestamp is set",
360 'sort' =>
'Property to sort by',
361 'dir' =>
'In which direction to sort',
362 'start' =>
"Timestamp to start listing from. Can only be used with {$p}sort=timestamp",
363 'end' =>
"Timestamp to end listing at. Can only be used with {$p}sort=timestamp",
364 'startsortkey' =>
"Sortkey to start listing from. Must be given in " .
365 "binary format. Can only be used with {$p}sort=sortkey",
366 'endsortkey' =>
"Sortkey to end listing at. Must be given in binary " .
367 "format. Can only be used with {$p}sort=sortkey",
368 'startsortkeyprefix' =>
"Sortkey prefix to start listing from. Can " .
369 "only be used with {$p}sort=sortkey. Overrides {$p}startsortkey",
370 'endsortkeyprefix' =>
"Sortkey prefix to end listing BEFORE (not at, " .
371 "if this value occurs it will not be included!). Can only be used with " .
372 "{$p}sort=sortkey. Overrides {$p}endsortkey",
373 'continue' =>
'For large categories, give the value returned from previous query',
374 'limit' =>
'The maximum number of pages to return.',
377 if ( $wgMiserMode ) {
378 $desc[
'namespace'] =
array(
380 "NOTE: Due to \$wgMiserMode, using this may result in fewer than \"{$p}limit\" results",
381 'returned before continuing; in extreme cases, zero results may be returned.',
382 "Note that you can use {$p}type=subcat or {$p}type=file instead of {$p}namespace=14 or 6.",
392 'pageid' =>
'integer'
399 'sortkey' =>
'string'
401 'sortkeyprefix' =>
array(
402 'sortkeyprefix' =>
'string'
413 'timestamp' =>
array(
414 'timestamp' =>
'timestamp'
420 return 'List all pages in a given category.';
424 return array_merge( parent::getPossibleErrors(),
427 array(
'code' =>
'invalidcategory',
'info' =>
'The category name you entered is not valid' ),
434 'api.php?action=query&list=categorymembers&cmtitle=Category:Physics'
435 =>
'Get first 10 pages in [[Category:Physics]]',
436 'api.php?action=query&generator=categorymembers&gcmtitle=Category:Physics&prop=info'
437 =>
'Get page info about first 10 pages in [[Category:Physics]]',
442 return 'https://www.mediawiki.org/wiki/API:Categorymembers';
getResultProperties()
Returns possible properties in the result, grouped by the value of the prop parameter that shows them...
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getExamples()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
addFields( $value)
Add a set of fields to select to the internal array.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
getTitleOrPageId( $params, $load=false)
getResult()
Get the result object.
select( $method, $extraQuery=array())
Execute a SELECT query based on the values in the internal arrays.
A query module to enumerate pages that belong to a category.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
setContinueEnumParameter( $paramName, $paramValue)
Overrides base in case of generator & smart continue to notify ApiQueryMain instead of adding them to...
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
getDB()
Get the Query database connection (read-only)
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
run( $resultPageSet=null)
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
presenting them properly to the user as errors is done by the caller $title
dieContinueUsageIf( $condition)
Die with the $prefix.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getParamDescription()
Returns an array of parameter descriptions.
getDescription()
Returns the description string for this module.
if(count( $args)==0) $dir
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
executeGenerator( $resultPageSet)
Execute this module as a generator.
getModuleName()
Get the name of the module being executed by this instance.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
__construct( $query, $moduleName)
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
getTitleOrPageIdErrorMessage()