var $messages, $target;
var $namespace = '', $mDb;
- function __construct( $target, $namespace = false ) {
- parent::__construct();
+ function __construct( IContextSource $context, $target, $namespace = false ) {
+ parent::__construct( $context );
$msgs = array( 'deletionlog', 'undeleteviewlink', 'diff' );
foreach( $msgs as $msg ) {
- $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities') );
+ $this->messages[$msg] = $this->msg( $msg )->escaped();
}
$this->target = $target;
$this->namespace = $namespace;
if ( isset( $this->mNavigationBar ) ) {
return $this->mNavigationBar;
}
- $lang = $this->getLang();
+ $lang = $this->getLanguage();
$fmtLimit = $lang->formatNum( $this->mLimit );
$linkTexts = array(
- 'prev' => wfMsgExt( 'pager-newer-n', array( 'escape', 'parsemag' ), $fmtLimit ),
- 'next' => wfMsgExt( 'pager-older-n', array( 'escape', 'parsemag' ), $fmtLimit ),
- 'first' => wfMsgHtml( 'histlast' ),
- 'last' => wfMsgHtml( 'histfirst' )
+ 'prev' => $this->msg( 'pager-newer-n', $fmtLimit )->escaped(),
+ 'next' => $this->msg( 'pager-older-n', $fmtLimit )->escaped(),
+ 'first' => $this->msg( 'histlast' )->escaped(),
+ 'last' => $this->msg( 'histfirst' )->escaped()
);
$pagingLinks = $this->getPagingLinks( $linkTexts );
$limits = $lang->pipeList( $limitLinks );
$this->mNavigationBar = "(" . $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " .
- wfMsgExt( 'viewprevnext', array( 'parsemag', 'escape', 'replaceafter' ), $pagingLinks['prev'], $pagingLinks['next'], $limits );
+ $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped();
return $this->mNavigationBar;
}
}
$comment = Linker::revComment( $rev );
- $date = htmlspecialchars( $this->getLang()->timeanddate( $rev->getTimestamp(), true ) );
+ $date = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $rev->getTimestamp(), $user ) );
if( !$user->isAllowed( 'undelete' ) || !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
$link = $date; // unusable link
$tools = Html::rawElement(
'span',
array( 'class' => 'mw-deletedcontribs-tools' ),
- wfMsg( 'parentheses', $this->getLang()->pipeList( array( $last, $dellog, $reviewlink ) ) )
+ $this->msg( 'parentheses' )->rawParams( $this->getLanguage()->pipeList(
+ array( $last, $dellog, $reviewlink ) ) )->escaped()
);
$ret = "{$del}{$link} {$tools} . . {$mflag} {$pagelink} {$comment}";
# Denote if username is redacted for this edit
if( $rev->isDeleted( Revision::DELETED_USER ) ) {
- $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
+ $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
}
$ret = Html::rawElement( 'li', array(), $ret ) . "\n";
$options['limit'] = $request->getInt( 'limit', $wgQueryPageDefaultLimit );
$options['target'] = $target;
- $nt = Title::makeTitleSafe( NS_USER, $target );
- if ( !$nt ) {
+ $userObj = User::newFromName( $target );
+ if ( !$userObj ) {
$out->addHTML( $this->getForm( '' ) );
return;
}
- $id = User::idFromName( $nt->getText() );
- $target = $nt->getText();
- $out->setSubtitle( $this->getSubTitle( $nt, $id ) );
+ $target = $userObj->getName();
+ $out->addSubtitle( $this->getSubTitle( $userObj ) );
if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
$options['namespace'] = intval( $ns );
$out->addHTML( $this->getForm( $options ) );
- $pager = new DeletedContribsPager( $target, $options['namespace'] );
+ $pager = new DeletedContribsPager( $this->getContext(), $target, $options['namespace'] );
if ( !$pager->getNumRows() ) {
$out->addWikiMsg( 'nocontribs' );
return;
? 'sp-contributions-footer-anon'
: 'sp-contributions-footer';
- if( !wfMessage( $message )->isDisabled() ) {
+ if( !$this->msg( $message )->isDisabled() ) {
$out->wrapWikiMsg( "<div class='mw-contributions-footer'>\n$1\n</div>", array( $message, $target ) );
}
}
/**
* 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 contributionsSub in SpecialContributions.php. Could be combined.
*/
- function getSubTitle( $nt, $id ) {
- if ( $id === null ) {
- $user = htmlspecialchars( $nt->getText() );
+ function getSubTitle( $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 );
+ $nt = $userObj->getUserPage();
+ $id = $userObj->getID();
$talk = $nt->getTalkPage();
if( $talk ) {
# Talk page link
- $tools[] = Linker::link( $talk, wfMsgHtml( 'sp-contributions-talk' ) );
+ $tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() );
if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) {
if( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
if ( $userObj->isBlocked() ) {
$tools[] = Linker::linkKnown( # Change block link
SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
- wfMsgHtml( 'change-blocklink' )
+ $this->msg( 'change-blocklink' )->escaped()
);
$tools[] = Linker::linkKnown( # Unblock link
SpecialPage::getTitleFor( 'BlockList' ),
- wfMsgHtml( 'unblocklink' ),
+ $this->msg( 'unblocklink' )->escaped(),
array(),
array(
'action' => 'unblock',
else { # User is not blocked
$tools[] = Linker::linkKnown( # Block link
SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
- wfMsgHtml( 'blocklink' )
+ $this->msg( 'blocklink' )->escaped()
);
}
}
# Block log link
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
- wfMsgHtml( 'sp-contributions-blocklog' ),
+ $this->msg( 'sp-contributions-blocklog' )->escaped(),
array(),
array(
'type' => 'block',
# Other logs link
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Log' ),
- wfMsgHtml( 'sp-contributions-logs' ),
+ $this->msg( 'sp-contributions-logs' )->escaped(),
array(),
array( 'user' => $nt->getText() )
);
# Link to contributions
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ),
- wfMsgHtml( 'sp-deletedcontributions-contribs' )
+ $this->msg( 'sp-deletedcontributions-contribs' )->escaped()
);
# Add a link to change user rights for privileged users
$userrightsPage = new UserrightsPage();
+ $userrightsPage->setContext( $this->getContext() );
if( $id !== null && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) {
$tools[] = Linker::linkKnown(
SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
- wfMsgHtml( 'sp-contributions-userrights' )
+ $this->msg( 'sp-contributions-userrights' )->escaped()
);
}
wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) );
- $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() ) {
// 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 );
}
}
}
$f .= Xml::openElement( 'fieldset' ) .
- Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
- Xml::tags( 'label', array( 'for' => 'target' ), wfMsgExt( 'sp-contributions-username', 'parseinline' ) ) . ' ' .
+ Xml::element( 'legend', array(), $this->msg( 'sp-contributions-search' )->text() ) .
+ Xml::tags( 'label', array( 'for' => 'target' ), $this->msg( 'sp-contributions-username' )->parse() ) . ' ' .
Html::input( 'target', $options['target'], 'text', array(
'size' => '20',
'required' => ''
) + ( $options['target'] ? array() : array( 'autofocus' ) ) ) . ' '.
- Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
+ Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . ' ' .
Xml::namespaceSelector( $options['namespace'], '' ) . ' ' .
- Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
+ Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' );
return $f;