Merge "ChangeTags: Hide tags whose description messages are disabled"

This commit is contained in:
jenkins-bot 2015-04-16 01:37:10 +00:00 committed by Gerrit Code Review
commit a20cb3a525
2 changed files with 38 additions and 7 deletions

View file

@ -11,12 +11,16 @@ production.
=== Configuration changes in 1.26 ===
=== New features in 1.26 ===
* Change tags can now be hidden in the interface by disabling the associated
"tag-<id>" interface message.
==== External libraries ====
=== Bug fixes in 1.26 ===
=== Action API changes in 1.26 ===
* API action=query&list=tags: The displayname can now be boolean false if the
tag is meant to be hidden from user interfaces.
=== Action API internal changes in 1.26 ===
@ -28,7 +32,8 @@ changes to languages because of Bugzilla reports.
=== Other changes in 1.26 ===
* ChangeTags::tagDescription() will return false if the interface message
for the tag is disabled.
== Compatibility ==

View file

@ -51,14 +51,26 @@ class ChangeTags {
$tags = explode( ',', $tags );
$displayTags = array();
foreach ( $tags as $tag ) {
if ( !$tag ) {
continue;
}
$description = self::tagDescription( $tag );
if ( $description === false ) {
continue;
}
$displayTags[] = Xml::tags(
'span',
array( 'class' => 'mw-tag-marker ' .
Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ),
self::tagDescription( $tag )
$description
);
$classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
}
if ( !$displayTags ) {
return array( '', array() );
}
$markers = wfMessage( 'tag-list-wrapper' )
->numParams( count( $displayTags ) )
->rawParams( $wgLang->commaList( $displayTags ) )
@ -69,16 +81,30 @@ class ChangeTags {
}
/**
* Get a short description for a tag
* Get a short description for a tag.
*
* Checks if message key "mediawiki:tag-$tag" exists. If it does not,
* returns the HTML-escaped tag name. Uses the message if the message
* exists, provided it is not disabled. If the message is disabled,
* we consider the tag hidden, and return false.
*
* @param string $tag Tag
*
* @return string Short description of the tag from "mediawiki:tag-$tag" if this message exists,
* html-escaped version of $tag otherwise
* @return string|bool Tag description or false if tag is to be hidden.
* @since 1.25 Returns false if tag is to be hidden.
*/
public static function tagDescription( $tag ) {
$msg = wfMessage( "tag-$tag" );
return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag );
if ( !$msg->exists() ) {
// No such message, so return the HTML-escaped tag name.
return htmlspecialchars( $tag );
}
if ( $msg->isDisabled() ) {
// The message exists but is disabled, hide the tag.
return false;
}
// Message exists and isn't disabled, use it.
return $msg->parse();
}
/**