From 816b5c16733caa89456248614c0e7346505c12d6 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Tue, 4 Apr 2006 19:24:01 +0000 Subject: [PATCH] (bug 1862) Namespace filtering in watchlists --- RELEASE-NOTES | 1 + includes/SpecialWatchlist.php | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 55b1e9e744..10cf9f3529 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -430,6 +430,7 @@ Special Pages: is disabled * (bug 5447) Convert first letter of username to uppercase before searching in Special:Listusers * (bug 759) Wrap redirects on the watchlist editing page in a span, class "watchlistredir" +* (bug 1862) Namespace filtering in watchlists Misc.: * PHP 4.1 compatibility fix: don't use new_link parameter to mysql_connect diff --git a/includes/SpecialWatchlist.php b/includes/SpecialWatchlist.php index cec90c4b63..e09eeaf722 100644 --- a/includes/SpecialWatchlist.php +++ b/includes/SpecialWatchlist.php @@ -37,6 +37,7 @@ function wfSpecialWatchlist( $par ) { /* float */ 'days' => 3.0, /* or 0.5, watch further below */ /* bool */ 'hideOwn' => false, /* bool */ 'hideBots' => false, + 'nameSpace' => 'all', ); extract($defaults); @@ -45,6 +46,16 @@ function wfSpecialWatchlist( $par ) { $days = $wgRequest->getVal( 'days' ); $hideOwn = $wgRequest->getBool( 'hideOwn' ); $hideBots = $wgRequest->getBool( 'hideBots' ); + + # Get namespace value, if supplied, and prepare a WHERE fragment + $nameSpace = $wgRequest->getIntOrNull( 'namespace' ); + if( !is_null( $nameSpace ) ) { + $nameSpace = intval( $nameSpace ); + $nameSpaceClause = " AND rc_namespace = $nameSpace"; + } else { + $nameSpace = ''; + $nameSpaceClause = ''; + } # Watchlist editing $action = $wgRequest->getVal( 'action' ); @@ -121,6 +132,7 @@ function wfSpecialWatchlist( $par ) { wfAppendToArrayIfNotDefault( 'days', $days, $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'hideOwn', $hideOwn, $defaults, $nondefaults); wfAppendToArrayIfNotDefault( 'hideBots', $hideBots, $defaults, $nondefaults); + wfAppendToArrayIfNotDefault( 'namespace', $nameSpace, $defaults, $nondefaults ); if ( $days <= 0 ) { $docutoff = ''; @@ -268,6 +280,7 @@ function wfSpecialWatchlist( $par ) { AND rc_cur_id=page_id $andHideOwn $andHideBotsOptional + $nameSpaceClause ORDER BY rc_timestamp DESC"; $res = $dbr->query( $sql, $fname ); @@ -300,6 +313,19 @@ function wfSpecialWatchlist( $par ) { $wgOut->addHTML( wfMsgHtml( "wlhideshowbots", " $s" ) ); } + # Form for namespace filtering + $thisTitle = Title::makeTitle( NS_SPECIAL, 'Watchlist' ); + $thisAction = $thisTitle->escapeLocalUrl(); + $nsForm = "
\n"; + $nsForm .= " "; + $nsForm .= HTMLnamespaceselector( $nameSpace, '' ) . "\n"; + $nsForm .= ( $hideOwn ? "\n" : "" ); + $nsForm .= ( $hideBots ? "\n" : "" ); + $nsForm .= "\n"; + $nsForm .= "\n"; + $nsForm .= "
\n"; + $wgOut->addHTML( $nsForm ); + if ( $numRows == 0 ) { $wgOut->addWikitext( "
" . wfMsg( 'watchnochange' ), false ); $wgOut->addHTML( "

\n" ); -- 2.20.1