<?php
/**
- *
- * @addtogroup SpecialPage
+ * @file
+ * @ingroup SpecialPage Watchlist
*/
/**
* @param $par Parameter passed to the page
*/
function wfSpecialWatchlist( $par ) {
- global $wgUser, $wgOut, $wgLang, $wgRequest, $wgContLang;
+ global $wgUser, $wgOut, $wgLang, $wgRequest;
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
global $wgEnotifWatchlist;
$fname = 'wfSpecialWatchlist';
$llink = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogin' ), wfMsgHtml( 'loginreqlink' ), 'returnto=' . $specialTitle->getPrefixedUrl() );
$wgOut->addHtml( wfMsgWikiHtml( 'watchlistanontext', $llink ) );
return;
- } else {
- $wgOut->setPageTitle( wfMsg( 'watchlist' ) );
- $wgOut->setSubtitle( wfMsgWikiHtml( 'watchlistfor', htmlspecialchars( $wgUser->getName() ) ) );
}
+ $wgOut->setPageTitle( wfMsg( 'watchlist' ) );
+
+ $sub = wfMsgExt( 'watchlistfor', 'parseinline', $wgUser->getName() );
+ $sub .= '<br />' . WatchlistEditor::buildTools( $wgUser->getSkin() );
+ $wgOut->setSubtitle( $sub );
+
if( ( $mode = WatchlistEditor::getMode( $wgRequest, $par ) ) !== false ) {
$editor = new WatchlistEditor();
$editor->execute( $wgUser, $wgOut, $wgRequest, $mode );
}
$uid = $wgUser->getId();
- if( $wgEnotifWatchlist && $wgRequest->getVal( 'reset' ) && $wgRequest->wasPosted() ) {
+ if( ($wgEnotifWatchlist || $wgShowUpdatedMarker) && $wgRequest->getVal( 'reset' ) && $wgRequest->wasPosted() ) {
$wgUser->clearAllNotifications( $uid );
+ $wgOut->redirect( $specialTitle->getFullUrl() );
+ return;
}
$defaults = array(
$dbr = wfGetDB( DB_SLAVE, 'watchlist' );
list( $page, $watchlist, $recentchanges ) = $dbr->tableNamesN( 'page', 'watchlist', 'recentchanges' );
- $sql = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_user=$uid";
- $res = $dbr->query( $sql, $fname );
- $s = $dbr->fetchObject( $res );
-
-# Patch *** A1 *** (see A2 below)
-# adjust for page X, talk:page X, which are both stored separately, but treated together
- $nitems = floor($s->n / 2);
-# $nitems = $s->n;
-
- if($nitems == 0) {
- $wgOut->addWikiText( wfMsg( 'nowatchlist' ) );
- return;
- }
+ $watchlistCount = $dbr->selectField( 'watchlist', 'COUNT(*)',
+ array( 'wl_user' => $uid ), __METHOD__ );
+ // Adjust for page X, talk:page X, which are both stored separately,
+ // but treated together
+ $nitems = floor($watchlistCount / 2);
if( is_null($days) || !is_numeric($days) ) {
$big = 1000; /* The magical big */
wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults );
wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults);
+ $hookSql = "";
+ if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser, &$hookSql)) ) {
+ return;
+ }
+
+ if($nitems == 0) {
+ $wgOut->addWikiMsg( 'nowatchlist' );
+ return;
+ }
+
if ( $days <= 0 ) {
$andcutoff = '';
- $npages = wfMsg( 'watchlistall1' );
} else {
$andcutoff = "AND rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
/*
$s = $dbr->fetchObject( $res );
$npages = $s->n;
*/
- $npages = 40000 * $days;
}
# If the watchlist is relatively short, it's simplest to zip
if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) {
$header .= wfMsg( 'wlheader-enotif' ) . "\n";
}
- if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) {
+ if ( $wgShowUpdatedMarker ) {
$header .= wfMsg( 'wlheader-showupdated' ) . "\n";
}
$andLatest='';
$limitWatchlist = 'LIMIT ' . intval( $wgUser->getOption( 'wllimit' ) );
} else {
- $andLatest= 'AND rc_this_oldid=page_latest';
+ # Top log Ids for a page are not stored
+ $andLatest = 'AND (rc_this_oldid=page_latest OR rc_type=' . RC_LOG . ') ';
$limitWatchlist = '';
}
- # TODO: Consider removing the third parameter
- $header .= wfMsgExt( 'watchdetails', array( 'parsemag' ), $wgLang->formatNum( $nitems ),
- $wgLang->formatNum( $npages ), '',
- $specialTitle->getFullUrl( 'edit=yes' ) );
+ $header .= wfMsgExt( 'watchlist-details', array( 'parsemag' ), $wgLang->formatNum( $nitems ) );
$wgOut->addWikiText( $header );
-
+
# Show a message about slave lag, if applicable
if( ( $lag = $dbr->getLag() ) > 0 )
$wgOut->showLagWarning( $lag );
- if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) {
+ if ( $wgShowUpdatedMarker ) {
$wgOut->addHTML( '<form action="' .
$specialTitle->escapeLocalUrl() .
'" method="post"><input type="submit" name="dummy" value="' .
'" /><input type="hidden" name="reset" value="all" /></form>' .
"\n\n" );
}
-
- $sql = "SELECT *
- FROM $watchlist,$recentchanges,$page
+ if ( $wgShowUpdatedMarker ) {
+ $wltsfield = ", ${watchlist}.wl_notificationtimestamp ";
+ } else {
+ $wltsfield = '';
+ }
+ $sql = "SELECT ${recentchanges}.* ${wltsfield}
+ FROM $watchlist,$recentchanges
+ LEFT JOIN $page ON rc_cur_id=page_id
WHERE wl_user=$uid
AND wl_namespace=rc_namespace
AND wl_title=rc_title
- AND rc_cur_id=page_id
$andcutoff
$andLatest
$andHideOwn
$andHideBots
$andHideMinor
$nameSpaceClause
+ $hookSql
ORDER BY rc_timestamp DESC
$limitWatchlist";
$label = $hideBots ? wfMsgHtml( 'watchlist-show-bots' ) : wfMsgHtml( 'watchlist-hide-bots' );
$linkBits = wfArrayToCGI( array( 'hideBots' => 1 - (int)$hideBots ), $nondefaults );
$links[] = $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits );
-
+
# Hide/show own edits
$label = $hideOwn ? wfMsgHtml( 'watchlist-show-own' ) : wfMsgHtml( 'watchlist-hide-own' );
$linkBits = wfArrayToCGI( array( 'hideOwn' => 1 - (int)$hideOwn ), $nondefaults );
# If there's nothing to show, stop here
if( $numRows == 0 ) {
- $wgOut->addWikiText( wfMsgNoTrans( 'watchnochange' ) );
+ $wgOut->addWikiMsg( 'watchnochange' );
return;
}
if ( $wgShowUpdatedMarker ) {
$updated = $obj->wl_notificationtimestamp;
} else {
- // Same visual appearance as MW 1.4
- $updated = true;
+ $updated = false;
}
if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
- $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" .$dbr->strencode($obj->page_title). "' AND wl_namespace='{$obj->page_namespace}'" ;
- $res3 = $dbr->query( $sql3, $fname );
- $x = $dbr->fetchObject( $res3 );
- $rc->numberofWatchingusers = $x->n;
+ $rc->numberofWatchingusers = $dbr->selectField( 'watchlist',
+ 'COUNT(*)',
+ array(
+ 'wl_namespace' => $obj->rc_namespace,
+ 'wl_title' => $obj->rc_title,
+ ),
+ __METHOD__ );
} else {
$rc->numberofWatchingusers = 0;
}
$count = floor( $count / 2 );
return( $count );
-}
\ No newline at end of file
+}