X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialContributions.php;h=5c98e1c6bd5410cddd6b9a1615792daa77400a44;hb=8b3e9bd80c2ba3df6cdffcecdf6980b22b8ba05e;hp=b5016de12f086ccfe069729dfb7396854abeea8f;hpb=ed14647e9da96d47d15edbad9ca8207e97f9ac20;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index b5016de12f..5c98e1c6bd 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -1,172 +1,247 @@ - - -function wfSpecialContributions( $par = "" ) -{ - global $wgUser, $wgOut, $wgLang, $target, $hideminor; - $fname = "wfSpecialContributions"; - $sysop = $wgUser->isSysop(); - - if( $par ) - $target = $par; - else - $target = wfCleanQueryVar( $target ); - - if ( "" == $target ) { - $wgOut->errorpage( "notargettitle", "notargettext" ); +getVal( 'target' ); + $namespace = $wgRequest->getInt( 'namespace', '' ); + $namespace = ($namespace == '') ? NULL : $namespace; + $invert = $wgRequest->getBool( 'invert' ); + $hideminor = ($wgRequest->getBool( 'hideminor' ) ? true : false); + + if ( '' == $target ) { + $wgOut->errorpage( 'notargettitle', 'notargettext' ); return; } - list( $limit, $offset ) = wfCheckLimits( 50, "" ); + + # FIXME: Change from numeric offsets to date offsets + list( $limit, $offset ) = wfCheckLimits( 50, '' ); $offlimit = $limit + $offset; - $hideminor = ($hideminor ? 1 : 0); + $querylimit = $offlimit + 1; + $sk = $wgUser->getSkin(); + $dbr =& wfGetDB( DB_SLAVE ); + $userCond = ""; $nt = Title::newFromURL( $target ); - $nt->setNamespace( Namespace::getUser() ); + if ( !$nt ) { + $wgOut->errorpage( 'notargettitle', 'notargettext' ); + return; + } + $nt =& Title::makeTitle( NS_USER, $nt->getDBkey() ); - $sk = $wgUser->getSkin(); $id = User::idFromName( $nt->getText() ); if ( 0 == $id ) { $ul = $nt->getText(); } else { - $ul = $sk->makeKnownLink( $nt->getPrefixedText(), $nt->getText() ); + $ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); + $userCond = '=' . $id; } $talk = $nt->getTalkPage(); - if( $talk ) - $ul .= " (" . $sk->makeLinkObj( $talk, $wgLang->getNsText(Namespace::getTalk(0)) ) . ")"; - else - $ul .= "brrrp"; - $wgOut->setSubtitle( wfMsg( "contribsub", $ul ) ); + if( $talk ) { + $ul .= ' (' . $sk->makeLinkObj( $talk, $wgLang->getNsText( NS_TALK ) ) . ')'; + } + + + if ( $target == 'newbies' ) { + # View the contributions of all recently created accounts + $max = $dbr->selectField( 'user', 'max(user_id)', false, $fname ); + $userCond = '>' . ($max - $max / 100); + $ul = wfMsg ( 'newbies' ); + $id = 0; + } + + $wgOut->setSubtitle( wfMsg( 'contribsub', $ul ) ); if ( $hideminor ) { - $cmq = "AND cur_minor_edit=0"; - $omq = "AND old_minor_edit=0"; - $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), - WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . - "&offset={$offset}&limit={$limit}&hideminor=0" ); + $minorQuery = "AND rev_minor_edit=0"; + $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Contributions" ), + WfMsg( "show" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) . + "&offset={$offset}&limit={$limit}&hideminor=0&namespace={$namespace}" ); + } else { + $minorQuery = ""; + $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Contributions" ), + WfMsg( 'hide' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) . + "&offset={$offset}&limit={$limit}&hideminor=1&namespace={$namespace}" ); + } + + if( !is_null($namespace) ) { + $minorQuery .= ' AND page_namespace ' . ($invert ? '!' : '') . "= {$namespace}"; + } + + extract( $dbr->tableNames( 'page', 'revision' ) ); + if ( $userCond == "" ) { + $condition = "rev_user_text=" . $dbr->addQuotes( $nt->getText() ); + $index = 'usertext_timestamp'; } else { - $cmq = $omq = ""; - $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Contributions" ), - WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) . - "&offset={$offset}&limit={$limit}&hideminor=1" ); + $condition = "rev_user {$userCond}"; + $index = 'user_timestamp'; } + + $use_index = $dbr->useIndexClause( $index ); + $sql = "SELECT + page_namespace,page_title,page_is_new,page_latest, + rev_id,rev_timestamp,rev_comment,rev_minor_edit,rev_user_text, + rev_deleted + FROM $page,$revision $use_index + WHERE page_id=rev_page AND $condition $minorQuery " . + "ORDER BY rev_timestamp DESC LIMIT {$querylimit}"; + $res = $dbr->query( $sql, $fname ); + $numRows = $dbr->numRows( $res ); + + $wgOut->addHTML( namespaceForm( $target, $hideminor, $namespace, $invert ) ); + $top = wfShowingResults( $offset, $limit ); $wgOut->addHTML( "
{$top}\n" );
$sl = wfViewPrevNext( $offset, $limit,
- $wgLang->specialpage( "Contributions" ), "hideminor={$hideminor}&target=" . wfUrlEncode( $target ) );
+ $wgContLang->specialpage( "Contributions" ),
+ "hideminor={$hideminor}&namespace={$namespace}&target=" . wfUrlEncode( $target ),
+ ($numRows) <= $offlimit);
- $shm = wfMsg( "showhideminor", $mlink );
- $wgOut->addHTML( "
{$sl} ($shm) \n");
-
- if ( 0 == $id ) {
- $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
- "WHERE cur_user_text='" . wfStrencode( $nt->getText() ) . "' {$cmq} " .
- "ORDER BY inverse_timestamp LIMIT {$offlimit}";
- $res1 = wfQuery( $sql, DB_READ, $fname );
-
- $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
- "WHERE old_user_text='" . wfStrencode( $nt->getText() ) . "' {$omq} " .
- "ORDER BY inverse_timestamp LIMIT {$offlimit}";
- $res2 = wfQuery( $sql, DB_READ, $fname );
- } else {
- $sql = "SELECT cur_namespace,cur_title,cur_timestamp,cur_comment,cur_minor_edit FROM cur " .
- "WHERE cur_user={$id} {$cmq} ORDER BY inverse_timestamp LIMIT {$offlimit}";
- $res1 = wfQuery( $sql, DB_READ, $fname );
-
- $sql = "SELECT old_namespace,old_title,old_timestamp,old_comment,old_minor_edit FROM old " .
- "WHERE old_user={$id} {$omq} ORDER BY inverse_timestamp LIMIT {$offlimit}";
- $res2 = wfQuery( $sql, DB_READ, $fname );
- }
- $nCur = wfNumRows( $res1 );
- $nOld = wfNumRows( $res2 );
+ $shm = wfMsg( "showhideminor", $mlink );
+ $wgOut->addHTML( "
{$sl} ($shm)
" . wfMsg( "nocontribs" ) . "
\n" ); return; } - if ( 0 != $nCur ) { $obj1 = wfFetchObject( $res1 ); } - if ( 0 != $nOld ) { $obj2 = wfFetchObject( $res2 ); } $wgOut->addHTML( "