$this->opts = array();
$request = $this->getRequest();
- if ( $par == 'newbies' ) {
- $target = 'newbies';
- $this->opts['contribs'] = 'newbie';
- } elseif ( $par !== null ) {
+ if ( $par !== null ) {
$target = $par;
} else {
$target = $request->getVal( 'target' );
$this->opts['target'] = $target;
$this->opts['topOnly'] = $request->getBool( 'topOnly' );
- $userObj = User::newFromName( $target, false );
+ $nt = Title::makeTitleSafe( NS_USER, $target );
+ if ( !$nt ) {
+ $out->addHTML( $this->getForm() );
+ return;
+ }
+ $userObj = User::newFromName( $nt->getText(), false );
if ( !$userObj ) {
$out->addHTML( $this->getForm() );
return;
}
- $nt = $userObj->getUserPage();
$id = $userObj->getID();
if ( $this->opts['contribs'] != 'newbie' ) {
}
$nt = $userObj->getUserPage();
$talk = $userObj->getTalkPage();
+ $links = '';
if ( $talk ) {
- $tools = $this->getUserLinks( $nt, $talk, $userObj, $this->getUser() );
+ $tools = $this->getUserLinks( $nt, $talk, $userObj );
$links = $this->getLanguage()->pipeList( $tools );
// Show a note if the user is blocked and display the last block log entry.
// 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'.
+ // @todo Should this be removed at some point?
$oldMsg = $this->msg( 'contribsub' );
if ( $oldMsg->exists() ) {
- return $oldMsg->rawParams( "$user ($links)" );
+ $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
+ return $oldMsg->rawParams( "$user $linksWithParentheses" );
} else {
return $this->msg( 'contribsub2' )->rawParams( $user, $links );
}
* @param $userpage Title: Target user page
* @param $talkpage Title: Talk page
* @param $target User: Target user object
- * @param $subject User: The viewing user ($wgUser might be still checked in some cases)
* @return array
*/
- public function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) {
+ public function getUserLinks( Title $userpage, Title $talkpage, User $target ) {
$id = $target->getId();
$username = $target->getName();
$tools[] = Linker::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
- if ( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
+ if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
if ( $target->isBlocked() ) {
$tools[] = Linker::linkKnown( # Change block link
SpecialPage::getTitleFor( 'Block', $username ),
);
# Add link to deleted user contributions for priviledged users
- if ( $subject->isAllowed( 'deletedhistory' ) ) {
+ if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'DeletedContributions', $username ),
$this->msg( 'sp-contributions-deleted' )->escaped()
# Add a link to change user rights for privileged users
$userrightsPage = new UserrightsPage();
- $userrightsPage->getContext()->setUser( $subject );
+ $userrightsPage->setContext( $this->getContext() );
if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Userrights', $username ),
)
) .
Xml::tags( 'td', null,
- Xml::namespaceSelector( $this->opts['namespace'], '' ) . ' ' .
+ Html::namespaceSelector( array(
+ 'selected' => $this->opts['namespace'],
+ 'all' => '',
+ ), array(
+ 'name' => 'namespace',
+ 'id' => 'namespace',
+ 'class' => 'namespaceselector',
+ ) ) .
+ ' ' .
Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
Xml::checkLabel(
$this->msg( 'invert' )->text(),
$filterSelection .
Xml::closeElement( 'tr' ) .
Xml::openElement( 'tr' ) .
- $extraOptions .
- Xml::closeElement( 'tr' ) .
- Xml::openElement( 'tr' ) .
+ $extraOptions .
+ Xml::closeElement( 'tr' ) .
+ Xml::openElement( 'tr' ) .
$dateSelectionAndSubmit .
Xml::closeElement( 'tr' ) .
Xml::closeElement( 'table' );
var $namespace = '', $mDb;
var $preventClickjacking = false;
+ /**
+ * @var array
+ */
+ protected $mParentLens;
+
function __construct( IContextSource $context, array $options ) {
parent::__construct( $context );
# @todo FIXME: Other groups may have 'bot' rights
$join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
} else {
- if ( IP::isIPAddress( $this->target ) ) {
+ $uid = User::idFromName( $this->target );
+ if ( $uid ) {
+ $condition['rev_user'] = $uid;
+ $index = 'user_timestamp';
+ } else {
$condition['rev_user_text'] = $this->target;
$index = 'usertext_timestamp';
- } else {
- $condition['rev_user'] = User::idFromName( $this->target );
- $index = 'user_timestamp';
- }
+ }
}
if ( $this->deletedOnly ) {
$condition[] = "rev_deleted != '0'";
$this->mResult->rewind();
$revIds = array();
foreach ( $this->mResult as $row ) {
- $revIds[] = $row->rev_parent_id;
+ if( $row->rev_parent_id ) {
+ $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 );
- $batch = new LinkBatch();
- # Give some pointers to make (last) links
- foreach ( $this->mResult as $row ) {
- $batch->addObj( Title::makeTitleSafe( NS_USER, $row->user_name ) );
- $batch->addObj( Title::makeTitleSafe( NS_USER_TALK, $row->user_name ) );
+ # Do a link batch query
+ $this->mResult->seek( 0 );
+ $batch = new LinkBatch();
+ # Give some pointers to make (last) links
+ foreach ( $this->mResult as $row ) {
+ if ( $this->contribs === 'newbie' ) { // multiple users
+ $batch->add( NS_USER, $row->user_name );
+ $batch->add( NS_USER_TALK, $row->user_name );
}
- $batch->execute();
- $this->mResult->seek( 0 );
+ $batch->add( $row->page_namespace, $row->page_title );
}
+ $batch->execute();
+ $this->mResult->seek( 0 );
}
/**
* Do a batched query to get the parent revision lengths
+ * @param $revIds array
+ * @return array
*/
private function getParentLengths( array $revIds ) {
$revLens = array();
* was not written by the target user.
*
* @todo This would probably look a lot nicer in a table.
+ * @param $row
+ * @return string
*/
function formatRow( $row ) {
wfProfileIn( __METHOD__ );
array( 'action' => 'history' )
);
- if ( isset( $this->mParentLens[$row->rev_parent_id] ) ) {
- $chardiff = ' . . ' . ChangesList::showCharacterDifference(
- $this->mParentLens[$row->rev_parent_id], $row->rev_len ) . ' . . ';
+ if ( $row->rev_parent_id === null ) {
+ // For some reason rev_parent_id isn't populated for this row.
+ // Its rumoured this is true on wikipedia for some revisions (bug 34922).
+ // Next best thing is to have the total number of bytes.
+ $chardiff = ' . . ' . Linker::formatRevisionSize( $row->rev_len ) . ' . . ';
} else {
- $chardiff = ' ';
+ $parentLen = isset( $this->mParentLens[$row->rev_parent_id] ) ? $this->mParentLens[$row->rev_parent_id] : 0;
+ $chardiff = ' . . ' . ChangesList::showCharacterDifference(
+ $parentLen, $row->rev_len ) . ' . . ';
}
$lang = $this->getLanguage();
$mflag = '';
}
- // Don't show useless link to people who cannot hide revisions
- $canHide = $user->isAllowed( 'deleterevision' );
- if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
- if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
- $del = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
- } else {
- $query = array(
- 'type' => 'revision',
- 'target' => $page->getPrefixedDbkey(),
- 'ids' => $rev->getId()
- );
- $del = Linker::revDeleteLink( $query,
- $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
- }
+ $del = Linker::getRevDeleteLink( $user, $rev, $page );
+ if ( $del !== '' ) {
$del .= ' ';
- } else {
- $del = '';
}
- $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
+ $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages['pipe-separator'] . $histlink )->escaped();
$ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
# Denote if username is redacted for this edit
/**
* Overwrite Pager function and return a helpful comment
+ * @return string
*/
function getSqlComment() {
if ( $this->namespace || $this->deletedOnly ) {
$this->preventClickjacking = true;
}
+ /**
+ * @return bool
+ */
public function getPreventClickjacking() {
return $this->preventClickjacking;
}