r39314 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39313‎ | r39314 | r39315 >
Date:23:08, 13 August 2008
Author:siebrand
Status:old (Comments)
Tags:
Comment:
(bug 15157) Special:Watchlist now has the same options as Special:Watchlist:
* Show/Hide logged in users
* Show/Hide anonymous
* Invert namespace selection
* Same ordering of options

Code comments: Toggles added in Preferences, messages added, code ordered as presented in special page
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialPreferences.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialWatchlist.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -48,6 +48,8 @@
4949 'tog-watchlisthideown',
5050 'tog-watchlisthidebots',
5151 'tog-watchlisthideminor',
 52+ 'tog-watchlisthideliu',
 53+ 'tog-watchlisthideanons',
5254 'tog-nolangconversion',
5355 'tog-ccmeonemails',
5456 'tog-diffonly',
@@ -1374,6 +1376,10 @@
13751377 'watchlist-hide-own',
13761378 'watchlist-show-minor',
13771379 'watchlist-hide-minor',
 1380+ 'watchlist-show-anons',
 1381+ 'watchlist-hide-anons',
 1382+ 'watchlist-show-liu',
 1383+ 'watchlist-hide-liu',
13781384 ),
13791385 'watching' => array(
13801386 'watching',
Index: trunk/phase3/includes/specials/SpecialPreferences.php
@@ -1023,7 +1023,7 @@
10241024 $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) );
10251025 $wgOut->addHtml( '<br /><br />' );
10261026
1027 - $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) );
 1027+ $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) );
10281028
10291029 if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) )
10301030 $wgOut->addHtml( $this->getToggle( 'watchcreations' ) );
Index: trunk/phase3/includes/specials/SpecialWatchlist.php
@@ -47,33 +47,44 @@
4848 }
4949
5050 $defaults = array(
51 - /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
52 - /* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ),
53 - /* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ),
54 - /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ),
 51+ /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
 52+ /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ),
 53+ /* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ),
 54+ /* bool */ 'hideAnons' => (int)$wgUser->getBoolOption( 'watchlisthideanons' ),
 55+ /* bool */ 'hideLiu' => (int)$wgUser->getBoolOption( 'watchlisthideliu' ),
 56+ /* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ),
5557 /* ? */ 'namespace' => 'all',
 58+ /* ? */ 'invert' => false,
5659 );
5760
5861 extract($defaults);
5962
6063 # Extract variables from the request, falling back to user preferences or
6164 # other default values if these don't exist
62 - $prefs['days' ] = floatval( $wgUser->getOption( 'watchlistdays' ) );
63 - $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' );
64 - $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' );
 65+ $prefs['days'] = floatval( $wgUser->getOption( 'watchlistdays' ) );
6566 $prefs['hideminor'] = $wgUser->getBoolOption( 'watchlisthideminor' );
 67+ $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' );
 68+ $prefs['hideanons'] = $wgUser->getBoolOption( 'watchlisthideanon' );
 69+ $prefs['hideliu'] = $wgUser->getBoolOption( 'watchlisthideliu' );
 70+ $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' );
6671
6772 # Get query variables
68 - $days = $wgRequest->getVal( 'days', $prefs['days'] );
69 - $hideOwn = $wgRequest->getBool( 'hideOwn', $prefs['hideown'] );
70 - $hideBots = $wgRequest->getBool( 'hideBots', $prefs['hidebots'] );
 73+ $days = $wgRequest->getVal( 'days' , $prefs['days'] );
7174 $hideMinor = $wgRequest->getBool( 'hideMinor', $prefs['hideminor'] );
 75+ $hideBots = $wgRequest->getBool( 'hideBots' , $prefs['hidebots'] );
 76+ $hideAnons = $wgRequest->getBool( 'hideAnons', $prefs['hideanons'] );
 77+ $hideLiu = $wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] );
 78+ $hideOwn = $wgRequest->getBool( 'hideOwn' , $prefs['hideown'] );
7279
7380 # Get namespace value, if supplied, and prepare a WHERE fragment
7481 $nameSpace = $wgRequest->getIntOrNull( 'namespace' );
 82+ $invert = $wgRequest->getIntOrNull( 'invert' );
