$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' ) );
$opts->add( 'hidecategorization', $user->getBoolOption( 'watchlisthidecategorization' ) );
}
- $opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
-
return $opts;
}
}
$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' ) ) {
$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 = '';
# 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'],
$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 ) {
$nondefaults = $opts->getChangedValues();
$form = "";
}
$form .= Xml::openElement( 'form', array(
- 'method' => 'post',
+ 'method' => 'get',
'action' => $this->getPageTitle()->getLocalURL(),
'id' => 'mw-watchlist-form'
) );
$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
- );
- }
-
- protected function daysLink( $d, $options = array() ) {
- $options['days'] = $d;
-
- return Linker::linkKnown(
- $this->getPageTitle(),
- $this->getLanguage()->formatNum( $d ),
- array(),
- $options
+ return Xml::checkLabel(
+ $this->msg( $message, '' )->text(),
+ $name,
+ $name,
+ (int)$value
);
}
- /**
- * 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();
- }
-
/**
* Count the number of items on a user's watchlist
*
"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.",