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();
454 array(
'page' => $page - 1 )
457 array(
'page' => $page - 1 ) );
463 $label =
wfMessage(
'imgmultipagenext' )->text();
468 array(
'page' => $page + 1 )
471 array(
'page' => $page + 1 ) );
479 'name' =>
'pageselector',
480 'action' => $wgScript,
483 for ( $i = 1; $i <=
$count; $i++ ) {
487 array(
'id' =>
'pageselector',
'name' =>
'page' ),
491 '</td><td><div class="multipageimagenavbox">' .
494 wfMessage(
'imgmultigoto' )->rawParams( $select )->parse() .
497 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
500 } elseif ( $this->displayImg->isSafeFile() ) {
501 # if direct link is allowed but it's not a renderable image, show an icon.
502 $icon = $this->displayImg->iconThumb();
504 $out->addHTML(
'<div class="fullImageLink" id="file">' .
505 $icon->toHtml(
array(
'file-link' =>
true ) ) .
509 $longDesc =
wfMessage(
'parentheses', $this->displayImg->getLongDesc() )->
text();
511 $medialink =
"[[Media:$filename|$linktext]]";
513 if ( !$this->displayImg->isSafeFile() ) {
514 $warning =
wfMessage(
'mediawarning' )->plain();
522 $out->addWikiText( <<<EOT
523 <div
class=
"fullMedia"><span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span></div>
524 <div
class=
"mediaWarning">$warning</div>
528 $out->addWikiText( <<<EOT
529 <div
class=
"fullMedia">{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
535 $renderLangOptions = $this->displayImg->getAvailableLanguages();
536 if ( count( $renderLangOptions ) >= 1 ) {
537 $currentLanguage = $renderLang;
538 $defaultLang = $this->displayImg->getDefaultRenderLanguage();
539 if ( is_null( $currentLanguage ) ) {
540 $currentLanguage = $defaultLang;
542 $out->addHtml( $this->
doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
546 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
552 $ext = $this->displayImg->getExtension();
554 'file-no-thumb-animation-' .
$ext,
555 'file-no-thumb-animation'
558 $out->addWikiText( <<<EOT
559 <div
class=
"mw-noanimatethumb">{$noAnimMesg}</div>
564 if ( !$this->displayImg->isLocal() ) {
568 # Image does not exist
569 if ( !$this->getID() ) {
570 # No article exists either
571 # Show deletion log to be consistent with normal articles
574 array(
'delete',
'move' ),
575 $this->
getTitle()->getPrefixedText(),
578 'conds' =>
array(
"log_action != 'revision'" ),
579 'showIfEmpty' =>
false,
580 'msgKey' =>
array(
'moveddeleted-notice' )
585 if ( $wgEnableUploads &&
$user->isAllowed(
'upload' ) ) {
589 'filepage-nofile-link',
590 $uploadTitle->getFullURL(
array(
'wpDestFile' => $this->mPage->getFile()->getName() ) )
593 $nofile =
'filepage-nofile';
598 $out->setRobotPolicy(
'noindex,nofollow' );
599 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
600 if ( !$this->getID() && $wgSend404Code ) {
603 $request->response()->header(
'HTTP/1.1 404 Not Found' );
606 $out->setFileVersion( $this->displayImg );
619 $thumbnail = $this->displayImg->transform(
$params );
620 if ( $thumbnail && !$thumbnail->isError() ) {
622 'href' => $thumbnail->getUrl(),
623 'class' =>
'mw-thumbnail-link'
624 ),
wfMessage(
'show-big-image-size' )->numParams(
625 $thumbnail->getWidth(), $thumbnail->getHeight()
639 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
640 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
643 if ( $descUrl && $this->mPage->getID() == 0 ) {
644 $out->setCanonicalUrl( $descUrl );
647 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
650 if ( $descUrl && $descText &&
wfMessage(
'sharedupload-desc-here' )->plain() !==
'-' ) {
651 $out->wrapWikiMsg( $wrap,
array(
'sharedupload-desc-here',
$repo, $descUrl ) );
652 } elseif ( $descUrl &&
wfMessage(
'sharedupload-desc-there' )->plain() !==
'-' ) {
653 $out->wrapWikiMsg( $wrap,
array(
'sharedupload-desc-there',
$repo, $descUrl ) );
659 $this->mExtraDescription = $descText;
666 return $uploadTitle->getFullURL(
array(
667 'wpDestFile' => $this->mPage->getFile()->getName(),
679 if ( !$wgEnableUploads ) {
684 if ( !$this->mPage->getFile()->isLocal() ) {
689 $out->addHTML(
"<ul>\n" );
691 # "Upload a new version of this file" link
695 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
697 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">" . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
700 $out->addHTML(
"</ul>\n" );
713 $out->addHTML( $pager->getBody() );
714 $out->preventClickjacking( $pager->getPreventClickjacking() );
716 $this->mPage->getFile()->resetHistory();
718 # Exist check because we don't want to show this on pages where an image
719 # doesn't exist along with the noimage message, that would suck. -ævar
720 if ( $this->mPage->getFile()->exists() ) {
734 array(
'imagelinks',
'page' ),
735 array(
'page_namespace',
'page_title',
'page_is_redirect',
'il_to' ),
736 array(
'il_to' => $target,
'il_from = page_id' ),
738 array(
'LIMIT' =>
$limit + 1,
'ORDER BY' =>
'il_from', )
748 $redirects =
array();
749 foreach (
$res as $row ) {
750 if ( $row->page_is_redirect ) {
751 $redirects[$row->page_title] =
array();
758 if ( !$hasMore && count( $redirects ) ) {
760 $limit - count( $rows ) + 1 );
761 foreach (
$res as $row ) {
762 $redirects[$row->il_to][] = $row;
765 $hasMore = (
$res->numRows() + count( $rows ) ) >
$limit;
771 array(
'id' =>
'mw-imagepage-nolinkstoimage' ),
"\n$1\n" ),
777 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
782 $out->addWikiMsg(
'linkstoimage-more',
784 $this->
getTitle()->getPrefixedDBkey()
790 array(
'class' =>
'mw-imagepage-linkstoimage' ) ) .
"\n"
795 usort( $rows,
array( $this,
'compare' ) );
799 foreach ( $rows
as $element ) {
801 if ( $currentCount >
$limit ) {
806 # Add a redirect=no to make redirect pages reachable
807 if ( isset( $redirects[$element->page_title] ) ) {
808 $query[
'redirect'] =
'no';
814 if ( !isset( $redirects[$element->page_title] ) ) {
817 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
818 # Redirect without usages
819 $liContents =
wfMessage(
'linkstoimage-redirect' )->rawParams(
$link,
'' )->parse();
821 # Redirect with usages
823 foreach ( $redirects[$element->page_title]
as $row ) {
825 if ( $currentCount >
$limit ) {
832 array(
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
839 array(
'class' =>
'mw-imagepage-redirectstofile' ),
842 $liContents =
wfMessage(
'linkstoimage-redirect' )->rawParams(
847 array(
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
858 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
867 $dupes = $this->mPage->getDuplicates();
868 if ( count( $dupes ) == 0 ) {
872 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
873 $out->addWikiMsg(
'duplicatesoffile',
874 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
876 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
883 if (
$file->isLocal() ) {
887 $file->getTitle()->getPrefixedText() );
888 $fromSrc =
wfMessage(
'shared-repo-from',
$file->getRepo()->getDisplayName() )->
text();
890 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
892 $out->addHTML(
"</ul></div>\n" );
898 public function delete() {
899 $file = $this->mPage->getFile();
900 if ( !
$file->exists() || !
$file->isLocal() ||
$file->getRedirected() ) {
918 $out->setRobotPolicy(
'noindex,nofollow' );
919 $out->setArticleRelated(
false );
920 $out->enableClientCache(
false );
921 $out->addWikiText( $description );
932 protected function compare( $a, $b ) {
933 if ( $a->page_namespace == $b->page_namespace ) {
934 return strcmp( $a->page_title, $b->page_title );
936 return $a->page_namespace - $b->page_namespace;
951 $option =
$user->getIntOption( $optionName );
952 if ( !isset( $wgImageLimits[$option] ) ) {
958 if ( !isset( $wgImageLimits[$option] ) ) {
963 return isset( $wgImageLimits[$option] )
964 ? $wgImageLimits[$option]
978 sort( $langChoices );
979 $curLang =
wfBCP47( $curLang );
980 $defaultLang =
wfBCP47( $defaultLang );
982 $haveCurrentLang =
false;
983 $haveDefaultLang =
false;
991 foreach ( $langChoices
as $lang ) {
994 if (
$name !==
'' ) {
999 $opts .=
"\n" .
Xml::option( $display, $code, $curLang === $code );
1000 if ( $curLang === $code ) {
1001 $haveCurrentLang =
true;
1003 if ( $defaultLang === $code ) {
1004 $haveDefaultLang =
true;
1007 if ( !$haveDefaultLang ) {
1012 if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
1014 if (
$name !==
'' ) {
1017 $display = $curLang;
1019 $opts =
Xml::option( $display, $curLang,
true ) . $opts;
1022 $select =
Html::rawElement(
'select',
array(
'id' =>
'mw-imglangselector',
'name' =>
'lang' ), $opts );
1025 $formContents =
wfMessage(
'img-lang-info' )->rawParams( $select, $submit )->parse()
1031 return $langSelectLine;
1069 global $wgShowArchiveThumbnails;
1074 $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
1098 .
"<div id=\"mw-imagepage-section-filehistory\">\n"
1099 . $this->
msg(
'filehist-help' )->parseAsBlock()
1103 . ( $this->current->isLocal() && ( $this->
getUser()->isAllowedAny(
'delete',
'deletedhistory' ) ) ?
'<td></td>' :
'' )
1104 .
'<th>' . $this->
msg(
'filehist-datetime' )->escaped() .
'</th>'
1105 . ( $this->showThumb ?
'<th>' . $this->
msg(
'filehist-thumb' )->escaped() .
'</th>' :
'' )
1106 .
'<th>' . $this->
msg(
'filehist-dimensions' )->escaped() .
'</th>'
1107 .
'<th>' . $this->
msg(
'filehist-user' )->escaped() .
'</th>'
1108 .
'<th>' . $this->
msg(
'filehist-comment' )->escaped() .
'</th>'
1117 return "</table>\n$navLinks\n</div>\n";
1132 $userId =
$file->getUser(
'id' );
1133 $userText =
$file->getUser(
'text' );
1136 $local = $this->current->isLocal();
1137 $row = $selected =
'';
1140 if ( $local && (
$user->isAllowedAny(
'delete',
'deletedhistory' ) ) ) {
1142 # Link to remove from history
1143 if (
$user->isAllowed(
'delete' ) ) {
1144 $q =
array(
'action' =>
'delete' );
1146 $q[
'oldimage'] =
$img;
1150 $this->
msg( $iscur ?
'filehist-deleteall' :
'filehist-deleteone' )->escaped(),
1154 # Link to hide content. Don't show useless link to people who cannot hide revisions.
1155 $canHide =
$user->isAllowed(
'deleterevision' );
1156 if ( $canHide || (
$user->isAllowed(
'deletedhistory' ) &&
$file->getVisibility() ) ) {
1157 if (
$user->isAllowed(
'delete' ) ) {
1164 list( $ts, ) = explode(
'!',
$img, 2 );
1166 'type' =>
'oldimage',
1167 'target' => $this->
title->getPrefixedText(),
1181 $row .= $this->
msg(
'filehist-current' )->escaped();
1182 } elseif ( $local && $this->
title->quickUserCan(
'edit',
$user )
1183 && $this->
title->quickUserCan(
'upload',
$user )
1186 $row .= $this->
msg(
'filehist-revert' )->escaped();
1190 $this->
msg(
'filehist-revert' )->escaped(),
1193 'action' =>
'revert',
1195 'wpEditToken' =>
$user->getEditToken(
$img )
1203 if (
$file->getTimestamp() === $this->img->getTimestamp() ) {
1204 $selected =
"class='filehistory-selected'";
1206 $row .=
"<td $selected style='white-space: nowrap;'>";
1208 # Don't link to unviewable files
1209 $row .=
'<span class="history-deleted">' . $lang->userTimeAndDate(
$timestamp,
$user ) .
'</span>';
1214 # Make a link to review the image
1220 'target' => $this->
title->getPrefixedText(),
1222 'token' =>
$user->getEditToken( $img )
1228 $row .=
'<span class="history-deleted">' . $url .
'</span>';
1230 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl(
$img );
1236 if ( $this->showThumb ) {
1242 $row .= htmlspecialchars(
$file->getDimensionsString() );
1243 $row .= $this->
msg(
'word-separator' )->plain();
1244 $row .=
'<span style="white-space: nowrap;">';
1253 $row .=
'<span class="history-deleted">' . $this->
msg(
'rev-deleted-user' )->escaped() .
'</span>';
1257 $row .= $this->
msg(
'word-separator' )->plain();
1258 $row .=
'<span style="white-space: nowrap;">';
1262 $row .= htmlspecialchars( $userText );
1269 $row .=
'<td><span class="history-deleted">' . $this->
msg(
'rev-deleted-comment' )->escaped() .
'</span></td>';
1276 $classAttr = $rowClass ?
" class='$rowClass'" :
'';
1278 return "<tr{$classAttr}>{$row}</tr>\n";
1299 'alt' => $this->
msg(
'filehist-thumbtext',
1303 'file-link' =>
true,
1306 if ( !$thumbnail ) {
1307 return $this->
msg(
'filehist-nothumb' )->escaped();
1310 return $thumbnail->toHtml(
$options );
1312 return $this->
msg(
'filehist-nothumb' )->escaped();
1349 $this->mImagePage = $imagePage;
1350 $this->mTitle = clone ( $imagePage->
getTitle() );
1351 $this->mTitle->setFragment(
'#filehistory' );
1353 $this->mHist =
array();
1354 $this->mRange =
array( 0, 0 );
1389 if ( count( $this->mHist ) ) {
1391 # Generate prev/next links
1393 $s = $list->beginImageHistoryList( $navLink );
1395 for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
1396 $file = $this->mHist[$i];
1397 $s .= $list->imageHistoryLine( !
$file->isOld(),
$file );
1399 $s .= $list->endImageHistoryList( $navLink );
1401 if ( $list->getPreventClickjacking() ) {
1409 if ( $this->mQueryDone ) {
1412 $this->mImg = $this->mImagePage->getFile();
1413 if ( !$this->mImg->exists() ) {
1416 $queryLimit = $this->mLimit + 1;
1417 if ( $this->mIsBackwards ) {
1419 $this->mHist = $this->mImg->getHistory( $queryLimit,
null, $this->mOffset,
false );
1421 $numRows = count( $this->mHist );
1422 if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() >
$this->mOffset ) {
1423 $this->mHist = array_merge(
array( $this->mImg ), $this->mHist );
1427 if ( !$this->mOffset || $this->mImg->getTimestamp() <
$this->mOffset ) {
1431 $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
1433 $this->mHist = array_merge( $this->mHist,
1434 $this->mImg->getHistory( $oiLimit, $this->mOffset,
null,
false ) );
1436 $numRows = count( $this->mHist );
1438 # Index value of top item in the list
1439 $firstIndex = $this->mIsBackwards ?
1440 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
1441 # Discard the extra result row if there is one
1442 if ( $numRows > $this->mLimit && $numRows > 1 ) {
1443 if ( $this->mIsBackwards ) {
1444 # Index value of item past the index
1445 $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
1446 # Index value of bottom item in the list
1447 $lastIndex = $this->mHist[1]->getTimestamp();
1449 $this->mRange =
array( 1, $numRows - 1 );
1451 # Index value of item past the index
1452 $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
1453 # Index value of bottom item in the list
1454 $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
1456 $this->mRange =
array( 0, $numRows - 2 );
1459 # Setting indexes to an empty string means that they will be
1460 # omitted if they would otherwise appear in URLs. It just so
1461 # happens that this is the right thing to do in the standard
1462 # UI, in all the relevant cases.
1463 $this->mPastTheEndIndex =
'';
1464 # Index value of bottom item in the list
1465 $lastIndex = $this->mIsBackwards ?
1466 $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
1468 $this->mRange =
array( 0, $numRows - 1 );
1473 $this->mPastTheEndIndex =
'';
1475 if ( $this->mIsBackwards ) {
1476 $this->mIsFirst = ( $numRows < $queryLimit );
1477 $this->mIsLast = ( $this->mOffset ==
'' );
1478 $this->mLastShown = $firstIndex;
1479 $this->mFirstShown = $lastIndex;
1481 $this->mIsFirst = ( $this->mOffset ==
'' );
1482 $this->mIsLast = ( $numRows < $queryLimit );
1483 $this->mLastShown = $lastIndex;
1484 $this->mFirstShown = $firstIndex;
1486 $this->mQueryDone =
true;