MediaWiki  REL1_22
ImagePage.php
Go to the documentation of this file.
00001 <?php
00028 class ImagePage extends Article {
00029 
00033     private $displayImg;
00037     private $repo;
00038     private $fileLoaded;
00039 
00040     var $mExtraDescription = false;
00041 
00046     protected function newPage( Title $title ) {
00047         // Overload mPage with a file-specific page
00048         return new WikiFilePage( $title );
00049     }
00050 
00056     public static function newFromID( $id ) {
00057         $t = Title::newFromID( $id );
00058         # @todo FIXME: Doesn't inherit right
00059         return $t == null ? null : new self( $t );
00060         # return $t == null ? null : new static( $t ); // PHP 5.3
00061     }
00062 
00067     public function setFile( $file ) {
00068         $this->mPage->setFile( $file );
00069         $this->displayImg = $file;
00070         $this->fileLoaded = true;
00071     }
00072 
00073     protected function loadFile() {
00074         if ( $this->fileLoaded ) {
00075             return;
00076         }
00077         $this->fileLoaded = true;
00078 
00079         $this->displayImg = $img = false;
00080         wfRunHooks( 'ImagePageFindFile', array( $this, &$img, &$this->displayImg ) );
00081         if ( !$img ) { // not set by hook?
00082             $img = wfFindFile( $this->getTitle() );
00083             if ( !$img ) {
00084                 $img = wfLocalFile( $this->getTitle() );
00085             }
00086         }
00087         $this->mPage->setFile( $img );
00088         if ( !$this->displayImg ) { // not set by hook?
00089             $this->displayImg = $img;
00090         }
00091         $this->repo = $img->getRepo();
00092     }
00093 
00098     public function render() {
00099         $this->getContext()->getOutput()->setArticleBodyOnly( true );
00100         parent::view();
00101     }
00102 
00103     public function view() {
00104         global $wgShowEXIF;
00105 
00106         $out = $this->getContext()->getOutput();
00107         $request = $this->getContext()->getRequest();
00108         $diff = $request->getVal( 'diff' );
00109         $diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) );
00110 
00111         if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) {
00112             parent::view();
00113             return;
00114         }
00115 
00116         $this->loadFile();
00117 
00118         if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
00119             if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
00120                 // mTitle is the same as the redirect target so ask Article
00121                 // to perform the redirect for us.
00122                 $request->setVal( 'diffonly', 'true' );
00123                 parent::view();
00124                 return;
00125             } else {
00126                 // mTitle is not the same as the redirect target so it is
00127                 // probably the redirect page itself. Fake the redirect symbol
00128                 $out->setPageTitle( $this->getTitle()->getPrefixedText() );
00129                 $out->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ),
00130                     /* $appendSubtitle */ true, /* $forceKnown */ true ) );
00131                 $this->mPage->doViewUpdates( $this->getContext()->getUser() );
00132                 return;
00133             }
00134         }
00135 
00136         if ( $wgShowEXIF && $this->displayImg->exists() ) {
00137             // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
00138             $formattedMetadata = $this->displayImg->formatMetadata();
00139             $showmeta = $formattedMetadata !== false;
00140         } else {
00141             $showmeta = false;
00142         }
00143 
00144         if ( !$diff && $this->displayImg->exists() ) {
00145             $out->addHTML( $this->showTOC( $showmeta ) );
00146         }
00147 
00148         if ( !$diff ) {
00149             $this->openShowImage();
00150         }
00151 
00152         # No need to display noarticletext, we use our own message, output in openShowImage()
00153         if ( $this->mPage->getID() ) {
00154             # NS_FILE is in the user language, but this section (the actual wikitext)
00155             # should be in page content language
00156             $pageLang = $this->getTitle()->getPageViewLanguage();
00157             $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content',
00158                 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
00159                 'class' => 'mw-content-' . $pageLang->getDir() ) ) );
00160 
00161             parent::view();
00162 
00163             $out->addHTML( Xml::closeElement( 'div' ) );
00164         } else {
00165             # Just need to set the right headers
00166             $out->setArticleFlag( true );
00167             $out->setPageTitle( $this->getTitle()->getPrefixedText() );
00168             $this->mPage->doViewUpdates( $this->getContext()->getUser() );
00169         }
00170 
00171         # Show shared description, if needed
00172         if ( $this->mExtraDescription ) {
00173             $fol = wfMessage( 'shareddescriptionfollows' );
00174             if ( !$fol->isDisabled() ) {
00175                 $out->addWikiText( $fol->plain() );
00176             }
00177             $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
00178         }
00179 
00180         $this->closeShowImage();
00181         $this->imageHistory();
00182         // TODO: Cleanup the following
00183 
00184         $out->addHTML( Xml::element( 'h2',
00185             array( 'id' => 'filelinks' ),
00186             wfMessage( 'imagelinks' )->text() ) . "\n" );
00187         $this->imageDupes();
00188         # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
00189         # Yet we return metadata about the target. Definitely an issue in the FileRepo
00190         $this->imageLinks();
00191 
00192         # Allow extensions to add something after the image links
00193         $html = '';
00194         wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) );
00195         if ( $html ) {
00196             $out->addHTML( $html );
00197         }
00198 
00199         if ( $showmeta ) {
00200             $out->addHTML( Xml::element(
00201                 'h2',
00202                 array( 'id' => 'metadata' ),
00203                 wfMessage( 'metadata' )->text() ) . "\n" );
00204             $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
00205             $out->addModules( array( 'mediawiki.action.view.metadata' ) );
00206         }
00207 
00208         // Add remote Filepage.css
00209         if ( !$this->repo->isLocal() ) {
00210             $css = $this->repo->getDescriptionStylesheetUrl();
00211             if ( $css ) {
00212                 $out->addStyle( $css );
00213             }
00214         }
00215         // always show the local local Filepage.css, bug 29277
00216         $out->addModuleStyles( 'filepage' );
00217     }
00218 
00222     public function getDisplayedFile() {
00223         $this->loadFile();
00224         return $this->displayImg;
00225     }
00226 
00233     protected function showTOC( $metadata ) {
00234         $r = array(
00235             '<li><a href="#file">' . wfMessage( 'file-anchor-link' )->escaped() . '</a></li>',
00236             '<li><a href="#filehistory">' . wfMessage( 'filehist' )->escaped() . '</a></li>',
00237             '<li><a href="#filelinks">' . wfMessage( 'imagelinks' )->escaped() . '</a></li>',
00238         );
00239         if ( $metadata ) {
00240             $r[] = '<li><a href="#metadata">' . wfMessage( 'metadata' )->escaped() . '</a></li>';
00241         }
00242 
00243         wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
00244 
00245         return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
00246     }
00247 
00256     protected function makeMetadataTable( $metadata ) {
00257         $r = "<div class=\"mw-imagepage-section-metadata\">";
00258         $r .= wfMessage( 'metadata-help' )->plain();
00259         $r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
00260         foreach ( $metadata as $type => $stuff ) {
00261             foreach ( $stuff as $v ) {
00262                 # @todo FIXME: Why is this using escapeId for a class?!
00263                 $class = Sanitizer::escapeId( $v['id'] );
00264                 if ( $type == 'collapsed' ) {
00265                     $class .= ' collapsable'; // sic
00266                 }
00267                 $r .= "<tr class=\"$class\">\n";
00268                 $r .= "<th>{$v['name']}</th>\n";
00269                 $r .= "<td>{$v['value']}</td>\n</tr>";
00270             }
00271         }
00272         $r .= "</table>\n</div>\n";
00273         return $r;
00274     }
00275 
00283     public function getContentObject() {
00284         $this->loadFile();
00285         if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getID() ) {
00286             return null;
00287         }
00288         return parent::getContentObject();
00289     }
00290 
00291     protected function openShowImage() {
00292         global $wgImageLimits, $wgEnableUploads, $wgSend404Code;
00293 
00294         $this->loadFile();
00295         $out = $this->getContext()->getOutput();
00296         $user = $this->getContext()->getUser();
00297         $lang = $this->getContext()->getLanguage();
00298         $dirmark = $lang->getDirMarkEntity();
00299         $request = $this->getContext()->getRequest();
00300 
00301         $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
00302         $maxWidth = $max[0];
00303         $maxHeight = $max[1];
00304 
00305         if ( $this->displayImg->exists() ) {
00306             # image
00307             $page = $request->getIntOrNull( 'page' );
00308             if ( is_null( $page ) ) {
00309                 $params = array();
00310                 $page = 1;
00311             } else {
00312                 $params = array( 'page' => $page );
00313             }
00314 
00315             $renderLang = $request->getVal( 'lang' );
00316             if ( !is_null( $renderLang ) ) {
00317                 $params['lang'] = $renderLang;
00318             }
00319 
00320             $width_orig = $this->displayImg->getWidth( $page );
00321             $width = $width_orig;
00322             $height_orig = $this->displayImg->getHeight( $page );
00323             $height = $height_orig;
00324 
00325             $filename = wfEscapeWikiText( $this->displayImg->getName() );
00326             $linktext = $filename;
00327 
00328             wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) );
00329 
00330             if ( $this->displayImg->allowInlineDisplay() ) {
00331                 # image
00332 
00333                 # "Download high res version" link below the image
00334                 # $msgsize = wfMessage( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
00335                 # We'll show a thumbnail of this image
00336                 if ( $width > $maxWidth || $height > $maxHeight ) {
00337                     # Calculate the thumbnail size.
00338                     # First case, the limiting factor is the width, not the height.
00339                     if ( $width / $height >= $maxWidth / $maxHeight ) { // FIXME: Possible division by 0. bug 36911
00340                         $height = round( $height * $maxWidth / $width ); // FIXME: Possible division by 0. bug 36911
00341                         $width = $maxWidth;
00342                         # Note that $height <= $maxHeight now.
00343                     } else {
00344                         $newwidth = floor( $width * $maxHeight / $height ); // FIXME: Possible division by 0. bug 36911
00345                         $height = round( $height * $newwidth / $width ); // FIXME: Possible division by 0. bug 36911
00346                         $width = $newwidth;
00347                         # Note that $height <= $maxHeight now, but might not be identical
00348                         # because of rounding.
00349                     }
00350                     $linktext = wfMessage( 'show-big-image' )->escaped();
00351                     if ( $this->displayImg->getRepo()->canTransformVia404() ) {
00352                         $thumbSizes = $wgImageLimits;
00353                     } else {
00354                         # Creating thumb links triggers thumbnail generation.
00355                         # Just generate the thumb for the current users prefs.
00356                         $thumbSizes = array( $this->getImageLimitsFromOption( $user, 'thumbsize' ) );
00357                     }
00358                     # Generate thumbnails or thumbnail links as needed...
00359                     $otherSizes = array();
00360                     foreach ( $thumbSizes as $size ) {
00361                         if ( $size[0] < $width_orig && $size[1] < $height_orig
00362                             && $size[0] != $width && $size[1] != $height )
00363                         {
00364                             $sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
00365                             if ( $sizeLink ) {
00366                                 $otherSizes[] = $sizeLink;
00367                             }
00368                         }
00369                     }
00370                     $msgsmall = '';
00371                     $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height );
00372                     if ( $sizeLinkBigImagePreview ) {
00373                         $msgsmall .= wfMessage( 'show-big-image-preview' )->
00374                             rawParams( $sizeLinkBigImagePreview )->
00375                             parse();
00376                     }
00377                     if ( count( $otherSizes ) ) {
00378                         $msgsmall .= ' ' .
00379                         Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ),
00380                             wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->
00381                             params( count( $otherSizes ) )->parse()
00382                         );
00383                     }
00384                 } elseif ( $width == 0 && $height == 0 ) {
00385                     # Some sort of audio file that doesn't have dimensions
00386                     # Don't output a no hi res message for such a file
00387                     $msgsmall = '';
00388                 } elseif ( $this->displayImg->isVectorized() ) {
00389                     # For vectorized images, full size is just the frame size
00390                     $msgsmall = '';
00391                 } else {
00392                     # Image is small enough to show full size on image page
00393                     $msgsmall = wfMessage( 'file-nohires' )->parse();
00394                 }
00395 
00396                 $params['width'] = $width;
00397                 $params['height'] = $height;
00398                 $thumbnail = $this->displayImg->transform( $params );
00399 
00400                 $anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall );
00401 
00402                 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
00403                 if ( $isMulti ) {
00404                     $out->addModules( 'mediawiki.page.image.pagination' );
00405                     $out->addHTML( '<table class="multipageimage"><tr><td>' );
00406                 }
00407 
00408                 if ( $thumbnail ) {
00409                     $options = array(
00410                         'alt' => $this->displayImg->getTitle()->getPrefixedText(),
00411                         'file-link' => true,
00412                     );
00413                     $out->addHTML( '<div class="fullImageLink" id="file">' .
00414                         $thumbnail->toHtml( $options ) .
00415                         $anchorclose . "</div>\n" );
00416                 }
00417 
00418                 if ( $isMulti ) {
00419                     $count = $this->displayImg->pageCount();
00420 
00421                     if ( $page > 1 ) {
00422                         $label = $out->parse( wfMessage( 'imgmultipageprev' )->text(), false );
00423                         // on the client side, this link is generated in ajaxifyPageNavigation()
00424                         // in the mediawiki.page.image.pagination module
00425                         $link = Linker::linkKnown(
00426                             $this->getTitle(),
00427                             $label,
00428                             array(),
00429                             array( 'page' => $page - 1 )
00430                         );
00431                         $thumb1 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
00432                             array( 'page' => $page - 1 ) );
00433                     } else {
00434                         $thumb1 = '';
00435                     }
00436 
00437                     if ( $page < $count ) {
00438                         $label = wfMessage( 'imgmultipagenext' )->text();
00439                         $link = Linker::linkKnown(
00440                             $this->getTitle(),
00441                             $label,
00442                             array(),
00443                             array( 'page' => $page + 1 )
00444                         );
00445                         $thumb2 = Linker::makeThumbLinkObj( $this->getTitle(), $this->displayImg, $link, $label, 'none',
00446                             array( 'page' => $page + 1 ) );
00447                     } else {
00448                         $thumb2 = '';
00449                     }
00450 
00451                     global $wgScript;
00452 
00453                     $formParams = array(
00454                         'name' => 'pageselector',
00455                         'action' => $wgScript,
00456                     );
00457                     $options = array();
00458                     for ( $i = 1; $i <= $count; $i++ ) {
00459                         $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
00460                     }
00461                     $select = Xml::tags( 'select',
00462                         array( 'id' => 'pageselector', 'name' => 'page' ),
00463                         implode( "\n", $options ) );
00464 
00465                     $out->addHTML(
00466                         '</td><td><div class="multipageimagenavbox">' .
00467                         Xml::openElement( 'form', $formParams ) .
00468                         Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
00469                             wfMessage( 'imgmultigoto' )->rawParams( $select )->parse() .
00470                         Xml::submitButton( wfMessage( 'imgmultigo' )->text() ) .
00471                         Xml::closeElement( 'form' ) .
00472                         "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
00473                     );
00474                 }
00475             } elseif ( $this->displayImg->isSafeFile() ) {
00476                 # if direct link is allowed but it's not a renderable image, show an icon.
00477                 $icon = $this->displayImg->iconThumb();
00478 
00479                 $out->addHTML( '<div class="fullImageLink" id="file">' .
00480                     $icon->toHtml( array( 'file-link' => true ) ) .
00481                     "</div>\n" );
00482             }
00483 
00484             $longDesc = wfMessage( 'parentheses', $this->displayImg->getLongDesc() )->text();
00485 
00486             $medialink = "[[Media:$filename|$linktext]]";
00487 
00488             if ( !$this->displayImg->isSafeFile() ) {
00489                 $warning = wfMessage( 'mediawarning' )->plain();
00490                 // dirmark is needed here to separate the file name, which
00491                 // most likely ends in Latin characters, from the description,
00492                 // which may begin with the file type. In RTL environment
00493                 // this will get messy.
00494                 // The dirmark, however, must not be immediately adjacent
00495                 // to the filename, because it can get copied with it.
00496                 // See bug 25277.
00497                 $out->addWikiText( <<<EOT
00498 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
00499 <div class="mediaWarning">$warning</div>
00500 EOT
00501                     );
00502             } else {
00503                 $out->addWikiText( <<<EOT
00504 <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
00505 </div>
00506 EOT
00507                 );
00508             }
00509 
00510             // Add cannot animate thumbnail warning
00511             if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
00512                 // Include the extension so wiki admins can
00513                 // customize it on a per file-type basis
00514                 // (aka say things like use format X instead).
00515                 // additionally have a specific message for
00516                 // file-no-thumb-animation-gif
00517                 $ext = $this->displayImg->getExtension();
00518                 $noAnimMesg = wfMessageFallback(
00519                     'file-no-thumb-animation-' . $ext,
00520                     'file-no-thumb-animation'
00521                 )->plain();
00522 
00523                 $out->addWikiText( <<<EOT
00524 <div class="mw-noanimatethumb">{$noAnimMesg}</div>
00525 EOT
00526                 );
00527             }
00528 
00529             if ( !$this->displayImg->isLocal() ) {
00530                 $this->printSharedImageText();
00531             }
00532         } else {
00533             # Image does not exist
00534             if ( !$this->getID() ) {
00535                 # No article exists either
00536                 # Show deletion log to be consistent with normal articles
00537                 LogEventsList::showLogExtract(
00538                     $out,
00539                     array( 'delete', 'move' ),
00540                     $this->getTitle()->getPrefixedText(),
00541                     '',
00542                     array( 'lim' => 10,
00543                         'conds' => array( "log_action != 'revision'" ),
00544                         'showIfEmpty' => false,
00545                         'msgKey' => array( 'moveddeleted-notice' )
00546                     )
00547                 );
00548             }
00549 
00550             if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
00551                 // Only show an upload link if the user can upload
00552                 $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
00553                 $nofile = array(
00554                     'filepage-nofile-link',
00555                     $uploadTitle->getFullURL( array( 'wpDestFile' => $this->mPage->getFile()->getName() ) )
00556                 );
00557             } else {
00558                 $nofile = 'filepage-nofile';
00559             }
00560             // Note, if there is an image description page, but
00561             // no image, then this setRobotPolicy is overridden
00562             // by Article::View().
00563             $out->setRobotPolicy( 'noindex,nofollow' );
00564             $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
00565             if ( !$this->getID() && $wgSend404Code ) {
00566                 // If there is no image, no shared image, and no description page,
00567                 // output a 404, to be consistent with articles.
00568                 $request->response()->header( 'HTTP/1.1 404 Not Found' );
00569             }
00570         }
00571         $out->setFileVersion( $this->displayImg );
00572     }
00573 
00581     private function makeSizeLink( $params, $width, $height ) {
00582         $params['width'] = $width;
00583         $params['height'] = $height;
00584         $thumbnail = $this->displayImg->transform( $params );
00585         if ( $thumbnail && !$thumbnail->isError() ) {
00586             return Html::rawElement( 'a', array(
00587                 'href' => $thumbnail->getUrl(),
00588                 'class' => 'mw-thumbnail-link'
00589                 ), wfMessage( 'show-big-image-size' )->numParams(
00590                     $thumbnail->getWidth(), $thumbnail->getHeight()
00591                 )->parse() );
00592         } else {
00593             return '';
00594         }
00595     }
00596 
00600     protected function printSharedImageText() {
00601         $out = $this->getContext()->getOutput();
00602         $this->loadFile();
00603 
00604         $descUrl = $this->mPage->getFile()->getDescriptionUrl();
00605         $descText = $this->mPage->getFile()->getDescriptionText();
00606 
00607         /* Add canonical to head if there is no local page for this shared file */
00608         if ( $descUrl && $this->mPage->getID() == 0 ) {
00609             $out->setCanonicalUrl( $descUrl );
00610         }
00611 
00612         $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
00613         $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
00614 
00615         if ( $descUrl && $descText && wfMessage( 'sharedupload-desc-here' )->plain() !== '-' ) {
00616             $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
00617         } elseif ( $descUrl && wfMessage( 'sharedupload-desc-there' )->plain() !== '-' ) {
00618             $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
00619         } else {
00620             $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
00621         }
00622 
00623         if ( $descText ) {
00624             $this->mExtraDescription = $descText;
00625         }
00626     }
00627 
00628     public function getUploadUrl() {
00629         $this->loadFile();
00630         $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
00631         return $uploadTitle->getFullURL( array(
00632             'wpDestFile' => $this->mPage->getFile()->getName(),
00633             'wpForReUpload' => 1
00634         ) );
00635     }
00636 
00641     protected function uploadLinksBox() {
00642         global $wgEnableUploads;
00643 
00644         if ( !$wgEnableUploads ) {
00645             return;
00646         }
00647 
00648         $this->loadFile();
00649         if ( !$this->mPage->getFile()->isLocal() ) {
00650             return;
00651         }
00652 
00653         $out = $this->getContext()->getOutput();
00654         $out->addHTML( "<ul>\n" );
00655 
00656         # "Upload a new version of this file" link
00657         $canUpload = $this->getTitle()->userCan( 'upload', $this->getContext()->getUser() );
00658         if ( $canUpload && UploadBase::userCanReUpload( $this->getContext()->getUser(), $this->mPage->getFile()->name ) ) {
00659             $ulink = Linker::makeExternalLink( $this->getUploadUrl(), wfMessage( 'uploadnewversion-linktext' )->text() );
00660             $out->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
00661         } else {
00662             $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">" . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
00663         }
00664 
00665         $out->addHTML( "</ul>\n" );
00666     }
00667 
00668     protected function closeShowImage() { } # For overloading
00669 
00674     protected function imageHistory() {
00675         $this->loadFile();
00676         $out = $this->getContext()->getOutput();
00677         $pager = new ImageHistoryPseudoPager( $this );
00678         $out->addHTML( $pager->getBody() );
00679         $out->preventClickjacking( $pager->getPreventClickjacking() );
00680 
00681         $this->mPage->getFile()->resetHistory(); // free db resources
00682 
00683         # Exist check because we don't want to show this on pages where an image
00684         # doesn't exist along with the noimage message, that would suck. -ævar
00685         if ( $this->mPage->getFile()->exists() ) {
00686             $this->uploadLinksBox();
00687         }
00688     }
00689 
00695     protected function queryImageLinks( $target, $limit ) {
00696         $dbr = wfGetDB( DB_SLAVE );
00697 
00698         return $dbr->select(
00699             array( 'imagelinks', 'page' ),
00700             array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
00701             array( 'il_to' => $target, 'il_from = page_id' ),
00702             __METHOD__,
00703             array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', )
00704         );
00705     }
00706 
00707     protected function imageLinks() {
00708         $limit = 100;
00709 
00710         $out = $this->getContext()->getOutput();
00711         $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
00712         $rows = array();
00713         $redirects = array();
00714         foreach ( $res as $row ) {
00715             if ( $row->page_is_redirect ) {
00716                 $redirects[$row->page_title] = array();
00717             }
00718             $rows[] = $row;
00719         }
00720         $count = count( $rows );
00721 
00722         $hasMore = $count > $limit;
00723         if ( !$hasMore && count( $redirects ) ) {
00724             $res = $this->queryImageLinks( array_keys( $redirects ),
00725                 $limit - count( $rows ) + 1 );
00726             foreach ( $res as $row ) {
00727                 $redirects[$row->il_to][] = $row;
00728                 $count++;
00729             }
00730             $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
00731         }
00732 
00733         if ( $count == 0 ) {
00734             $out->wrapWikiMsg(
00735                 Html::rawElement( 'div',
00736                     array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
00737                 'nolinkstoimage'
00738             );
00739             return;
00740         }
00741 
00742         $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
00743         if ( !$hasMore ) {
00744             $out->addWikiMsg( 'linkstoimage', $count );
00745         } else {
00746             // More links than the limit. Add a link to [[Special:Whatlinkshere]]
00747             $out->addWikiMsg( 'linkstoimage-more',
00748                 $this->getContext()->getLanguage()->formatNum( $limit ),
00749                 $this->getTitle()->getPrefixedDBkey()
00750             );
00751         }
00752 
00753         $out->addHTML(
00754             Html::openElement( 'ul',
00755                 array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
00756         );
00757         $count = 0;
00758 
00759         // Sort the list by namespace:title
00760         usort( $rows, array( $this, 'compare' ) );
00761 
00762         // Create links for every element
00763         $currentCount = 0;
00764         foreach ( $rows as $element ) {
00765             $currentCount++;
00766             if ( $currentCount > $limit ) {
00767                 break;
00768             }
00769 
00770             $query = array();
00771             # Add a redirect=no to make redirect pages reachable
00772             if ( isset( $redirects[$element->page_title] ) ) {
00773                 $query['redirect'] = 'no';
00774             }
00775             $link = Linker::linkKnown(
00776                 Title::makeTitle( $element->page_namespace, $element->page_title ),
00777                 null, array(), $query
00778             );
00779             if ( !isset( $redirects[$element->page_title] ) ) {
00780                 # No redirects
00781                 $liContents = $link;
00782             } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
00783                 # Redirect without usages
00784                 $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams( $link, '' )->parse();
00785             } else {
00786                 # Redirect with usages
00787                 $li = '';
00788                 foreach ( $redirects[$element->page_title] as $row ) {
00789                     $currentCount++;
00790                     if ( $currentCount > $limit ) {
00791                         break;
00792                     }
00793 
00794                     $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
00795                     $li .= Html::rawElement(
00796                         'li',
00797                         array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
00798                         $link2
00799                         ) . "\n";
00800                 }
00801 
00802                 $ul = Html::rawElement(
00803                     'ul',
00804                     array( 'class' => 'mw-imagepage-redirectstofile' ),
00805                     $li
00806                     ) . "\n";
00807                 $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
00808                     $link, $ul )->parse();
00809             }
00810             $out->addHTML( Html::rawElement(
00811                     'li',
00812                     array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
00813                     $liContents
00814                 ) . "\n"
00815             );
00816 
00817         };
00818         $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
00819         $res->free();
00820 
00821         // Add a links to [[Special:Whatlinkshere]]
00822         if ( $count > $limit ) {
00823             $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
00824         }
00825         $out->addHTML( Html::closeElement( 'div' ) . "\n" );
00826     }
00827 
00828     protected function imageDupes() {
00829         $this->loadFile();
00830         $out = $this->getContext()->getOutput();
00831 
00832         $dupes = $this->mPage->getDuplicates();
00833         if ( count( $dupes ) == 0 ) {
00834             return;
00835         }
00836 
00837         $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
00838         $out->addWikiMsg( 'duplicatesoffile',
00839             $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
00840         );
00841         $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
00842 
00846         foreach ( $dupes as $file ) {
00847             $fromSrc = '';
00848             if ( $file->isLocal() ) {
00849                 $link = Linker::linkKnown( $file->getTitle() );
00850             } else {
00851                 $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
00852                     $file->getTitle()->getPrefixedText() );
00853                 $fromSrc = wfMessage( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text();
00854             }
00855             $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
00856         }
00857         $out->addHTML( "</ul></div>\n" );
00858     }
00859 
00863     public function delete() {
00864         $file = $this->mPage->getFile();
00865         if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
00866             // Standard article deletion
00867             parent::delete();
00868             return;
00869         }
00870 
00871         $deleter = new FileDeleteForm( $file );
00872         $deleter->execute();
00873     }
00874 
00880     function showError( $description ) {
00881         $out = $this->getContext()->getOutput();
00882         $out->setPageTitle( wfMessage( 'internalerror' ) );
00883         $out->setRobotPolicy( 'noindex,nofollow' );
00884         $out->setArticleRelated( false );
00885         $out->enableClientCache( false );
00886         $out->addWikiText( $description );
00887     }
00888 
00897     protected function compare( $a, $b ) {
00898         if ( $a->page_namespace == $b->page_namespace ) {
00899             return strcmp( $a->page_title, $b->page_title );
00900         } else {
00901             return $a->page_namespace - $b->page_namespace;
00902         }
00903     }
00904 
00913     public function getImageLimitsFromOption( $user, $optionName ) {
00914         global $wgImageLimits;
00915 
00916         $option = $user->getIntOption( $optionName );
00917         if ( !isset( $wgImageLimits[$option] ) ) {
00918             $option = User::getDefaultOption( $optionName );
00919         }
00920 
00921         // The user offset might still be incorrect, specially if
00922         // $wgImageLimits got changed (see bug #8858).
00923         if ( !isset( $wgImageLimits[$option] ) ) {
00924             // Default to the first offset in $wgImageLimits
00925             $option = 0;
00926         }
00927 
00928         return isset( $wgImageLimits[$option] )
00929             ? $wgImageLimits[$option]
00930             : array( 800, 600 ); // if nothing is set, fallback to a hardcoded default
00931     }
00932 }
00933 
00939 class ImageHistoryList extends ContextSource {
00940 
00944     protected $title;
00945 
00949     protected $img;
00950 
00954     protected $imagePage;
00955 
00959     protected $current;
00960 
00961     protected $repo, $showThumb;
00962     protected $preventClickjacking = false;
00963 
00967     public function __construct( $imagePage ) {
00968         global $wgShowArchiveThumbnails;
00969         $this->current = $imagePage->getFile();
00970         $this->img = $imagePage->getDisplayedFile();
00971         $this->title = $imagePage->getTitle();
00972         $this->imagePage = $imagePage;
00973         $this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
00974         $this->setContext( $imagePage->getContext() );
00975     }
00976 
00980     public function getImagePage() {
00981         return $this->imagePage;
00982     }
00983 
00987     public function getFile() {
00988         return $this->img;
00989     }
00990 
00995     public function beginImageHistoryList( $navLinks = '' ) {
00996         return Xml::element( 'h2', array( 'id' => 'filehistory' ), $this->msg( 'filehist' )->text() ) . "\n"
00997             . "<div id=\"mw-imagepage-section-filehistory\">\n"
00998             . $this->msg( 'filehist-help' )->parseAsBlock()
00999             . $navLinks . "\n"
01000             . Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
01001             . '<tr><td></td>'
01002             . ( $this->current->isLocal() && ( $this->getUser()->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
01003             . '<th>' . $this->msg( 'filehist-datetime' )->escaped() . '</th>'
01004             . ( $this->showThumb ? '<th>' . $this->msg( 'filehist-thumb' )->escaped() . '</th>' : '' )
01005             . '<th>' . $this->msg( 'filehist-dimensions' )->escaped() . '</th>'
01006             . '<th>' . $this->msg( 'filehist-user' )->escaped() . '</th>'
01007             . '<th>' . $this->msg( 'filehist-comment' )->escaped() . '</th>'
01008             . "</tr>\n";
01009     }
01010 
01015     public function endImageHistoryList( $navLinks = '' ) {
01016         return "</table>\n$navLinks\n</div>\n";
01017     }
01018 
01024     public function imageHistoryLine( $iscur, $file ) {
01025         global $wgContLang;
01026 
01027         $user = $this->getUser();
01028         $lang = $this->getLanguage();
01029         $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
01030         $img = $iscur ? $file->getName() : $file->getArchiveName();
01031         $userId = $file->getUser( 'id' );
01032         $userText = $file->getUser( 'text' );
01033         $description = $file->getDescription( File::FOR_THIS_USER, $user );
01034 
01035         $local = $this->current->isLocal();
01036         $row = $selected = '';
01037 
01038         // Deletion link
01039         if ( $local && ( $user->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
01040             $row .= '<td>';
01041             # Link to remove from history
01042             if ( $user->isAllowed( 'delete' ) ) {
01043                 $q = array( 'action' => 'delete' );
01044                 if ( !$iscur ) {
01045                     $q['oldimage'] = $img;
01046                 }
01047                 $row .= Linker::linkKnown(
01048                     $this->title,
01049                     $this->msg( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' )->escaped(),
01050                     array(), $q
01051                 );
01052             }
01053             # Link to hide content. Don't show useless link to people who cannot hide revisions.
01054             $canHide = $user->isAllowed( 'deleterevision' );
01055             if ( $canHide || ( $user->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
01056                 if ( $user->isAllowed( 'delete' ) ) {
01057                     $row .= '<br />';
01058                 }
01059                 // If file is top revision or locked from this user, don't link
01060                 if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
01061                     $del = Linker::revDeleteLinkDisabled( $canHide );
01062                 } else {
01063                     list( $ts, ) = explode( '!', $img, 2 );
01064                     $query = array(
01065                         'type' => 'oldimage',
01066                         'target' => $this->title->getPrefixedText(),
01067                         'ids' => $ts,
01068                     );
01069                     $del = Linker::revDeleteLink( $query,
01070                         $file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
01071                 }
01072                 $row .= $del;
01073             }
01074             $row .= '</td>';
01075         }
01076 
01077         // Reversion link/current indicator
01078         $row .= '<td>';
01079         if ( $iscur ) {
01080             $row .= $this->msg( 'filehist-current' )->escaped();
01081         } elseif ( $local && $this->title->quickUserCan( 'edit', $user )
01082             && $this->title->quickUserCan( 'upload', $user )
01083         ) {
01084             if ( $file->isDeleted( File::DELETED_FILE ) ) {
01085                 $row .= $this->msg( 'filehist-revert' )->escaped();
01086             } else {
01087                 $row .= Linker::linkKnown(
01088                     $this->title,
01089                     $this->msg( 'filehist-revert' )->escaped(),
01090                     array(),
01091                     array(
01092                         'action' => 'revert',
01093                         'oldimage' => $img,
01094                         'wpEditToken' => $user->getEditToken( $img )
01095                     )
01096                 );
01097             }
01098         }
01099         $row .= '</td>';
01100 
01101         // Date/time and image link
01102         if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
01103             $selected = "class='filehistory-selected'";
01104         }
01105         $row .= "<td $selected style='white-space: nowrap;'>";
01106         if ( !$file->userCan( File::DELETED_FILE, $user ) ) {
01107             # Don't link to unviewable files
01108             $row .= '<span class="history-deleted">' . $lang->userTimeAndDate( $timestamp, $user ) . '</span>';
01109         } elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
01110             if ( $local ) {
01111                 $this->preventClickjacking();
01112                 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
01113                 # Make a link to review the image
01114                 $url = Linker::linkKnown(
01115                     $revdel,
01116                     $lang->userTimeAndDate( $timestamp, $user ),
01117                     array(),
01118                     array(
01119                         'target' => $this->title->getPrefixedText(),
01120                         'file' => $img,
01121                         'token' => $user->getEditToken( $img )
01122                     )
01123                 );
01124             } else {
01125                 $url = $lang->userTimeAndDate( $timestamp, $user );
01126             }
01127             $row .= '<span class="history-deleted">' . $url . '</span>';
01128         } else {
01129             $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
01130             $row .= Xml::element( 'a', array( 'href' => $url ), $lang->userTimeAndDate( $timestamp, $user ) );
01131         }
01132         $row .= "</td>";
01133 
01134         // Thumbnail
01135         if ( $this->showThumb ) {
01136             $row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
01137         }
01138 
01139         // Image dimensions + size
01140         $row .= '<td>';
01141         $row .= htmlspecialchars( $file->getDimensionsString() );
01142         $row .= $this->msg( 'word-separator' )->plain();
01143         $row .= '<span style="white-space: nowrap;">';
01144         $row .= $this->msg( 'parentheses' )->rawParams( Linker::formatSize( $file->getSize() ) )->plain();
01145         $row .= '</span>';
01146         $row .= '</td>';
01147 
01148         // Uploading user
01149         $row .= '<td>';
01150         // Hide deleted usernames
01151         if ( $file->isDeleted( File::DELETED_USER ) ) {
01152             $row .= '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
01153         } else {
01154             if ( $local ) {
01155                 $row .= Linker::userLink( $userId, $userText );
01156                 $row .= $this->msg( 'word-separator' )->plain();
01157                 $row .= '<span style="white-space: nowrap;">';
01158                 $row .= Linker::userToolLinks( $userId, $userText );
01159                 $row .= '</span>';
01160             } else {
01161                 $row .= htmlspecialchars( $userText );
01162             }
01163         }
01164         $row .= '</td>';
01165 
01166         // Don't show deleted descriptions
01167         if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
01168             $row .= '<td><span class="history-deleted">' . $this->msg( 'rev-deleted-comment' )->escaped() . '</span></td>';
01169         } else {
01170             $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment( $description, $this->title ) . '</td>';
01171         }
01172 
01173         $rowClass = null;
01174         wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
01175         $classAttr = $rowClass ? " class='$rowClass'" : '';
01176 
01177         return "<tr{$classAttr}>{$row}</tr>\n";
01178     }
01179 
01184     protected function getThumbForLine( $file ) {
01185         $lang = $this->getLanguage();
01186         $user = $this->getUser();
01187         if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE, $user )
01188             && !$file->isDeleted( File::DELETED_FILE ) )
01189         {
01190             $params = array(
01191                 'width' => '120',
01192                 'height' => '120',
01193             );
01194             $timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
01195 
01196             $thumbnail = $file->transform( $params );
01197             $options = array(
01198                 'alt' => $this->msg( 'filehist-thumbtext',
01199                     $lang->userTimeAndDate( $timestamp, $user ),
01200                     $lang->userDate( $timestamp, $user ),
01201                     $lang->userTime( $timestamp, $user ) )->text(),
01202                 'file-link' => true,
01203             );
01204 
01205             if ( !$thumbnail ) {
01206                 return $this->msg( 'filehist-nothumb' )->escaped();
01207             }
01208 
01209             return $thumbnail->toHtml( $options );
01210         } else {
01211             return $this->msg( 'filehist-nothumb' )->escaped();
01212         }
01213     }
01214 
01218     protected function preventClickjacking( $enable = true ) {
01219         $this->preventClickjacking = $enable;
01220     }
01221 
01225     public function getPreventClickjacking() {
01226         return $this->preventClickjacking;
01227     }
01228 }
01229 
01230 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
01231     protected $preventClickjacking = false;
01232 
01236     protected $mImg;
01237 
01241     protected $mTitle;
01242 
01246     function __construct( $imagePage ) {
01247         parent::__construct( $imagePage->getContext() );
01248         $this->mImagePage = $imagePage;
01249         $this->mTitle = clone ( $imagePage->getTitle() );
01250         $this->mTitle->setFragment( '#filehistory' );
01251         $this->mImg = null;
01252         $this->mHist = array();
01253         $this->mRange = array( 0, 0 ); // display range
01254     }
01255 
01259     function getTitle() {
01260         return $this->mTitle;
01261     }
01262 
01263     function getQueryInfo() {
01264         return false;
01265     }
01266 
01270     function getIndexField() {
01271         return '';
01272     }
01273 
01278     function formatRow( $row ) {
01279         return '';
01280     }
01281 
01285     function getBody() {
01286         $s = '';
01287         $this->doQuery();
01288         if ( count( $this->mHist ) ) {
01289             $list = new ImageHistoryList( $this->mImagePage );
01290             # Generate prev/next links
01291             $navLink = $this->getNavigationBar();
01292             $s = $list->beginImageHistoryList( $navLink );
01293             // Skip rows there just for paging links
01294             for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
01295                 $file = $this->mHist[$i];
01296                 $s .= $list->imageHistoryLine( !$file->isOld(), $file );
01297             }
01298             $s .= $list->endImageHistoryList( $navLink );
01299 
01300             if ( $list->getPreventClickjacking() ) {
01301                 $this->preventClickjacking();
01302             }
01303         }
01304         return $s;
01305     }
01306 
01307     function doQuery() {
01308         if ( $this->mQueryDone ) {
01309             return;
01310         }
01311         $this->mImg = $this->mImagePage->getFile(); // ensure loading
01312         if ( !$this->mImg->exists() ) {
01313             return;
01314         }
01315         $queryLimit = $this->mLimit + 1; // limit plus extra row
01316         if ( $this->mIsBackwards ) {
01317             // Fetch the file history
01318             $this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
01319             // The current rev may not meet the offset/limit
01320             $numRows = count( $this->mHist );
01321             if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
01322                 $this->mHist = array_merge( array( $this->mImg ), $this->mHist );
01323             }
01324         } else {
01325             // The current rev may not meet the offset
01326             if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
01327                 $this->mHist[] = $this->mImg;
01328             }
01329             // Old image versions (fetch extra row for nav links)
01330             $oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
01331             // Fetch the file history
01332             $this->mHist = array_merge( $this->mHist,
01333                 $this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
01334         }
01335         $numRows = count( $this->mHist ); // Total number of query results
01336         if ( $numRows ) {
01337             # Index value of top item in the list
01338             $firstIndex = $this->mIsBackwards ?
01339                 $this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
01340             # Discard the extra result row if there is one
01341             if ( $numRows > $this->mLimit && $numRows > 1 ) {
01342                 if ( $this->mIsBackwards ) {
01343                     # Index value of item past the index
01344                     $this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
01345                     # Index value of bottom item in the list
01346                     $lastIndex = $this->mHist[1]->getTimestamp();
01347                     # Display range
01348                     $this->mRange = array( 1, $numRows - 1 );
01349                 } else {
01350                     # Index value of item past the index
01351                     $this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
01352                     # Index value of bottom item in the list
01353                     $lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
01354                     # Display range
01355                     $this->mRange = array( 0, $numRows - 2 );
01356                 }
01357             } else {
01358                 # Setting indexes to an empty string means that they will be
01359                 # omitted if they would otherwise appear in URLs. It just so
01360                 # happens that this  is the right thing to do in the standard
01361                 # UI, in all the relevant cases.
01362                 $this->mPastTheEndIndex = '';
01363                 # Index value of bottom item in the list
01364                 $lastIndex = $this->mIsBackwards ?
01365                     $this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
01366                 # Display range
01367                 $this->mRange = array( 0, $numRows - 1 );
01368             }
01369         } else {
01370             $firstIndex = '';
01371             $lastIndex = '';
01372             $this->mPastTheEndIndex = '';
01373         }
01374         if ( $this->mIsBackwards ) {
01375             $this->mIsFirst = ( $numRows < $queryLimit );
01376             $this->mIsLast = ( $this->mOffset == '' );
01377             $this->mLastShown = $firstIndex;
01378             $this->mFirstShown = $lastIndex;
01379         } else {
01380             $this->mIsFirst = ( $this->mOffset == '' );
01381             $this->mIsLast = ( $numRows < $queryLimit );
01382             $this->mLastShown = $lastIndex;
01383             $this->mFirstShown = $firstIndex;
01384         }
01385         $this->mQueryDone = true;
01386     }
01387 
01391     protected function preventClickjacking( $enable = true ) {
01392         $this->preventClickjacking = $enable;
01393     }
01394 
01398     public function getPreventClickjacking() {
01399         return $this->preventClickjacking;
01400     }
01401 
01402 }