X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fchangetags%2FChangeTags.php;h=95848ea0850eda0d9eebec0b1b40c9c48cad4530;hb=a18476eab39dc201384c68cbd27228c5af32f7fc;hp=fa981247c2020e33694fdb250ee7e6096c5b9680;hpb=d6276525455e6a00fffc90229ef81a1fc8feaa25;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index fa981247c2..95848ea085 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -32,10 +32,45 @@ class ChangeTags { */ const MAX_DELETE_USES = 5000; + private static $definedSoftwareTags = [ + 'mw-contentmodelchange', + 'mw-new-redirect', + 'mw-removed-redirect', + 'mw-changed-redirect-target', + 'mw-blank', + 'mw-replace', + 'mw-rollback', + 'mw-undo', + ]; + /** - * @var string[] + * Loads defined core tags, checks for invalid types (if not array), + * and filters for supported and enabled (if $all is false) tags only. + * + * @param bool $all If true, return all valid defined tags. Otherwise, return only enabled ones. + * @return array Array of all defined/enabled tags. */ - private static $coreTags = [ 'mw-contentmodelchange' ]; + public static function getSoftwareTags( $all = false ) { + global $wgSoftwareTags; + $softwareTags = []; + + if ( !is_array( $wgSoftwareTags ) ) { + wfWarn( 'wgSoftwareTags should be associative array of enabled tags. + Please refer to documentation for the list of tags you can enable' ); + return $softwareTags; + } + + $availableSoftwareTags = !$all ? + array_keys( array_filter( $wgSoftwareTags ) ) : + array_keys( $wgSoftwareTags ); + + $softwareTags = array_intersect( + $availableSoftwareTags, + self::$definedSoftwareTags + ); + + return $softwareTags; + } /** * Creates HTML for the given tags @@ -100,7 +135,7 @@ class ChangeTags { * exists, provided it is not disabled. If the message is disabled, * we consider the tag hidden, and return false. * - * @param string $tag Tag + * @param string $tag * @param IContextSource $context * @return string|bool Tag description or false if tag is to be hidden. * @since 1.25 Returns false if tag is to be hidden. @@ -127,7 +162,7 @@ class ChangeTags { * or if message is disabled, returns false. Otherwise, returns the message object * for the long description. * - * @param string $tag Tag + * @param string $tag * @param IContextSource $context * @return Message|bool Message object of the tag long description or false if * there is no description. @@ -1210,7 +1245,7 @@ class ChangeTags { */ public static function listSoftwareActivatedTags() { // core active tags - $tags = self::$coreTags; + $tags = self::getSoftwareTags(); if ( !Hooks::isRegistered( 'ChangeTagsListActive' ) ) { return $tags; } @@ -1301,7 +1336,7 @@ class ChangeTags { */ public static function listSoftwareDefinedTags() { // core defined tags - $tags = self::$coreTags; + $tags = self::getSoftwareTags( true ); if ( !Hooks::isRegistered( 'ListDefinedTags' ) ) { return $tags; }