MediaWiki master
ApiQueryAllCategories.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Api;
10
13
21
22 public function __construct( ApiQuery $query, string $moduleName ) {
23 parent::__construct( $query, $moduleName, 'ac' );
24 }
25
26 public function execute() {
27 $this->run();
28 }
29
31 public function getCacheMode( $params ) {
32 return 'public';
33 }
34
36 public function executeGenerator( $resultPageSet ) {
37 $this->run( $resultPageSet );
38 }
39
43 private function run( $resultPageSet = null ) {
44 $db = $this->getDB();
45 $params = $this->extractRequestParams();
46
47 $this->createQuery( $db, $params );
48 $this->executeQuery( $params, $resultPageSet );
49 }
50
52 public function getAllowedParams() {
53 return [
54 'from' => null,
55 'continue' => [
56 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
57 ],
58 'to' => null,
59 'prefix' => null,
60 'dir' => [
61 ParamValidator::PARAM_DEFAULT => 'ascending',
62 ParamValidator::PARAM_TYPE => [
63 'ascending',
64 'descending'
65 ],
66 ],
67 'min' => [
68 ParamValidator::PARAM_TYPE => 'integer'
69 ],
70 'max' => [
71 ParamValidator::PARAM_TYPE => 'integer'
72 ],
73 'limit' => [
74 ParamValidator::PARAM_DEFAULT => 10,
75 ParamValidator::PARAM_TYPE => 'limit',
76 IntegerDef::PARAM_MIN => 1,
77 IntegerDef::PARAM_MAX => ApiBase::LIMIT_BIG1,
78 IntegerDef::PARAM_MAX2 => ApiBase::LIMIT_BIG2
79 ],
80 'prop' => [
81 ParamValidator::PARAM_TYPE => [ 'size', 'hidden' ],
82 ParamValidator::PARAM_DEFAULT => '',
83 ParamValidator::PARAM_ISMULTI => true,
85 ],
86 ];
87 }
88
90 protected function getExamplesMessages() {
91 return [
92 'action=query&list=allcategories&acprop=size'
93 => 'apihelp-query+allcategories-example-size',
94 'action=query&generator=allcategories&gacprefix=List&prop=info'
95 => 'apihelp-query+allcategories-example-generator',
96 ];
97 }
98
100 public function getHelpUrls() {
101 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Allcategories';
102 }
103}
104
106class_alias( ApiQueryAllCategories::class, 'ApiQueryAllCategories' );
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
Definition ApiBase.php:207
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:167
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:234
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:823
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:232
Query module to enumerate all categories, even the ones that don't have category pages.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
__construct(ApiQuery $query, string $moduleName)
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
getCacheMode( $params)
Get the cache mode for the data generated by this module.Override this in the module subclass....
executeGenerator( $resultPageSet)
Execute this module as a generator.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getHelpUrls()
Return links to more detailed help pages about the module.1.25, returning boolean false is deprecated...
createQuery(IReadableDatabase $db, array $params)
executeQuery(array $params, ?ApiPageSet $resultPageSet=null, array $options=[])
This is the main query class.
Definition ApiQuery.php:36
Service for formatting and validating API parameters.
Type definition for integer types.
Language name search API.