3 * Special handling for file description pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 * Class for viewing MediaWiki file description pages
28 class ImagePage
extends Article
{
39 protected $mExtraDescription = false;
43 * @return WikiFilePage
45 protected function newPage( Title
$title ) {
46 // Overload mPage with a file-specific page
47 return new WikiFilePage( $title );
51 * Constructor from a page id
52 * @param int $id Article ID to load
53 * @return ImagePage|null
55 public static function newFromID( $id ) {
56 $t = Title
::newFromID( $id );
57 # @todo FIXME: Doesn't inherit right
58 return $t == null ?
null : new self( $t );
59 # return $t == null ? null : new static( $t ); // PHP 5.3
66 public function setFile( $file ) {
67 $this->mPage
->setFile( $file );
68 $this->displayImg
= $file;
69 $this->fileLoaded
= true;
72 protected function loadFile() {
73 if ( $this->fileLoaded
) {
76 $this->fileLoaded
= true;
78 $this->displayImg
= $img = false;
79 Hooks
::run( 'ImagePageFindFile', array( $this, &$img, &$this->displayImg
) );
80 if ( !$img ) { // not set by hook?
81 $img = wfFindFile( $this->getTitle() );
83 $img = wfLocalFile( $this->getTitle() );
86 $this->mPage
->setFile( $img );
87 if ( !$this->displayImg
) { // not set by hook?
88 $this->displayImg
= $img;
90 $this->repo
= $img->getRepo();
94 * Handler for action=render
95 * Include body text only; none of the image extras
97 public function render() {
98 $this->getContext()->getOutput()->setArticleBodyOnly( true );
102 public function view() {
105 $out = $this->getContext()->getOutput();
106 $request = $this->getContext()->getRequest();
107 $diff = $request->getVal( 'diff' );
108 $diffOnly = $request->getBool(
110 $this->getContext()->getUser()->getOption( 'diffonly' )
113 if ( $this->getTitle()->getNamespace() != NS_FILE ||
( $diff !== null && $diffOnly ) ) {
120 if ( $this->getTitle()->getNamespace() == NS_FILE
&& $this->mPage
->getFile()->getRedirected() ) {
121 if ( $this->getTitle()->getDBkey() == $this->mPage
->getFile()->getName() ||
$diff !== null ) {
122 // mTitle is the same as the redirect target so ask Article
123 // to perform the redirect for us.
124 $request->setVal( 'diffonly', 'true' );
128 // mTitle is not the same as the redirect target so it is
129 // probably the redirect page itself. Fake the redirect symbol
130 $out->setPageTitle( $this->getTitle()->getPrefixedText() );
131 $out->addHTML( $this->viewRedirect(
132 Title
::makeTitle( NS_FILE
, $this->mPage
->getFile()->getName() ),
133 /* $appendSubtitle */ true,
134 /* $forceKnown */ true )
136 $this->mPage
->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() );
141 if ( $wgShowEXIF && $this->displayImg
->exists() ) {
142 // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
143 $formattedMetadata = $this->displayImg
->formatMetadata( $this->getContext() );
144 $showmeta = $formattedMetadata !== false;
149 if ( !$diff && $this->displayImg
->exists() ) {
150 $out->addHTML( $this->showTOC( $showmeta ) );
154 $this->openShowImage();
157 # No need to display noarticletext, we use our own message, output in openShowImage()
158 if ( $this->mPage
->getID() ) {
159 # NS_FILE is in the user language, but this section (the actual wikitext)
160 # should be in page content language
161 $pageLang = $this->getTitle()->getPageViewLanguage();
162 $out->addHTML( Xml
::openElement( 'div', array( 'id' => 'mw-imagepage-content',
163 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
164 'class' => 'mw-content-' . $pageLang->getDir() ) ) );
168 $out->addHTML( Xml
::closeElement( 'div' ) );
170 # Just need to set the right headers
171 $out->setArticleFlag( true );
172 $out->setPageTitle( $this->getTitle()->getPrefixedText() );
173 $this->mPage
->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() );
176 # Show shared description, if needed
177 if ( $this->mExtraDescription
) {
178 $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
179 if ( !$fol->isDisabled() ) {
180 $out->addWikiText( $fol->plain() );
182 $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription
. "</div>\n" );
185 $this->closeShowImage();
186 $this->imageHistory();
187 // TODO: Cleanup the following
189 $out->addHTML( Xml
::element( 'h2',
190 array( 'id' => 'filelinks' ),
191 $this->getContext()->msg( 'imagelinks' )->text() ) . "\n" );
193 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
194 # Yet we return metadata about the target. Definitely an issue in the FileRepo
197 # Allow extensions to add something after the image links
199 Hooks
::run( 'ImagePageAfterImageLinks', array( $this, &$html ) );
201 $out->addHTML( $html );
205 $out->addHTML( Xml
::element(
207 array( 'id' => 'metadata' ),
208 $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
209 $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
210 $out->addModules( array( 'mediawiki.action.view.metadata' ) );
213 // Add remote Filepage.css
214 if ( !$this->repo
->isLocal() ) {
215 $css = $this->repo
->getDescriptionStylesheetUrl();
217 $out->addStyle( $css );
220 // always show the local local Filepage.css, bug 29277
221 $out->addModuleStyles( 'filepage' );
223 // Add MediaWiki styles for a file page
224 $out->addModuleStyles( 'mediawiki.action.view.filepage' );
230 public function getDisplayedFile() {
232 return $this->displayImg
;
238 * @param bool $metadata Whether or not to show the metadata link
241 protected function showTOC( $metadata ) {
243 '<li><a href="#file">' . $this->getContext()->msg( 'file-anchor-link' )->escaped() . '</a></li>',
244 '<li><a href="#filehistory">' . $this->getContext()->msg( 'filehist' )->escaped() . '</a></li>',
245 '<li><a href="#filelinks">' . $this->getContext()->msg( 'imagelinks' )->escaped() . '</a></li>',
248 Hooks
::run( 'ImagePageShowTOC', array( $this, &$r ) );
251 $r[] = '<li><a href="#metadata">' .
252 $this->getContext()->msg( 'metadata' )->escaped() .
256 return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
260 * Make a table with metadata to be shown in the output page.
262 * @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
264 * @param array $metadata The array containing the Exif data
265 * @return string The metadata table. This is treated as Wikitext (!)
267 protected function makeMetadataTable( $metadata ) {
268 $r = "<div class=\"mw-imagepage-section-metadata\">";
269 $r .= $this->getContext()->msg( 'metadata-help' )->plain();
270 $r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
271 foreach ( $metadata as $type => $stuff ) {
272 foreach ( $stuff as $v ) {
273 # @todo FIXME: Why is this using escapeId for a class?!
274 $class = Sanitizer
::escapeId( $v['id'] );
275 if ( $type == 'collapsed' ) {
276 // Handled by mediawiki.action.view.metadata module.
277 $class .= ' collapsable';
279 $r .= "<tr class=\"$class\">\n";
280 $r .= "<th>{$v['name']}</th>\n";
281 $r .= "<td>{$v['value']}</td>\n</tr>";
284 $r .= "</table>\n</div>\n";
289 * Overloading Article's getContentObject method.
291 * Omit noarticletext if sharedupload; text will be fetched from the
292 * shared upload server if possible.
295 public function getContentObject() {
297 if ( $this->mPage
->getFile() && !$this->mPage
->getFile()->isLocal() && 0 == $this->getID() ) {
300 return parent
::getContentObject();
303 protected function openShowImage() {
304 global $wgEnableUploads, $wgSend404Code, $wgSVGMaxSize;
307 $out = $this->getContext()->getOutput();
308 $user = $this->getContext()->getUser();
309 $lang = $this->getContext()->getLanguage();
310 $dirmark = $lang->getDirMarkEntity();
311 $request = $this->getContext()->getRequest();
313 $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
315 $maxHeight = $max[1];
317 if ( $this->displayImg
->exists() ) {
319 $page = $request->getIntOrNull( 'page' );
320 if ( is_null( $page ) ) {
324 $params = array( 'page' => $page );
327 $renderLang = $request->getVal( 'lang' );
328 if ( !is_null( $renderLang ) ) {
329 $handler = $this->displayImg
->getHandler();
330 if ( $handler && $handler->validateParam( 'lang', $renderLang ) ) {
331 $params['lang'] = $renderLang;
337 $width_orig = $this->displayImg
->getWidth( $page );
338 $width = $width_orig;
339 $height_orig = $this->displayImg
->getHeight( $page );
340 $height = $height_orig;
342 $filename = wfEscapeWikiText( $this->displayImg
->getName() );
343 $linktext = $filename;
345 Hooks
::run( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
347 if ( $this->displayImg
->allowInlineDisplay() ) {
349 # "Download high res version" link below the image
350 # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
351 # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
352 # We'll show a thumbnail of this image
353 if ( $width > $maxWidth ||
$height > $maxHeight ||
$this->displayImg
->isVectorized() ) {
354 list( $width, $height ) = $this->getDisplayWidthHeight(
355 $maxWidth, $maxHeight, $width, $height
357 $linktext = $this->getContext()->msg( 'show-big-image' )->escaped();
359 $thumbSizes = $this->getThumbSizes( $width_orig, $height_orig );
360 # Generate thumbnails or thumbnail links as needed...
361 $otherSizes = array();
362 foreach ( $thumbSizes as $size ) {
363 // We include a thumbnail size in the list, if it is
364 // less than or equal to the original size of the image
365 // asset ($width_orig/$height_orig). We also exclude
366 // the current thumbnail's size ($width/$height)
367 // since that is added to the message separately, so
368 // it can be denoted as the current size being shown.
369 // Vectorized images are limited by $wgSVGMaxSize big,
370 // so all thumbs less than or equal that are shown.
371 if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
372 ||
( $this->displayImg
->isVectorized()
373 && max( $size[0], $size[1] ) <= $wgSVGMaxSize )
375 && $size[0] != $width && $size[1] != $height
377 $sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
379 $otherSizes[] = $sizeLink;
383 $otherSizes = array_unique( $otherSizes );
386 $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height );
387 if ( $sizeLinkBigImagePreview ) {
388 $msgsmall .= $this->getContext()->msg( 'show-big-image-preview' )->
389 rawParams( $sizeLinkBigImagePreview )->
392 if ( count( $otherSizes ) ) {
396 array( 'class' => 'mw-filepage-other-resolutions' ),
397 $this->getContext()->msg( 'show-big-image-other' )
398 ->rawParams( $lang->pipeList( $otherSizes ) )
399 ->params( count( $otherSizes ) )
403 } elseif ( $width == 0 && $height == 0 ) {
404 # Some sort of audio file that doesn't have dimensions
405 # Don't output a no hi res message for such a file
408 # Image is small enough to show full size on image page
409 $msgsmall = $this->getContext()->msg( 'file-nohires' )->parse();
412 $params['width'] = $width;
413 $params['height'] = $height;
414 $thumbnail = $this->displayImg
->transform( $params );
415 Linker
::processResponsiveImages( $this->displayImg
, $thumbnail, $params );
417 $anchorclose = Html
::rawElement(
419 array( 'class' => 'mw-filepage-resolutioninfo' ),
423 $isMulti = $this->displayImg
->isMultipage() && $this->displayImg
->pageCount() > 1;
425 $out->addModules( 'mediawiki.page.image.pagination' );
426 $out->addHTML( '<table class="multipageimage"><tr><td>' );
431 'alt' => $this->displayImg
->getTitle()->getPrefixedText(),
434 $out->addHTML( '<div class="fullImageLink" id="file">' .
435 $thumbnail->toHtml( $options ) .
436 $anchorclose . "</div>\n" );
440 $count = $this->displayImg
->pageCount();
443 $label = $out->parse( $this->getContext()->msg( 'imgmultipageprev' )->text(), false );
444 // on the client side, this link is generated in ajaxifyPageNavigation()
445 // in the mediawiki.page.image.pagination module
446 $link = Linker
::linkKnown(
450 array( 'page' => $page - 1 )
452 $thumb1 = Linker
::makeThumbLinkObj(
458 array( 'page' => $page - 1 )
464 if ( $page < $count ) {
465 $label = $this->getContext()->msg( 'imgmultipagenext' )->text();
466 $link = Linker
::linkKnown(
470 array( 'page' => $page +
1 )
472 $thumb2 = Linker
::makeThumbLinkObj(
478 array( 'page' => $page +
1 )
487 'name' => 'pageselector',
488 'action' => $wgScript,
491 for ( $i = 1; $i <= $count; $i++
) {
492 $options[] = Xml
::option( $lang->formatNum( $i ), $i, $i == $page );
494 $select = Xml
::tags( 'select',
495 array( 'id' => 'pageselector', 'name' => 'page' ),
496 implode( "\n", $options ) );
499 '</td><td><div class="multipageimagenavbox">' .
500 Xml
::openElement( 'form', $formParams ) .
501 Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
502 $this->getContext()->msg( 'imgmultigoto' )->rawParams( $select )->parse() .
503 Xml
::submitButton( $this->getContext()->msg( 'imgmultigo' )->text() ) .
504 Xml
::closeElement( 'form' ) .
505 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
508 } elseif ( $this->displayImg
->isSafeFile() ) {
509 # if direct link is allowed but it's not a renderable image, show an icon.
510 $icon = $this->displayImg
->iconThumb();
512 $out->addHTML( '<div class="fullImageLink" id="file">' .
513 $icon->toHtml( array( 'file-link' => true ) ) .
517 $longDesc = $this->getContext()->msg( 'parentheses', $this->displayImg
->getLongDesc() )->text();
519 $handler = $this->displayImg
->getHandler();
521 // If this is a filetype with potential issues, warn the user.
523 $warningConfig = $handler->getWarningConfig( $this->displayImg
);
525 if ( $warningConfig !== null ) {
526 // The warning will be displayed via CSS and JavaScript.
527 // We just need to tell the client side what message to use.
528 $output = $this->getContext()->getOutput();
529 $output->addJsConfigVars( 'wgFileWarning', $warningConfig );
530 $output->addModules( $warningConfig['module'] );
531 $output->addModules( 'mediawiki.filewarning' );
535 $medialink = "[[Media:$filename|$linktext]]";
537 if ( !$this->displayImg
->isSafeFile() ) {
538 $warning = $this->getContext()->msg( 'mediawarning' )->plain();
539 // dirmark is needed here to separate the file name, which
540 // most likely ends in Latin characters, from the description,
541 // which may begin with the file type. In RTL environment
542 // this will get messy.
543 // The dirmark, however, must not be immediately adjacent
544 // to the filename, because it can get copied with it.
546 // @codingStandardsIgnoreStart Ignore long line
547 $out->addWikiText( <<<EOT
548 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
549 <div class="mediaWarning">$warning</div>
552 // @codingStandardsIgnoreEnd
554 $out->addWikiText( <<<EOT
555 <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
561 $renderLangOptions = $this->displayImg
->getAvailableLanguages();
562 if ( count( $renderLangOptions ) >= 1 ) {
563 $currentLanguage = $renderLang;
564 $defaultLang = $this->displayImg
->getDefaultRenderLanguage();
565 if ( is_null( $currentLanguage ) ) {
566 $currentLanguage = $defaultLang;
568 $out->addHtml( $this->doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
571 // Add cannot animate thumbnail warning
572 if ( !$this->displayImg
->canAnimateThumbIfAppropriate() ) {
573 // Include the extension so wiki admins can
574 // customize it on a per file-type basis
575 // (aka say things like use format X instead).
576 // additionally have a specific message for
577 // file-no-thumb-animation-gif
578 $ext = $this->displayImg
->getExtension();
579 $noAnimMesg = wfMessageFallback(
580 'file-no-thumb-animation-' . $ext,
581 'file-no-thumb-animation'
584 $out->addWikiText( <<<EOT
585 <div class="mw-noanimatethumb">{$noAnimMesg}</div>
590 if ( !$this->displayImg
->isLocal() ) {
591 $this->printSharedImageText();
594 # Image does not exist
595 if ( !$this->getID() ) {
596 # No article exists either
597 # Show deletion log to be consistent with normal articles
598 LogEventsList
::showLogExtract(
600 array( 'delete', 'move' ),
601 $this->getTitle()->getPrefixedText(),
604 'conds' => array( "log_action != 'revision'" ),
605 'showIfEmpty' => false,
606 'msgKey' => array( 'moveddeleted-notice' )
611 if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
612 // Only show an upload link if the user can upload
613 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
615 'filepage-nofile-link',
616 $uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage
->getFile()->getName() ) )
619 $nofile = 'filepage-nofile';
621 // Note, if there is an image description page, but
622 // no image, then this setRobotPolicy is overridden
623 // by Article::View().
624 $out->setRobotPolicy( 'noindex,nofollow' );
625 $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
626 if ( !$this->getID() && $wgSend404Code ) {
627 // If there is no image, no shared image, and no description page,
628 // output a 404, to be consistent with Article::showMissingArticle.
629 $request->response()->statusHeader( 404 );
632 $out->setFileVersion( $this->displayImg
);
636 * Creates an thumbnail of specified size and returns an HTML link to it
637 * @param array $params Scaler parameters
642 private function makeSizeLink( $params, $width, $height ) {
643 $params['width'] = $width;
644 $params['height'] = $height;
645 $thumbnail = $this->displayImg
->transform( $params );
646 if ( $thumbnail && !$thumbnail->isError() ) {
647 return Html
::rawElement( 'a', array(
648 'href' => $thumbnail->getUrl(),
649 'class' => 'mw-thumbnail-link'
650 ), $this->getContext()->msg( 'show-big-image-size' )->numParams(
651 $thumbnail->getWidth(), $thumbnail->getHeight()
659 * Show a notice that the file is from a shared repository
661 protected function printSharedImageText() {
662 $out = $this->getContext()->getOutput();
665 $descUrl = $this->mPage
->getFile()->getDescriptionUrl();
666 $descText = $this->mPage
->getFile()->getDescriptionText( $this->getContext()->getLanguage() );
668 /* Add canonical to head if there is no local page for this shared file */
669 if ( $descUrl && $this->mPage
->getID() == 0 ) {
670 $out->setCanonicalUrl( $descUrl );
673 $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
674 $repo = $this->mPage
->getFile()->getRepo()->getDisplayName();
678 $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-'
680 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
681 } elseif ( $descUrl &&
682 $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-'
684 $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
686 $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
690 $this->mExtraDescription
= $descText;
694 public function getUploadUrl() {
696 $uploadTitle = SpecialPage
::getTitleFor( 'Upload' );
697 return $uploadTitle->getFullURL( array(
698 'wpDestFile' => $this->mPage
->getFile()->getName(),
704 * Print out the various links at the bottom of the image page, e.g. reupload,
705 * external editing (and instructions link) etc.
707 protected function uploadLinksBox() {
708 global $wgEnableUploads;
710 if ( !$wgEnableUploads ) {
715 if ( !$this->mPage
->getFile()->isLocal() ) {
719 $out = $this->getContext()->getOutput();
720 $out->addHTML( "<ul>\n" );
722 # "Upload a new version of this file" link
723 $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
724 if ( $canUpload && UploadBase
::userCanReUpload(
725 $this->getContext()->getUser(),
726 $this->mPage
->getFile() )
728 $ulink = Linker
::makeExternalLink(
729 $this->getUploadUrl(),
730 $this->getContext()->msg( 'uploadnewversion-linktext' )->text()
732 $out->addHTML( "<li id=\"mw-imagepage-reupload-link\">"
733 . "<div class=\"plainlinks\">{$ulink}</div></li>\n" );
735 $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">"
736 . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
739 $out->addHTML( "</ul>\n" );
745 protected function closeShowImage() {
749 * If the page we've just displayed is in the "Image" namespace,
750 * we follow it with an upload history of the image and its usage.
752 protected function imageHistory() {
754 $out = $this->getContext()->getOutput();
755 $pager = new ImageHistoryPseudoPager( $this );
756 $out->addHTML( $pager->getBody() );
757 $out->preventClickjacking( $pager->getPreventClickjacking() );
759 $this->mPage
->getFile()->resetHistory(); // free db resources
761 # Exist check because we don't want to show this on pages where an image
762 # doesn't exist along with the noimage message, that would suck. -ævar
763 if ( $this->mPage
->getFile()->exists() ) {
764 $this->uploadLinksBox();
769 * @param string $target
771 * @return ResultWrapper
773 protected function queryImageLinks( $target, $limit ) {
774 $dbr = wfGetDB( DB_SLAVE
);
777 array( 'imagelinks', 'page' ),
778 array( 'page_namespace', 'page_title', 'il_to' ),
779 array( 'il_to' => $target, 'il_from = page_id' ),
781 array( 'LIMIT' => $limit +
1, 'ORDER BY' => 'il_from', )
785 protected function imageLinks() {
788 $out = $this->getContext()->getOutput();
791 $redirects = array();
792 foreach ( $this->getTitle()->getRedirectsHere( NS_FILE
) as $redir ) {
793 $redirects[$redir->getDBkey()] = array();
794 $rows[] = (object)array(
795 'page_namespace' => NS_FILE
,
796 'page_title' => $redir->getDBkey(),
800 $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit +
1 );
801 foreach ( $res as $row ) {
804 $count = count( $rows );
806 $hasMore = $count > $limit;
807 if ( !$hasMore && count( $redirects ) ) {
808 $res = $this->queryImageLinks( array_keys( $redirects ),
809 $limit - count( $rows ) +
1 );
810 foreach ( $res as $row ) {
811 $redirects[$row->il_to
][] = $row;
814 $hasMore = ( $res->numRows() +
count( $rows ) ) > $limit;
819 Html
::rawElement( 'div',
820 array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
826 $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
828 $out->addWikiMsg( 'linkstoimage', $count );
830 // More links than the limit. Add a link to [[Special:Whatlinkshere]]
831 $out->addWikiMsg( 'linkstoimage-more',
832 $this->getContext()->getLanguage()->formatNum( $limit ),
833 $this->getTitle()->getPrefixedDBkey()
838 Html
::openElement( 'ul',
839 array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
843 // Sort the list by namespace:title
844 usort( $rows, array( $this, 'compare' ) );
846 // Create links for every element
848 foreach ( $rows as $element ) {
850 if ( $currentCount > $limit ) {
855 # Add a redirect=no to make redirect pages reachable
856 if ( isset( $redirects[$element->page_title
] ) ) {
857 $query['redirect'] = 'no';
859 $link = Linker
::linkKnown(
860 Title
::makeTitle( $element->page_namespace
, $element->page_title
),
861 null, array(), $query
863 if ( !isset( $redirects[$element->page_title
] ) ) {
866 } elseif ( count( $redirects[$element->page_title
] ) === 0 ) {
867 # Redirect without usages
868 $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )
869 ->rawParams( $link, '' )
872 # Redirect with usages
874 foreach ( $redirects[$element->page_title
] as $row ) {
876 if ( $currentCount > $limit ) {
880 $link2 = Linker
::linkKnown( Title
::makeTitle( $row->page_namespace
, $row->page_title
) );
881 $li .= Html
::rawElement(
883 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace
),
888 $ul = Html
::rawElement(
890 array( 'class' => 'mw-imagepage-redirectstofile' ),
893 $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams(
894 $link, $ul )->parse();
896 $out->addHTML( Html
::rawElement(
898 array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace
),
904 $out->addHTML( Html
::closeElement( 'ul' ) . "\n" );
907 // Add a links to [[Special:Whatlinkshere]]
908 if ( $count > $limit ) {
909 $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
911 $out->addHTML( Html
::closeElement( 'div' ) . "\n" );
914 protected function imageDupes() {
916 $out = $this->getContext()->getOutput();
918 $dupes = $this->mPage
->getDuplicates();
919 if ( count( $dupes ) == 0 ) {
923 $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
924 $out->addWikiMsg( 'duplicatesoffile',
925 $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
927 $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
932 foreach ( $dupes as $file ) {
934 if ( $file->isLocal() ) {
935 $link = Linker
::linkKnown( $file->getTitle() );
937 $link = Linker
::makeExternalLink( $file->getDescriptionUrl(),
938 $file->getTitle()->getPrefixedText() );
939 $fromSrc = $this->getContext()->msg(
941 $file->getRepo()->getDisplayName()
944 $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
946 $out->addHTML( "</ul></div>\n" );
950 * Delete the file, or an earlier version of it
952 public function delete() {
953 $file = $this->mPage
->getFile();
954 if ( !$file->exists() ||
!$file->isLocal() ||
$file->getRedirected() ) {
955 // Standard article deletion
960 $deleter = new FileDeleteForm( $file );
965 * Display an error with a wikitext description
967 * @param string $description
969 function showError( $description ) {
970 $out = $this->getContext()->getOutput();
971 $out->setPageTitle( $this->getContext()->msg( 'internalerror' ) );
972 $out->setRobotPolicy( 'noindex,nofollow' );
973 $out->setArticleRelated( false );
974 $out->enableClientCache( false );
975 $out->addWikiText( $description );
979 * Callback for usort() to do link sorts by (namespace, title)
980 * Function copied from Title::compare()
982 * @param object $a Object page to compare with
983 * @param object $b Object page to compare with
984 * @return int Result of string comparison, or namespace comparison
986 protected function compare( $a, $b ) {
987 if ( $a->page_namespace
== $b->page_namespace
) {
988 return strcmp( $a->page_title
, $b->page_title
);
990 return $a->page_namespace
- $b->page_namespace
;
995 * Returns the corresponding $wgImageLimits entry for the selected user option
998 * @param string $optionName Name of a option to check, typically imagesize or thumbsize
1002 public function getImageLimitsFromOption( $user, $optionName ) {
1003 global $wgImageLimits;
1005 $option = $user->getIntOption( $optionName );
1006 if ( !isset( $wgImageLimits[$option] ) ) {
1007 $option = User
::getDefaultOption( $optionName );
1010 // The user offset might still be incorrect, specially if
1011 // $wgImageLimits got changed (see bug #8858).
1012 if ( !isset( $wgImageLimits[$option] ) ) {
1013 // Default to the first offset in $wgImageLimits
1017 return isset( $wgImageLimits[$option] )
1018 ?
$wgImageLimits[$option]
1019 : array( 800, 600 ); // if nothing is set, fallback to a hardcoded default
1023 * Output a drop-down box for language options for the file
1025 * @param array $langChoices Array of string language codes
1026 * @param string $curLang Language code file is being viewed in.
1027 * @param string $defaultLang Language code that image is rendered in by default
1028 * @return string HTML to insert underneath image.
1030 protected function doRenderLangOpt( array $langChoices, $curLang, $defaultLang ) {
1032 sort( $langChoices );
1033 $curLang = wfBCP47( $curLang );
1034 $defaultLang = wfBCP47( $defaultLang );
1036 $haveCurrentLang = false;
1037 $haveDefaultLang = false;
1039 // We make a list of all the language choices in the file.
1040 // Additionally if the default language to render this file
1041 // is not included as being in this file (for example, in svgs
1042 // usually the fallback content is the english content) also
1043 // include a choice for that. Last of all, if we're viewing
1044 // the file in a language not on the list, add it as a choice.
1045 foreach ( $langChoices as $lang ) {
1046 $code = wfBCP47( $lang );
1047 $name = Language
::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
1048 if ( $name !== '' ) {
1049 $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
1053 $opts .= "\n" . Xml
::option( $display, $code, $curLang === $code );
1054 if ( $curLang === $code ) {
1055 $haveCurrentLang = true;
1057 if ( $defaultLang === $code ) {
1058 $haveDefaultLang = true;
1061 if ( !$haveDefaultLang ) {
1062 // Its hard to know if the content is really in the default language, or
1063 // if its just unmarked content that could be in any language.
1064 $opts = Xml
::option(
1065 $this->getContext()->msg( 'img-lang-default' )->text(),
1067 $defaultLang === $curLang
1070 if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
1071 $name = Language
::fetchLanguageName( $curLang, $this->getContext()->getLanguage()->getCode() );
1072 if ( $name !== '' ) {
1073 $display = $this->getContext()->msg( 'img-lang-opt', $curLang, $name )->text();
1075 $display = $curLang;
1077 $opts = Xml
::option( $display, $curLang, true ) . $opts;
1080 $select = Html
::rawElement(
1082 array( 'id' => 'mw-imglangselector', 'name' => 'lang' ),
1085 $submit = Xml
::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() );
1087 $formContents = $this->getContext()->msg( 'img-lang-info' )
1088 ->rawParams( $select, $submit )
1090 $formContents .= Html
::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
1092 $langSelectLine = Html
::rawElement( 'div', array( 'id' => 'mw-imglangselector-line' ),
1093 Html
::rawElement( 'form', array( 'action' => $wgScript ), $formContents )
1095 return $langSelectLine;
1099 * Get the width and height to display image at.
1101 * @note This method assumes that it is only called if one
1102 * of the dimensions are bigger than the max, or if the
1103 * image is vectorized.
1105 * @param int $maxWidth Max width to display at
1106 * @param int $maxHeight Max height to display at
1107 * @param int $width Actual width of the image
1108 * @param int $height Actual height of the image
1109 * @throws MWException
1110 * @return array Array (width, height)
1112 protected function getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height ) {
1113 if ( !$maxWidth ||
!$maxHeight ) {
1114 // should never happen
1115 throw new MWException( 'Using a choice from $wgImageLimits that is 0x0' );
1118 if ( !$width ||
!$height ) {
1119 return array( 0, 0 );
1122 # Calculate the thumbnail size.
1123 if ( $width <= $maxWidth && $height <= $maxHeight ) {
1124 // Vectorized image, do nothing.
1125 } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1126 # The limiting factor is the width, not the height.
1127 $height = round( $height * $maxWidth / $width );
1129 # Note that $height <= $maxHeight now.
1131 $newwidth = floor( $width * $maxHeight / $height );
1132 $height = round( $height * $newwidth / $width );
1134 # Note that $height <= $maxHeight now, but might not be identical
1135 # because of rounding.
1137 return array( $width, $height );
1141 * Get alternative thumbnail sizes.
1143 * @note This will only list several alternatives if thumbnails are rendered on 404
1144 * @param int $origWidth Actual width of image
1145 * @param int $origHeight Actual height of image
1146 * @return array An array of [width, height] pairs.
1148 protected function getThumbSizes( $origWidth, $origHeight ) {
1149 global $wgImageLimits;
1150 if ( $this->displayImg
->getRepo()->canTransformVia404() ) {
1151 $thumbSizes = $wgImageLimits;
1152 // Also include the full sized resolution in the list, so
1153 // that users know they can get it. This will link to the
1154 // original file asset if mustRender() === false. In the case
1155 // that we mustRender, some users have indicated that they would
1156 // find it useful to have the full size image in the rendered
1158 $thumbSizes[] = array( $origWidth, $origHeight );
1160 # Creating thumb links triggers thumbnail generation.
1161 # Just generate the thumb for the current users prefs.
1162 $thumbSizes = array(
1163 $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' )
1165 if ( !$this->displayImg
->mustRender() ) {
1166 // We can safely include a link to the "full-size" preview,
1167 // without actually rendering.
1168 $thumbSizes[] = array( $origWidth, $origHeight );
1177 * Builds the image revision log shown on image pages
1181 class ImageHistoryList
extends ContextSource
{
1196 protected $imagePage;
1203 protected $repo, $showThumb;
1204 protected $preventClickjacking = false;
1207 * @param ImagePage $imagePage
1209 public function __construct( $imagePage ) {
1210 global $wgShowArchiveThumbnails;
1211 $this->current
= $imagePage->getFile();
1212 $this->img
= $imagePage->getDisplayedFile();
1213 $this->title
= $imagePage->getTitle();
1214 $this->imagePage
= $imagePage;
1215 $this->showThumb
= $wgShowArchiveThumbnails && $this->img
->canRender();
1216 $this->setContext( $imagePage->getContext() );
1222 public function getImagePage() {
1223 return $this->imagePage
;
1229 public function getFile() {
1234 * @param string $navLinks
1237 public function beginImageHistoryList( $navLinks = '' ) {
1238 return Xml
::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() )
1240 . "<div id=\"mw-imagepage-section-filehistory\">\n"
1241 . $this->msg( 'filehist-help' )->parseAsBlock()
1243 . Xml
::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
1245 . ( $this->current
->isLocal()
1246 && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ?
'<th></th>' : '' )
1247 . '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
1248 . ( $this->showThumb ?
'<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
1249 . '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
1250 . '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
1251 . '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
1256 * @param string $navLinks
1259 public function endImageHistoryList( $navLinks = '' ) {
1260 return "</table>\n$navLinks\n</div>\n";
1264 * @param bool $iscur
1268 public function imageHistoryLine( $iscur, $file ) {
1271 $user = $this->getUser();
1272 $lang = $this->getLanguage();
1273 $timestamp = wfTimestamp( TS_MW
, $file->getTimestamp() );
1274 $img = $iscur ?
$file->getName() : $file->getArchiveName();
1275 $userId = $file->getUser( 'id' );
1276 $userText = $file->getUser( 'text' );
1277 $description = $file->getDescription( File
::FOR_THIS_USER
, $user );
1279 $local = $this->current
->isLocal();
1280 $row = $selected = '';
1283 if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
1285 # Link to remove from history
1286 if ( $user->isAllowed( 'delete' ) ) {
1287 $q = array( 'action' => 'delete' );
1289 $q['oldimage'] = $img;
1291 $row .= Linker
::linkKnown(
1293 $this->msg( $iscur ?
'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
1297 # Link to hide content. Don't show useless link to people who cannot hide revisions.
1298 $canHide = $user->isAllowed( 'deleterevision' );
1299 if ( $canHide ||
( $user->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
1300 if ( $user->isAllowed( 'delete' ) ) {
1303 // If file is top revision or locked from this user, don't link
1304 if ( $iscur ||
!$file->userCan( File
::DELETED_RESTRICTED
, $user ) ) {
1305 $del = Linker
::revDeleteLinkDisabled( $canHide );
1307 list( $ts, ) = explode( '!', $img, 2 );
1309 'type' => 'oldimage',
1310 'target' => $this->title
->getPrefixedText(),
1313 $del = Linker
::revDeleteLink( $query,
1314 $file->isDeleted( File
::DELETED_RESTRICTED
), $canHide );
1321 // Reversion link/current indicator
1324 $row .= $this->msg( 'filehist-current' )->escaped();
1325 } elseif ( $local && $this->title
->quickUserCan( 'edit', $user )
1326 && $this->title
->quickUserCan( 'upload', $user )
1328 if ( $file->isDeleted( File
::DELETED_FILE
) ) {
1329 $row .= $this->msg( 'filehist-revert' )->escaped();
1331 $row .= Linker
::linkKnown(
1333 $this->msg( 'filehist-revert' )->escaped(),
1336 'action' => 'revert',
1338 'wpEditToken' => $user->getEditToken( $img )
1345 // Date/time and image link
1346 if ( $file->getTimestamp() === $this->img
->getTimestamp() ) {
1347 $selected = "class='filehistory-selected'";
1349 $row .= "<td $selected style='white-space: nowrap;'>";
1350 if ( !$file->userCan( File
::DELETED_FILE
, $user ) ) {
1351 # Don't link to unviewable files
1352 $row .= '<span class="history-deleted">'
1353 . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
1354 } elseif ( $file->isDeleted( File
::DELETED_FILE
) ) {
1356 $this->preventClickjacking();
1357 $revdel = SpecialPage
::getTitleFor( 'Revisiondelete' );
1358 # Make a link to review the image
1359 $url = Linker
::linkKnown(
1361 $lang->userTimeAndDate( $timestamp, $user ),
1364 'target' => $this->title
->getPrefixedText(),
1366 'token' => $user->getEditToken( $img )
1370 $url = $lang->userTimeAndDate( $timestamp, $user );
1372 $row .= '<span class="history-deleted">' . $url . '</span>';
1373 } elseif ( !$file->exists() ) {
1374 $row .= '<span class="mw-file-missing">'
1375 . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
1377 $url = $iscur ?
$this->current
->getUrl() : $this->current
->getArchiveUrl( $img );
1378 $row .= Xml
::element(
1380 array( 'href' => $url ),
1381 $lang->userTimeAndDate( $timestamp, $user )
1387 if ( $this->showThumb
) {
1388 $row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
1391 // Image dimensions + size
1393 $row .= htmlspecialchars( $file->getDimensionsString() );
1394 $row .= $this->msg( 'word-separator' )->escaped();
1395 $row .= '<span style="white-space: nowrap;">';
1396 $row .= $this->msg( 'parentheses' )->sizeParams( $file->getSize() )->escaped();
1402 // Hide deleted usernames
1403 if ( $file->isDeleted( File
::DELETED_USER
) ) {
1404 $row .= '<span class="history-deleted">'
1405 . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
1408 $row .= Linker
::userLink( $userId, $userText );
1409 $row .= '<span style="white-space: nowrap;">';
1410 $row .= Linker
::userToolLinks( $userId, $userText );
1413 $row .= htmlspecialchars( $userText );
1418 // Don't show deleted descriptions
1419 if ( $file->isDeleted( File
::DELETED_COMMENT
) ) {
1420 $row .= '<td><span class="history-deleted">' .
1421 $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
1423 $row .= '<td dir="' . $wgContLang->getDir() . '">' .
1424 Linker
::formatComment( $description, $this->title
) . '</td>';
1428 Hooks
::run( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
1429 $classAttr = $rowClass ?
" class='$rowClass'" : '';
1431 return "<tr{$classAttr}>{$row}</tr>\n";
1438 protected function getThumbForLine( $file ) {
1439 $lang = $this->getLanguage();
1440 $user = $this->getUser();
1441 if ( $file->allowInlineDisplay() && $file->userCan( File
::DELETED_FILE
, $user )
1442 && !$file->isDeleted( File
::DELETED_FILE
)
1448 $timestamp = wfTimestamp( TS_MW
, $file->getTimestamp() );
1450 $thumbnail = $file->transform( $params );
1452 'alt' => $this->msg( 'filehist-thumbtext',
1453 $lang->userTimeAndDate( $timestamp, $user ),
1454 $lang->userDate( $timestamp, $user ),
1455 $lang->userTime( $timestamp, $user ) )->text(),
1456 'file-link' => true,
1459 if ( !$thumbnail ) {
1460 return $this->msg( 'filehist-nothumb' )->escaped();
1463 return $thumbnail->toHtml( $options );
1465 return $this->msg( 'filehist-nothumb' )->escaped();
1470 * @param bool $enable
1472 protected function preventClickjacking( $enable = true ) {
1473 $this->preventClickjacking
= $enable;
1479 public function getPreventClickjacking() {
1480 return $this->preventClickjacking
;
1484 class ImageHistoryPseudoPager
extends ReverseChronologicalPager
{
1485 protected $preventClickjacking = false;
1498 * @param ImagePage $imagePage
1500 function __construct( $imagePage ) {
1501 parent
::__construct( $imagePage->getContext() );
1502 $this->mImagePage
= $imagePage;
1503 $this->mTitle
= clone ( $imagePage->getTitle() );
1504 $this->mTitle
->setFragment( '#filehistory' );
1506 $this->mHist
= array();
1507 $this->mRange
= array( 0, 0 ); // display range
1513 function getTitle() {
1514 return $this->mTitle
;
1517 function getQueryInfo() {
1524 function getIndexField() {
1529 * @param object $row
1532 function formatRow( $row ) {
1539 function getBody() {
1542 if ( count( $this->mHist
) ) {
1543 if ( $this->mImg
->isLocal() ) {
1544 // Do a batch existence check for user pages and talkpages
1545 $linkBatch = new LinkBatch();
1546 for ( $i = $this->mRange
[0]; $i <= $this->mRange
[1]; $i++
) {
1547 $file = $this->mHist
[$i];
1548 $user = $file->getUser( 'text' );
1549 $linkBatch->add( NS_USER
, $user );
1550 $linkBatch->add( NS_USER_TALK
, $user );
1552 $linkBatch->execute();
1555 $list = new ImageHistoryList( $this->mImagePage
);
1556 # Generate prev/next links
1557 $navLink = $this->getNavigationBar();
1558 $s = $list->beginImageHistoryList( $navLink );
1559 // Skip rows there just for paging links
1560 for ( $i = $this->mRange
[0]; $i <= $this->mRange
[1]; $i++
) {
1561 $file = $this->mHist
[$i];
1562 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
1564 $s .= $list->endImageHistoryList( $navLink );
1566 if ( $list->getPreventClickjacking() ) {
1567 $this->preventClickjacking();
1573 function doQuery() {
1574 if ( $this->mQueryDone
) {
1577 $this->mImg
= $this->mImagePage
->getFile(); // ensure loading
1578 if ( !$this->mImg
->exists() ) {
1581 $queryLimit = $this->mLimit +
1; // limit plus extra row
1582 if ( $this->mIsBackwards
) {
1583 // Fetch the file history
1584 $this->mHist
= $this->mImg
->getHistory( $queryLimit, null, $this->mOffset
, false );
1585 // The current rev may not meet the offset/limit
1586 $numRows = count( $this->mHist
);
1587 if ( $numRows <= $this->mLimit
&& $this->mImg
->getTimestamp() > $this->mOffset
) {
1588 $this->mHist
= array_merge( array( $this->mImg
), $this->mHist
);
1591 // The current rev may not meet the offset
1592 if ( !$this->mOffset ||
$this->mImg
->getTimestamp() < $this->mOffset
) {
1593 $this->mHist
[] = $this->mImg
;
1595 // Old image versions (fetch extra row for nav links)
1596 $oiLimit = count( $this->mHist
) ?
$this->mLimit
: $this->mLimit +
1;
1597 // Fetch the file history
1598 $this->mHist
= array_merge( $this->mHist
,
1599 $this->mImg
->getHistory( $oiLimit, $this->mOffset
, null, false ) );
1601 $numRows = count( $this->mHist
); // Total number of query results
1603 # Index value of top item in the list
1604 $firstIndex = $this->mIsBackwards ?
1605 $this->mHist
[$numRows - 1]->getTimestamp() : $this->mHist
[0]->getTimestamp();
1606 # Discard the extra result row if there is one
1607 if ( $numRows > $this->mLimit
&& $numRows > 1 ) {
1608 if ( $this->mIsBackwards
) {
1609 # Index value of item past the index
1610 $this->mPastTheEndIndex
= $this->mHist
[0]->getTimestamp();
1611 # Index value of bottom item in the list
1612 $lastIndex = $this->mHist
[1]->getTimestamp();
1614 $this->mRange
= array( 1, $numRows - 1 );
1616 # Index value of item past the index
1617 $this->mPastTheEndIndex
= $this->mHist
[$numRows - 1]->getTimestamp();
1618 # Index value of bottom item in the list
1619 $lastIndex = $this->mHist
[$numRows - 2]->getTimestamp();
1621 $this->mRange
= array( 0, $numRows - 2 );
1624 # Setting indexes to an empty string means that they will be
1625 # omitted if they would otherwise appear in URLs. It just so
1626 # happens that this is the right thing to do in the standard
1627 # UI, in all the relevant cases.
1628 $this->mPastTheEndIndex
= '';
1629 # Index value of bottom item in the list
1630 $lastIndex = $this->mIsBackwards ?
1631 $this->mHist
[0]->getTimestamp() : $this->mHist
[$numRows - 1]->getTimestamp();
1633 $this->mRange
= array( 0, $numRows - 1 );
1638 $this->mPastTheEndIndex
= '';
1640 if ( $this->mIsBackwards
) {
1641 $this->mIsFirst
= ( $numRows < $queryLimit );
1642 $this->mIsLast
= ( $this->mOffset
== '' );
1643 $this->mLastShown
= $firstIndex;
1644 $this->mFirstShown
= $lastIndex;
1646 $this->mIsFirst
= ( $this->mOffset
== '' );
1647 $this->mIsLast
= ( $numRows < $queryLimit );
1648 $this->mLastShown
= $lastIndex;
1649 $this->mFirstShown
= $firstIndex;
1651 $this->mQueryDone
= true;
1655 * @param bool $enable
1657 protected function preventClickjacking( $enable = true ) {
1658 $this->preventClickjacking
= $enable;
1664 public function getPreventClickjacking() {
1665 return $this->preventClickjacking
;