Use local context to get messages and time formatting methods of Language class.

Only updated the code in the ImageHistoryList class.

Change-Id: I75bbbcb5c93f3c35c347ec8a0156cbb4b7c10142
This commit is contained in:
Alexandre Emsenhuber 2012-07-11 20:30:14 +02:00
parent 049fcb5f87
commit 65a0b35bd4

View file

@ -944,18 +944,18 @@ class ImageHistoryList extends ContextSource {
* @return string
*/
public function beginImageHistoryList( $navLinks = '' ) {
return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) ) . "\n"
return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
. "<div id=\"mw-imagepage-section-filehistory\">\n"
. $this->getOutput()->parse( wfMsgNoTrans( 'filehist-help' ) )
. $this->msg( 'filehist-help' )->parseAsBlock()
. $navLinks . "\n"
. Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
. '<tr><td></td>'
. ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
. ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
. '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
. '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
. '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
. ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
. '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
. '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
. '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
. "</tr>\n";
}
@ -997,7 +997,7 @@ class ImageHistoryList extends ContextSource {
}
$row .= Linker::linkKnown(
$this->title,
wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
$this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
array(), $q
);
}
@ -1008,7 +1008,7 @@ class ImageHistoryList extends ContextSource {
$row .= '<br />';
}
// If file is top revision or locked from this user, don't link
if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED ) ) {
if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
$del = Linker::revDeleteLinkDisabled( $canHide );
} else {
list( $ts, ) = explode( '!', $img, 2 );
@ -1028,16 +1028,16 @@ class ImageHistoryList extends ContextSource {
// Reversion link/current indicator
$row .= '<td>';
if ( $iscur ) {
$row .= wfMsgHtml( 'filehist-current' );
} elseif ( $local && $this->title->quickUserCan( 'edit' )
&& $this->title->quickUserCan( 'upload' )
$row .= $this->msg( 'filehist-current' )->escaped();
} elseif ( $local && $this->title->quickUserCan( 'edit', $user )
&& $this->title->quickUserCan( 'upload', $user )
) {
if ( $file->isDeleted( File::DELETED_FILE ) ) {
$row .= wfMsgHtml( 'filehist-revert' );
$row .= $this->msg( 'filehist-revert' )->escaped();
} else {
$row .= Linker::linkKnown(
$this->title,
wfMsgHtml( 'filehist-revert' ),
$this->msg( 'filehist-revert' )->escaped(),
array(),
array(
'action' => 'revert',
@ -1054,9 +1054,9 @@ class ImageHistoryList extends ContextSource {
$selected = "class='filehistory-selected'";
}
$row .= "<td $selected style='white-space: nowrap;'>";
if ( !$file->userCan( File::DELETED_FILE ) ) {
if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
# Don't link to unviewable files
$row .= '<span class="history-deleted">' . $lang->timeanddate( $timestamp, true ) . '</span>';
$row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
} elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
if ( $local ) {
$this->preventClickjacking();
@ -1064,7 +1064,7 @@ class ImageHistoryList extends ContextSource {
# Make a link to review the image
$url = Linker::linkKnown(
$revdel,
$lang->timeanddate( $timestamp, true ),
$lang->userTimeAndDate( $timestamp, $user ),
array(),
array(
'target' => $this->title->getPrefixedText(),
@ -1073,12 +1073,12 @@ class ImageHistoryList extends ContextSource {
)
);
} else {
$url = $lang->timeanddate( $timestamp, true );
$url = $lang->userTimeAndDate( $timestamp, $user );
}
$row .= '<span class="history-deleted">' . $url . '</span>';
} else {
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
$row .= Xml::element( 'a', array( 'href' => $url ), $lang->timeanddate( $timestamp, true ) );
$row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
}
$row .= "</td>";
@ -1090,9 +1090,9 @@ class ImageHistoryList extends ContextSource {
// Image dimensions + size
$row .= '<td>';
$row .= htmlspecialchars( $file->getDimensionsString() );
$row .= $this->getContext()->msg( 'word-separator' )->plain();
$row .= $this->msg( 'word-separator' )->plain();
$row .= '<span style="white-space: nowrap;">';
$row .= $this->getContext()->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
$row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
$row .= '</span>';
$row .= '</td>';
@ -1100,11 +1100,11 @@ class ImageHistoryList extends ContextSource {
$row .= '<td>';
// Hide deleted usernames
if ( $file->isDeleted( File::DELETED_USER ) ) {
$row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
$row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
} else {
if ( $local ) {
$row .= Linker::userLink( $userId, $userText );
$row .= $this->getContext()->msg( 'word-separator' )->plain();
$row .= $this->msg( 'word-separator' )->plain();
$row .= '<span style="white-space: nowrap;">';
$row .= Linker::userToolLinks( $userId, $userText );
$row .= '</span>';
@ -1116,7 +1116,7 @@ class ImageHistoryList extends ContextSource {
// Don't show deleted descriptions
if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
$row .= '<td><span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span></td>';
$row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
} else {
$row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
}
@ -1134,7 +1134,10 @@ class ImageHistoryList extends ContextSource {
*/
protected function getThumbForLine( $file ) {
$lang = $this->getLanguage();
if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
$user = $this->getUser();
if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE,$user )
&& !$file->isDeleted( File::DELETED_FILE ) )
{
$params = array(
'width' => '120',
'height' => '120',
@ -1143,20 +1146,20 @@ class ImageHistoryList extends ContextSource {
$thumbnail = $file->transform( $params );
$options = array(
'alt' => wfMsg( 'filehist-thumbtext',
$lang->timeanddate( $timestamp, true ),
$lang->date( $timestamp, true ),
$lang->time( $timestamp, true ) ),
'alt' => $this->msg( 'filehist-thumbtext',
$lang->userTimeAndDate( $timestamp, $user ),
$lang->userDate( $timestamp, $user ),
$lang->userTime( $timestamp, $user ) )->text(),
'file-link' => true,
);
if ( !$thumbnail ) {
return wfMsgHtml( 'filehist-nothumb' );
return $this->msg( 'filehist-nothumb' )->escaped();
}
return $thumbnail->toHtml( $options );
} else {
return wfMsgHtml( 'filehist-nothumb' );
return $this->msg( 'filehist-nothumb' )->escaped();
}
}