From 5324a9ac4c8383caf6a6eda484656ada47000765 Mon Sep 17 00:00:00 2001 From: Shane King Date: Wed, 24 Nov 2004 12:41:45 +0000 Subject: [PATCH] Allow filtering of Special:Contributions by namespace. Originally intended so as to allow filtering of user image uploads, see bug #905. --- includes/SpecialContributions.php | 58 +++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index 875bd25d7c..b0d7ff9a4f 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -34,6 +34,12 @@ function wfSpecialContributions( $par = '' ) { $sk = $wgUser->getSkin(); $dbr =& wfGetDB( DB_SLAVE ); $userCond = ""; + $namespace = $wgRequest->getVal( 'namespace', '' ); + if( $namespace != '' ) { + $namespace = IntVal( $namespace ); + } else { + $namespace = NULL; + } $nt = Title::newFromURL( $target ); if ( !$nt ) { @@ -71,12 +77,17 @@ function wfSpecialContributions( $par = '' ) { $omq = 'AND old_minor_edit=0'; $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Contributions' ), WfMsg( 'show' ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) . - "&offset={$offset}&limit={$limit}&hideminor=0" ); + "&offset={$offset}&limit={$limit}&hideminor=0&namespace={$namespace}" ); } else { $cmq = $omq = ''; $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Contributions" ), WfMsg( 'hide' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) . - "&offset={$offset}&limit={$limit}&hideminor=1" ); + "&offset={$offset}&limit={$limit}&hideminor=1&namespace={$namespace}" ); + } + + if( !is_null($namespace) ) { + $cmq .= " AND cur_namespace = {$namespace}"; + $omq .= " AND old_namespace = {$namespace}"; } extract( $dbr->tableNames( 'old', 'cur' ) ); @@ -102,12 +113,14 @@ function wfSpecialContributions( $par = '' ) { $nCur = $dbr->numRows( $res1 ); $nOld = $dbr->numRows( $res2 ); + $wgOut->addHTML( namespaceForm( $target, $hideminor, $namespace ) ); + $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "

{$top}\n" ); $sl = wfViewPrevNext( $offset, $limit, $wgContLang->specialpage( 'Contributions' ), - "hideminor={$hideminor}&target=" . wfUrlEncode( $target ), + "hideminor={$hideminor}&namespace={$namespace}&target=" . wfUrlEncode( $target ), ($nCur + $nOld) <= $offlimit); $shm = wfMsg( 'showhideminor', $mlink ); @@ -256,4 +269,43 @@ function ucDaysLink( $lim, $d ) { "{$d}", "target={$target}&days={$d}&limit={$lim}" ); return $s; } + +/** + * Generates a form used to restrict display of contributions + * to a specific namespace + * + * @return none + * @param string $target target user to show contributions for + * @param string $hideminor whether minor contributions are hidden + * @param string $namespace currently selected namespace, NULL for show all + */ +function namespaceForm ( $target, $hideminor, $namespace ) { + global $wgContLang, $wgScript; + + $namespaceselect = '

'; + + $frombox = ''; + $submitbutton = ''; + + $out = "
"; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= wfMsg ( 'allpagesformtext2', $namespaceselect, $submitbutton ); + $out .= ''; + return $out; +} ?> -- 2.20.1