From 3515b335cff3d7182b4441e25d0cb8b066807544 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 17 Apr 2006 23:53:54 +0000 Subject: [PATCH] (bug 2910) Default view preferences for watchlists --- RELEASE-NOTES | 1 + includes/SpecialPreferences.php | 24 ++++++++++++++++++++++++ includes/SpecialWatchlist.php | 12 ++++++++++-- languages/Language.php | 2 ++ languages/Messages.php | 3 +++ 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8316b2822c..3523d3715c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -92,6 +92,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN the timestamp of the last update, in YYYYMMDDHHMMSS format. * (bug 5628) More translations for MessagesHr.php * (bug 5595) Localisation for Bosnian language (bs) +* (bug 2910) Default view preferences for watchlists == Compatibility == diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index a3b5617ae2..6af866246b 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -64,6 +64,7 @@ class PreferencesForm { $this->mReset = $request->getCheck( 'wpReset' ); $this->mPosted = $request->wasPosted(); $this->mSuccess = $request->getCheck( 'success' ); + $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' ); $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && $this->mPosted && @@ -129,6 +130,16 @@ class PreferencesForm { return $val; } + /** + * @access private + */ + function validateFloat( &$val, $min, $max=0x7fffffff ) { + $val = floatval( $val ); + $val = min( $val, $max ); + $val = max( $val, $min ); + return( $val ); + } + /** * @access private */ @@ -254,6 +265,7 @@ class PreferencesForm { $wgUser->setOption( 'imagesize', $this->mImageSize ); $wgUser->setOption( 'thumbsize', $this->mThumbSize ); $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) ); + $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0.5, 5 ) ); # Set search namespace options foreach( $this->mSearchNs as $i => $value ) { @@ -351,6 +363,7 @@ class PreferencesForm { $this->mThumbSize = $wgUser->getOption( 'thumbsize' ); $this->mRecent = $wgUser->getOption( 'rclimit' ); $this->mUnderline = $wgUser->getOption( 'underline' ); + $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' ); $togs = $wgLang->getUserToggles(); foreach ( $togs as $tname ) { @@ -834,6 +847,17 @@ class PreferencesForm { ) . '' ); + # Watchlist + $wgOut->addHTML( '
' . wfMsgHtml( 'prefs-watchlist' ) . '' ); + + $wgOut->addHTML( ' ' ); + $wgOut->addHTML( '' ); + $wgOut->addHTML( '

' ); # Spacing + $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown' ) ) ); + + $wgOut->addHTML( '
' ); + + # Search $wgOut->addHTML( '
' . wfMsg( 'searchresultshead' ) . '' . $this->addRow( '', diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index c9405de099..890761d168 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -46,9 +46,17 @@ function wfSpecialWatchlist( $par ) { 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' ); + + # The hide bots thing is b0rk3d for now + # $prefs['bots'] = $wgUser->getBoolOption( 'watchlisthidebots' ); + # Get query variables - $days = $wgRequest->getVal( 'days' ); - $hideOwn = $wgRequest->getBool( 'hideOwn' ); + $days = $wgRequest->getVal( 'days', $prefs['days'] ); + $hideOwn = $wgRequest->getBool( 'hideOwn', $prefs['hideown'] ); $hideBots = $wgRequest->getBool( 'hideBots' ); # Get namespace value, if supplied, and prepare a WHERE fragment diff --git a/languages/Language.php b/languages/Language.php index a6ba21973b..067c8b32dd 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -84,6 +84,7 @@ if(isset($wgExtraNamespaces)) { 'showjumplinks' => 1, 'numberheadings' => 0, 'uselivepreview' => 0, + 'watchlistdays' => 3.0, ); /* private */ $wgQuickbarSettingsEn = array( @@ -161,6 +162,7 @@ $wgDateFormatsEn = array( 'uselivepreview', 'autopatrol', 'forceeditsummary', + 'watchlisthideown', ); /* private */ $wgBookstoreListEn = array( diff --git a/languages/Messages.php b/languages/Messages.php index a9d899fdc5..bb6d94e206 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -63,6 +63,7 @@ parent class in order maintain consistency across languages. 'tog-uselivepreview' => 'Use live preview (JavaScript) (Experimental)', 'tog-autopatrol' => 'Mark edits I make as patrolled', 'tog-forceeditsummary' => 'Prompt me when entering a blank edit summary', +'tog-watchlisthideown' => 'Hide my edits from the watchlist', 'underline-always' => 'Always', 'underline-never' => 'Never', @@ -695,6 +696,8 @@ $2 List redirects   Search for $3 $9", 'math_notexvc' => 'Missing texvc executable; please see math/README to configure.', 'prefs-personal' => 'User profile', 'prefs-rc' => 'Recent changes', +'prefs-watchlist' => 'Watchlist', +'prefs-watchlist-days' => 'Number of days to show in watchlist:', 'prefs-misc' => 'Misc', 'saveprefs' => 'Save', 'resetprefs' => 'Reset', -- 2.20.1