* @param ImagePage $imagePage
*/
public function __construct( $imagePage ) {
- global $wgShowArchiveThumbnails;
+ $context = $imagePage->getContext();
$this->current = $imagePage->getPage()->getFile();
$this->img = $imagePage->getDisplayedFile();
$this->title = $imagePage->getTitle();
$this->imagePage = $imagePage;
- $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
- $this->setContext( $imagePage->getContext() );
+ $this->showThumb = $context->getConfig()->get( 'ShowArchiveThumbnails' ) &&
+ $this->img->canRender();
+ $this->setContext( $context );
}
/**
. Xml::openElement( 'table', [ 'class' => 'wikitable filehistory' ] ) . "\n"
. '<tr><th></th>'
. ( $this->current->isLocal()
- && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<th></th>' : '' )
+ && ( MediaWikiServices::getInstance()
+ ->getPermissionManager()
+ ->userHasAnyRight( $this->getUser(), 'delete', 'deletedhistory' ) ) ? '<th></th>' : '' )
. '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
. ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
. '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
public function imageHistoryLine( $iscur, $file ) {
$user = $this->getUser();
$lang = $this->getLanguage();
+ $pm = MediaWikiServices::getInstance()->getPermissionManager();
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
$img = $iscur ? $file->getName() : $file->getArchiveName();
$userId = $file->getUser( 'id' );
$row = $selected = '';
// Deletion link
- if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
+ if ( $local && ( $pm->userHasAnyRight( $user, 'delete', 'deletedhistory' ) )
+ ) {
$row .= '<td>';
# Link to remove from history
if ( $user->isAllowed( 'delete' ) ) {
$row .= '<td>';
if ( $iscur ) {
$row .= $this->msg( 'filehist-current' )->escaped();
- } elseif ( $local && $this->title->quickUserCan( 'edit', $user )
- && $this->title->quickUserCan( 'upload', $user )
+ } elseif ( $local && $pm->quickUserCan( 'edit', $user, $this->title )
+ && $pm->quickUserCan( 'upload', $user, $this->title )
) {
if ( $file->isDeleted( File::DELETED_FILE ) ) {
$row .= $this->msg( 'filehist-revert' )->escaped();
$row .= "<td $selected style='white-space: nowrap;'>";
if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
# Don't link to unviewable files
- $row .= '<span class="history-deleted">'
- . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
+ $row .= Html::element( 'span', [ 'class' => 'history-deleted' ],
+ $lang->userTimeAndDate( $timestamp, $user )
+ );
} elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
+ $timeAndDate = htmlspecialchars( $lang->userTimeAndDate( $timestamp, $user ) );
if ( $local ) {
$this->preventClickjacking();
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
# Make a link to review the image
$url = Linker::linkKnown(
$revdel,
- $lang->userTimeAndDate( $timestamp, $user ),
+ $timeAndDate,
[],
[
'target' => $this->title->getPrefixedText(),
]
);
} else {
- $url = $lang->userTimeAndDate( $timestamp, $user );
+ $url = $timeAndDate;
}
$row .= '<span class="history-deleted">' . $url . '</span>';
} elseif ( !$file->exists() ) {
- $row .= '<span class="mw-file-missing">'
- . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
+ $row .= Html::element( 'span', [ 'class' => 'mw-file-missing' ],
+ $lang->userTimeAndDate( $timestamp, $user )
+ );
} else {
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
$row .= Xml::element(
$row .= '<td><span class="history-deleted">' .
$this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
} else {
- $row .=
- '<td dir="' . MediaWikiServices::getInstance()->getContentLanguage()->getDir() .
- '">' . Linker::formatComment( $description, $this->title ) . '</td>';
+ $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+ $row .= Html::rawElement(
+ 'td',
+ [ 'dir' => $contLang->getDir() ],
+ Linker::formatComment( $description, $this->title )
+ );
}
$rowClass = null;