$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->setHTMLTitleMsg( '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->setHTMLTitleMsg( '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['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
'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 );
$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';
}
$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;
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->contribs = isset( $options['contribs'] ) ? $options['contribs'] : 'users';
$this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
$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';
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();
}
$mflag = '';
}
+ if ( !is_null( $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
+ $mSize = $this->getSkin()->formatRevisionSize( $rev->getSize() );
+ } else {
+ $mSize = '';
+ }
+
// Don't show useless link to people who cannot hide revisions
$canHide = $user->isAllowed( 'deleterevision' );
if( $canHide || ($rev->getVisibility() && $user->isAllowed('deletedhistory')) ) {
}
$diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
- $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
+ $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$mSize} {$comment} {$topmarktext}";
# Denote if username is redacted for this edit
if( $rev->isDeleted( Revision::DELETED_USER ) ) {