(bug 2910) Default view preferences for watchlists
authorRob Church <robchurch@users.mediawiki.org>
Mon, 17 Apr 2006 23:53:54 +0000 (23:53 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 17 Apr 2006 23:53:54 +0000 (23:53 +0000)
RELEASE-NOTES
includes/SpecialPreferences.php
includes/SpecialWatchlist.php
languages/Language.php
languages/Messages.php

index 8316b28..3523d37 100644 (file)
@@ -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 ==
 
index a3b5617..6af8662 100644 (file)
@@ -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 {
                        ) . '</fieldset>'
                );
 
+               # Watchlist
+               $wgOut->addHTML( '<fieldset><legend>' . wfMsgHtml( 'prefs-watchlist' ) . '</legend>' );
+
+               $wgOut->addHTML( '<label for="wpWatchlistDays">' . wfMsgHtml( 'prefs-watchlist-days' ) . '</label> ' );
+               $wgOut->addHTML( '<input type="text" name="wpWatchlistDays" id="wpWatchlistDays" value="' . $this->mWatchlistDays . '" size="3" />' );
+               $wgOut->addHTML( '<p></p>' ); # Spacing
+               $wgOut->addHTML( $this->getToggles( array( 'watchlisthideown' ) ) );
+
+               $wgOut->addHTML( '</fieldset>' );
+
+               # Search
                $wgOut->addHTML( '<fieldset><legend>' . wfMsg( 'searchresultshead' ) . '</legend><table>' .
                        $this->addRow(
                                '<label for="wpSearch">' . wfMsg( 'resultsperpage' ) . '</label>',
index c9405de..890761d 100644 (file)
@@ -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
index a6ba219..067c8b3 100644 (file)
@@ -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(
index a9d899f..bb6d94e 100644 (file)
@@ -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 &nbsp; 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',