X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQueryTags.php;h=45f73b206a3d26e46f730be507a375e7993b0484;hb=e35e90f7d222b21f568d61ccaf9d7f1ab9530e60;hp=7f2dc85fb7dca82d6073edd293ef899be28bbaef;hpb=bd95dc1d5c345ed94fac17dc060e0432a5912c8c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQueryTags.php b/includes/api/ApiQueryTags.php index 7f2dc85fb7..45f73b206a 100644 --- a/includes/api/ApiQueryTags.php +++ b/includes/api/ApiQueryTags.php @@ -44,11 +44,17 @@ class ApiQueryTags extends ApiQueryBase { $fld_description = isset( $prop['description'] ); $fld_hitcount = isset( $prop['hitcount'] ); $fld_defined = isset( $prop['defined'] ); + $fld_source = isset( $prop['source'] ); + $fld_active = isset( $prop['active'] ); $limit = $params['limit']; $result = $this->getResult(); - $definedTags = array_fill_keys( ChangeTags::listDefinedTags(), 0 ); + $extensionDefinedTags = array_fill_keys( ChangeTags::listExtensionDefinedTags(), 0 ); + $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 ); + $extensionActivatedTags = array_fill_keys( ChangeTags::listExtensionActivatedTags(), 0 ); + + $definedTags = array_merge( $extensionDefinedTags, $explicitlyDefinedTags ); # Fetch defined tags that aren't past the continuation if ( $params['continue'] !== null ) { @@ -99,8 +105,25 @@ class ApiQueryTags extends ApiQueryBase { $tag['hitcount'] = $hitcount; } - if ( $fld_defined && isset( $definedTags[$tagName] ) ) { - $tag['defined'] = ''; + $isExtension = isset( $extensionDefinedTags[$tagName] ); + $isExplicit = isset( $explicitlyDefinedTags[$tagName] ); + + if ( $fld_defined ) { + $tag['defined'] = $isExtension || $isExplicit; + } + + if ( $fld_source ) { + $tag['source'] = array(); + if ( $isExtension ) { + $tag['source'][] = 'extension'; + } + if ( $isExplicit ) { + $tag['source'][] = 'manual'; + } + } + + if ( $fld_active ) { + $tag['active'] = $isExplicit || isset( $extensionActivatedTags[$tagName] ); } $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $tag ); @@ -110,7 +133,7 @@ class ApiQueryTags extends ApiQueryBase { } } - $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'tag' ); + $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'tag' ); } public function getCacheMode( $params ) { @@ -137,6 +160,8 @@ class ApiQueryTags extends ApiQueryBase { 'description', 'hitcount', 'defined', + 'source', + 'active', ), ApiBase::PARAM_ISMULTI => true )