Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172098

Change subject: Hide change tags whose description messages are disabled
......................................................................

Hide change tags whose description messages are disabled

If an interface message describing the given tag exists, check if it has been
disabled. If so, take that as an indication that the tag should not be
displayed.

This amounts to an adequate (if somewhat low-level) interface for managing
which edit tags are shown in change list views like Special:RecentChanges and
Special:Contributions.

This patch is based on a suggestion made by Jack McBarn in a review comment on
change Iec9befeba. I did it in a separate change because I'd be interested in
hiding the HHVM tag even if we end up deciding against a generic mechanism for
hiding tags.

Change-Id: I515cf2118ab929da985d6b40481325640e800dcd
---
M RELEASE-NOTES-1.25
M includes/ChangeTags.php
2 files changed, 31 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/98/172098/1

diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index b649c2b..71ac309 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -182,6 +182,8 @@
   <https://www.mediawiki.org/xml/export-0.10.xsd>.
 * MWFunction::call() and MWFunction::callArray() were removed, having being
   deprecated in 1.22.
+* ChangeTags::tagDescription() will return false if the interface message
+  for the tag is disabled.
 
 == Compatibility ==
 
diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php
index a3c2360..2fb88f1 100644
--- a/includes/ChangeTags.php
+++ b/includes/ChangeTags.php
@@ -34,23 +34,26 @@
        public static function formatSummaryRow( $tags, $page ) {
                global $wgLang;
 
-               if ( !$tags ) {
-                       return array( '', array() );
-               }
-
                $classes = array();
-
-               $tags = explode( ',', $tags );
                $displayTags = array();
-               foreach ( $tags as $tag ) {
+               foreach ( explode( ',', $tags ) as $tag ) {
+                       $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 ) )
@@ -61,16 +64,29 @@
        }
 
        /**
-        * 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 );
+               } else if ( !$msg->isDisabled() ) {
+                       // Message exists and isn't disabled, so use it.
+                       return $msg->parse();
+               } else {
+                       // If the message exists but is disabled, don't show 
the tag.
+                       return false;
+               }
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/172098
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I515cf2118ab929da985d6b40481325640e800dcd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to