From 758f361698594691c36bcb0320b010daa68aaece Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Wed, 13 Aug 2008 23:08:22 +0000 Subject: [PATCH] (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 --- RELEASE-NOTES | 2 + includes/specials/SpecialPreferences.php | 2 +- includes/specials/SpecialWatchlist.php | 87 ++++++++++++++++-------- languages/messages/MessagesEn.php | 6 ++ maintenance/language/messages.inc | 6 ++ 5 files changed, 74 insertions(+), 29 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 5344cc0515..f5f53fbe96 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -78,6 +78,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN so-called GIFAR vulnerability. * (bug 15141) Give ability to only list protected pages with the cascading option enabled on Special:ProtectedPages +* (bug 15157) Special:Watchlist has the same options as Special:Watchlist: + Show/Hide logged in users, Show/Hide anonymous, Invert namespace selection === Bug fixes in 1.14 === diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 3c7416ef0f..de0c0d6b1a 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -1023,7 +1023,7 @@ class PreferencesForm { $wgOut->addHtml( wfInputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) ); $wgOut->addHtml( '

' ); - $wgOut->addHtml( $this->getToggles( array( 'watchlisthideown', 'watchlisthidebots', 'watchlisthideminor' ) ) ); + $wgOut->addHtml( $this->getToggles( array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', 'watchlisthideanons', 'watchlisthideliu' ) ) ); if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) ) $wgOut->addHtml( $this->getToggle( 'watchcreations' ) ); diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index db7cd42353..3e729f27ae 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -47,33 +47,44 @@ function wfSpecialWatchlist( $par ) { } $defaults = array( - /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */ - /* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ), - /* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ), - /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ), + /* float */ 'days' => floatval( $wgUser->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */ + /* bool */ 'hideMinor' => (int)$wgUser->getBoolOption( 'watchlisthideminor' ), + /* bool */ 'hideBots' => (int)$wgUser->getBoolOption( 'watchlisthidebots' ), + /* bool */ 'hideAnons' => (int)$wgUser->getBoolOption( 'watchlisthideanons' ), + /* bool */ 'hideLiu' => (int)$wgUser->getBoolOption( 'watchlisthideliu' ), + /* bool */ 'hideOwn' => (int)$wgUser->getBoolOption( 'watchlisthideown' ), /* ? */ 'namespace' => 'all', + /* ? */ 'invert' => false, ); extract($defaults); # Extract variables from the request, falling back to user preferences or # other default values if these don't exist - $prefs['days' ] = floatval( $wgUser->getOption( 'watchlistdays' ) ); - $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' ); - $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' ); + $prefs['days'] = floatval( $wgUser->getOption( 'watchlistdays' ) ); $prefs['hideminor'] = $wgUser->getBoolOption( 'watchlisthideminor' ); + $prefs['hidebots'] = $wgUser->getBoolOption( 'watchlisthidebots' ); + $prefs['hideanons'] = $wgUser->getBoolOption( 'watchlisthideanon' ); + $prefs['hideliu'] = $wgUser->getBoolOption( 'watchlisthideliu' ); + $prefs['hideown' ] = $wgUser->getBoolOption( 'watchlisthideown' ); # Get query variables - $days = $wgRequest->getVal( 'days', $prefs['days'] ); - $hideOwn = $wgRequest->getBool( 'hideOwn', $prefs['hideown'] ); - $hideBots = $wgRequest->getBool( 'hideBots', $prefs['hidebots'] ); + $days = $wgRequest->getVal( 'days' , $prefs['days'] ); $hideMinor = $wgRequest->getBool( 'hideMinor', $prefs['hideminor'] ); + $hideBots = $wgRequest->getBool( 'hideBots' , $prefs['hidebots'] ); + $hideAnons = $wgRequest->getBool( 'hideAnons', $prefs['hideanons'] ); + $hideLiu = $wgRequest->getBool( 'hideLiu' , $prefs['hideliu'] ); + $hideOwn = $wgRequest->getBool( 'hideOwn' , $prefs['hideown'] ); # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $wgRequest->getIntOrNull( 'namespace' ); + $invert = $wgRequest->getIntOrNull( 'invert' ); if( !is_null( $nameSpace ) ) { $nameSpace = intval( $nameSpace ); - $nameSpaceClause = " AND rc_namespace = $nameSpace"; + if( $invert && $nameSpace != 'all' ) + $nameSpaceClause = " AND rc_namespace != $nameSpace"; + else + $nameSpaceClause = " AND rc_namespace = $nameSpace"; } else { $nameSpace = ''; $nameSpaceClause = ''; @@ -103,11 +114,13 @@ function wfSpecialWatchlist( $par ) { // Dump everything here $nondefaults = array(); - wfAppendToArrayIfNotDefault('days' , $days , $defaults, $nondefaults); - wfAppendToArrayIfNotDefault('hideOwn' , (int)$hideOwn , $defaults, $nondefaults); - wfAppendToArrayIfNotDefault('hideBots' , (int)$hideBots, $defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'days' , $days , $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults ); - wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'hideBots' , (int)$hideBots , $defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'hideAnons', (int)$hideAnons, $defaults, $nondefaults ); + wfAppendToArrayIfNotDefault( 'hideLiu' , (int)$hideLiu , $defaults, $nondefaults ); + wfAppendToArrayIfNotDefault( 'hideOwn' , (int)$hideOwn , $defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'namespace', $nameSpace , $defaults, $nondefaults); $hookSql = ""; if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) { @@ -140,9 +153,11 @@ function wfSpecialWatchlist( $par ) { # Up estimate of watched items by 15% to compensate for talk pages... # Toggles - $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : ''; - $andHideBots = $hideBots ? "AND (rc_bot = 0)" : ''; - $andHideMinor = $hideMinor ? 'AND rc_minor = 0' : ''; + $andHideOwn = $hideOwn ? "AND (rc_user <> $uid)" : ''; + $andHideBots = $hideBots ? "AND (rc_bot = 0)" : ''; + $andHideMinor = $hideMinor ? "AND (rc_minor = 0)" : ''; + $andHideLiu = $hideLiu ? "AND (rc_user = 0)" : ''; + $andHideAnons = $hideAnons ? "AND (rc_user != 0)" : ''; # Show watchlist header $header = ''; @@ -194,6 +209,8 @@ function wfSpecialWatchlist( $par ) { $andHideOwn $andHideBots $andHideMinor + $andHideLiu + $andHideAnons $nameSpaceClause $hookSql ORDER BY rc_timestamp DESC @@ -230,21 +247,31 @@ function wfSpecialWatchlist( $par ) { $thisTitle = SpecialPage::getTitleFor( 'Watchlist' ); $skin = $wgUser->getSkin(); + # Hide/show minor edits + $label = $hideMinor ? wfMsgHtml( 'watchlist-show-minor' ) : wfMsgHtml( 'watchlist-hide-minor' ); + $linkBits = wfArrayToCGI( array( 'hideMinor' => 1 - (int)$hideMinor ), $nondefaults ); + $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); + # Hide/show bot edits $label = $hideBots ? wfMsgHtml( 'watchlist-show-bots' ) : wfMsgHtml( 'watchlist-hide-bots' ); $linkBits = wfArrayToCGI( array( 'hideBots' => 1 - (int)$hideBots ), $nondefaults ); $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); + # Hide/show anonymous edits + $label = $hideAnons ? wfMsgHtml( 'watchlist-show-anons' ) : wfMsgHtml( 'watchlist-hide-anons' ); + $linkBits = wfArrayToCGI( array( 'hideAnons' => 1 - (int)$hideAnons ), $nondefaults ); + $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); + + # Hide/show logged in edits + $label = $hideLiu ? wfMsgHtml( 'watchlist-show-liu' ) : wfMsgHtml( 'watchlist-hide-liu' ); + $linkBits = wfArrayToCGI( array( 'hideLiu' => 1 - (int)$hideLiu ), $nondefaults ); + $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); + # Hide/show own edits $label = $hideOwn ? wfMsgHtml( 'watchlist-show-own' ) : wfMsgHtml( 'watchlist-hide-own' ); $linkBits = wfArrayToCGI( array( 'hideOwn' => 1 - (int)$hideOwn ), $nondefaults ); $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); - # Hide/show minor edits - $label = $hideMinor ? wfMsgHtml( 'watchlist-show-minor' ) : wfMsgHtml( 'watchlist-hide-minor' ); - $linkBits = wfArrayToCGI( array( 'hideMinor' => 1 - (int)$hideMinor ), $nondefaults ); - $links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ); - $wgOut->addHTML( implode( ' | ', $links ) ); # Form for namespace filtering @@ -252,14 +279,19 @@ function wfSpecialWatchlist( $par ) { $form .= '

'; $form .= Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' '; $form .= Xml::namespaceSelector( $nameSpace, '' ) . ' '; + $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . "
"; $form .= Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . '

'; $form .= Xml::hidden( 'days', $days ); - if( $hideOwn ) - $form .= Xml::hidden( 'hideOwn', 1 ); - if( $hideBots ) - $form .= Xml::hidden( 'hideBots', 1 ); if( $hideMinor ) $form .= Xml::hidden( 'hideMinor', 1 ); + if( $hideBots ) + $form .= Xml::hidden( 'hideBots', 1 ); + if( $hideAnons ) + $form .= Xml::hidden( 'hideAnons', 1 ); + if( $hideLiu ) + $form .= Xml::hidden( 'hideLiu', 1 ); + if( $hideOwn ) + $form .= Xml::hidden( 'hideOwn', 1 ); $form .= Xml::closeElement( 'form' ); $wgOut->addHtml( $form ); @@ -316,7 +348,6 @@ function wfSpecialWatchlist( $par ) { $dbr->freeResult( $res ); $wgOut->addHTML( $s ); - } function wlHoursLink( $h, $page, $options = array() ) { diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 3a1d1ceacd..da55356a37 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -528,6 +528,8 @@ XHTML id names. 'tog-watchlisthideown' => 'Hide my edits from the watchlist', 'tog-watchlisthidebots' => 'Hide bot edits from the watchlist', 'tog-watchlisthideminor' => 'Hide minor edits from the watchlist', +'tog-watchlisthideliu' => 'Hide edits by logged in users from the watchlist', +'tog-watchlisthideanons' => 'Hide edits by anonymous users from the watchlist', 'tog-nolangconversion' => 'Disable variants conversion', # only translate this message to other languages if you have to change it 'tog-ccmeonemails' => 'Send me copies of e-mails I send to other users', 'tog-diffonly' => 'Do not show page content below diffs', @@ -2097,6 +2099,10 @@ Future changes to this page and its associated talk page will be listed there, a 'watchlist-hide-own' => 'Hide my edits', 'watchlist-show-minor' => 'Show minor edits', 'watchlist-hide-minor' => 'Hide minor edits', +'watchlist-show-anons' => 'Show anonymous edits', +'watchlist-hide-anons' => 'Hide anonymous edits', +'watchlist-show-liu' => 'Show logged-in user edits', +'watchlist-hide-liu' => 'Hide logged-in user edits', # Displayed when you click the "watch" button and it is in the process of watching 'watching' => 'Watching...', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 9a7ac6d08f..1597e7d14d 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -48,6 +48,8 @@ $wgMessageStructure = array( 'tog-watchlisthideown', 'tog-watchlisthidebots', 'tog-watchlisthideminor', + 'tog-watchlisthideliu', + 'tog-watchlisthideanons', 'tog-nolangconversion', 'tog-ccmeonemails', 'tog-diffonly', @@ -1374,6 +1376,10 @@ $wgMessageStructure = array( 'watchlist-hide-own', 'watchlist-show-minor', 'watchlist-hide-minor', + 'watchlist-show-anons', + 'watchlist-hide-anons', + 'watchlist-show-liu', + 'watchlist-hide-liu', ), 'watching' => array( 'watching', -- 2.20.1