58 # @todo FIXME: Doesn't inherit right
59 return $t ==
null ? null :
new self(
$t );
60 # return $t == null ? null : new static( $t ); // PHP 5.3
68 $this->mPage->setFile(
$file );
69 $this->displayImg =
$file;
70 $this->fileLoaded =
true;
74 if ( $this->fileLoaded ) {
77 $this->fileLoaded =
true;
79 $this->displayImg = $img =
false;
80 wfRunHooks(
'ImagePageFindFile',
array( $this, &$img, &$this->displayImg ) );
87 $this->mPage->setFile( $img );
88 if ( !$this->displayImg ) {
89 $this->displayImg = $img;
91 $this->repo = $img->getRepo();
99 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
103 public function view() {
108 $diff = $request->getVal(
'diff' );
109 $diffOnly = $request->getBool(
'diffonly', $this->
getContext()->getUser()->getOption(
'diffonly' ) );
111 if ( $this->
getTitle()->getNamespace() !=
NS_FILE || ( $diff !==
null && $diffOnly ) ) {
118 if ( $this->
getTitle()->getNamespace() ==
NS_FILE && $this->mPage->getFile()->getRedirected() ) {
119 if ( $this->
getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
122 $request->setVal(
'diffonly',
'true' );
128 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
136 if ( $wgShowEXIF && $this->displayImg->exists() ) {
138 $formattedMetadata = $this->displayImg->formatMetadata();
139 $showmeta = $formattedMetadata !==
false;
144 if ( !$diff && $this->displayImg->exists() ) {
152 # No need to display noarticletext, we use our own message, output in openShowImage()
153 if ( $this->mPage->getID() ) {
154 # NS_FILE is in the user language, but this section (the actual wikitext)
155 # should be in page content language
156 $pageLang = $this->
getTitle()->getPageViewLanguage();
158 'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
159 'class' =>
'mw-content-' . $pageLang->getDir() ) ) );
165 # Just need to set the right headers
166 $out->setArticleFlag(
true );
167 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
171 # Show shared description, if needed
172 if ( $this->mExtraDescription ) {
173 $fol =
wfMessage(
'shareddescriptionfollows' );
174 if ( !$fol->isDisabled() ) {
175 $out->addWikiText( $fol->plain() );
177 $out->addHTML(
'<div id="shared-image-desc">' . $this->mExtraDescription .
"</div>\n" );
185 array(
'id' =>
'filelinks' ),
188 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
189 # Yet we return metadata about the target. Definitely an issue in the FileRepo
192 # Allow extensions to add something after the image links
202 array(
'id' =>
'metadata' ),
205 $out->addModules(
array(
'mediawiki.action.view.metadata' ) );
209 if ( !$this->repo->isLocal() ) {
210 $css = $this->repo->getDescriptionStylesheetUrl();
216 $out->addModuleStyles(
'filepage' );
233 protected function showTOC( $metadata ) {
235 '<li><a href="#file">' .
wfMessage(
'file-anchor-link' )->escaped() .
'</a></li>',
236 '<li><a href="#filehistory">' .
wfMessage(
'filehist' )->escaped() .
'</a></li>',
237 '<li><a href="#filelinks">' .
wfMessage(
'imagelinks' )->escaped() .
'</a></li>',
240 $r[] =
'<li><a href="#metadata">' .
wfMessage(
'metadata' )->escaped() .
'</a></li>';
245 return '<ul id="filetoc">' . implode(
"\n", $r ) .
'</ul>';
257 $r =
"<div class=\"mw-imagepage-section-metadata\">";
258 $r .=
wfMessage(
'metadata-help' )->plain();
259 $r .=
"<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
260 foreach ( $metadata
as $type => $stuff ) {
261 foreach ( $stuff
as $v ) {
262 # @todo FIXME: Why is this using escapeId for a class?!
264 if (
$type ==
'collapsed' ) {
267 $class .=
' collapsable';
269 $r .=
"<tr class=\"$class\">\n";
270 $r .=
"<th>{$v['name']}</th>\n";
271 $r .=
"<td>{$v['value']}</td>\n</tr>";
274 $r .=
"</table>\n</div>\n";
287 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
290 return parent::getContentObject();
294 global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
300 $dirmark = $lang->getDirMarkEntity();
305 $maxHeight = $max[1];
307 if ( $this->displayImg->exists() ) {
309 $page = $request->getIntOrNull(
'page' );
310 if ( is_null( $page ) ) {
317 $renderLang = $request->getVal(
'lang' );
318 if ( !is_null( $renderLang ) ) {
319 $handler = $this->displayImg->getHandler();
320 if ( $handler && $handler->validateParam(
'lang', $renderLang ) ) {
327 $width_orig = $this->displayImg->getWidth( $page );
328 $width = $width_orig;
329 $height_orig = $this->displayImg->getHeight( $page );
330 $height = $height_orig;
333 $linktext = $filename;
337 if ( $this->displayImg->allowInlineDisplay() ) {
340 # "Download high res version" link below the image
341 # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
342 # We'll show a thumbnail of this image
343 if ( $width > $maxWidth || $height > $maxHeight ) {
344 # Calculate the thumbnail size.
345 # First case, the limiting factor is the width, not the height.
346 if ( $width / $height >= $maxWidth / $maxHeight ) {
347 $height = round( $height * $maxWidth / $width );
349 # Note that $height <= $maxHeight now.
351 $newwidth = floor( $width * $maxHeight / $height );
352 $height = round( $height * $newwidth / $width );
354 # Note that $height <= $maxHeight now, but might not be identical
355 # because of rounding.
357 $linktext =
wfMessage(
'show-big-image' )->escaped();
358 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
359 $thumbSizes = $wgImageLimits;
366 $thumbSizes[] =
array( $width_orig, $height_orig );
368 # Creating thumb links triggers thumbnail generation.
369 # Just generate the thumb for the current users prefs.
371 if ( !$this->displayImg->mustRender() ) {
374 $thumbSizes[] =
array( $width_orig, $height_orig );
377 # Generate thumbnails or thumbnail links as needed...
378 $otherSizes =
array();
379 foreach ( $thumbSizes
as $size ) {
386 if (
$size[0] <= $width_orig &&
$size[1] <= $height_orig
391 $otherSizes[] = $sizeLink;
395 $otherSizes = array_unique( $otherSizes );
398 if ( $sizeLinkBigImagePreview ) {
399 $msgsmall .=
wfMessage(
'show-big-image-preview' )->
400 rawParams( $sizeLinkBigImagePreview )->
403 if ( count( $otherSizes ) ) {
406 wfMessage(
'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->
407 params( count( $otherSizes ) )->parse()
410 } elseif ( $width == 0 && $height == 0 ) {
411 # Some sort of audio file that doesn't have dimensions
412 # Don't output a no hi res message for such a file
414 } elseif ( $this->displayImg->isVectorized() ) {
415 # For vectorized images, full size is just the frame size
418 # Image is small enough to show full size on image page
419 $msgsmall =
wfMessage(
'file-nohires' )->parse();
424 $thumbnail = $this->displayImg->transform(
$params );
427 $anchorclose =
Html::rawElement(
'div',
array(
'class' =>
'mw-filepage-resolutioninfo' ), $msgsmall );
429 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
431 $out->addModules(
'mediawiki.page.image.pagination' );
432 $out->addHTML(
'<table class="multipageimage"><tr><td>' );
437 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
440 $out->addHTML(
'<div class="fullImageLink" id="file">' .
442 $anchorclose .
"</div>\n" );
446 $count = $this->displayImg->pageCount();
456 array(
'page' => $page - 1 )
459 array(
'page' => $page - 1 ) );
465 $label =
wfMessage(
'imgmultipagenext' )->text();
470 array(
'page' => $page + 1 )
473 array(
'page' => $page + 1 ) );
481 'name' =>
'pageselector',
482 'action' => $wgScript,
485 for ( $i = 1; $i <=
$count; $i++ ) {
489 array(
'id' =>
'pageselector',
'name' =>
'page' ),
493 '</td><td><div class="multipageimagenavbox">' .
496 wfMessage(
'imgmultigoto' )->rawParams( $select )->parse() .
499 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
502 } elseif ( $this->displayImg->isSafeFile() ) {
503 # if direct link is allowed but it's not a renderable image, show an icon.
504 $icon = $this->displayImg->iconThumb();
506 $out->addHTML(
'<div class="fullImageLink" id="file">' .
507 $icon->toHtml(
array(
'file-link' =>
true ) ) .
511 $longDesc =
wfMessage(
'parentheses', $this->displayImg->getLongDesc() )->
text();
513 $medialink =
"[[Media:$filename|$linktext]]";
515 if ( !$this->displayImg->isSafeFile() ) {
516 $warning =
wfMessage(
'mediawarning' )->plain();
524 $out->addWikiText( <<<EOT
525 <div
class=
"fullMedia"><span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span></div>
526 <div
class=
"mediaWarning">$warning</div>
530 $out->addWikiText( <<<EOT
531 <div
class=
"fullMedia">{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
537 $renderLangOptions = $this->displayImg->getAvailableLanguages();
538 if ( count( $renderLangOptions ) >= 1 ) {
539 $currentLanguage = $renderLang;
540 $defaultLang = $this->displayImg->getDefaultRenderLanguage();
541 if ( is_null( $currentLanguage ) ) {
542 $currentLanguage = $defaultLang;
544 $out->addHtml( $this->
doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
548 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
554 $ext = $this->displayImg->getExtension();
556 'file-no-thumb-animation-' .
$ext,
557 'file-no-thumb-animation'
560 $out->addWikiText( <<<EOT
561 <div
class=
"mw-noanimatethumb">{$noAnimMesg}</div>
566 if ( !$this->displayImg->isLocal() ) {
570 # Image does not exist
571 if ( !$this->getID() ) {
572 # No article exists either
573 # Show deletion log to be consistent with normal articles
576 array(
'delete',
'move' ),
577 $this->
getTitle()->getPrefixedText(),
580 'conds' =>
array(
"log_action != 'revision'" ),
581 'showIfEmpty' =>
false,
582 'msgKey' =>
array(
'moveddeleted-notice' )
587 if ( $wgEnableUploads &&
$user->isAllowed(
'upload' ) ) {
591 'filepage-nofile-link',
592 $uploadTitle->getFullURL(
array(
'wpDestFile' => $this->mPage->getFile()->getName() ) )
595 $nofile =
'filepage-nofile';
600 $out->setRobotPolicy(
'noindex,nofollow' );
601 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
602 if ( !$this->getID() && $wgSend404Code ) {
605 $request->response()->header(
'HTTP/1.1 404 Not Found' );
608 $out->setFileVersion( $this->displayImg );
621 $thumbnail = $this->displayImg->transform(
$params );
622 if ( $thumbnail && !$thumbnail->isError() ) {
624 'href' => $thumbnail->getUrl(),
625 'class' =>
'mw-thumbnail-link'
626 ),
wfMessage(
'show-big-image-size' )->numParams(
627 $thumbnail->getWidth(), $thumbnail->getHeight()
641 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
642 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
645 if ( $descUrl && $this->mPage->getID() == 0 ) {
646 $out->setCanonicalUrl( $descUrl );
649 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
652 if ( $descUrl && $descText &&
wfMessage(
'sharedupload-desc-here' )->plain() !==
'-' ) {
653 $out->wrapWikiMsg( $wrap,
array(
'sharedupload-desc-here',
$repo, $descUrl ) );
654 } elseif ( $descUrl &&
wfMessage(
'sharedupload-desc-there' )->plain() !==
'-' ) {
655 $out->wrapWikiMsg( $wrap,
array(
'sharedupload-desc-there',
$repo, $descUrl ) );
661 $this->mExtraDescription = $descText;
668 return $uploadTitle->getFullURL(
array(
669 'wpDestFile' => $this->mPage->getFile()->getName(),
681 if ( !$wgEnableUploads ) {
686 if ( !$this->mPage->getFile()->isLocal() ) {
691 $out->addHTML(
"<ul>\n" );
693 # "Upload a new version of this file" link
695 if ( $canUpload && UploadBase::userCanReUpload( $this->
getContext()->getUser(), $this->mPage->getFile()->name ) ) {
697 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
699 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">" . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
702 $out->addHTML(
"</ul>\n" );
715 $out->addHTML( $pager->getBody() );
716 $out->preventClickjacking( $pager->getPreventClickjacking() );
718 $this->mPage->getFile()->resetHistory();
720 # Exist check because we don't want to show this on pages where an image
721 # doesn't exist along with the noimage message, that would suck. -ævar
722 if ( $this->mPage->getFile()->exists() ) {
736 array(
'imagelinks',
'page' ),
737 array(
'page_namespace',
'page_title',
'page_is_redirect',
'il_to' ),
738 array(
'il_to' => $target,
'il_from = page_id' ),
740 array(
'LIMIT' =>
$limit + 1,
'ORDER BY' =>
'il_from', )
750 $redirects =
array();
751 foreach (
$res as $row ) {
752 if ( $row->page_is_redirect ) {
753 $redirects[$row->page_title] =
array();
760 if ( !$hasMore && count( $redirects ) ) {
762 $limit - count( $rows ) + 1 );
763 foreach (
$res as $row ) {
764 $redirects[$row->il_to][] = $row;
767 $hasMore = (
$res->numRows() + count( $rows ) ) >
$limit;
773 array(
'id' =>
'mw-imagepage-nolinkstoimage' ),
"\n$1\n" ),
779 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
784 $out->addWikiMsg(
'linkstoimage-more',
786 $this->
getTitle()->getPrefixedDBkey()
792 array(
'class' =>
'mw-imagepage-linkstoimage' ) ) .
"\n"
797 usort( $rows,
array( $this,
'compare' ) );
801 foreach ( $rows
as $element ) {
803 if ( $currentCount >
$limit ) {
808 # Add a redirect=no to make redirect pages reachable
809 if ( isset( $redirects[$element->page_title] ) ) {
810 $query[
'redirect'] =
'no';
816 if ( !isset( $redirects[$element->page_title] ) ) {
819 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
820 # Redirect without usages
821 $liContents =
wfMessage(
'linkstoimage-redirect' )->rawParams(
$link,
'' )->parse();
823 # Redirect with usages
825 foreach ( $redirects[$element->page_title]
as $row ) {
827 if ( $currentCount >
$limit ) {
834 array(
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
841 array(
'class' =>
'mw-imagepage-redirectstofile' ),
844 $liContents =
wfMessage(
'linkstoimage-redirect' )->rawParams(
849 array(
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
860 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
869 $dupes = $this->mPage->getDuplicates();
870 if ( count( $dupes ) == 0 ) {
874 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
875 $out->addWikiMsg(
'duplicatesoffile',
876 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
878 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
885 if (
$file->isLocal() ) {
889 $file->getTitle()->getPrefixedText() );
890 $fromSrc =
wfMessage(
'shared-repo-from',
$file->getRepo()->getDisplayName() )->
text();
892 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
894 $out->addHTML(
"</ul></div>\n" );
900 public function delete() {
901 $file = $this->mPage->getFile();
902 if ( !
$file->exists() || !
$file->isLocal() ||
$file->getRedirected() ) {
920 $out->setRobotPolicy(
'noindex,nofollow' );
921 $out->setArticleRelated(
false );
922 $out->enableClientCache(
false );
923 $out->addWikiText( $description );
934 protected function compare( $a, $b ) {
935 if ( $a->page_namespace == $b->page_namespace ) {
936 return strcmp( $a->page_title, $b->page_title );
938 return $a->page_namespace - $b->page_namespace;
953 $option =
$user->getIntOption( $optionName );
954 if ( !isset( $wgImageLimits[$option] ) ) {
960 if ( !isset( $wgImageLimits[$option] ) ) {
965 return isset( $wgImageLimits[$option] )
966 ? $wgImageLimits[$option]
980 sort( $langChoices );
981 $curLang =
wfBCP47( $curLang );
982 $defaultLang =
wfBCP47( $defaultLang );
984 $haveCurrentLang =
false;
985 $haveDefaultLang =
false;
993 foreach ( $langChoices
as $lang ) {
996 if (
$name !==
'' ) {
1001 $opts .=
"\n" .
Xml::option( $display, $code, $curLang === $code );
1002 if ( $curLang === $code ) {
1003 $haveCurrentLang =
true;
1005 if ( $defaultLang === $code ) {
1006 $haveDefaultLang =
true;
1009 if ( !$haveDefaultLang ) {
1014 if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
1016 if (
$name !==
'' ) {
1019 $display = $curLang;
1021 $opts =
Xml::option( $display, $curLang,
true ) . $opts;
1024 $select =
Html::rawElement(
'select',
array(
'id' =>
'mw-imglangselector',
'name' =>
'lang' ), $opts );
1027 $formContents =
wfMessage(
'img-lang-info' )->rawParams( $select, $submit )->parse()
1033 return $langSelectLine;
1071 global $wgShowArchiveThumbnails;
1076 $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
1100 .
"<div id=\"mw-imagepage-section-filehistory\">\n"
1101 . $this->
msg(
'filehist-help' )->parseAsBlock()
1105 . ( $this->current->isLocal() && ( $this->
getUser()->isAllowedAny(
'delete',
'deletedhistory' ) ) ?
'<td></td>' :
'' )
1106 .
'<th>' . $this->
msg(
'filehist-datetime' )->escaped() .
'</th>'
1107 . ( $this->showThumb ?
'<th>' . $this->
msg(
'filehist-thumb' )->escaped() .
'</th>' :
'' )
1108 .
'<th>' . $this->
msg(
'filehist-dimensions' )->escaped() .
'</th>'
1109 .
'<th>' . $this->
msg(
'filehist-user' )->escaped() .
'</th>'
1110 .
'<th>' . $this->
msg(
'filehist-comment' )->escaped() .
'</th>'
1119 return "</table>\n$navLinks\n</div>\n";
1134 $userId =
$file->getUser(
'id' );
1135 $userText =
$file->getUser(
'text' );
1138 $local = $this->current->isLocal();
1139 $row = $selected =
'';
1142 if ( $local && (
$user->isAllowedAny(
'delete',
'deletedhistory' ) ) ) {
1144 # Link to remove from history
1145 if (
$user->isAllowed(
'delete' ) ) {
1146 $q =
array(
'action' =>
'delete' );
1148 $q[
'oldimage'] =
$img;
1152 $this->
msg( $iscur ?
'filehist-deleteall' :
'filehist-deleteone' )->escaped(),
1156 # Link to hide content. Don't show useless link to people who cannot hide revisions.
1157 $canHide =
$user->isAllowed(
'deleterevision' );
1158 if ( $canHide || (
$user->isAllowed(
'deletedhistory' ) &&
$file->getVisibility() ) ) {
1159 if (
$user->isAllowed(
'delete' ) ) {
1166 list( $ts, ) = explode(
'!',
$img, 2 );
1168 'type' =>
'oldimage',
1169 'target' => $this->
title->getPrefixedText(),
1183 $row .= $this->
msg(
'filehist-current' )->escaped();
1184 } elseif ( $local && $this->
title->quickUserCan(
'edit',
$user )
1185 && $this->
title->quickUserCan(
'upload',
$user )
1188 $row .= $this->
msg(
'filehist-revert' )->escaped();
1192 $this->
msg(
'filehist-revert' )->escaped(),
1195 'action' =>
'revert',
1197 'wpEditToken' =>
$user->getEditToken(
$img )
1205 if (
$file->getTimestamp() === $this->img->getTimestamp() ) {
1206 $selected =
"class='filehistory-selected'";
1208 $row .=
"<td $selected style='white-space: nowrap;'>";
1210 # Don't link to unviewable files
1211 $row .=
'<span class="history-deleted">' . $lang->userTimeAndDate(
$timestamp,
$user ) .
'</span>';
1216 # Make a link to review the image
1222 'target' => $this->
title->getPrefixedText(),
1224 'token' =>
$user->getEditToken( $img )
1230 $row .=
'<span class="history-deleted">' . $url .
'</span>';
1232 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl(
$img );
1238 if ( $this->showThumb ) {
1244 $row .= htmlspecialchars(
$file->getDimensionsString() );
1245 $row .= $this->
msg(
'word-separator' )->plain();
1246 $row .=
'<span style="white-space: nowrap;">';
1255 $row .=
'<span class="history-deleted">' . $this->
msg(
'rev-deleted-user' )->escaped() .
'</span>';
1259 $row .= $this->
msg(
'word-separator' )->plain();
1260 $row .=
'<span style="white-space: nowrap;">';
1264 $row .= htmlspecialchars( $userText );
1271 $row .=
'<td><span class="history-deleted">' . $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span></td>';
1278 $classAttr = $rowClass ?
" class='$rowClass'" :
'';
1280 return "<tr{$classAttr}>{$row}</tr>\n";
1301 'alt' => $this->
msg(
'filehist-thumbtext',
1305 'file-link' =>
true,
1308 if ( !$thumbnail ) {
1309 return $this->
msg(
'filehist-nothumb' )->escaped();
1312 return $thumbnail->toHtml(
$options );
1314 return $this->
msg(
'filehist-nothumb' )->escaped();
1351 $this->mImagePage = $imagePage;
1352 $this->mTitle = clone ( $imagePage->
getTitle() );
1353 $this->mTitle->setFragment(
'#filehistory' );
1355 $this->mHist =
array();
1356 $this->mRange =
array( 0, 0 );
1391 if ( count( $this->mHist ) ) {
1393 # Generate prev/next links
1395 $s = $list->beginImageHistoryList( $navLink );
1397 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
1398 $file = $this->mHist[$i];
1399 $s .= $list->imageHistoryLine( !
$file->isOld(),
$file );
1401 $s .= $list->endImageHistoryList( $navLink );
1403 if ( $list->getPreventClickjacking() ) {
1411 if ( $this->mQueryDone ) {
1414 $this->mImg = $this->mImagePage->getFile();
1415 if ( !$this->mImg->exists() ) {
1418 $queryLimit = $this->mLimit + 1;
1419 if ( $this->mIsBackwards ) {
1421 $this->mHist = $this->mImg->getHistory( $queryLimit,
null, $this->mOffset,
false );
1423 $numRows = count( $this->mHist );
1424 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() >
$this->mOffset ) {
1425 $this->mHist = array_merge(
array( $this->mImg ), $this->mHist );
1429 if ( !$this->mOffset || $this->mImg->getTimestamp() <
$this->mOffset ) {
1433 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
1435 $this->mHist = array_merge( $this->mHist,
1436 $this->mImg->getHistory( $oiLimit, $this->mOffset,
null,
false ) );
1438 $numRows = count( $this->mHist );
1440 # Index value of top item in the list
1441 $firstIndex = $this->mIsBackwards ?
1442 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
1443 # Discard the extra result row if there is one
1444 if ( $numRows > $this->mLimit && $numRows > 1 ) {
1445 if ( $this->mIsBackwards ) {
1446 # Index value of item past the index
1447 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
1448 # Index value of bottom item in the list
1449 $lastIndex = $this->mHist[1]->getTimestamp();
1451 $this->mRange =
array( 1, $numRows - 1 );
1453 # Index value of item past the index
1454 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
1455 # Index value of bottom item in the list
1456 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
1458 $this->mRange =
array( 0, $numRows - 2 );
1461 # Setting indexes to an empty string means that they will be
1462 # omitted if they would otherwise appear in URLs. It just so
1463 # happens that this is the right thing to do in the standard
1464 # UI, in all the relevant cases.
1465 $this->mPastTheEndIndex =
'';
1466 # Index value of bottom item in the list
1467 $lastIndex = $this->mIsBackwards ?
1468 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
1470 $this->mRange =
array( 0, $numRows - 1 );
1475 $this->mPastTheEndIndex =
'';
1477 if ( $this->mIsBackwards ) {
1478 $this->mIsFirst = ( $numRows < $queryLimit );
1479 $this->mIsLast = ( $this->mOffset ==
'' );
1480 $this->mLastShown = $firstIndex;
1481 $this->mFirstShown = $lastIndex;
1483 $this->mIsFirst = ( $this->mOffset ==
'' );
1484 $this->mIsLast = ( $numRows < $queryLimit );
1485 $this->mLastShown = $lastIndex;
1486 $this->mFirstShown = $firstIndex;
1488 $this->mQueryDone =
true;