123 $pm = MediaWikiServices::getInstance()->getPermissionManager();
124 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
128 $userId =
$file->getUser(
'id' );
129 $userText =
$file->getUser(
'text' );
130 $description =
$file->getDescription( File::FOR_THIS_USER, $user );
132 $local = $this->current->isLocal();
133 $row = $selected =
'';
136 if ( $local && ( $pm->userHasAnyRight( $user,
'delete',
'deletedhistory' ) ) ) {
138 # Link to remove from history
139 if ( $pm->userHasRight( $user,
'delete' ) ) {
140 $q = [
'action' =>
'delete' ];
142 $q[
'oldimage'] =
$img;
144 $row .= $linkRenderer->makeKnownLink(
146 $this->
msg( $iscur ?
'filehist-deleteall' :
'filehist-deleteone' )->text(),
150 # Link to hide content. Don't show useless link to people who cannot hide revisions.
151 $canHide = $pm->userHasRight( $user,
'deleterevision' );
152 if ( $canHide || ( $pm->userHasRight( $user,
'deletedhistory' )
153 &&
$file->getVisibility() ) ) {
154 if ( $pm->userHasRight( $user,
'delete' ) ) {
158 if ( $iscur || !
$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
161 list( $ts, ) = explode(
'!',
$img, 2 );
163 'type' =>
'oldimage',
164 'target' => $this->title->getPrefixedText(),
168 $file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
178 $row .= $this->
msg(
'filehist-current' )->escaped();
179 } elseif ( $local && $pm->quickUserCan(
'edit', $user, $this->title )
180 && $pm->quickUserCan(
'upload', $user, $this->title )
182 if (
$file->isDeleted( File::DELETED_FILE ) ) {
183 $row .= $this->
msg(
'filehist-revert' )->escaped();
185 $row .= $linkRenderer->makeKnownLink(
187 $this->
msg(
'filehist-revert' )->text(),
190 'action' =>
'revert',
199 if (
$file->getTimestamp() === $this->img->getTimestamp() ) {
200 $selected =
"class='filehistory-selected'";
202 $row .=
"<td $selected style='white-space: nowrap;'>";
203 if ( !
$file->userCan( File::DELETED_FILE, $user ) ) {
204 # Don't link to unviewable files
205 $row .= Html::element(
'span', [
'class' =>
'history-deleted' ],
206 $lang->userTimeAndDate( $timestamp, $user )
208 } elseif (
$file->isDeleted( File::DELETED_FILE ) ) {
209 $timeAndDate =
$lang->userTimeAndDate( $timestamp, $user );
213 # Make a link to review the image
214 $url = $linkRenderer->makeKnownLink(
219 'target' => $this->title->getPrefixedText(),
221 'token' => $user->getEditToken(
$img )
225 $url = htmlspecialchars( $timeAndDate );
227 $row .=
'<span class="history-deleted">' . $url .
'</span>';
228 } elseif ( !
$file->exists() ) {
229 $row .= Html::element(
'span', [
'class' =>
'mw-file-missing' ],
230 $lang->userTimeAndDate( $timestamp, $user )
233 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl(
$img );
234 $row .= Xml::element(
237 $lang->userTimeAndDate( $timestamp, $user )
243 if ( $this->showThumb ) {
249 $row .= htmlspecialchars(
$file->getDimensionsString() );
250 $row .= $this->
msg(
'word-separator' )->escaped();
251 $row .=
'<span style="white-space: nowrap;">';
252 $row .= $this->
msg(
'parentheses' )->sizeParams(
$file->getSize() )->escaped();
259 if (
$file->isDeleted( File::DELETED_USER ) ) {
260 $row .=
'<span class="history-deleted">'
261 . $this->
msg(
'rev-deleted-user' )->escaped() .
'</span>';
265 $row .=
'<span style="white-space: nowrap;">';
269 $row .= htmlspecialchars( $userText );
275 if (
$file->isDeleted( File::DELETED_COMMENT ) ) {
276 $row .=
'<td><span class="history-deleted">' .
277 $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span></td>';
279 $contLang = MediaWikiServices::getInstance()->getContentLanguage();
280 $row .= Html::rawElement(
282 [
'dir' => $contLang->getDir() ],
288 $this->getHookRunner()->onImagePageFileHistoryLine( $this,
$file, $row, $rowClass );
289 $classAttr = $rowClass ?
" class='$rowClass'" :
'';
291 return "<tr{$classAttr}>{$row}</tr>\n";
301 if (
$file->allowInlineDisplay() &&
$file->userCan( File::DELETED_FILE, $user )
302 && !
$file->isDeleted( File::DELETED_FILE )
310 $thumbnail =
$file->transform( $params );
312 'alt' => $this->
msg(
'filehist-thumbtext',
313 $lang->userTimeAndDate( $timestamp, $user ),
314 $lang->userDate( $timestamp, $user ),
315 $lang->userTime( $timestamp, $user ) )->text(),
320 return $this->
msg(
'filehist-nothumb' )->escaped();
323 return $thumbnail->toHtml( $options );
325 return $this->
msg(
'filehist-nothumb' )->escaped();