jenkins-bot has submitted this change and it was merged.

Change subject: Cleaner Special:Watchlist options form
......................................................................


Cleaner Special:Watchlist options form

* Show/hide links have been changed to checkboxes
* The 'show last' links have been changed to a selector
* New hidden parameter as action=submit has been added to detect form
  submissions
* Changed form method to 'get', so as to make links bookmarkable

Bug: T50615
Change-Id: I3bcd27596c21aa474547f182469abbf2ca34c4eb
---
M includes/specials/SpecialWatchlist.php
M languages/i18n/en.json
M languages/i18n/qqq.json
3 files changed, 80 insertions(+), 66 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  Siebrand: Looks good to me, but someone else must approve
  Florianschmidtwelzow: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/includes/specials/SpecialWatchlist.php 
b/includes/specials/SpecialWatchlist.php
index 962e0c3..7cc7d5f 100644
--- a/includes/specials/SpecialWatchlist.php
+++ b/includes/specials/SpecialWatchlist.php
@@ -103,6 +103,11 @@
                $user = $this->getUser();
 
                $opts->add( 'days', $user->getOption( 'watchlistdays' ), 
FormOptions::FLOAT );
+               $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' 
) );
+               if ( $this->getRequest()->getVal( 'action' ) == 'submit' ) {
+                       // The user has submitted the form, so we dont need the 
default values
+                       return $opts;
+               }
 
                $opts->add( 'hideminor', $user->getBoolOption( 
'watchlisthideminor' ) );
                $opts->add( 'hidebots', $user->getBoolOption( 
'watchlisthidebots' ) );
@@ -114,8 +119,6 @@
                if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
                        $opts->add( 'hidecategorization', $user->getBoolOption( 
'watchlisthidecategorization' ) );
                }
-
-               $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' 
) );
 
                return $opts;
        }
@@ -418,16 +421,16 @@
                }
 
                $nondefaults = $opts->getChangedValues();
