getVal( 'target' );
if ( '' == $target ) {
$wgOut->errorpage( 'notargettitle', 'notargettext' );
return;
}
# FIXME: Change from numeric offsets to date offsets
list( $limit, $offset ) = wfCheckLimits( 50, '' );
$offlimit = $limit + $offset;
$querylimit = $offlimit + 1;
$hideminor = ($wgRequest->getVal( 'hideminor' ) ? 1 : 0);
$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 ) {
$wgOut->errorpage( 'notargettitle', 'notargettext' );
return;
}
$nt =& Title::makeTitle( NS_USER, $nt->getDBkey() );
$id = User::idFromName( $nt->getText() );
if ( 0 == $id ) {
$ul = $nt->getText();
} else {
$ul = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
$userCond = '=' . $id;
}
$talk = $nt->getTalkPage();
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 ) {
$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 = {$namespace}";
}
extract( $dbr->tableNames( 'page', 'revision' ) );
if ( $userCond == "" ) {
$condition = "rev_user_text=" . $dbr->addQuotes( $nt->getText() );
$index = 'usertext_timestamp';
} else {
$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
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 ) );
$top = wfShowingResults( $offset, $limit );
$wgOut->addHTML( "
{$top}\n" );
$sl = wfViewPrevNext( $offset, $limit,
$wgContLang->specialpage( "Contributions" ),
"hideminor={$hideminor}&namespace={$namespace}&target=" . wfUrlEncode( $target ),
($numRows) <= $offlimit);
$shm = wfMsg( "showhideminor", $mlink );
$wgOut->addHTML( " {$sl} ($shm)
\n");
if ( 0 == $numRows ) {
$wgOut->addHTML( "\n" . wfMsg( "nocontribs" ) . "
\n" );
return;
}
$wgOut->addHTML( "\n" );
while( $obj = $dbr->fetchObject( $res ) ) {
ucListEdit( $sk,
$obj->page_namespace,
$obj->page_title,
$obj->rev_timestamp,
($obj->rev_id == $obj->page_latest),
$obj->rev_comment,
($obj->rev_minor_edit),
$obj->page_is_new,
$obj->rev_user_text,
$obj->rev_id );
}
$wgOut->addHTML( " \n" );
$wgOut->addHTML( " {$sl} ($shm)\n");
}
/**
* Generates each row in the contributions list.
*
* Contributions which are marked "top" are currently on top of the history.
* For these contributions, a [rollback] link is shown for users with sysop
* privileges. The rollback link restores the most recent version that was not
* written by the target user.
*
* If the contributions page is called with the parameter &bot=1, all rollback
* links also get that parameter. It causes the edit itself and the rollback
* to be marked as "bot" edits. Bot edits are hidden by default from recent
* changes, so this allows sysops to combat a busy vandal without bothering
* other users.
*
* @todo This would probably look a lot nicer in a table.
*/
function ucListEdit( $sk, $ns, $t, $ts, $topmark, $comment, $isminor, $isnew, $target, $oldid ) {
$fname = 'ucListEdit';
wfProfileIn( $fname );
global $wgLang, $wgOut, $wgUser, $wgRequest;
static $messages;
if( !isset( $messages ) ) {
foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist minoreditletter' ) as $msg ) {
$messages[$msg] = wfMsg( $msg );
}
}
$page =& Title::makeTitle( $ns, $t );
$link = $sk->makeKnownLinkObj( $page, '' );
$difftext = $topmarktext = '';
if($topmark) {
$topmarktext .= '' . $messages['uctop'] . ' ';
if(!$isnew) {
$difftext .= $sk->makeKnownLinkObj( $page, '(' . $messages['diff'] . ')', 'diff=0' );
} else {
$difftext .= $messages['newarticle'];
}
if( $wgUser->isAllowed('rollback') ) {
$extraRollback = $wgRequest->getBool( 'bot' ) ? '&bot=1' : '';
$extraRollback .= '&token=' . urlencode(
$wgUser->editToken( array( $page->getPrefixedText(), $target ) ) );
# $target = $wgRequest->getText( 'target' );
$topmarktext .= ' ['. $sk->makeKnownLinkObj( $page,
$messages['rollbacklink'],
'action=rollback&from=' . urlencode( $target ) . $extraRollback ) .']';
}
}
if ( $oldid ) {
$difftext= $sk->makeKnownLinkObj( $page, '(' . $messages['diff'].')', 'diff=prev&oldid='.$oldid );
}
$histlink='('.$sk->makeKnownLinkObj( $page, $messages['hist'], 'action=history' ) . ')';
$comment = $sk->commentBlock( $comment, $page );
$d = $wgLang->timeanddate( $ts, true );
if ($isminor) {
$mflag = '' . $messages['minoreditletter'] . ' ';
} else {
$mflag = '';
}
$wgOut->addHTML( "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext} \n" );
wfProfileOut( $fname );
}
/**
* 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 = '';
$namespaceselect .= ''.wfMsg( 'all' ).' ';
$arr = $wgContLang->getNamespaces();
foreach( array_keys( $arr ) as $i ) {
if( $i < 0 ) {
continue;
}
$namespacename = str_replace ( "_", " ", $arr[$i] );
$n = ($i == 0) ? wfMsg ( 'articlenamespace' ) : $namespacename;
$sel = ($i === $namespace) ? ' selected="selected"' : '';
$namespaceselect .= "{$n} ";
}
$namespaceselect .= ' ';
$submitbutton = ' ';
$out = "
';
return $out;
}
?>