$this->opts['target'] = $target;
$this->opts['topOnly'] = $request->getBool( 'topOnly' );
- $nt = Title::makeTitleSafe( NS_USER, $target );
- if( !$nt ) {
+ $userObj = User::newFromName( $target, false );
+ if( !$userObj ) {
$out->addHTML( $this->getForm() );
return;
}
- $id = User::idFromName( $nt->getText() );
+ $nt = $userObj->getUserPage();
+ $id = $userObj->getID();
if( $this->opts['contribs'] != 'newbie' ) {
$target = $nt->getText();
- $out->setSubtitle( $this->contributionsSub( $nt, $id ) );
- $out->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) );
- $userObj = User::newFromName( $target, false );
- if ( is_object( $userObj ) ) {
- $this->getSkin()->setRelevantUser( $userObj );
- }
+ $out->addSubtitle( $this->contributionsSub( $userObj ) );
+ $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ), $target ) ) );
+ $this->getSkin()->setRelevantUser( $userObj );
} else {
- $out->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
- $out->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
+ $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub') );
+ $out->setHTMLTitle( $this->msg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
}
if( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
$this->opts['namespace'] = '';
}
- $this->opts['tagFilter'] = (string) $request->getVal( 'tagFilter' );
+ $this->opts['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
+
+ $this->opts['tagfilter'] = (string) $request->getVal( 'tagfilter' );
// Allows reverts to have the bot flag in recent changes. It is just here to
// be passed in the form at the top of the page
if ( $this->opts['deletedOnly'] ) {
$apiParams['deletedonly'] = true;
}
- if ( $this->opts['tagFilter'] !== '' ) {
- $apiParams['tagfilter'] = $this->opts['tagFilter'];
+ if ( $this->opts['tagfilter'] !== '' ) {
+ $apiParams['tagfilter'] = $this->opts['tagfilter'];
}
if ( $this->opts['namespace'] !== '' ) {
$apiParams['namespace'] = $this->opts['namespace'];
'month' => $this->opts['month'],
'deletedOnly' => $this->opts['deletedOnly'],
'topOnly' => $this->opts['topOnly'],
+ 'nsInvert' => $this->opts['nsInvert'],
) );
if( !$pager->getNumRows() ) {
$out->addWikiMsg( 'nocontribs', $target );
if ( IP::isIPAddress( $target ) ) {
$message = 'sp-contributions-footer-anon';
} else {
- $userObj = User::newFromName( $target );
- if ( !$userObj || $userObj->isAnon() ) {
+ if ( $userObj->isAnon() ) {
// No message for non-existing users
return;
}
/**
* Generates the subheading with links
- * @param $nt Title object for the target
- * @param $id Integer: User ID for the target
+ * @param $userObj User object for the target
* @return String: appropriately-escaped HTML to be output literally
* @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
*/
- protected function contributionsSub( $nt, $id ) {
- if ( $id === null ) {
- $user = htmlspecialchars( $nt->getText() );
+ protected function contributionsSub( $userObj ) {
+ if ( $userObj->isAnon() ) {
+ $user = htmlspecialchars( $userObj->getName() );
} else {
- $user = Linker::link( $nt, htmlspecialchars( $nt->getText() ) );
+ $user = Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
}
- $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false );
- $talk = $nt->getTalkPage();
+ $nt = $userObj->getUserPage();
+ $talk = $userObj->getTalkPage();
if( $talk ) {
$tools = self::getUserLinks( $nt, $talk, $userObj, $this->getUser() );
- $links = $this->getLang()->pipeList( $tools );
+ $links = $this->getLanguage()->pipeList( $tools );
// Show a note if the user is blocked and display the last block log entry.
if ( $userObj->isBlocked() ) {
$userObj->isAnon() ?
'sp-contributions-blocked-notice-anon' :
'sp-contributions-blocked-notice',
- $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
+ $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
),
'offset' => '' # don't use WebRequest parameter offset
)
// languages that want to put the "for" bit right after $user but before
// $links. If 'contribsub' is around, use it for reverse compatibility,
// otherwise use 'contribsub2'.
- if( wfEmptyMsg( 'contribsub' ) ) {
- return wfMsgHtml( 'contribsub2', $user, $links );
+ $oldMsg = $this->msg( 'contribsub' );
+ if ( $oldMsg->exists() ) {
+ return $oldMsg->rawParams( "$user ($links)" );
} else {
- return wfMsgHtml( 'contribsub', "$user ($links)" );
+ return $this->msg( 'contribsub2' )->rawParams( $user, $links );
}
}
$this->opts['namespace'] = '';
}
+ if( !isset( $this->opts['nsInvert'] ) ) {
+ $this->opts['nsInvert'] = '';
+ }
+
if( !isset( $this->opts['contribs'] ) ) {
$this->opts['contribs'] = 'user';
}
$this->opts['target'] = '';
}
- if( !isset( $this->opts['tagFilter'] ) ) {
- $this->opts['tagFilter'] = '';
+ if( !isset( $this->opts['tagfilter'] ) ) {
+ $this->opts['tagfilter'] = '';
}
if( !isset( $this->opts['topOnly'] ) ) {
$f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
# Add hidden params for tracking except for parameters in $skipParameters
- $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
+ $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
foreach ( $this->opts as $name => $value ) {
if( in_array( $name, $skipParameters ) ) {
continue;
$f .= "\t" . Html::hidden( $name, $value ) . "\n";
}
- $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
+ $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
$f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
Xml::namespaceSelector( $this->opts['namespace'], '' )
) .
+ Xml::checkLabel( wfMsg('invert'), 'nsInvert', 'nsInvert', $this->opts['nsInvert'] ) . ' ' .
Xml::checkLabel( wfMsg( 'history-show-deleted' ),
'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
$this->target = isset( $options['target'] ) ? $options['target'] : '';
$this->contribs = isset( $options['contribs'] ) ? $options['contribs'] : 'users';
$this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
- $this->tagFilter = isset( $options['tagFilter'] ) ? $options['tagFilter'] : false;
+ $this->tagFilter = isset( $options['tagfilter'] ) ? $options['tagfilter'] : false;
+ $this->nsInvert = isset( $options['nsInvert'] ) ? $options['nsInvert'] : false;
$this->deletedOnly = !empty( $options['deletedOnly'] );
$this->topOnly = !empty( $options['topOnly'] );
$user = $this->getUser();
$conds = array_merge( $userCond, $this->getNamespaceCond() );
+
// Paranoia: avoid brute force searches (bug 17342)
if( !$user->isAllowed( 'deletedhistory' ) ) {
$conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
}
# Don't include orphaned revisions
- $join_cond['page'] = array( 'INNER JOIN', 'page_id = rev_page' );
+ $join_cond['page'] = Revision::pageJoinCond();
# Get the current user name for accounts
- $join_cond['user'] = array( 'LEFT JOIN', 'rev_user != 0 AND user_id = rev_user' );
+ $join_cond['user'] = Revision::userJoinCond();
$queryInfo = array(
'tables' => $tables,
function getNamespaceCond() {
if( $this->namespace !== '' ) {
- return array( 'page_namespace' => (int)$this->namespace );
+ if ( $this->nsInvert ) {
+ return array( 'page_namespace != ' . (int)$this->namespace );
+ } else {
+ return array( 'page_namespace' => (int)$this->namespace );
+ }
} else {
return array();
}
}
function doBatchLookups() {
- global $wgRCShowChangedSize;
-
- $this->mParentLens = array();
- if ( $wgRCShowChangedSize ) {
- $this->mResult->rewind();
- $revIds = array();
- foreach ( $this->mResult as $row ) {
- $revIds[] = $row->rev_parent_id;
- }
- $this->mParentLens = $this->getParentLengths( $revIds );
- $this->mResult->rewind(); // reset
+ $this->mResult->rewind();
+ $revIds = array();
+ foreach ( $this->mResult as $row ) {
+ $revIds[] = $row->rev_parent_id;
}
+ $this->mParentLens = $this->getParentLengths( $revIds );
+ $this->mResult->rewind(); // reset
+
if ( $this->contribs === 'newbie' ) { // multiple users
# Do a link batch query
$this->mResult->seek( 0 );
}
}
- /*
+ /**
* Do a batched query to get the parent revision lengths
*/
private function getParentLengths( array $revIds ) {
$chardiff = ' ';
}
- $comment = $this->getLang()->getDirMark() . Linker::revComment( $rev, false, true );
- $date = $this->getLang()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
+ $comment = $this->getLanguage()->getDirMark() . Linker::revComment( $rev, false, true );
+ $date = $this->getLanguage()->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
if( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$d = Linker::linkKnown(
$page,