X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialWatchlist.php;h=bb5e7ba06f90b04aca97e8e5c03c66ef86a095cb;hb=328e3473d61a11358d23017597672e7c1b2b44c8;hp=a921e982a3c452dfebed539e3a2c3998b60f3e2e;hpb=a4536a5a72b21aafdd8bc756810012e051ac4b76;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php
index a921e982a3..bb5e7ba06f 100644
--- a/includes/SpecialWatchlist.php
+++ b/includes/SpecialWatchlist.php
@@ -1,7 +1,7 @@
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 .= '
' . WatchlistEditor::buildTools( $wgUser->getSkin() );
+ $wgOut->setSubtitle( $sub );
+
if( ( $mode = WatchlistEditor::getMode( $wgRequest, $par ) ) !== false ) {
$editor = new WatchlistEditor();
$editor->execute( $wgUser, $wgOut, $wgRequest, $mode );
@@ -42,8 +45,10 @@ function wfSpecialWatchlist( $par ) {
}
$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(
@@ -82,19 +87,11 @@ function wfSpecialWatchlist( $par ) {
$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 */
@@ -117,9 +114,18 @@ function wfSpecialWatchlist( $par ) {
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 ) )."'";
/*
@@ -128,7 +134,6 @@ function wfSpecialWatchlist( $par ) {
$s = $dbr->fetchObject( $res );
$npages = $s->n;
*/
- $npages = 40000 * $days;
}
# If the watchlist is relatively short, it's simplest to zip
@@ -149,7 +154,7 @@ function wfSpecialWatchlist( $par ) {
if( $wgUser->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist) {
$header .= wfMsg( 'wlheader-enotif' ) . "\n";
}
- if ( $wgEnotifWatchlist && $wgShowUpdatedMarker ) {
+ if ( $wgShowUpdatedMarker ) {
$header .= wfMsg( 'wlheader-showupdated' ) . "\n";
}
@@ -158,21 +163,19 @@ function wfSpecialWatchlist( $par ) {
$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( '