37 parent::__construct( $query, $moduleName,
'tg' );
38 $this->changeTagsStore = $changeTagsStore;
44 $prop = array_fill_keys( $params[
'prop'],
true );
46 $fld_displayname = isset( $prop[
'displayname'] );
47 $fld_description = isset( $prop[
'description'] );
48 $fld_hitcount = isset( $prop[
'hitcount'] );
49 $fld_defined = isset( $prop[
'defined'] );
50 $fld_source = isset( $prop[
'source'] );
51 $fld_active = isset( $prop[
'active'] );
53 $limit = $params[
'limit'];
56 $softwareDefinedTags = array_fill_keys( $this->changeTagsStore->listSoftwareDefinedTags(), 0 );
57 $explicitlyDefinedTags = array_fill_keys( $this->changeTagsStore->listExplicitlyDefinedTags(), 0 );
58 $softwareActivatedTags = array_fill_keys( $this->changeTagsStore->listSoftwareActivatedTags(), 0 );
60 $tagHitcounts = array_merge(
62 $explicitlyDefinedTags,
63 $this->changeTagsStore->tagUsageStatistics()
65 $tags = array_keys( $tagHitcounts );
67 # Fetch defined tags that aren't past the continuation
68 if ( $params[
'continue'] !==
null ) {
69 $cont = $params[
'continue'];
70 $tags = array_filter( $tags,
static function ( $v ) use ( $cont ) {
75 # Now make sure the array is sorted for proper continuation
79 foreach ( $tags as $tagName ) {
80 if ( ++$count > $limit ) {
86 $tag[
'name'] = $tagName;
88 if ( $fld_displayname ) {
92 if ( $fld_description ) {
93 $msg = $this->
msg(
"tag-$tagName-description" );
94 $tag[
'description'] = $msg->exists() ? $msg->text() :
'';
97 if ( $fld_hitcount ) {
98 $tag[
'hitcount'] = (int)$tagHitcounts[$tagName];
101 $isSoftware = isset( $softwareDefinedTags[$tagName] );
102 $isExplicit = isset( $explicitlyDefinedTags[$tagName] );
104 if ( $fld_defined ) {
105 $tag[
'defined'] = $isSoftware || $isExplicit;
112 $tag[
'source'][] =
'extension';
115 $tag[
'source'][] =
'manual';
120 $tag[
'active'] = $isExplicit || isset( $softwareActivatedTags[$tagName] );
123 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $tag );
130 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'tag' );
143 ParamValidator::PARAM_DEFAULT => 10,
144 ParamValidator::PARAM_TYPE =>
'limit',
145 IntegerDef::PARAM_MIN => 1,
150 ParamValidator::PARAM_DEFAULT =>
'',
151 ParamValidator::PARAM_TYPE => [
159 ParamValidator::PARAM_ISMULTI =>
true,
167 'action=query&list=tags&tgprop=displayname|description|hitcount|defined'
168 =>
'apihelp-query+tags-example-simple',
173 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, or 'string' with PARAM_ISMULTI,...
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()