Add legend and tooltips to explain RC flags
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 2 Aug 2009 22:15:55 +0000 (22:15 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 2 Aug 2009 22:15:55 +0000 (22:15 +0000)
Based on a patch submitted by svip on IRC.  I also changed the <span>
for unpatrolled into an <abbr>, and created a new message in case anyone
wants to localize !, for the sake of uniformity.

CREDITS
RELEASE-NOTES
includes/ChangesList.php
includes/specials/SpecialRecentchanges.php
languages/messages/MessagesEn.php
maintenance/language/messageTypes.inc
maintenance/language/messages.inc
skins/common/shared.css

diff --git a/CREDITS b/CREDITS
index df88b0b..6aa650b 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -102,6 +102,7 @@ following names for their contribution to the product.
 * Simon Walker
 * Stefano Codari
 * Str4nd
+* svip
 
 == Translators ==
 * Anders Wegge Jakobsen
index dee4461..de2d514 100644 (file)
@@ -180,6 +180,8 @@ this. Was used when mwEmbed was going to be an extension.
 * (bug 16322) Allow maintenance scripts to accept DB user/pass over input or params
 * (bug 18566) Maintenance script to un/protect pages
 * (bug 671) The HTML <abbr> tag is now permitted.
+* RecentChanges now has a legend to explain what the Nmb! flags mean, and the
+  flags have tooltips.
 
 === Bug fixes in 1.16 ===
 
index b51b166..2691dd4 100644 (file)
@@ -68,8 +68,8 @@ class ChangesList {
         */
        private function preCacheMessages() {
                if( !isset( $this->message ) ) {
-                       foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
-                               'blocklink history boteditletter semicolon-separator pipe-separator' ) as $msg ) {
+                       foreach ( explode( ' ', 'cur diff hist last blocklink history ' .
+                       'semicolon-separator pipe-separator' ) as $msg ) {
                                $this->message[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
                        }
                }
@@ -86,15 +86,43 @@ class ChangesList {
         * @return string
         */
        protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = '&nbsp;', $bot = false ) {
-               $f = $new ?
-                       '<abbr class="newpage">' . $this->message['newpageletter'] . '</abbr>' : $nothing;
-               $f .= $minor ?
-                       '<abbr class="minor">' . $this->message['minoreditletter'] . '</abbr>' : $nothing;
-               $f .= $bot ? '<abbr class="bot">' . $this->message['boteditletter'] . '</abbr>' : $nothing;
-               $f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
+               $f = $new ? self::flag( 'newpage' ) : $nothing;
+               $f .= $minor ? self::flag( 'minor' ) : $nothing;
+               $f .= $bot ? self::flag( 'bot' ) : $nothing;
+               $f .= $patrolled ? self::flag( 'unpatrolled' ) : $nothing;
                return $f;
        }
 
+       /**
+        * Provide the <abbr> element appropriate to a given abbreviated flag,
+        * namely the flag indicating a new page, a minor edit, a bot edit, or an
+        * unpatrolled edit.  By default in English it will contain "N", "m", "b",
+        * "!" respectively, plus it will have an appropriate title and class.
+        *
+        * @param $key string 'newpage', 'unpatrolled', 'minor', or 'bot'
+        * @return string Raw HTML
+        */
+       public static function flag( $key ) {
+               static $messages = null;
+               if ( is_null( $messages ) ) {
+                       foreach ( explode( ' ', 'minoreditletter boteditletter newpageletter ' .
+                       'unpatrolledletter recentchanges-label-minor recentchanges-label-bot ' .
+                       'recentchanges-label-newpage recentchanges-label-unpatrolled' ) as $msg ) {
+                               $messages[$msg] = wfMsgExt( $msg, 'escapenoentities' );
+                       }
+               }
+               # Inconsistent naming, bleh
+               if ( $key == 'newpage' || $key == 'unpatrolled' ) {
+                       $key2 = $key;
+               } else {
+                       $key2 = $key . 'edit';
+               }
+               return "<abbr class=\"$key\" title=\""
+                       . $messages["recentchanges-label-$key"] . "\">"
+                       . $messages["${key2}letter"]
+                       . '</abbr>';
+       }
+
        /**
         * Returns text for the start of the tabular part of RC
         * @return string
index caeda53..04dfb40 100644 (file)
@@ -457,6 +457,13 @@ class SpecialRecentChanges extends SpecialPage {
                        Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
                );
 
+               # TODO: This is probably a bad format for the message.  If anyone
+               # customizes it and we add a new flag, it won't show up in the
+               # customized message unless it's changed.
+               $wgOut->addWikiMsg( 'recentchanges-label-legend',
+                       ChangesList::flag( 'newpage' ), ChangesList::flag( 'minor' ),
+                       ChangesList::flag( 'bot' ), ChangesList::flag( 'unpatrolled' ) );
+
                $this->setBottomText( $wgOut, $opts );
        }
 
index 5b4f06f..24068e4 100644 (file)
@@ -1963,6 +1963,11 @@ You can also choose to let others contact you through your user or talk page wit
 'recentchanges-legend'              => 'Recent changes options',
 'recentchangestext'                 => 'Track the most recent changes to the wiki on this page.',
 'recentchanges-feed-description'    => 'Track the most recent changes to the wiki in this feed.',
+'recentchanges-label-legend'        => "Legend: $1 - new page, $2 - minor edit, $3 - bot edit, $4 - unpatrolled edit.",
+'recentchanges-label-newpage'       => 'This edit created a new page',
+'recentchanges-label-minor'         => 'This is a minor edit',
+'recentchanges-label-bot'           => 'This edit was performed by a bot',
+'recentchanges-label-unpatrolled'   => 'This edit has not yet been patrolled',
 'rcnote'                            => "Below {{PLURAL:$1|is '''1''' change|are the last '''$1''' changes}} in the last {{PLURAL:$2|day|'''$2''' days}}, as of $5, $4.",
 'rcnotefrom'                        => "Below are the changes since '''$2''' (up to '''$1''' shown).",
 'rclistfrom'                        => 'Show new changes starting from $1',
@@ -1980,6 +1985,7 @@ You can also choose to let others contact you through your user or talk page wit
 'minoreditletter'                   => 'm',
 'newpageletter'                     => 'N',
 'boteditletter'                     => 'b',
+'unpatrolledletter'                 => '!', # only translate this message to other languages if you have to change it
 'sectionlink'                       => '→', # only translate this message to other languages if you have to change it
 'number_of_watching_users_RCview'   => '[$1]', # do not translate or duplicate this message to other languages
 'number_of_watching_users_pageview' => '[$1 watching {{PLURAL:$1|user|users}}]',
index b6af4b2..35cb1bf 100644 (file)
@@ -341,6 +341,7 @@ $wgOptionalMessages = array(
        'timezone-utc',
        'whatlinkshere-backlink',
        'recentchangeslinked-backlink',
+       'unpatrolledletter',
        'diff-with-additional',
        'pagetitle-view-mainpage',
        'trackback',
index 2061faf..d7bc8f6 100644 (file)
@@ -1149,6 +1149,11 @@ $wgMessageStructure = array(
                'recentchanges-legend',
                'recentchangestext',
                'recentchanges-feed-description',
+               'recentchanges-label-legend',
+               'recentchanges-label-newpage',
+               'recentchanges-label-minor',
+               'recentchanges-label-bot',
+               'recentchanges-label-unpatrolled',
                'rcnote',
                'rcnotefrom',
                'rclistfrom',
@@ -1166,6 +1171,7 @@ $wgMessageStructure = array(
                'minoreditletter',
                'newpageletter',
                'boteditletter',
+               'unpatrolledletter',
                'sectionlink',
                'number_of_watching_users_RCview',
                'number_of_watching_users_pageview',
index 1287c9d..626094f 100644 (file)
@@ -68,7 +68,7 @@ li span.deleted, span.history-deleted {
        background-color: #ffa;
 }
 
-span.unpatrolled {
+.unpatrolled {
        font-weight: bold;
        color: red;
 }
@@ -436,7 +436,7 @@ td.os-suggest-result-hl {
 }
 
 /** Generic minor/bot/newpage styling */
-abbr.newpage, abbr.minor, abbr.bot {
+.newpage, .minor, .bot {
        font-weight: bold;
 }