Add legend to Special:RecentChanges and Special:Watchlist
authorScimonster <tehalmightyscimonster@gmail.com>
Sun, 24 Nov 2013 09:30:50 +0000 (11:30 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Sun, 24 Nov 2013 17:13:03 +0000 (18:13 +0100)
Bug: 52005
Change-Id: Iabf4873ff8534ddf39bc8bbef79214fd3138e984

includes/specials/SpecialRecentchanges.php
includes/specials/SpecialWatchlist.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc
resources/mediawiki.special/mediawiki.special.changeslist.css

index 23203ea..e8e35aa 100644 (file)
@@ -562,6 +562,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                $nondefaults = $opts->getChangedValues();
 
                $panel = array();
+               $panel[] = self::makeLegend( $this->getContext() );
                $panel[] = $this->optionsPanel( $defaults, $nondefaults );
                $panel[] = '<hr />';
 
@@ -653,6 +654,59 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                return $extraOpts;
        }
 
+       /**
+        * Return the legend displayed within the fieldset
+        *
+        * @param $context the object available as $this in non-static functions
+        * @return string
+        */
+       public static function makeLegend( IContextSource $context ) {
+               $user = $context->getUser();
+               # The legend showing what the letters and stuff mean
+               $legend = Xml::openElement( 'dl', array( 'class' => 'mw-changeslist-legend' ) ) . "\n";
+               # Iterates through them and gets the messages for both letter and tooltip
+               # Messages:
+               # * minoreditletter
+               # * boteditletter
+               # * newpageletter
+               # * unpatrolledletter
+               # * recentchanges-label-minor
+               # * recentchanges-label-bot
+               # * recentchanges-label-newpage
+               # * recentchanges-label-unpatrolled
+               $legendItems = array( 'newpage' => 'newpage', 'minor' => 'minoredit', 'bot' => 'botedit' );
+               if ( $user->useRCPatrol() ) {
+                       $legendItems['unpatrolled'] = 'unpatrolled';
+               }
+               foreach ( $legendItems as $label => $letter ) { # generate items of the legend
+                       $legend .= Xml::element( 'dt',
+                               array( 'class' => $label ), $context->msg( $letter . 'letter' )->text()
+                       ) . "\n";
+                       if ( $letter === 'newpage' ) {
+                               $legend .= Xml::openElement( 'dd' );
+                               $legend .= $context->msg( "recentchanges-label-$label" )->escaped();
+                               $legend .= ' ' . $context->msg( 'recentchanges-legend-newpage' )->parse();
+                               $legend .= Xml::closeElement( 'dd' ) . "\n";
+                       } else {
+                               $legend .= Xml::element( 'dd', array(),
+                                       $context->msg( "recentchanges-label-$label" )->text()
+                               ) . "\n";
+                       }
+               }
+               # (+-123)
+               $legend .= Xml::tags( 'dt',
+                       array( 'class' => 'mw-plusminus-pos' ),
+                       $context->msg( 'recentchanges-legend-plusminus' )->parse()
+               ) . "\n";
+               $legend .= Xml::element(
+                       'dd',
+                       array( 'class' => 'mw-changeslist-legend-plusminus' ),
+                       $context->msg( 'recentchanges-label-plusminus' )->text()
+               ) . "\n";
+               $legend .= Xml::closeElement( 'dl' ) . "\n";
+               return $legend;
+       }
+
        /**
         * Send the text to be displayed above the options
         *
index 2c511f5..154825a 100644 (file)
@@ -39,6 +39,7 @@ class SpecialWatchlist extends SpecialPage {
 
                $user = $this->getUser();
                $output = $this->getOutput();
+               $output->addModuleStyles( 'mediawiki.special.changeslist' );
 
                # Anons don't get a watchlist
                $this->requireLogin( 'watchlistanontext' );
@@ -255,6 +256,8 @@ class SpecialWatchlist extends SpecialPage {
                        array( 'id' => 'mw-watchlist-options' )
                );
 
+               $form .= SpecialRecentChanges::makeLegend( $this->getContext() );
+
                $tables = array( 'recentchanges', 'watchlist' );
                $fields = RecentChange::selectFields();
                $join_conds = array(
index ea1f20c..3720b05 100644 (file)
@@ -2209,6 +2209,9 @@ Your email address is not revealed when other users contact you.',
 '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',
+'recentchanges-label-plusminus'     => 'The page size changed by this number of bytes',
+'recentchanges-legend-newpage'      => '(also see [[Special:NewPages|list of new pages]])',
+'recentchanges-legend-plusminus'    => "(''±123'')",
 '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',
index f1da92f..cca04d2 100644 (file)
  * @author SPQRobin
  * @author Sanbec
  * @author Sborsody
+ * @author Scimonster
  * @author Se4598
  * @author Seb35
  * @author Sherbrooke
@@ -3589,6 +3590,9 @@ See also:
 'recentchanges-label-minor' => 'Tooltip for {{msg-mw|minoreditletter}}',
 'recentchanges-label-bot' => 'Tooltip for {{msg-mw|boteditletter}}',
 'recentchanges-label-unpatrolled' => 'Tooltip for {{msg-mw|unpatrolledletter}}',
+'recentchanges-label-plusminus' => 'Legend item for plus/minus',
+'recentchanges-legend-newpage' => 'A link to [[Special:NewPages]]',
+'recentchanges-legend-plusminus' => 'A plus/minus sign with a number for the legend.',
 'rcnote' => 'Used on [[Special:RecentChanges]].
 
 Similar to {{msg-mw|wlnote}} which is used on [[Special:Watchlist]].
index a6c99bd..02a4002 100644 (file)
@@ -1328,6 +1328,9 @@ $wgMessageStructure = array(
                'recentchanges-label-minor',
                'recentchanges-label-bot',
                'recentchanges-label-unpatrolled',
+               'recentchanges-label-plusminus',
+               'recentchanges-legend-newpage',
+               'recentchanges-legend-plusminus',
                'rcnote',
                'rcnotefrom',
                'rclistfrom',
index 5e4af7b..b96a26e 100644 (file)
@@ -5,3 +5,27 @@
 .mw-changeslist-line-watched .mw-title {
        font-weight: bold;
 }
+
+.mw-changeslist-legend {
+       float: right;
+       margin-left: 1em;
+       margin-bottom: 0.5em;
+       clear: right;
+       font-size: 85%;
+       line-height: 1.2em;
+       padding: 0.5em;
+       border: 1px solid #ddd;
+}
+
+.mw-changeslist-legend dt {
+       float: left;
+}
+
+.mw-changeslist-legend dd {
+       margin-left: 1.5em;
+       line-height: 1.3em;
+}
+
+.mw-changeslist-legend dd.mw-changeslist-legend-plusminus {
+       margin-left: 3.5em;
+}