-               $cutofflinks = $this->cutoffLinks( $opts['days'], $nondefaults 
) . "<br />\n";
+               $cutofflinks = $this->msg( 'wlshowtime' ) . ' ' . 
$this->cutoffselector( $opts );
 
                # Spit out some control panel links
                $filters = array(
-                       'hideminor' => 'rcshowhideminor',
-                       'hidebots' => 'rcshowhidebots',
-                       'hideanons' => 'rcshowhideanons',
-                       'hideliu' => 'rcshowhideliu',
-                       'hidemyself' => 'rcshowhidemine',
-                       'hidepatrolled' => 'rcshowhidepatr'
+                       'hideminor' => 'wlshowhideminor',
+                       'hidebots' => 'wlshowhidebots',
+                       'hideanons' => 'wlshowhideanons',
+                       'hideliu' => 'wlshowhideliu',
+                       'hidemyself' => 'wlshowhidemine',
+                       'hidepatrolled' => 'wlshowhidepatr'
                );
 
                if ( $this->getConfig()->get( 'RCWatchCategoryMembership' ) ) {
@@ -444,13 +447,18 @@
 
                $links = array();
                foreach ( $filters as $name => $msg ) {
-                       $links[] = $this->showHideLink( $nondefaults, $msg, 
$name, $opts[$name] );
+                       $links[] = $this->showHideCheck( $nondefaults, $msg, 
$name, $opts[$name] );
                }
 
                $hiddenFields = $nondefaults;
+               $hiddenFields['action'] = 'submit';
                unset( $hiddenFields['namespace'] );
                unset( $hiddenFields['invert'] );
                unset( $hiddenFields['associated'] );
+               unset( $hiddenFields['days'] );
+               foreach ( $filters as $key => $value ) {
+                       unset( $hiddenFields[$key] );
+               }
 
                # Create output
                $form = '';
@@ -458,8 +466,10 @@
                # Namespace filter and put the whole form together.
                $form .= $wlInfo;
                $form .= $cutofflinks;
-               $form .= $lang->pipeList( $links ) . "\n";
-               $form .= "<hr />\n<p>";
+               $form .= $this->msg( 'hide' ) .
+                       $this->msg( 'colon-separator' )->escaped() .
+                       implode( ' ', $links );
+               $form .= "\n<hr />\n<p>";
                $form .= Html::namespaceSelector(
                        array(
                                'selected' => $opts['namespace'],
@@ -494,6 +504,41 @@
                $this->getOutput()->addHTML( $form );
 
                $this->setBottomText( $opts );
+       }
+
+       function cutoffselector( $options ) {
+               $list = array();
+               $selectOptions = '';
+               $hours = array( 1, 2, 6, 12 );
+               $days = array( 1, 3, 7 );
+               foreach ( $hours as $h ) {
+                       $name = $this->msg( 'hours', $h );
+                       $value = $h / 24;
+                       $selected = ( $value == $options['days'] ) ? true : 
false;
+
+                       $selectOptions .= Xml::option( $name, $value, $selected 
);
+               }
+               foreach ( $days as $d ) {
+                       $name = $this->msg( 'days', $d );
+                       $value = $d;
+                       $selected = ( $value == $options['days'] ) ? true : 
false;
+
+                       $selectOptions .= Xml::option( $name, $value, $selected 
);
+               }
+
+               // all option
+               $name = $this->msg( 'watchlistall2' );
+               $value = 0;
+               $selected = ( $value == $options['days'] ) ? true : false;
+               $selectOptions .= Xml::option( $name, $value, $selected );
+
+               $attribs = array( "name" => "days", "id" => "days" );
+               return Xml::openElement( 'select', $attribs )
+                       . "\n"
+                       . $selectOptions
+                       . "\n"
+                       . Xml::closeElement( 'select' )
+                       . "<br />\n";
        }
 
        function setTopText( FormOptions $opts ) {
@@ -535,7 +580,7 @@
                }
 
                $form .= Xml::openElement( 'form', array(
-                       'method' => 'post',
+                       'method' => 'get',
                        'action' => $this->getPageTitle()->getLocalURL(),
                        'id' => 'mw-watchlist-form'
                ) );
@@ -550,62 +595,15 @@
                $this->getOutput()->addHTML( $form );
        }
 
-       protected function showHideLink( $options, $message, $name, $value ) {
-               $label = $this->msg( $value ? 'show' : 'hide' )->escaped();
+       protected function showHideCheck( $options, $message, $name, $value ) {
                $options[$name] = 1 - (int)$value;
 
-               return $this->msg( $message )
-                       ->rawParams( Linker::linkKnown( $this->getPageTitle(), 
$label, array(), $options ) )
-                       ->escaped();
-       }
-
-       protected function hoursLink( $h, $options = array() ) {
-               $options['days'] = ( $h / 24.0 );
-
-               return Linker::linkKnown(
-                       $this->getPageTitle(),
-                       $this->getLanguage()->formatNum( $h ),
-                       array(),
-                       $options
+               return Xml::checkLabel(
+                       $this->msg( $message, '' )->text(),
+                       $name,
+                       $name,
+                       (int)$value
                );
-       }
-
-       protected function daysLink( $d, $options = array() ) {
-               $options['days'] = $d;
-
-               return Linker::linkKnown(
-                       $this->getPageTitle(),
-                       $this->getLanguage()->formatNum( $d ),
-                       array(),
-                       $options
-               );
-       }
-
-       /**
-        * Returns html
-        *
-        * @param int $days This gets overwritten, so is not used
-        * @param array $options Query parameters for URL
-        * @return string
-        */
-       protected function cutoffLinks( $days, $options = array() ) {
-               global $wgRCMaxAge;
-               $watchlistMaxDays = ceil( $wgRCMaxAge / ( 3600 * 24 ) );
-
-               $hours = array( 1, 2, 6, 12 );
-               $days = array( 1, 3, 7, $watchlistMaxDays );
-               $i = 0;
-               foreach ( $hours as $h ) {
-                       $hours[$i++] = $this->hoursLink( $h, $options );
-               }
-               $i = 0;
-               foreach ( $days as $d ) {
-                       $days[$i++] = $this->daysLink( $d, $options );
-               }
-
-               return $this->msg( 'wlshowlast' )->rawParams(
-                       $this->getLanguage()->pipeList( $hours ),
-                       $this->getLanguage()->pipeList( $days ) )->parse();
        }
 
        /**
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index 853c9ed..2a296c1 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1923,6 +1923,14 @@
        "wlheader-showupdated": "Pages that have been changed since you last 
visited them are shown in <strong>bold</strong>.",
        "wlnote": "Below {{PLURAL:$1|is the last change|are the last 
<strong>$1</strong> changes}} in the last {{PLURAL:$2|hour|<strong>$2</strong> 
hours}}, as of $3, $4.",
        "wlshowlast": "Show last $1 hours $2 days",
+       "watchlistall2": "all",
+       "wlshowtime": "Show last:",
+       "wlshowhideminor": "minor edits",
+       "wlshowhidebots": "bots",
+       "wlshowhideliu": "registered users",
+       "wlshowhideanons": "anonymous users",
+       "wlshowhidepatr": "patrolled edits",
+       "wlshowhidemine": "my edits",
        "watchlist-options": "Watchlist options",
        "watching": "Watching...",
        "unwatching": "Unwatching...",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index 17d259d..1f8078c 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2097,6 +2097,14 @@
        "wlheader-showupdated": "Message at the top of [[Special:Watchlist]], 
after {{msg-mw|watchlist-details}}. Has to be a full sentence.",
        "wlnote": "Used on [[Special:Watchlist]] when a maximum number of hours 
or days is specified.\n\nParameters:\n* $1 - the number of changes shown\n* $2 
- the number of hours for which the changes are shown\n* $3 - a date alone\n* 
$4 - a time alone",
        "wlshowlast": "Appears on [[Special:Watchlist]]. Parameters:\n* $1 - a 
choice of different numbers of hours (\"1 | 2 | 6 | 12\")\n* $2 - a choice of 
different numbers of days (\"1 | 3 | 7\" and the maximum number of days 
available)\nClicking on your choice changes the list of changes you see 
(without changing the default in my preferences).",
+       "wlshowtime": "Appears on [[Special:Watchlist]].",
+       "watchlistall2": "Appears on [[Special:Watchlist]], after 
{{msg-mw|wlshowtime}}, as the option to display all available data regardless 
of age.",
+       "wlshowhideminor": "Option text in [[Special:Watchlist]].",
+       "wlshowhidebots": "Option text in [[Special:Watchlist]].",
+       "wlshowhideliu": "Option text in [[Special:Watchlist]].",
+       "wlshowhideanons": "Option text in [[Special:Watchlist]].",
+       "wlshowhidepatr": "Option text in [[Special:Watchlist]].",
+       "wlshowhidemine": "Option text in [[Special:Watchlist]].",
        "watchlist-options": "Legend of the fieldset of 
[[Special:Watchlist]]\n\nSee also:\n* {{msg-mw|Watchlist-details|watchlist 
header}}\n* {{msg-mw|Wlheader-enotif|watchlist header}}\n* {{msg-mw|enotif 
reset|Submit button text}}",
        "watching": "Text displayed when clicked on the watch tab: 
{{msg-mw|Watch}}. It means the wiki is adding that page to your watchlist.",
        "unwatching": "Text displayed when clicked on the unwatch tab: 
{{msg-mw|Unwatch}}. It means the wiki is removing that page from your 
watchlist.",

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3bcd27596c21aa474547f182469abbf2ca34c4eb
Gerrit-PatchSet: 13
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Rohan013 <rohan1...@yahoo.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Rillke <ril...@wikipedia.de>
Gerrit-Reviewer: Rohan013 <rohan1...@yahoo.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to