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'] )
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' );
76 if ( $gadgets ===
false ) {
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 ) );
147 'rights' => $g->getRequiredRights(),
148 'skins' => $g->getRequiredSkins(),
149 'default' => $g->isOnByDefault(),
150 'hidden' => $g->isHidden(),
152 'category' => $g->getCategory(),
153 'legacyscripts' => (bool)$g->getLegacyScripts(),
156 'scripts' => $g->getScripts(),
157 'styles' => $g->getStyles(),
158 'dependencies' => $g->getDependencies(),
159 'peers' => $g->getPeers(),
160 'messages' => $g->getMessages(),
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 = isset( $tagNames[$key] ) ? $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.
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
getResult()
Get the result object.
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.
isAllowed( $user)
Checks whether given user has permissions to use this gadget.
isEnabled( $user)
Checks whether this gadget is enabled for given user.
namespace being checked & $result