*/
class SpecialEditWatchlist extends UnlistedSpecialPage {
/**
- * Editing modes
+ * Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
+ * too much. Now it's passed on to the raw editor, from which it's very easy to clear.
*/
const EDIT_CLEAR = 1;
const EDIT_RAW = 2;
$mode = self::getMode( $this->getRequest(), $mode );
switch ( $mode ) {
- case self::EDIT_CLEAR:
- // The "Clear" link scared people too much.
- // Pass on to the raw editor, from which it's very easy to clear.
-
case self::EDIT_RAW:
$out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
$form = $this->getRawForm();
$this->toc = false;
}
- $form = new EditWatchlistNormalHTMLForm( $fields, $this->getContext() );
- $form->setTitle( $this->getTitle() );
+ $context = new DerivativeContext( $this->getContext() );
+ $context->setTitle( $this->getTitle() ); // Remove subpage
+ $form = new EditWatchlistNormalHTMLForm( $fields, $context );
$form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
# Used message keys: 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
$form->setSubmitTooltip( 'watchlistedit-normal-submit' );
'default' => $titles,
),
);
- $form = new HTMLForm( $fields, $this->getContext() );
- $form->setTitle( $this->getTitle( 'raw' ) );
+ $context = new DerivativeContext( $this->getContext() );
+ $context->setTitle( $this->getTitle( 'raw' ) ); // Reset subpage
+ $form = new HTMLForm( $fields, $context );
$form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
# Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
$form->setSubmitTooltip( 'watchlistedit-raw-submit' );
switch ( $mode ) {
case 'clear':
case self::EDIT_CLEAR:
- return self::EDIT_CLEAR;
case 'raw':
case self::EDIT_RAW:
return self::EDIT_RAW;
$mode = SpecialEditWatchlist::getMode( $request, $par );
if ( $mode !== false ) {
- # TODO: localise?
- switch ( $mode ) {
- case SpecialEditWatchlist::EDIT_CLEAR:
- $mode = 'clear';
- break;
- case SpecialEditWatchlist::EDIT_RAW:
- $mode = 'raw';
- break;
- default:
- $mode = null;
+ if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
+ $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
+ } else {
+ $title = SpecialPage::getTitleFor( 'EditWatchlist' );
}
- $title = SpecialPage::getTitleFor( 'EditWatchlist', $mode );
+
$output->redirect( $title->getLocalURL() );
return;
}
// @todo use FormOptions!
$defaults = array(
- /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
+ /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ),
/* bool */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ),
/* bool */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ),
/* bool */ 'hideAnons' => (int)$user->getBoolOption( 'watchlisthideanons' ),
# Extract variables from the request, falling back to user preferences or
# other default values if these don't exist
$values = array();
- $values['days'] = $request->getVal( 'days', $defaults['days'] );
+ $values['days'] = floatval( $request->getVal( 'days', $defaults['days'] ) );
$values['hideMinor'] = (int)$request->getBool( 'hideMinor', $defaults['hideMinor'] );
$values['hideBots'] = (int)$request->getBool( 'hideBots', $defaults['hideBots'] );
$values['hideAnons'] = (int)$request->getBool( 'hideAnons', $defaults['hideAnons'] );
$values['invert'] = $invert;
$values['associated'] = $associated;
- if ( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
- $big = 1000; /* The magical big */
- if ( $nitems > $big ) {
- # Set default cutoff shorter
- $values['days'] = $defaults['days'] = ( 12.0 / 24.0 ); # 12 hours...
- } else {
- $values['days'] = $defaults['days']; # default cutoff for shortlisters
- }
- } else {
- $values['days'] = floatval( $values['days'] );
- }
-
// Dump everything here
$nondefaults = array();
foreach ( $defaults as $name => $defValue ) {
$conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $values['days'] * 86400 ) ) );
}
- # If the watchlist is relatively short, it's simplest to zip
- # down its entirety and then sort the results.
-
- # If it's relatively long, it may be worth our while to zip
- # through the time-sorted page list checking for watched items.
-
- # Up estimate of watched items by 15% to compensate for talk pages...
-
# Toggles
if ( $values['hideOwn'] ) {
$conds[] = 'rc_user != ' . $user->getId();
$usePage = false;
} else {
# Top log Ids for a page are not stored
- $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
+ $nonRevisionTypes = array( RC_LOG );
+ wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) );
+ if ( $nonRevisionTypes ) {
+ if ( count( $nonRevisionTypes ) === 1 ) {
+ // if only one use an equality instead of IN condition
+ $nonRevisionTypes = reset( $nonRevisionTypes );
+ }
+ $conds[] = $dbr->makeList(
+ array(
+ 'rc_this_oldid=page_latest',
+ 'rc_type' => $nonRevisionTypes,
+ ),
+ LIST_OR
+ );
+ }
$limitWatchlist = 0;
$usePage = true;
}