getUser();
// Overwrite RC options with Watchlist options
// (calling #add() again is okay)
$opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT );
$opts->add( 'hideminor', $user->getBoolOption( 'watchlisthideminor' ) );
$opts->add( 'hidebots', $user->getBoolOption( 'watchlisthidebots' ) );
$opts->add( 'hideanons', $user->getBoolOption( 'watchlisthideanons' ) );
$opts->add( 'hideliu', $user->getBoolOption( 'watchlisthideliu' ) );
$opts->add( 'hidepatrolled', $user->getBoolOption( 'watchlisthidepatrolled' ) );
$opts->add( 'hidemyself', $user->getBoolOption( 'watchlisthideown' ) );
// Add new ones
$opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
return $opts;
}
/**
* Fetch values for a FormOptions object from the WebRequest associated with this instance.
*
* Maps old pre-1.23 request parameters Watchlist used to use (different from Recentchanges' ones)
* to the current ones.
*
* @param FormOptions $parameters
* @return FormOptions
*/
protected function fetchOptionsFromRequest( $opts ) {
static $compatibilityMap = array(
'hideMinor' => 'hideminor',
'hideBots' => 'hidebots',
'hideAnons' => 'hideanons',
'hideLiu' => 'hideliu',
'hidePatrolled' => 'hidepatrolled',
'hideOwn' => 'hidemyself',
);
$params = $this->getRequest()->getValues();
foreach ( $compatibilityMap as $from => $to ) {
if ( isset( $params[$from] ) ) {
$params[$to] = $params[$from];
unset( $params[$from] );
}
}
// Not the prettiest way to achieve this… FormOptions internally depends on data sanitization
// methods defined on WebRequest and removing this dependency would cause some code duplication.
$request = new DerivativeRequest( $this->getRequest(), $params );
$opts->fetchValuesFromRequest( $request );
return $opts;
}
/**
* Get custom show/hide filters
*
* @return array Map of filter URL param names to properties (msg/default)
*/
protected function getCustomFilters() {
if ( $this->customFilters === null ) {
$this->customFilters = array();
wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
}
return $this->customFilters;
}
/**
* Process $par and put options found if $opts. Not used for Watchlist.
*
* @param string $par
* @param FormOptions $opts
*/
public function parseParameters( $par, FormOptions $opts ) {
}
/**
* Get the current FormOptions for this request
*/
public function getOptions() {
if ( $this->rcOptions === null ) {
$this->rcOptions = $this->setup( null );
}
return $this->rcOptions;
}
/**
* Execute
* @param $par Parameter passed to the page
*/
function execute( $par ) {
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
$user = $this->getUser();
$output = $this->getOutput();
$output->addModuleStyles( 'mediawiki.special.changeslist' );
$output->addModules( 'mediawiki.special.changeslist.js' );
# Anons don't get a watchlist
$this->requireLogin( 'watchlistanontext' );
// Check permissions
$this->checkPermissions();
$request = $this->getRequest();
$opts = $this->getOptions();
$mode = SpecialEditWatchlist::getMode( $request, $par );
if ( $mode !== false ) {
if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
$title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
} else {
$title = SpecialPage::getTitleFor( 'EditWatchlist' );
}
$output->redirect( $title->getLocalURL() );
return;
}
if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
$request->wasPosted() )
{
$user->clearAllNotifications();
$output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
return;
}
$this->setHeaders();
$this->outputHeader();
$this->addModules();
// Add feed links
$wlToken = $user->getTokenFromOption( 'watchlisttoken' );
if ( $wlToken ) {
$this->addFeedLinks( array(
'action' => 'feedwatchlist',
'allrev' => 1,
'wlowner' => $user->getName(),
'wltoken' => $wlToken,
) );
}
$output->addSubtitle(
$this->msg( 'watchlistfor2', $user->getName() )
->rawParams( SpecialEditWatchlist::buildTools( null ) )
);
$dbr = wfGetDB( DB_SLAVE, 'watchlist' );
# Show a message about slave lag, if applicable
$lag = wfGetLB()->safeGetLag( $dbr );
if ( $lag > 0 ) {
$output->showLagWarning( $lag );
}
$nitems = $this->countItems( $dbr );
if ( $nitems == 0 ) {
$output->addWikiMsg( 'nowatchlist' );
return;
}
# Possible where conditions
$conds = array();
if ( $opts['days'] > 0 ) {
$conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $opts['days'] * 86400 ) ) );
}
# Toggles
if ( $opts['hidemyself'] ) {
$conds[] = 'rc_user != ' . $user->getId();
}
if ( $opts['hidebots'] ) {
$conds[] = 'rc_bot = 0';
}
if ( $opts['hideminor'] ) {
$conds[] = 'rc_minor = 0';
}
if ( $opts['hideliu'] ) {
$conds[] = 'rc_user = 0';
}
if ( $opts['hideanons'] ) {
$conds[] = 'rc_user != 0';
}
if ( $user->useRCPatrol() && $opts['hidepatrolled'] ) {
$conds[] = 'rc_patrolled != 1';
}
# Namespace filtering
if ( $opts['namespace'] !== '' ) {
$selectedNS = $dbr->addQuotes( $opts['namespace'] );
$operator = $opts['invert'] ? '!=' : '=';
$boolean = $opts['invert'] ? 'AND' : 'OR';
# namespace association (bug 2429)
if ( !$opts['associated'] ) {
$condition = "rc_namespace $operator $selectedNS";
} else {
# Also add the associated namespace
$associatedNS = $dbr->addQuotes(
MWNamespace::getAssociated( $opts['namespace'] )
);
$condition = "(rc_namespace $operator $selectedNS "
. $boolean
. " rc_namespace $operator $associatedNS)";
}
$conds[] = $condition;
}
# Toggle watchlist content (all recent edits or just the latest)
if ( $opts['extended'] ) {
$limitWatchlist = $user->getIntOption( 'wllimit' );
$usePage = false;
} else {
# Top log Ids for a page are not stored
$nonRevisionTypes = array( RC_LOG );
wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) );
if ( $nonRevisionTypes ) {
$conds[] = $dbr->makeList(
array(
'rc_this_oldid=page_latest',
'rc_type' => $nonRevisionTypes,
),
LIST_OR
);
}
$limitWatchlist = 0;
$usePage = true;
}
$tables = array( 'recentchanges', 'watchlist' );
$fields = RecentChange::selectFields();
$join_conds = array(
'watchlist' => array(
'INNER JOIN',
array(
'wl_user' => $user->getId(),
'wl_namespace=rc_namespace',
'wl_title=rc_title'
),
),
);
$options = array( 'ORDER BY' => 'rc_timestamp DESC' );
if ( $wgShowUpdatedMarker ) {
$fields[] = 'wl_notificationtimestamp';
}
if ( $limitWatchlist ) {
$options['LIMIT'] = $limitWatchlist;
}
$rollbacker = $user->isAllowed( 'rollback' );
if ( $usePage || $rollbacker ) {
$tables[] = 'page';
$join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
if ( $rollbacker ) {
$fields[] = 'page_latest';
}
}
// Log entries with DELETED_ACTION must not show up unless the user has
// the necessary rights.
if ( !$user->isAllowed( 'deletedhistory' ) ) {
$bitmask = LogPage::DELETED_ACTION;
} elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
$bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ( $bitmask ) {
$conds[] = $dbr->makeList( array(
'rc_type != ' . RC_LOG,
$dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
), LIST_OR );
}
ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' );
wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields, $opts ) );
$rows = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
$numRows = $rows->numRows();
/* Start bottom header */
$lang = $this->getLanguage();
$wlInfo = '';
if ( $opts['days'] > 0 ) {
$timestamp = wfTimestampNow();
$wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $opts['days'] * 24 ) )->params(
$lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "
\n";
}
$nondefaults = $opts->getChangedValues();
$cutofflinks = $this->cutoffLinks( $opts['days'], $nondefaults ) . "
\n";
# Spit out some control panel links
$filters = array(
'hideminor' => 'rcshowhideminor',
'hidebots' => 'rcshowhidebots',
'hideanons' => 'rcshowhideanons',
'hideliu' => 'rcshowhideliu',
'hidemyself' => 'rcshowhidemine',
'hidepatrolled' => 'rcshowhidepatr'
);
foreach ( $this->getCustomFilters() as $key => $params ) {
$filters[$key] = $params['msg'];
}
// Disable some if needed
if ( !$user->useNPPatrol() ) {
unset( $filters['hidepatrolled'] );
}
$links = array();
foreach ( $filters as $name => $msg ) {
$links[] = $this->showHideLink( $nondefaults, $msg, $name, $opts[$name] );
}
$hiddenFields = $nondefaults;
unset( $hiddenFields['namespace'] );
unset( $hiddenFields['invert'] );
unset( $hiddenFields['associated'] );
# Create output
$form = '';
# Show watchlist header
$form .= "
"; $form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n"; if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) { $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n"; } if ( $wgShowUpdatedMarker ) { $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n"; } $form .= "
"; if ( $wgShowUpdatedMarker ) { $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL(), 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" . Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" . Html::hidden( 'reset', 'all' ) . "\n"; foreach ( $nondefaults as $key => $value ) { $form .= Html::hidden( $key, $value ) . "\n"; } $form .= Xml::closeElement( 'form' ) . "\n"; } $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getPageTitle()->getLocalURL(), 'id' => 'mw-watchlist-form' ) ); $form .= Xml::fieldset( $this->msg( 'watchlist-options' )->text(), false, array( 'id' => 'mw-watchlist-options' ) ); $form .= SpecialRecentChanges::makeLegend( $this->getContext() ); # Namespace filter and put the whole form together. $form .= $wlInfo; $form .= $cutofflinks; $form .= $lang->pipeList( $links ) . "\n"; $form .= ""; $form .= Html::namespaceSelector( array( 'selected' => $opts['namespace'], 'all' => '', 'label' => $this->msg( 'namespace' )->text() ), array( 'name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector', ) ) . ' '; $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $opts['invert'], array( 'title' => $this->msg( 'tooltip-invert' )->text() ) ) . ' '; $form .= Xml::checkLabel( $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated', $opts['associated'], array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() ) ) . ' '; $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "
\n"; foreach ( $hiddenFields as $key => $value ) { $form .= Html::hidden( $key, $value ) . "\n"; } $form .= Xml::closeElement( 'fieldset' ) . "\n"; $form .= Xml::closeElement( 'form' ) . "\n"; $output->addHTML( $form ); # If there's nothing to show, stop here if ( $numRows == 0 ) { $output->wrapWikiMsg( "