40 parent::__construct( $query, $moduleName,
'tg' );
41 $this->changeTagsStore = $changeTagsStore;
47 $prop = array_fill_keys(
$params[
'prop'],
true );
49 $fld_displayname = isset( $prop[
'displayname'] );
50 $fld_description = isset( $prop[
'description'] );
51 $fld_hitcount = isset( $prop[
'hitcount'] );
52 $fld_defined = isset( $prop[
'defined'] );
53 $fld_source = isset( $prop[
'source'] );
54 $fld_active = isset( $prop[
'active'] );
59 $softwareDefinedTags = array_fill_keys( $this->changeTagsStore->listSoftwareDefinedTags(), 0 );
60 $explicitlyDefinedTags = array_fill_keys( $this->changeTagsStore->listExplicitlyDefinedTags(), 0 );
61 $softwareActivatedTags = array_fill_keys( $this->changeTagsStore->listSoftwareActivatedTags(), 0 );
63 $tagHitcounts = array_merge(
65 $explicitlyDefinedTags,
66 $this->changeTagsStore->tagUsageStatistics()
68 $tags = array_keys( $tagHitcounts );
70 # Fetch defined tags that aren't past the continuation
71 if (
$params[
'continue'] !==
null ) {
73 $tags = array_filter( $tags,
static function ( $v ) use ( $cont ) {
78 # Now make sure the array is sorted for proper continuation
82 foreach ( $tags as $tagName ) {
83 if ( ++$count > $limit ) {
89 $tag[
'name'] = $tagName;
91 if ( $fld_displayname ) {
95 if ( $fld_description ) {
96 $msg = $this->
msg(
"tag-$tagName-description" );
97 $tag[
'description'] = $msg->exists() ? $msg->text() :
'';
100 if ( $fld_hitcount ) {
101 $tag[
'hitcount'] = (int)$tagHitcounts[$tagName];
104 $isSoftware = isset( $softwareDefinedTags[$tagName] );
105 $isExplicit = isset( $explicitlyDefinedTags[$tagName] );
107 if ( $fld_defined ) {
108 $tag[
'defined'] = $isSoftware || $isExplicit;
114 $tag[
'source'][] =
'software';
116 $tag[
'source'][] =
'extension';
119 $tag[
'source'][] =
'manual';
124 $tag[
'active'] = $isExplicit || isset( $softwareActivatedTags[$tagName] );
127 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $tag );
134 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'tag' );
147 ParamValidator::PARAM_DEFAULT => 10,
148 ParamValidator::PARAM_TYPE =>
'limit',
149 IntegerDef::PARAM_MIN => 1,
154 ParamValidator::PARAM_DEFAULT =>
'',
155 ParamValidator::PARAM_TYPE => [
163 ParamValidator::PARAM_ISMULTI =>
true,
171 'action=query&list=tags&tgprop=displayname|description|hitcount|defined'
172 =>
'apihelp-query+tags-example-simple',
177 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tags';
182class_alias( ApiQueryTags::class,
'ApiQueryTags' );
array $params
The job parameters.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()