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',