7583 if( !is_null( $nameSpace ) ) {
7684 $nameSpace = intval( $nameSpace );
77 - $nameSpaceClause = " AND rc_namespace = $nameSpace";
 85+ if( $invert && $nameSpace != 'all' )
 86+ $nameSpaceClause = " AND rc_namespace != $nameSpace";
 87+ else
 88+ $nameSpaceClause = " AND rc_namespace = $nameSpace";
7889 } else {
7990 $nameSpace = '';
8091 $nameSpaceClause = '';
@@ -103,11 +114,13 @@
104115 // Dump everything here
105116 $nondefaults = array();
106117
107 - wfAppendToArrayIfNotDefault('days' , $days , $defaults, $nondefaults);
108 - wfAppendToArrayIfNotDefault('hideOwn' , (int)$hideOwn , $defaults, $nondefaults);
109 - wfAppendToArrayIfNotDefault('hideBots' , (int)$hideBots, $defaults, $nondefaults);
 118+ wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults);
110119 wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults );
111 - wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults);
 120+ wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults);
 121+ wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons, $defaults, $nondefaults );
 122+ wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu , $defaults, $nondefaults );
 123+ wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults);
 124+ wfAppendToArrayIfNotDefault( 'namespace', $nameSpace , $defaults, $nondefaults);
