34 parent::__construct( $query, $moduleName,
'tg' );
40 $prop = array_fill_keys( $params[
'prop'],
true );
42 $fld_displayname = isset( $prop[
'displayname'] );
43 $fld_description = isset( $prop[
'description'] );
44 $fld_hitcount = isset( $prop[
'hitcount'] );
45 $fld_defined = isset( $prop[
'defined'] );
46 $fld_source = isset( $prop[
'source'] );
47 $fld_active = isset( $prop[
'active'] );
49 $limit = $params[
'limit'];
57 $tagHitcounts = array_merge( $softwareDefinedTags, $explicitlyDefinedTags, $tagStats );
58 $tags = array_keys( $tagHitcounts );
60 # Fetch defined tags that aren't past the continuation
61 if ( $params[
'continue'] !==
null ) {
62 $cont = $params[
'continue'];
63 $tags = array_filter( $tags,
static function ( $v ) use ( $cont ) {
68 # Now make sure the array is sorted for proper continuation
72 foreach ( $tags as $tagName ) {
73 if ( ++$count > $limit ) {
79 $tag[
'name'] = $tagName;
81 if ( $fld_displayname ) {
85 if ( $fld_description ) {
86 $msg = $this->
msg(
"tag-$tagName-description" );
87 $tag[
'description'] = $msg->exists() ? $msg->text() :
'';
90 if ( $fld_hitcount ) {
91 $tag[
'hitcount'] = (int)$tagHitcounts[$tagName];
94 $isSoftware = isset( $softwareDefinedTags[$tagName] );
95 $isExplicit = isset( $explicitlyDefinedTags[$tagName] );
98 $tag[
'defined'] = $isSoftware || $isExplicit;
105 $tag[
'source'][] =
'extension';
108 $tag[
'source'][] =
'manual';
113 $tag[
'active'] = $isExplicit || isset( $softwareActivatedTags[$tagName] );
116 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $tag );
123 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'tag' );
136 ParamValidator::PARAM_DEFAULT => 10,
137 ParamValidator::PARAM_TYPE =>
'limit',
138 IntegerDef::PARAM_MIN => 1,
143 ParamValidator::PARAM_DEFAULT =>
'',
144 ParamValidator::PARAM_TYPE => [
152 ParamValidator::PARAM_ISMULTI =>
true,
160 'action=query&list=tags&tgprop=displayname|description|hitcount|defined'
161 =>
'apihelp-query+tags-example-simple',
166 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tags';
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
This is the main query class.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()