Matmarex has uploaded a new change for review.

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


Change subject: SpecialRecentChanges: Rewrite the options form
......................................................................

SpecialRecentChanges: Rewrite the options form

Gotten rid of the ugly links you had to click one after another,
previously wrapped in 'rclinks' message. Instead there's a lovely form
with dropdown select boxes and checkboxes.

Affects Special:RecentChanges and Special:RecentChangesLinked. The
same should be done for Special:Watchlist, but that'd probably be best
solved by refactoring it to extend SpecialRecentChanges (bug 48641).

Messages modified: 'rcshowhideminor', 'rcshowhidebots',
'rcshowhideliu', 'rcshowhideanons', 'rcshowhidepatr', 'rcshowhidemine'
Messages added: 'rcshowlast', 'rcshowhide'
Message removed: 'rclinks'

Bug: 48615
Change-Id: I0fcc95850aa13ea7f4b5a4fdcfddb8ca6b66bf88
---
M includes/specials/SpecialRecentchanges.php
M languages/messages/MessagesEn.php
M languages/messages/MessagesQqq.php
M maintenance/language/messages.inc
4 files changed, 123 insertions(+), 83 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/15/64615/1

diff --git a/includes/specials/SpecialRecentchanges.php 
b/includes/specials/SpecialRecentchanges.php
index 1e91d51..3b5dfc1 100644
--- a/includes/specials/SpecialRecentchanges.php
+++ b/includes/specials/SpecialRecentchanges.php
@@ -666,18 +666,28 @@
         * @return array
         */
        function getExtraOptions( $opts ) {
-               $opts->consumeValues( array(
-                       'namespace', 'invert', 'associated', 'tagfilter', 
'categories', 'categories_any'
-               ) );
-
                $extraOpts = array();
+
+               $opts->consumeValues( array( 'hideminor', 'hidebots', 
'hideanons', 'hideliu', 'hidepatrolled', 'hidemyself' ) );
+               $extraOpts['show'] = $this->showFilterForm( $opts );
+
+               // Consume 'from' as it would otherwise overwrite 'days'
+               $opts->consumeValues( array( 'days', 'from' ) );
+               $extraOpts['showlast'] = $this->showlastFilterForm( $opts );
+
+               $opts->consumeValues( array( 'limit' ) );
+               $extraOpts['limit'] = $this->limitFilterForm( $opts );
+
+               $opts->consumeValues( array( 'namespace', 'invert', 
'associated' ) );
                $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
 
+               $opts->consumeValues( array( 'categories', 'categories_any' ) );
                global $wgAllowCategorizedRecentChanges;
                if ( $wgAllowCategorizedRecentChanges ) {
                        $extraOpts['category'] = $this->categoryFilterForm( 
$opts );
                }
 
+               $opts->consumeValues( array( 'tagfilter' ) );
                $tagFilter = ChangeTags::buildTagFilterSelector( 
$opts['tagfilter'] );
                if ( count( $tagFilter ) ) {
                        $extraOpts['tagfilter'] = $tagFilter;
@@ -745,6 +755,91 @@
                );
 
                return array( $nsLabel, "$nsSelect $invert $associated" );
+       }
+
+       /**
+        * Creates the 'show bots/logged in/anons/...' checkboxes
+        *
+        * @param FormOptions $opts
+        * @return string
+        */
+       protected function showFilterForm( FormOptions $opts ) {
+               $user = $this->getUser();
+               $checkboxes = array();
+
+               $filters = array(
+                       'hideminor' => 'rcshowhideminor',
+                       'hidebots' => 'rcshowhidebots',
+                       'hideanons' => 'rcshowhideanons',
+                       'hideliu' => 'rcshowhideliu',
+                       'hidepatrolled' => 'rcshowhidepatr',
+                       'hidemyself' => 'rcshowhidemine',
+               );
+               foreach ( $this->getCustomFilters() as $key => $params ) {
+                       $filters[$key] = $params['msg'];
+               }
+               // Disable some if needed
+               if ( !$user->useRCPatrol() ) {
+                       unset( $filters['hidepatrolled'] );
+               }
+
+               foreach ( $filters as $key => $msg ) {
+                       $checkboxes[] = Xml::checkLabel(
+                               $this->msg( $msg )->text(),
+                               $key,
+                               "mw-recentchanges-showhide-$key",
+                               $opts[$key]
+                       );
+               }
+
+               return array(
+                       Xml::label( $this->msg( 'rcshowhide' ) ),
+                       implode( ' ', $checkboxes ),
+               );
+       }
+
+       /**
+        * Creates the 'show last days' selector
+        *
+        * @param FormOptions $opts
+        * @return string
+        */
+       protected function showlastFilterForm( FormOptions $opts ) {
+               global $wgRCLinkDays;
+
+               $lang = $this->getLanguage();
+               $select = new XmlSelect( 'days', false, $opts['days'] );
+
+               foreach ( $wgRCLinkDays as $value ) {
+                       $select->addOption( $lang->formatTimePeriod( $value * 
24 * 60 * 60 ) , $value );
+               }
+
+               return array(
+                       Xml::label( $this->msg( 'rcshowlast' ) ),
+                       $select->getHTML(),
+               );
+       }
+
+       /**
+        * Creates the 'limit' selector
+        *
+        * @param FormOptions $opts
+        * @return string
+        */
+       protected function limitFilterForm( FormOptions $opts ) {
+               global $wgRCLinkLimits;
+
+               $lang = $this->getLanguage();
+               $select = new XmlSelect( 'limit', false, $opts['limit'] );
+
+               foreach ( $wgRCLinkLimits as $value ) {
+                       $select->addOption( $lang->formatNum( $value ) , $value 
);
+               }
+
+               return array(
+                       Xml::label( $this->msg( 'rclimit' ) ),
+                       $select->getHTML(),
+               );
        }
 
        /**
@@ -883,67 +978,16 @@
                                $lang->userTime( $options['from'], $user ) 
)->parse() . '<br />';
                }
 
-               # Sort data for display and make sure it's unique after we've 
added user data.
-               $wgRCLinkLimits[] = $options['limit'];
-               $wgRCLinkDays[] = $options['days'];
-               sort( $wgRCLinkLimits );
-               sort( $wgRCLinkDays );
-               $wgRCLinkLimits = array_unique( $wgRCLinkLimits );
-               $wgRCLinkDays = array_unique( $wgRCLinkDays );
-
-               // limit links
-               $cl = array();
-               foreach ( $wgRCLinkLimits as $value ) {
-                       $cl[] = $this->makeOptionsLink( $lang->formatNum( 
$value ),
-                               array( 'limit' => $value ), $nondefaults, 
$value == $options['limit'] );
-               }
-               $cl = $lang->pipeList( $cl );
-
-               // day links, reset 'from' to none
-               $dl = array();
-               foreach ( $wgRCLinkDays as $value ) {
-                       $dl[] = $this->makeOptionsLink( $lang->formatNum( 
$value ),
-                               array( 'days' => $value, 'from' => '' ), 
$nondefaults, $value == $options['days'] );
-               }
-               $dl = $lang->pipeList( $dl );
-
-               // show/hide links
-               $showhide = array( $this->msg( 'show' )->text(), $this->msg( 
'hide' )->text() );
-               $filters = array(
-                       'hideminor' => 'rcshowhideminor',
-                       'hidebots' => 'rcshowhidebots',
-                       'hideanons' => 'rcshowhideanons',
-                       'hideliu' => 'rcshowhideliu',
-                       'hidepatrolled' => 'rcshowhidepatr',
-                       'hidemyself' => 'rcshowhidemine'
-               );
-               foreach ( $this->getCustomFilters() as $key => $params ) {
-                       $filters[$key] = $params['msg'];
-               }
-               // Disable some if needed
-               if ( !$user->useRCPatrol() ) {
-                       unset( $filters['hidepatrolled'] );
-               }
-
-               $links = array();
-               foreach ( $filters as $key => $msg ) {
-                       $link = $this->makeOptionsLink( $showhide[1 - 
$options[$key]],
-                               array( $key => 1 - $options[$key] ), 
$nondefaults );
-                       $links[] = $this->msg( $msg )->rawParams( $link 
)->escaped();
-               }
-
-               // show from this onward link
+               // show "from now onward" link
                $timestamp = wfTimestampNow();
                $now = $lang->userTimeAndDate( $timestamp, $user );
                $tl = $this->makeOptionsLink(
                        $now, array( 'from' => $timestamp ), $nondefaults
                );
 
-               $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, 
$lang->pipeList( $links ) )
-                       ->parse();
                $rclistfrom = $this->msg( 'rclistfrom' )->rawParams( $tl 
)->parse();
 
-               return "{$note}$rclinks<br />$rclistfrom";
+               return "$note<br />$rclistfrom";
        }
 
        /**
diff --git a/languages/messages/MessagesEn.php 
b/languages/messages/MessagesEn.php
index 2606b23..52d5dd9 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -2155,13 +2155,15 @@
 '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',
-'rcshowhideminor'                   => '$1 minor edits',
-'rcshowhidebots'                    => '$1 bots',
-'rcshowhideliu'                     => '$1 logged-in users',
-'rcshowhideanons'                   => '$1 anonymous users',
-'rcshowhidepatr'                    => '$1 patrolled edits',
-'rcshowhidemine'                    => '$1 my edits',
-'rclinks'                           => 'Show last $1 changes in last $2 
days<br />$3',
+'rcshowlast'                        => 'Show last:',
+'rclimit'                           => 'Limit:',
+'rcshowhide'                        => 'Show:',
+'rcshowhideminor'                   => 'Minor edits',
+'rcshowhidebots'                    => 'Bots',
+'rcshowhideliu'                     => 'Logged-in users',
+'rcshowhideanons'                   => 'Anonymous users',
+'rcshowhidepatr'                    => 'Patrolled edits',
+'rcshowhidemine'                    => 'My edits',
 'diff'                              => 'diff',
 'hist'                              => 'hist',
 'hide'                              => 'Hide',
diff --git a/languages/messages/MessagesQqq.php 
b/languages/messages/MessagesQqq.php
index 1492c12..aff5593 100644
--- a/languages/messages/MessagesQqq.php
+++ b/languages/messages/MessagesQqq.php
@@ -2990,24 +2990,17 @@
 * Parameter $3 is a date. (alternative to $1)
 * Parameter $4 is a time. (alternative to $1)',
 'rclistfrom' => 'Used on [[Special:RecentChanges]]. Parameter $1 is a link to 
the revision of a specific date and time. The date and the time are the link 
description (without split of date and time, [[bugzilla:19104|Bug 19104]]). The 
corrosponding message is {{msg-mw|Rcnotefrom}}.',
-'rcshowhideminor' => "Option text in [[Special:RecentChanges]]. Parameters:
-* $1 is the 'show/hide' command, with the text taken from either 
{{msg-mw|show}} or {{msg-mw|hide}}.",
-'rcshowhidebots' => "Option text in [[Special:RecentChanges]]. Parameters:
-* $1 is the 'show/hide' command, with the text taken from either 
{{msg-mw|show}} or {{msg-mw|hide}}.
-{{Identical|$1 bots}}",
-'rcshowhideliu' => 'Option text in [[Special:RecentChanges]]',
-'rcshowhideanons' => "Option text in [[Special:RecentChanges]]. Parameters:
-* $1 is the 'show/hide' command, with the text taken from either 
{{msg-mw|show}} or {{msg-mw|hide}}.
-{{Identical|Anonymous user}}",
-'rcshowhidepatr' => "Option text in [[Special:RecentChanges]]. Parameters:
-* $1 is the 'show/hide' command, with the text taken from either 
{{msg-mw|show}} or {{msg-mw|hide}}.",
-'rcshowhidemine' => "Option text in [[Special:RecentChanges]]. Parameters:
-* $1 is the 'show/hide' command, with the text taken from either 
{{msg-mw|show}} or {{msg-mw|hide}}.",
-'rclinks' => "Used on [[Special:RecentChanges]].
-* '''\$1''' is a list of different choices with number of pages to be 
shown.<br />&nbsp;Example: 
\"''50{{int:pipe-separator}}100{{int:pipe-separator}}250{{int:pipe-separator}}500\".
-* '''\$2''' is a list of clickable links with a number of days for which 
recent changes are to be displayed.<br />&nbsp;Example: 
\"''1{{int:pipe-separator}}3{{int:pipe-separator}}7{{int:pipe-separator}}14{{int:pipe-separator}}30''\".
-* '''\$3''' is a block of text that consists of other messages.<br 
/>&nbsp;Example: \"''Hide minor edits{{int:pipe-separator}}Show 
bots{{int:pipe-separator}}Hide anonymous users{{int:pipe-separator}}Hide 
logged-in users{{int:pipe-separator}}Hide patrolled 
edits{{int:pipe-separator}}Hide my edits''\"
-List elements are separated by {{msg-mw|pipe-separator}} each. Each list 
element is, or contains, a link.",
+'rcshowlast' => "Label for a dropdown select box on [[Special:RecentChanges]].
+'last' refers to a period of time like '6 hours' or '3 days'.",
+'rclimit' => "Label for a dropdown select box on [[Special:RecentChanges]].
+This refers to the maximum number of changes to show, like '50' or '200'.",
+'rcshowhide' => 'Label for a set of checkboxes on [[Special:RecentChanges]], 
each describing one type of edit to be shown or not.',
+'rcshowhideminor' => "Checkbox label on [[Special:RecentChanges]].",
+'rcshowhidebots' => "Checkbox label on [[Special:RecentChanges]].",
+'rcshowhideliu' => 'Checkbox label on [[Special:RecentChanges]]',
+'rcshowhideanons' => "Checkbox label on [[Special:RecentChanges]].",
+'rcshowhidepatr' => "Checkbox label on [[Special:RecentChanges]].",
+'rcshowhidemine' => "Checkbox label on [[Special:RecentChanges]].",
 'diff' => 'Short form of "differences". Used on [[Special:RecentChanges]], 
[[Special:Watchlist]], ...',
 'hist' => 'Short form of "history". Used on [[Special:RecentChanges]], 
[[Special:Watchlist]], ...',
 'hide' => '{{doc-actionlink}}
diff --git a/maintenance/language/messages.inc 
b/maintenance/language/messages.inc
index 1a62b8d..bb3ee57 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -1283,13 +1283,14 @@
                'rcnote',
                'rcnotefrom',
                'rclistfrom',
+               'rcshowlast',
+               'rcshowhide',
                'rcshowhideminor',
                'rcshowhidebots',
                'rcshowhideliu',
                'rcshowhideanons',
                'rcshowhidepatr',
                'rcshowhidemine',
-               'rclinks',
                'diff',
                'hist',
                'hide',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0fcc95850aa13ea7f4b5a4fdcfddb8ca6b66bf88
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matmarex <[email protected]>

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

Reply via email to