112125
113126 $hookSql = "";
114127 if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) {
@@ -140,9 +153,11 @@
141154 # Up estimate of watched items by 15% to compensate for talk pages...
142155
143156 # Toggles
144 - $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : '';
145 - $andHideBots = $hideBots ? "AND (rc_bot = 0)" : '';
146 - $andHideMinor = $hideMinor ? 'AND rc_minor = 0' : '';
 157+ $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : '';
 158+ $andHideBots = $hideBots ? "AND (rc_bot = 0)" : '';
 159+ $andHideMinor = $hideMinor ? "AND (rc_minor = 0)" : '';
 160+ $andHideLiu = $hideLiu ? "AND (rc_user = 0)" : '';
 161+ $andHideAnons = $hideAnons ? "AND (rc_user != 0)" : '';
147162
148163 # Show watchlist header
149164 $header = '';
@@ -194,6 +209,8 @@
195210 $andHideOwn
196211 $andHideBots
197212 $andHideMinor
 213+ $andHideLiu
 214+ $andHideAnons
198215 $nameSpaceClause
199216 $hookSql
200217 ORDER BY rc_timestamp DESC
@@ -230,21 +247,31 @@
231248 $thisTitle = SpecialPage::getTitleFor( 'Watchlist' );
232249 $skin = $wgUser->getSkin();
233250
 251+ # Hide/show minor edits
 252+ $label = $hideMinor ? wfMsgHtml( 'watchlist-show-minor' ) : wfMsgHtml( 'watchlist-hide-minor' );
 253+ $linkBits = wfArrayToCGI( array( 'hideMinor' => 1 - (int)$hideMinor ), $nondefaults );
 254+ $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
 255+
234256 # Hide/show bot edits
235257 $label = $hideBots ? wfMsgHtml( 'watchlist-show-bots' ) : wfMsgHtml( 'watchlist-hide-bots' );
236258 $linkBits = wfArrayToCGI( array( 'hideBots' => 1 - (int)$hideBots ), $nondefaults );
237259 $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
238260
 261+ # Hide/show anonymous edits
 262+ $label = $hideAnons ? wfMsgHtml( 'watchlist-show-anons' ) : wfMsgHtml( 'watchlist-hide-anons' );
 263+ $linkBits = wfArrayToCGI( array( 'hideAnons' => 1 - (int)$hideAnons ), $nondefaults );
 264+ $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
 265+
 266+ # Hide/show logged in edits
 267+ $label = $hideLiu ? wfMsgHtml( 'watchlist-show-liu' ) : wfMsgHtml( 'watchlist-hide-liu' );
 268+ $linkBits = wfArrayToCGI( array( 'hideLiu' => 1 - (int)$hideLiu ), $nondefaults );
 269+ $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
 270+
239271 # Hide/show own edits
240272 $label = $hideOwn ? wfMsgHtml( 'watchlist-show-own' ) : wfMsgHtml( 'watchlist-hide-own' );
241273 $linkBits = wfArrayToCGI( array( 'hideOwn' => 1 - (int)$hideOwn ), $nondefaults );
242274 $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
243275
244 - # Hide/show minor edits
245 - $label = $hideMinor ? wfMsgHtml( 'watchlist-show-minor' ) : wfMsgHtml( 'watchlist-hide-minor' );
246 - $linkBits = wfArrayToCGI( array( 'hideMinor' => 1 - (int)$hideMinor ), $nondefaults );
247 - $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
248 -
249276 $wgOut->addHTML( implode( ' | ', $links ) );
250277
251278 # Form for namespace filtering
@@ -252,14 +279,19 @@
253280 $form .= '<p>';
254281 $form .= Xml::label( wfMsg( 'namespace' ), 'namespace' ) . '&nbsp;';
255282 $form .= Xml::namespaceSelector( $nameSpace, '' ) . '&nbsp;';
 283+ $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . "<br />";
256284 $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . '</p>';
257285 $form .= Xml::hidden( 'days', $days );
 286+ if( $hideMinor )
 287+ $form .= Xml::hidden( 'hideMinor', 1 );
 288+ if( $hideBots )
 289+ $form .= Xml::hidden( 'hideBots', 1 );
 290+ if( $hideAnons )
 291+ $form .= Xml::hidden( 'hideAnons', 1 );
 292+ if( $hideLiu )
 293+ $form .= Xml::hidden( 'hideLiu', 1 );
258294 if( $hideOwn )
259295 $form .= Xml::hidden( 'hideOwn', 1 );
260 - if( $hideBots )
261 - $form .= Xml::hidden( 'hideBots', 1 );
262 - if( $hideMinor )
263 - $form .= Xml::hidden( 'hideMinor', 1 );
264296 $form .= Xml::closeElement( 'form' );
265297 $wgOut->addHtml( $form );
266298
@@ -316,7 +348,6 @@
317349
318350 $dbr->freeResult( $res );
319351 $wgOut->addHTML( $s );
320 -
321352 }
322353
323354 function wlHoursLink( $h, $page, $options = array() ) {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -528,6 +528,8 @@
529529 'tog-watchlisthideown' => 'Hide my edits from the watchlist',
530530 'tog-watchlisthidebots' => 'Hide bot edits from the watchlist',
531531 'tog-watchlisthideminor' => 'Hide minor edits from the watchlist',
 532+'tog-watchlisthideliu' => 'Hide edits by logged in users from the watchlist',
 533+'tog-watchlisthideanons' => 'Hide edits by anonymous users from the watchlist',
532534 'tog-nolangconversion' => 'Disable variants conversion', # only translate this message to other languages if you have to change it
533535 'tog-ccmeonemails' => 'Send me copies of e-mails I send to other users',
534536 'tog-diffonly' => 'Do not show page content below diffs',
@@ -2097,6 +2099,10 @@
20982100 'watchlist-hide-own' => 'Hide my edits',
20992101 'watchlist-show-minor' => 'Show minor edits',
21002102 'watchlist-hide-minor' => 'Hide minor edits',
 2103+'watchlist-show-anons' => 'Show anonymous edits',
 2104+'watchlist-hide-anons' => 'Hide anonymous edits',
 2105+'watchlist-show-liu' => 'Show logged-in user edits',
 2106+'watchlist-hide-liu' => 'Hide logged-in user edits',
21012107
21022108 # Displayed when you click the "watch" button and it is in the process of watching
21032109 'watching' => 'Watching...',
Index: trunk/phase3/RELEASE-NOTES
@@ -78,6 +78,8 @@
7979 so-called GIFAR vulnerability.
8080 * (bug 15141) Give ability to only list protected pages with the cascading
8181 option enabled on Special:ProtectedPages
 82+* (bug 15157) Special:Watchlist has the same options as Special:Watchlist:
 83+ Show/Hide logged in users, Show/Hide anonymous, Invert namespace selection
8284
8385 === Bug fixes in 1.14 ===
8486

Follow-up revisions

RevisionCommit summaryAuthorDate
r39584Fix for r39314 (adding the new toggles to $mToggles in User.php)siebrand13:26, 18 August 2008
r39836Tweak for r39314: don't add a line break before the "Go" button on the watchl...simetrical15:28, 22 August 2008
r81210(Bug 26961) hide anons from watchlist preference was broken due to typo in...bawolff18:17, 30 January 2011

Comments

#Comment by Krinkle (talk | contribs)   19:40, 28 January 2011

See https://bugzilla.wikimedia.org/show_bug.cgi?id=26961#c3 ('Hide edits by anonymous users from the watchlist ' option does not reflect in the watchlist)

> It is a typo in r39314: 'watchlisthideanon' vs 'watchlisthideanon*s*'.

Status & tagging log