49 parent::__construct( $queryModule, $moduleName,
'ga' );
54 $this->props = array_flip( $params[
'prop'] );
55 $this->categories = isset( $params[
'categories'] )
56 ? array_flip( $params[
'categories'] )
58 $this->neededIds = isset( $params[
'ids'] )
59 ? array_flip( $params[
'ids'] )
61 $this->listAllowed = isset( $params[
'allowedonly'] ) && $params[
'allowedonly'];
62 $this->listEnabled = isset( $params[
'enabledonly'] ) && $params[
'enabledonly'];
64 $this->
getMain()->setCacheMode( $this->listAllowed || $this->listEnabled
65 ?
'anon-public-user-private' :
'public' );
81 foreach ( $gadgets as $category => $list ) {
82 if ( $this->categories && !isset( $this->categories[$category] ) ) {
86 foreach ( $list as $g ) {
105 foreach ( $gadgets as $g ) {
107 if ( isset( $this->props[
'id'] ) ) {
108 $row[
'id'] = $g->getName();
111 if ( isset( $this->props[
'metadata'] ) ) {
116 if ( isset( $this->props[
'desc'] ) ) {
117 $row[
'desc'] = $g->getDescription();
123 $result->setIndexedTagName( $data,
'gadget' );
135 return ( $this->neededIds ===
false || isset( $this->neededIds[$gadget->
getName()] ) )
136 && ( !$this->listAllowed || $gadget->
isAllowed( $user ) )
137 && ( !$this->listEnabled || $gadget->
isEnabled( $user ) );
169 'scripts' =>
'script',
171 'dependencies' =>
'dependency',
173 'messages' =>
'message',
177 foreach ( $metadata as $data ) {
178 foreach ( $data as $key => $value ) {
179 if ( is_array( $value ) ) {
180 $tag = $tagNames[$key] ?? $key;
181 $result->setIndexedTagName( $value, $tag );
206 'allowedonly' =>
false,
207 'enabledonly' =>
false,
219 'action=query&list=gadgets&gaprop=id|desc'
220 =>
'apihelp-query+gadgets-example-1',
221 "action=query&list=gadgets&gaprop=$allProps"
222 =>
'apihelp-query+gadgets-example-2',
223 'action=query&list=gadgets&gacategories=foo'
224 =>
'apihelp-query+gadgets-example-3',
225 'action=query&list=gadgets&gaids=foo|bar&gaprop=id|desc|metadata'
226 =>
'apihelp-query+gadgets-example-4',
227 'action=query&list=gadgets&gaenabledonly'
228 =>
'apihelp-query+gadgets-example-5',
getMain()
Get the main module.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
This is a base class for all Query modules.
Created on 15 April 2011 API for Gadgets extension.
setIndexedTagNameForMetadata(&$metadata)
__construct(ApiQuery $queryModule, $moduleName)
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
This is the main query class.
static singleton()
Get the configured default GadgetRepo.
getPeers()
Get list of extra modules that should be loaded when this gadget is enabled.
getLegacyScripts()
Returns list of scripts that don't support ResourceLoader.
getRequiredSkins()
Returns array of skins where this gadget works.
isAllowed(User $user)
Checks whether given user has permissions to use this gadget.
getDependencies()
Returns names of resources this gadget depends on.
isEnabled( $user)
Checks whether this gadget is enabled for given user.
getRequiredRights()
Returns array of permissions required by this gadget.