2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Special handling for image description pages
|
2007-04-24 06:53:31 +00:00
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-09-01 09:59:53 +00:00
|
|
|
class ImagePage extends Article {
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
2011-04-18 19:03:14 +00:00
|
|
|
private $img;
|
|
|
|
|
private $displayImg;
|
|
|
|
|
private $repo;
|
|
|
|
|
private $fileLoaded;
|
2011-03-05 17:01:33 +00:00
|
|
|
|
2005-07-04 02:59:23 +00:00
|
|
|
var $mExtraDescription = false;
|
2008-05-15 19:17:21 +00:00
|
|
|
var $dupes;
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2008-05-23 09:03:49 +00:00
|
|
|
function __construct( $title ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
parent::__construct( $title );
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->dupes = null;
|
|
|
|
|
$this->repo = null;
|
|
|
|
|
}
|
2010-11-15 15:49:52 +00:00
|
|
|
|
|
|
|
|
/**
|
2011-04-02 14:50:31 +00:00
|
|
|
* @param $file File:
|
2010-11-15 15:49:52 +00:00
|
|
|
* @return void
|
|
|
|
|
*/
|
2008-12-15 23:51:28 +00:00
|
|
|
public function setFile( $file ) {
|
|
|
|
|
$this->displayImg = $file;
|
|
|
|
|
$this->img = $file;
|
|
|
|
|
$this->fileLoaded = true;
|
|
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
protected function loadFile() {
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->fileLoaded ) {
|
2008-05-20 03:26:59 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->fileLoaded = true;
|
|
|
|
|
|
|
|
|
|
$this->displayImg = $this->img = false;
|
|
|
|
|
wfRunHooks( 'ImagePageFindFile', array( $this, &$this->img, &$this->displayImg ) );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->img ) {
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->img = wfFindFile( $this->mTitle );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->img ) {
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->img = wfLocalFile( $this->mTitle );
|
2008-05-21 22:20:07 +00:00
|
|
|
}
|
2008-05-23 09:03:49 +00:00
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->displayImg ) {
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->displayImg = $this->img;
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
2008-05-15 19:17:21 +00:00
|
|
|
$this->repo = $this->img->getRepo();
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
/**
|
|
|
|
|
* Handler for action=render
|
|
|
|
|
* Include body text only; none of the image extras
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function render() {
|
2005-07-03 04:56:53 +00:00
|
|
|
global $wgOut;
|
2006-01-13 00:29:20 +00:00
|
|
|
$wgOut->setArticleBodyOnly( true );
|
2008-04-09 22:42:29 +00:00
|
|
|
parent::view();
|
2005-07-03 04:56:53 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function view() {
|
2007-01-17 05:01:54 +00:00
|
|
|
global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
|
2010-06-09 21:09:13 +00:00
|
|
|
|
|
|
|
|
$diff = $wgRequest->getVal( 'diff' );
|
|
|
|
|
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
|
|
|
|
|
|
|
|
|
|
if ( $this->mTitle->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) {
|
2010-07-25 20:52:30 +00:00
|
|
|
return parent::view();
|
2010-06-09 21:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mTitle->getNamespace() == NS_FILE && $this->img->getRedirected() ) {
|
2010-06-09 21:09:13 +00:00
|
|
|
if ( $this->mTitle->getDBkey() == $this->img->getName() || isset( $diff ) ) {
|
2008-05-14 11:52:59 +00:00
|
|
|
// mTitle is the same as the redirect target so ask Article
|
|
|
|
|
// to perform the redirect for us.
|
2010-06-09 21:09:13 +00:00
|
|
|
$wgRequest->setVal( 'diffonly', 'true' );
|
2010-07-25 20:52:30 +00:00
|
|
|
return parent::view();
|
2008-05-11 19:49:08 +00:00
|
|
|
} else {
|
2008-05-14 11:52:59 +00:00
|
|
|
// mTitle is not the same as the redirect target so it is
|
|
|
|
|
// probably the redirect page itself. Fake the redirect symbol
|
2008-05-11 19:49:08 +00:00
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
2008-12-01 17:14:30 +00:00
|
|
|
$wgOut->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->img->getName() ),
|
2008-08-02 02:39:09 +00:00
|
|
|
/* $appendSubtitle */ true, /* $forceKnown */ true ) );
|
2008-05-11 19:49:08 +00:00
|
|
|
$this->viewUpdates();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-08 20:55:13 +00:00
|
|
|
|
2009-09-24 20:46:31 +00:00
|
|
|
$this->showRedirectedFromHeader();
|
2005-05-05 02:39:21 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $wgShowEXIF && $this->displayImg->exists() ) {
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
|
2008-05-21 21:33:58 +00:00
|
|
|
$formattedMetadata = $this->displayImg->formatMetadata();
|
2007-07-28 01:15:35 +00:00
|
|
|
$showmeta = $formattedMetadata !== false;
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
$showmeta = false;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$diff && $this->displayImg->exists() ) {
|
2010-03-20 22:58:48 +00:00
|
|
|
$wgOut->addHTML( $this->showTOC( $showmeta ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$diff ) {
|
2009-01-02 19:11:34 +00:00
|
|
|
$this->openShowImage();
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-04 02:59:23 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
# No need to display noarticletext, we use our own message, output in openShowImage()
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->getID() ) {
|
2010-07-25 20:52:30 +00:00
|
|
|
parent::view();
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
# Just need to set the right headers
|
|
|
|
|
$wgOut->setArticleFlag( true );
|
|
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
|
|
|
|
$this->viewUpdates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show shared description, if needed
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mExtraDescription ) {
|
2011-01-14 10:51:05 +00:00
|
|
|
$fol = wfMessage( 'shareddescriptionfollows' );
|
|
|
|
|
if ( !$fol->isDisabled() ) {
|
|
|
|
|
$wgOut->addWikiText( $fol->plain() );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
2009-03-28 16:41:00 +00:00
|
|
|
$wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->closeShowImage();
|
|
|
|
|
$this->imageHistory();
|
2008-05-14 15:11:48 +00:00
|
|
|
// TODO: Cleanup the following
|
2010-03-20 22:58:48 +00:00
|
|
|
|
2008-08-08 21:31:38 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2',
|
|
|
|
|
array( 'id' => 'filelinks' ),
|
2008-05-15 19:17:21 +00:00
|
|
|
wfMsg( 'imagelinks' ) ) . "\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
$this->imageDupes();
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: For some freaky reason, we can't redirect to foreign images.
|
2009-02-25 22:18:44 +00:00
|
|
|
# Yet we return metadata about the target. Definitely an issue in the FileRepo
|
2008-05-15 19:17:21 +00:00
|
|
|
$this->imageLinks();
|
2009-11-07 09:31:16 +00:00
|
|
|
|
|
|
|
|
# Allow extensions to add something after the image links
|
|
|
|
|
$html = '';
|
|
|
|
|
wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $html ) {
|
2009-11-07 09:31:16 +00:00
|
|
|
$wgOut->addHTML( $html );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2007-01-17 05:01:54 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $showmeta ) {
|
2009-03-28 16:41:00 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" );
|
2007-07-28 01:15:35 +00:00
|
|
|
$wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
|
2011-04-16 11:54:43 +00:00
|
|
|
$wgOut->addModules( array( 'mediawiki.action.view.metadata' ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2010-07-02 19:54:46 +00:00
|
|
|
|
|
|
|
|
$css = $this->repo->getDescriptionStylesheetUrl();
|
|
|
|
|
if ( $css ) {
|
|
|
|
|
$wgOut->addStyle( $css );
|
|
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2008-05-08 20:55:13 +00:00
|
|
|
|
|
|
|
|
public function getRedirectTarget() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->img->isLocal() ) {
|
2008-05-08 20:55:13 +00:00
|
|
|
return parent::getRedirectTarget();
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-05-08 20:55:13 +00:00
|
|
|
// Foreign image page
|
|
|
|
|
$from = $this->img->getRedirected();
|
2008-05-10 11:12:53 +00:00
|
|
|
$to = $this->img->getName();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $from == $to ) {
|
|
|
|
|
return null;
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-12-01 17:14:30 +00:00
|
|
|
return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to );
|
2008-05-08 20:55:13 +00:00
|
|
|
}
|
2011-03-05 17:01:33 +00:00
|
|
|
|
2008-05-08 21:25:12 +00:00
|
|
|
public function followRedirect() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->img->isLocal() ) {
|
2008-05-08 21:25:12 +00:00
|
|
|
return parent::followRedirect();
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-05-08 21:25:12 +00:00
|
|
|
$from = $this->img->getRedirected();
|
2008-05-10 11:12:53 +00:00
|
|
|
$to = $this->img->getName();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $from == $to ) {
|
|
|
|
|
return false;
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
return Title::makeTitle( NS_FILE, $to );
|
2008-05-08 21:25:12 +00:00
|
|
|
}
|
2011-03-05 17:01:33 +00:00
|
|
|
|
2008-05-09 19:48:32 +00:00
|
|
|
public function isRedirect( $text = false ) {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $this->img->isLocal() ) {
|
2008-05-09 19:48:32 +00:00
|
|
|
return parent::isRedirect( $text );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2008-05-09 10:42:49 +00:00
|
|
|
|
|
|
|
|
return (bool)$this->img->getRedirected();
|
|
|
|
|
}
|
2008-05-10 11:12:53 +00:00
|
|
|
|
|
|
|
|
public function isLocal() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2008-05-10 11:12:53 +00:00
|
|
|
return $this->img->isLocal();
|
|
|
|
|
}
|
2008-05-10 14:19:25 +00:00
|
|
|
|
|
|
|
|
public function getFile() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2008-05-10 14:19:25 +00:00
|
|
|
return $this->img;
|
|
|
|
|
}
|
2008-05-15 19:17:21 +00:00
|
|
|
|
2008-05-21 21:33:58 +00:00
|
|
|
public function getDisplayedFile() {
|
|
|
|
|
$this->loadFile();
|
|
|
|
|
return $this->displayImg;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-15 19:17:21 +00:00
|
|
|
public function getDuplicates() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !is_null( $this->dupes ) ) {
|
2008-05-20 03:26:59 +00:00
|
|
|
return $this->dupes;
|
|
|
|
|
}
|
2011-04-02 14:50:31 +00:00
|
|
|
$hash = $this->img->getSha1();
|
|
|
|
|
if ( !( $hash ) ) {
|
2008-05-15 19:17:21 +00:00
|
|
|
return $this->dupes = array();
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-05-15 19:17:21 +00:00
|
|
|
$dupes = RepoGroup::singleton()->findBySha1( $hash );
|
|
|
|
|
// Remove duplicates with self and non matching file sizes
|
2010-03-20 22:58:48 +00:00
|
|
|
$self = $this->img->getRepoName() . ':' . $this->img->getName();
|
2008-05-15 19:17:21 +00:00
|
|
|
$size = $this->img->getSize();
|
|
|
|
|
foreach ( $dupes as $index => $file ) {
|
2010-03-20 22:58:48 +00:00
|
|
|
$key = $file->getRepoName() . ':' . $file->getName();
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $key == $self ) {
|
2008-05-15 19:17:21 +00:00
|
|
|
unset( $dupes[$index] );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
|
|
|
|
if ( $file->getSize() != $size ) {
|
2008-05-15 19:17:21 +00:00
|
|
|
unset( $dupes[$index] );
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2008-05-15 19:17:21 +00:00
|
|
|
}
|
|
|
|
|
return $this->dupes = $dupes;
|
|
|
|
|
}
|
2005-04-29 19:45:49 +00:00
|
|
|
|
2005-05-05 02:39:21 +00:00
|
|
|
/**
|
|
|
|
|
* Create the TOC
|
|
|
|
|
*
|
2010-07-02 21:22:38 +00:00
|
|
|
* @param $metadata Boolean: whether or not to show the metadata link
|
|
|
|
|
* @return String
|
2005-05-05 02:39:21 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function showTOC( $metadata ) {
|
2009-11-08 11:09:20 +00:00
|
|
|
$r = array(
|
2011-04-02 14:50:31 +00:00
|
|
|
'<li><a href="#file">' . wfMsgHtml( 'file-anchor-link' ) . '</a></li>',
|
|
|
|
|
'<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>',
|
|
|
|
|
'<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>',
|
2009-11-08 11:09:20 +00:00
|
|
|
);
|
|
|
|
|
if ( $metadata ) {
|
|
|
|
|
$r[] = '<li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wfRunHooks( 'ImagePageShowTOC', array( $this, &$r ) );
|
|
|
|
|
|
|
|
|
|
return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
|
2005-04-29 19:45:49 +00:00
|
|
|
}
|
2005-04-21 11:28:56 +00:00
|
|
|
|
2005-05-05 02:39:21 +00:00
|
|
|
/**
|
|
|
|
|
* Make a table with metadata to be shown in the output page.
|
|
|
|
|
*
|
2011-05-17 22:03:20 +00:00
|
|
|
* @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
*
|
2010-07-02 21:22:38 +00:00
|
|
|
* @param $metadata Array: the array containing the EXIF data
|
2011-04-16 01:23:15 +00:00
|
|
|
* @return String The metadata table. This is treated as Wikitext (!)
|
2005-05-05 02:39:21 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function makeMetadataTable( $metadata ) {
|
2009-05-25 14:02:54 +00:00
|
|
|
$r = "<div class=\"mw-imagepage-section-metadata\">";
|
|
|
|
|
$r .= wfMsgNoTrans( 'metadata-help' );
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
|
2007-07-28 01:15:35 +00:00
|
|
|
foreach ( $metadata as $type => $stuff ) {
|
2007-08-21 03:57:54 +00:00
|
|
|
foreach ( $stuff as $v ) {
|
2011-05-17 22:03:20 +00:00
|
|
|
# @todo FIXME: Why is this using escapeId for a class?!
|
2007-07-28 01:15:35 +00:00
|
|
|
$class = Sanitizer::escapeId( $v['id'] );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $type == 'collapsed' ) {
|
2007-07-28 01:15:35 +00:00
|
|
|
$class .= ' collapsable';
|
|
|
|
|
}
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "<tr class=\"$class\">\n";
|
|
|
|
|
$r .= "<th>{$v['name']}</th>\n";
|
|
|
|
|
$r .= "<td>{$v['value']}</td>\n</tr>";
|
2005-11-28 23:56:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-03-28 16:41:00 +00:00
|
|
|
$r .= "</table>\n</div>\n";
|
2005-11-28 23:56:35 +00:00
|
|
|
return $r;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-05-20 22:41:17 +00:00
|
|
|
/**
|
|
|
|
|
* Overloading Article's getContent method.
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
2006-01-13 00:29:20 +00:00
|
|
|
* Omit noarticletext if sharedupload; text will be fetched from the
|
|
|
|
|
* shared upload server if possible.
|
2005-05-20 22:41:17 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getContent() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
|
2005-05-20 22:41:17 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2010-11-28 16:05:41 +00:00
|
|
|
return parent::getContent();
|
2005-05-20 22:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function openShowImage() {
|
2009-05-24 20:45:31 +00:00
|
|
|
global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
|
|
|
|
|
$wgLang, $wgContLang, $wgEnableUploads;
|
2005-12-04 18:27:59 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
$sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
|
|
|
|
|
if ( !isset( $wgImageLimits[$sizeSel] ) ) {
|
2004-12-21 03:21:41 +00:00
|
|
|
$sizeSel = User::getDefaultOption( 'imagesize' );
|
2007-02-02 16:22:22 +00:00
|
|
|
|
|
|
|
|
// The user offset might still be incorrect, specially if
|
|
|
|
|
// $wgImageLimits got changed (see bug #8858).
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !isset( $wgImageLimits[$sizeSel] ) ) {
|
2007-02-02 16:22:22 +00:00
|
|
|
// Default to the first offset in $wgImageLimits
|
|
|
|
|
$sizeSel = 0;
|
|
|
|
|
}
|
2004-09-10 00:53:31 +00:00
|
|
|
}
|
2004-12-21 03:21:41 +00:00
|
|
|
$max = $wgImageLimits[$sizeSel];
|
|
|
|
|
$maxWidth = $max[0];
|
|
|
|
|
$maxHeight = $max[1];
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2007-10-30 09:40:35 +00:00
|
|
|
$dirmark = $wgContLang->getDirMark();
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->displayImg->exists() ) {
|
2005-05-21 07:46:17 +00:00
|
|
|
# image
|
2006-08-13 17:34:48 +00:00
|
|
|
$page = $wgRequest->getIntOrNull( 'page' );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( is_null( $page ) ) {
|
2007-04-20 12:31:36 +00:00
|
|
|
$params = array();
|
2006-08-13 17:34:48 +00:00
|
|
|
$page = 1;
|
2007-04-20 12:31:36 +00:00
|
|
|
} else {
|
|
|
|
|
$params = array( 'page' => $page );
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2010-07-19 14:35:20 +00:00
|
|
|
$width_orig = $this->displayImg->getWidth( $page );
|
2007-02-27 18:27:11 +00:00
|
|
|
$width = $width_orig;
|
2010-07-19 14:35:20 +00:00
|
|
|
$height_orig = $this->displayImg->getHeight( $page );
|
2007-02-27 18:27:11 +00:00
|
|
|
$height = $height_orig;
|
2010-10-14 20:53:04 +00:00
|
|
|
|
2011-02-02 14:07:08 +00:00
|
|
|
$longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2009-12-04 11:33:50 +00:00
|
|
|
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
|
2007-05-16 19:52:22 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->displayImg->allowInlineDisplay() ) {
|
2004-01-16 18:11:47 +00:00
|
|
|
# image
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-04-29 19:45:49 +00:00
|
|
|
# "Download high res version" link below the image
|
2011-04-02 14:50:31 +00:00
|
|
|
# $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->displayImg->getSize() ), $mime );
|
2005-12-04 08:52:01 +00:00
|
|
|
# We'll show a thumbnail of this image
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $width > $maxWidth || $height > $maxHeight ) {
|
2005-12-04 08:52:01 +00:00
|
|
|
# Calculate the thumbnail size.
|
|
|
|
|
# First case, the limiting factor is the width, not the height.
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $width / $height >= $maxWidth / $maxHeight ) {
|
|
|
|
|
$height = round( $height * $maxWidth / $width );
|
2005-12-04 08:52:01 +00:00
|
|
|
$width = $maxWidth;
|
|
|
|
|
# Note that $height <= $maxHeight now.
|
|
|
|
|
} else {
|
2010-03-20 22:58:48 +00:00
|
|
|
$newwidth = floor( $width * $maxHeight / $height );
|
2005-12-04 08:52:01 +00:00
|
|
|
$height = round( $height * $newwidth / $width );
|
|
|
|
|
$width = $newwidth;
|
|
|
|
|
# Note that $height <= $maxHeight now, but might not be identical
|
|
|
|
|
# because of rounding.
|
|
|
|
|
}
|
2007-04-30 17:41:12 +00:00
|
|
|
$msgbig = wfMsgHtml( 'show-big-image' );
|
2011-03-12 22:49:31 +00:00
|
|
|
$otherSizes = array();
|
|
|
|
|
foreach ( $wgImageLimits as $size ) {
|
|
|
|
|
if ( $size[0] < $width_orig && $size[1] < $height_orig &&
|
|
|
|
|
$size[0] != $width && $size[1] != $height ) {
|
|
|
|
|
$otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$msgsmall = wfMessage( 'show-big-image-preview' )->
|
|
|
|
|
rawParams( $this->makeSizeLink( $params, $width, $height ) )->
|
|
|
|
|
parse() . ' ' .
|
|
|
|
|
wfMessage( 'show-big-image-other' )->
|
|
|
|
|
rawParams( $wgLang->pipeList( $otherSizes ) )->parse();
|
2007-04-27 22:04:01 +00:00
|
|
|
} else {
|
|
|
|
|
# Image is small enough to show full size on image page
|
2007-04-30 17:41:12 +00:00
|
|
|
$msgsmall = wfMsgExt( 'file-nohires', array( 'parseinline' ) );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2007-04-27 22:04:01 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
$params['width'] = $width;
|
2011-03-12 22:49:31 +00:00
|
|
|
$params['height'] = $height;
|
2008-05-21 21:33:58 +00:00
|
|
|
$thumbnail = $this->displayImg->transform( $params );
|
2005-12-04 08:52:01 +00:00
|
|
|
|
2010-10-27 01:50:07 +00:00
|
|
|
$showLink = true;
|
2011-04-02 14:50:31 +00:00
|
|
|
$anchorclose = '<br />' . $msgsmall;
|
2006-08-13 17:34:48 +00:00
|
|
|
|
2009-12-04 11:33:50 +00:00
|
|
|
$isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $isMulti ) {
|
2006-08-13 17:34:48 +00:00
|
|
|
$wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $thumbnail ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$options = array(
|
2008-05-21 21:33:58 +00:00
|
|
|
'alt' => $this->displayImg->getTitle()->getPrefixedText(),
|
2007-08-31 02:51:23 +00:00
|
|
|
'file-link' => true,
|
|
|
|
|
);
|
2008-04-14 07:45:50 +00:00
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file">' .
|
2007-08-31 02:51:23 +00:00
|
|
|
$thumbnail->toHtml( $options ) .
|
2009-03-28 16:41:00 +00:00
|
|
|
$anchorclose . "</div>\n" );
|
2007-04-20 12:31:36 +00:00
|
|
|
}
|
2006-08-13 17:34:48 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $isMulti ) {
|
2008-05-21 21:33:58 +00:00
|
|
|
$count = $this->displayImg->pageCount();
|
2007-01-26 12:00:04 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $page > 1 ) {
|
2007-01-26 12:00:04 +00:00
|
|
|
$label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
|
2009-06-06 22:42:48 +00:00
|
|
|
$link = $sk->link(
|
|
|
|
|
$this->mTitle,
|
|
|
|
|
$label,
|
|
|
|
|
array(),
|
|
|
|
|
array( 'page' => $page - 1 ),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2008-05-21 21:33:58 +00:00
|
|
|
$thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none',
|
2007-04-20 12:31:36 +00:00
|
|
|
array( 'page' => $page - 1 ) );
|
2007-01-26 12:00:04 +00:00
|
|
|
} else {
|
|
|
|
|
$thumb1 = '';
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $page < $count ) {
|
2007-01-26 12:00:04 +00:00
|
|
|
$label = wfMsg( 'imgmultipagenext' );
|
2009-06-06 22:42:48 +00:00
|
|
|
$link = $sk->link(
|
|
|
|
|
$this->mTitle,
|
|
|
|
|
$label,
|
|
|
|
|
array(),
|
|
|
|
|
array( 'page' => $page + 1 ),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2008-05-21 21:33:58 +00:00
|
|
|
$thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->displayImg, $link, $label, 'none',
|
2007-04-20 12:31:36 +00:00
|
|
|
array( 'page' => $page + 1 ) );
|
2007-01-26 12:00:04 +00:00
|
|
|
} else {
|
|
|
|
|
$thumb2 = '';
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2007-01-26 12:00:04 +00:00
|
|
|
|
2007-01-26 12:10:06 +00:00
|
|
|
global $wgScript;
|
2008-05-10 11:56:02 +00:00
|
|
|
|
|
|
|
|
$formParams = array(
|
|
|
|
|
'name' => 'pageselector',
|
|
|
|
|
'action' => $wgScript,
|
|
|
|
|
'onchange' => 'document.pageselector.submit();',
|
|
|
|
|
);
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
for ( $i = 1; $i <= $count; $i++ ) {
|
|
|
|
|
$options[] = Xml::option( $wgLang->formatNum( $i ), $i, $i == $page );
|
2007-01-26 12:00:04 +00:00
|
|
|
}
|
2008-05-10 11:56:02 +00:00
|
|
|
$select = Xml::tags( 'select',
|
|
|
|
|
array( 'id' => 'pageselector', 'name' => 'page' ),
|
|
|
|
|
implode( "\n", $options ) );
|
|
|
|
|
|
|
|
|
|
$wgOut->addHTML(
|
|
|
|
|
'</td><td><div class="multipageimagenavbox">' .
|
|
|
|
|
Xml::openElement( 'form', $formParams ) .
|
2011-04-02 14:50:31 +00:00
|
|
|
Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
|
2008-05-10 11:56:02 +00:00
|
|
|
wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) .
|
|
|
|
|
Xml::submitButton( wfMsg( 'imgmultigo' ) ) .
|
|
|
|
|
Xml::closeElement( 'form' ) .
|
|
|
|
|
"<hr />$thumb1\n$thumb2<br clear=\"all\" /></div></td></tr></table>"
|
|
|
|
|
);
|
2006-08-13 17:34:48 +00:00
|
|
|
}
|
2004-01-16 18:11:47 +00:00
|
|
|
} else {
|
2010-03-20 22:58:48 +00:00
|
|
|
# if direct link is allowed but it's not a renderable image, show an icon.
|
|
|
|
|
if ( $this->displayImg->isSafeFile() ) {
|
|
|
|
|
$icon = $this->displayImg->iconThumb();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-08-31 02:51:23 +00:00
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file">' .
|
2011-04-02 14:50:31 +00:00
|
|
|
$icon->toHtml( array( 'file-link' => true ) ) .
|
|
|
|
|
"</div>\n" );
|
2005-05-21 07:46:17 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
$showLink = true;
|
2004-01-16 18:11:47 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $showLink ) {
|
2008-05-21 21:33:58 +00:00
|
|
|
$filename = wfEscapeWikiText( $this->displayImg->getName() );
|
2010-10-27 01:50:07 +00:00
|
|
|
$linktext = $filename;
|
|
|
|
|
if ( isset( $msgbig ) ) {
|
|
|
|
|
$linktext = wfEscapeWikiText( $msgbig );
|
|
|
|
|
}
|
|
|
|
|
$medialink = "[[Media:$filename|$linktext]]";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->displayImg->isSafeFile() ) {
|
2008-02-18 07:25:35 +00:00
|
|
|
$warning = wfMsgNoTrans( 'mediawarning' );
|
2007-05-30 21:02:32 +00:00
|
|
|
$wgOut->addWikiText( <<<EOT
|
2010-10-27 01:56:23 +00:00
|
|
|
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span>$dirmark <span class="fileInfo">$longDesc</span></div>
|
2005-08-12 04:44:43 +00:00
|
|
|
<div class="mediaWarning">$warning</div>
|
2007-05-30 21:02:32 +00:00
|
|
|
EOT
|
2005-08-12 04:44:43 +00:00
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
} else {
|
2007-05-30 21:02:32 +00:00
|
|
|
$wgOut->addWikiText( <<<EOT
|
2010-10-27 01:56:23 +00:00
|
|
|
<div class="fullMedia">{$medialink}{$dirmark} <span class="fileInfo">$longDesc</span>
|
2005-08-12 04:44:43 +00:00
|
|
|
</div>
|
2007-05-30 21:02:32 +00:00
|
|
|
EOT
|
2009-05-25 13:53:48 +00:00
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->displayImg->isLocal() ) {
|
2005-07-03 04:40:07 +00:00
|
|
|
$this->printSharedImageText();
|
2004-10-21 05:04:14 +00:00
|
|
|
}
|
2005-04-17 08:30:15 +00:00
|
|
|
} else {
|
|
|
|
|
# Image does not exist
|
2009-05-24 20:45:31 +00:00
|
|
|
if ( $wgEnableUploads && $wgUser->isAllowed( 'upload' ) ) {
|
|
|
|
|
// Only show an upload link if the user can upload
|
2009-05-25 13:53:48 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2009-06-15 13:20:40 +00:00
|
|
|
$nofile = array(
|
2009-05-25 13:53:48 +00:00
|
|
|
'filepage-nofile-link',
|
2011-04-02 14:50:31 +00:00
|
|
|
$uploadTitle->getFullURL( array( 'wpDestFile' => $this->img->getName() ) )
|
2009-05-25 13:53:48 +00:00
|
|
|
);
|
2011-04-02 14:50:31 +00:00
|
|
|
} else {
|
2009-06-15 13:20:40 +00:00
|
|
|
$nofile = 'filepage-nofile';
|
2009-05-24 20:45:31 +00:00
|
|
|
}
|
2011-01-16 00:43:56 +00:00
|
|
|
// Note, if there is an image description page, but
|
|
|
|
|
// no image, then this setRobotPolicy is overriden
|
|
|
|
|
// by Article::View().
|
2009-02-26 20:10:48 +00:00
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
2009-06-25 05:38:54 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
|
2011-01-16 00:43:56 +00:00
|
|
|
if ( !$this->getID() ) {
|
|
|
|
|
// If there is no image, no shared image, and no description page,
|
|
|
|
|
// output a 404, to be consistent with articles.
|
2011-04-02 14:50:31 +00:00
|
|
|
$wgRequest->response()->header( 'HTTP/1.1 404 Not Found' );
|
2011-01-16 00:43:56 +00:00
|
|
|
}
|
2004-01-12 00:55:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-03-12 22:49:31 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an thumbnail of specified size and returns an HTML link to it
|
|
|
|
|
* @param array $params Scaler parameters
|
|
|
|
|
* @param int $width
|
|
|
|
|
* @param int $height
|
|
|
|
|
*/
|
|
|
|
|
private function makeSizeLink( $params, $width, $height ) {
|
|
|
|
|
$params['width'] = $width;
|
|
|
|
|
$params['height'] = $height;
|
|
|
|
|
$thumbnail = $this->displayImg->transform( $params );
|
|
|
|
|
if ( $thumbnail && !$thumbnail->isError() ) {
|
|
|
|
|
return Html::rawElement( 'a', array(
|
|
|
|
|
'href' => $thumbnail->getUrl(),
|
|
|
|
|
'class' => 'mw-thumbnail-link'
|
|
|
|
|
), wfMessage( 'show-big-image-size' )->numParams(
|
|
|
|
|
$thumbnail->getWidth(), $thumbnail->getHeight()
|
|
|
|
|
)->parse() );
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2008-02-19 16:29:28 +00:00
|
|
|
/**
|
|
|
|
|
* Show a notice that the file is from a shared repository
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function printSharedImageText() {
|
2009-04-28 03:03:48 +00:00
|
|
|
global $wgOut;
|
2006-11-08 07:12:03 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
$descUrl = $this->img->getDescriptionUrl();
|
|
|
|
|
$descText = $this->img->getDescriptionText();
|
2009-03-28 08:21:29 +00:00
|
|
|
|
2010-11-19 01:40:56 +00:00
|
|
|
/* Add canonical to head if there is no local page for this shared file */
|
|
|
|
|
if( $descUrl && $this->getID() == 0 ) {
|
2010-11-17 00:23:30 +00:00
|
|
|
$wgOut->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-28 16:41:00 +00:00
|
|
|
$wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
|
2009-03-28 08:21:29 +00:00
|
|
|
$repo = $this->img->getRepo()->getDisplayName();
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $descUrl && $descText && wfMsgNoTrans( 'sharedupload-desc-here' ) !== '-' ) {
|
2009-03-28 08:21:29 +00:00
|
|
|
$wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) );
|
|
|
|
|
} elseif ( $descUrl && wfMsgNoTrans( 'sharedupload-desc-there' ) !== '-' ) {
|
|
|
|
|
$wgOut->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) );
|
|
|
|
|
} else {
|
|
|
|
|
$wgOut->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ );
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $descText ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$this->mExtraDescription = $descText;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getUploadUrl() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2006-10-30 06:25:31 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2011-04-02 14:50:31 +00:00
|
|
|
return $uploadTitle->getFullURL( array(
|
2009-05-25 14:02:54 +00:00
|
|
|
'wpDestFile' => $this->img->getName(),
|
2009-05-25 13:53:48 +00:00
|
|
|
'wpForReUpload' => 1
|
|
|
|
|
) );
|
2005-04-17 08:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
/**
|
|
|
|
|
* Print out the various links at the bottom of the image page, e.g. reupload,
|
|
|
|
|
* external editing (and instructions link) etc.
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function uploadLinksBox() {
|
2010-02-05 14:07:18 +00:00
|
|
|
global $wgUser, $wgOut, $wgEnableUploads, $wgUseExternalEditor;
|
2009-05-24 20:45:31 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
if ( !$wgEnableUploads ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-07-03 05:21:06 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$this->img->isLocal() ) {
|
2005-07-03 05:21:06 +00:00
|
|
|
return;
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2005-07-03 05:21:06 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-03-28 16:41:00 +00:00
|
|
|
$wgOut->addHTML( "<br /><ul>\n" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# "Upload a new version of this file" link
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( UploadBase::userCanReUpload( $wgUser, $this->img->name ) ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
|
2009-03-28 16:41:00 +00:00
|
|
|
$wgOut->addHTML( "<li id=\"mw-imagepage-reupload-link\"><div class=\"plainlinks\">{$ulink}</div></li>\n" );
|
2005-09-05 06:16:48 +00:00
|
|
|
}
|
2008-03-19 16:58:56 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# External editing link
|
2010-02-05 14:07:18 +00:00
|
|
|
if ( $wgUseExternalEditor ) {
|
|
|
|
|
$elink = $sk->link(
|
|
|
|
|
$this->mTitle,
|
|
|
|
|
wfMsgHtml( 'edit-externally' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'edit',
|
|
|
|
|
'externaledit' => 'true',
|
|
|
|
|
'mode' => 'file'
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2011-04-02 14:50:31 +00:00
|
|
|
$wgOut->addHTML(
|
|
|
|
|
'<li id="mw-imagepage-edit-external">' . $elink . ' <small>' .
|
|
|
|
|
wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) .
|
|
|
|
|
"</small></li>\n"
|
|
|
|
|
);
|
2010-02-05 14:07:18 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2009-03-28 16:41:00 +00:00
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
2005-03-24 13:30:09 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
protected function closeShowImage() { } # For overloading
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* If the page we've just displayed is in the "Image" namespace,
|
|
|
|
|
* we follow it with an upload history of the image and its usage.
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function imageHistory() {
|
2010-02-05 14:07:18 +00:00
|
|
|
global $wgOut;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2008-12-14 07:10:42 +00:00
|
|
|
$pager = new ImageHistoryPseudoPager( $this );
|
|
|
|
|
$wgOut->addHTML( $pager->getBody() );
|
2011-01-04 06:12:33 +00:00
|
|
|
$wgOut->preventClickjacking( $pager->getPreventClickjacking() );
|
2005-04-30 01:59:51 +00:00
|
|
|
|
2008-08-08 21:31:38 +00:00
|
|
|
$this->img->resetHistory(); // free db resources
|
2007-07-07 03:04:20 +00:00
|
|
|
|
2005-04-30 02:37:16 +00:00
|
|
|
# Exist check because we don't want to show this on pages where an image
|
|
|
|
|
# doesn't exist along with the noimage message, that would suck. -ævar
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->img->exists() ) {
|
2005-04-30 01:59:51 +00:00
|
|
|
$this->uploadLinksBox();
|
|
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-14 12:20:45 +00:00
|
|
|
protected function queryImageLinks( $target, $limit ) {
|
2008-05-05 22:14:55 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
|
2011-05-14 12:20:45 +00:00
|
|
|
return $dbr->select(
|
2008-05-09 11:31:00 +00:00
|
|
|
array( 'imagelinks', 'page' ),
|
2011-05-14 12:20:45 +00:00
|
|
|
array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
|
|
|
|
|
array( 'il_to' => $target, 'il_from = page_id' ),
|
2008-05-09 11:31:00 +00:00
|
|
|
__METHOD__,
|
2010-03-20 22:58:48 +00:00
|
|
|
array( 'LIMIT' => $limit + 1 )
|
2011-05-14 12:20:45 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function imageLinks() {
|
|
|
|
|
global $wgUser, $wgOut, $wgLang;
|
|
|
|
|
|
|
|
|
|
$limit = 100;
|
|
|
|
|
|
|
|
|
|
$res = $this->queryImageLinks( $this->mTitle->getDbKey(), $limit + 1);
|
|
|
|
|
$rows = array();
|
|
|
|
|
$redirects = array();
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
if ( $row->page_is_redirect ) {
|
|
|
|
|
$redirects[$row->page_title] = array();
|
|
|
|
|
}
|
|
|
|
|
$rows[] = $row;
|
|
|
|
|
}
|
|
|
|
|
$count = count( $rows );
|
|
|
|
|
|
|
|
|
|
$hasMore = $count > $limit;
|
|
|
|
|
if ( !$hasMore && count( $redirects ) ) {
|
|
|
|
|
$res = $this->queryImageLinks( array_keys( $redirects ),
|
|
|
|
|
$limit - count( $rows ) + 1 );
|
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
|
$redirects[$row->il_to][] = $row;
|
|
|
|
|
$count++;
|
|
|
|
|
}
|
|
|
|
|
$hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $count == 0 ) {
|
2011-04-02 14:50:31 +00:00
|
|
|
$wgOut->wrapWikiMsg(
|
|
|
|
|
Html::rawElement( 'div',
|
|
|
|
|
array( 'id' => 'mw-imagepage-nolinkstoimage' ), "\n$1\n" ),
|
|
|
|
|
'nolinkstoimage'
|
|
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
return;
|
2008-08-08 20:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$wgOut->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
|
2011-05-14 12:20:45 +00:00
|
|
|
if ( !$hasMore ) {
|
2008-08-07 18:46:18 +00:00
|
|
|
$wgOut->addWikiMsg( 'linkstoimage', $count );
|
|
|
|
|
} else {
|
|
|
|
|
// More links than the limit. Add a link to [[Special:Whatlinkshere]]
|
2008-08-08 21:31:38 +00:00
|
|
|
$wgOut->addWikiMsg( 'linkstoimage-more',
|
|
|
|
|
$wgLang->formatNum( $limit ),
|
|
|
|
|
$this->mTitle->getPrefixedDBkey()
|
|
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
$wgOut->addHTML(
|
|
|
|
|
Html::openElement( 'ul',
|
|
|
|
|
array( 'class' => 'mw-imagepage-linkstoimage' ) ) . "\n"
|
|
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2008-05-09 11:31:00 +00:00
|
|
|
$count = 0;
|
2010-06-29 13:38:55 +00:00
|
|
|
|
|
|
|
|
// Sort the list by namespace:title
|
2011-05-14 12:20:45 +00:00
|
|
|
usort( $rows, array( $this, 'compare' ) );
|
2010-06-29 13:38:55 +00:00
|
|
|
|
|
|
|
|
// Create links for every element
|
2011-05-14 12:20:45 +00:00
|
|
|
$currentCount = 0;
|
|
|
|
|
foreach( $rows as $element ) {
|
|
|
|
|
$currentCount++;
|
|
|
|
|
if ( $currentCount > $limit ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-29 14:37:39 +00:00
|
|
|
$link = $sk->linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) );
|
2011-05-14 12:20:45 +00:00
|
|
|
if ( !isset( $redirects[$element->page_title] ) ) {
|
|
|
|
|
$liContents = $link;
|
|
|
|
|
} else {
|
|
|
|
|
$ul = "<ul class='mw-imagepage-redirectstofile'>\n";
|
|
|
|
|
foreach ( $redirects[$element->page_title] as $row ) {
|
|
|
|
|
$currentCount++;
|
|
|
|
|
if ( $currentCount > $limit ) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$link2 = $sk->linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
|
|
|
|
|
$ul .= Html::rawElement(
|
|
|
|
|
'li',
|
|
|
|
|
array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
|
|
|
|
|
$link2
|
|
|
|
|
) . "\n";
|
|
|
|
|
}
|
|
|
|
|
$ul .= '</ul>';
|
|
|
|
|
$liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
|
|
|
|
|
$link, $ul )->parse();
|
|
|
|
|
}
|
2010-06-29 13:38:55 +00:00
|
|
|
$wgOut->addHTML( Html::rawElement(
|
2011-04-02 14:50:31 +00:00
|
|
|
'li',
|
|
|
|
|
array( 'id' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
|
2011-05-14 12:20:45 +00:00
|
|
|
$liContents
|
2011-04-02 14:50:31 +00:00
|
|
|
) . "\n"
|
2010-06-29 13:38:55 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
$wgOut->addHTML( Html::closeElement( 'ul' ) . "\n" );
|
2008-05-09 11:31:00 +00:00
|
|
|
$res->free();
|
2008-06-11 12:07:58 +00:00
|
|
|
|
2008-05-09 11:31:00 +00:00
|
|
|
// Add a links to [[Special:Whatlinkshere]]
|
2010-06-29 13:38:55 +00:00
|
|
|
if ( $count > $limit ) {
|
2008-05-09 18:40:52 +00:00
|
|
|
$wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() );
|
2010-06-29 13:38:55 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( Html::closeElement( 'div' ) . "\n" );
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
2008-06-11 12:07:58 +00:00
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function imageDupes() {
|
2008-08-08 21:31:38 +00:00
|
|
|
global $wgOut, $wgUser, $wgLang;
|
2008-05-20 03:26:59 +00:00
|
|
|
|
|
|
|
|
$this->loadFile();
|
|
|
|
|
|
2008-05-15 19:17:21 +00:00
|
|
|
$dupes = $this->getDuplicates();
|
2011-03-05 17:01:33 +00:00
|
|
|
if ( count( $dupes ) == 0 ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-05-15 07:16:22 +00:00
|
|
|
|
2008-06-11 01:51:12 +00:00
|
|
|
$wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
|
2008-08-08 21:31:38 +00:00
|
|
|
$wgOut->addWikiMsg( 'duplicatesoffile',
|
2009-02-16 08:51:38 +00:00
|
|
|
$wgLang->formatNum( count( $dupes ) ), $this->mTitle->getDBkey()
|
2008-08-08 21:31:38 +00:00
|
|
|
);
|
2008-06-11 01:51:12 +00:00
|
|
|
$wgOut->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
|
2008-05-15 07:16:22 +00:00
|
|
|
|
2008-05-14 15:11:48 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
foreach ( $dupes as $file ) {
|
2009-02-17 22:27:10 +00:00
|
|
|
$fromSrc = '';
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->isLocal() ) {
|
2009-06-06 22:42:48 +00:00
|
|
|
$link = $sk->link(
|
|
|
|
|
$file->getTitle(),
|
|
|
|
|
null,
|
|
|
|
|
array(),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
} else {
|
2008-08-08 21:31:38 +00:00
|
|
|
$link = $sk->makeExternalLink( $file->getDescriptionUrl(),
|
2008-05-14 17:29:38 +00:00
|
|
|
$file->getTitle()->getPrefixedText() );
|
2009-02-17 22:27:10 +00:00
|
|
|
$fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() );
|
2008-08-08 21:31:38 +00:00
|
|
|
}
|
2009-02-17 22:27:10 +00:00
|
|
|
$wgOut->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
}
|
2008-05-28 19:51:18 +00:00
|
|
|
$wgOut->addHTML( "</ul></div>\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
}
|
2008-05-05 22:14:55 +00:00
|
|
|
|
2006-06-07 06:40:24 +00:00
|
|
|
/**
|
2007-08-17 20:53:17 +00:00
|
|
|
* Delete the file, or an earlier version of it
|
2006-06-07 06:40:24 +00:00
|
|
|
*/
|
2007-08-17 20:53:17 +00:00
|
|
|
public function delete() {
|
2009-09-11 23:36:28 +00:00
|
|
|
global $wgUploadMaintenance;
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $wgUploadMaintenance && $this->mTitle && $this->mTitle->getNamespace() == NS_FILE ) {
|
2009-09-11 23:36:28 +00:00
|
|
|
global $wgOut;
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n", array( 'filedelete-maintenance' ) );
|
2009-09-11 23:36:28 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->img->exists() || !$this->img->isLocal() || $this->img->getRedirected() ) {
|
2007-08-17 20:53:17 +00:00
|
|
|
// Standard article deletion
|
2010-07-25 21:08:34 +00:00
|
|
|
parent::delete();
|
2007-08-17 20:53:17 +00:00
|
|
|
return;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2007-08-17 20:53:17 +00:00
|
|
|
$deleter = new FileDeleteForm( $this->img );
|
|
|
|
|
$deleter->execute();
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-29 22:00:46 +00:00
|
|
|
/**
|
|
|
|
|
* Revert the file to an earlier version
|
|
|
|
|
*/
|
2007-08-17 20:53:17 +00:00
|
|
|
public function revert() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2007-07-29 22:00:46 +00:00
|
|
|
$reverter = new FileRevertForm( $this->img );
|
|
|
|
|
$reverter->execute();
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-03-01 01:27:36 +00:00
|
|
|
/**
|
|
|
|
|
* Override handling of action=purge
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function doPurge() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->img->exists() ) {
|
2011-04-02 14:50:31 +00:00
|
|
|
wfDebug( 'ImagePage::doPurge purging ' . $this->img->getName() . "\n" );
|
2006-06-18 12:42:16 +00:00
|
|
|
$update = new HTMLCacheUpdate( $this->mTitle, 'imagelinks' );
|
|
|
|
|
$update->doUpdate();
|
2007-05-04 19:39:19 +00:00
|
|
|
$this->img->upgradeRow();
|
2006-03-01 01:27:36 +00:00
|
|
|
$this->img->purgeCache();
|
|
|
|
|
} else {
|
2011-04-02 14:50:31 +00:00
|
|
|
wfDebug( 'ImagePage::doPurge no image for ' . $this->img->getName() . "; limiting purge to cache only\n" );
|
2009-04-24 23:11:07 +00:00
|
|
|
// even if the file supposedly doesn't exist, force any cached information
|
|
|
|
|
// to be updated (in case the cached information is wrong)
|
|
|
|
|
$this->img->purgeCache();
|
2006-03-01 01:27:36 +00:00
|
|
|
}
|
|
|
|
|
parent::doPurge();
|
|
|
|
|
}
|
2005-07-01 21:15:31 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
/**
|
2007-07-22 14:45:12 +00:00
|
|
|
* Display an error with a wikitext description
|
2007-05-30 21:02:32 +00:00
|
|
|
*/
|
2007-07-22 14:45:12 +00:00
|
|
|
function showError( $description ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
global $wgOut;
|
2011-04-02 14:50:31 +00:00
|
|
|
$wgOut->setPageTitle( wfMsg( 'internalerror' ) );
|
|
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
2007-05-30 21:02:32 +00:00
|
|
|
$wgOut->setArticleRelated( false );
|
|
|
|
|
$wgOut->enableClientCache( false );
|
2007-07-22 14:45:12 +00:00
|
|
|
$wgOut->addWikiText( $description );
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-29 13:38:55 +00:00
|
|
|
/**
|
|
|
|
|
* Callback for usort() to do link sorts by (namespace, title)
|
|
|
|
|
* Function copied from Title::compare()
|
|
|
|
|
*
|
|
|
|
|
* @param $a object page to compare with
|
|
|
|
|
* @param $b object page to compare with
|
|
|
|
|
* @return Integer: result of string comparison, or namespace comparison
|
|
|
|
|
*/
|
|
|
|
|
protected function compare( $a, $b ) {
|
|
|
|
|
if ( $a->page_namespace == $b->page_namespace ) {
|
|
|
|
|
return strcmp( $a->page_title, $b->page_title );
|
|
|
|
|
} else {
|
|
|
|
|
return $a->page_namespace - $b->page_namespace;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-27 19:51:47 +00:00
|
|
|
/**
|
2007-07-29 18:41:49 +00:00
|
|
|
* Builds the image revision log shown on image pages
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Media
|
2005-01-27 19:51:47 +00:00
|
|
|
*/
|
2004-11-25 13:47:17 +00:00
|
|
|
class ImageHistoryList {
|
2007-07-29 18:41:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
protected $title;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
|
|
|
|
protected $img;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var ImagePage
|
|
|
|
|
*/
|
|
|
|
|
protected $imagePage;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Skin
|
|
|
|
|
*/
|
|
|
|
|
protected $skin;
|
|
|
|
|
|
|
|
|
|
protected $repo, $showThumb;
|
2011-01-04 06:12:33 +00:00
|
|
|
protected $preventClickjacking = false;
|
2008-05-23 09:03:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @param ImagePage $imagePage
|
|
|
|
|
*/
|
2008-05-23 09:03:49 +00:00
|
|
|
public function __construct( $imagePage ) {
|
2009-07-12 05:37:12 +00:00
|
|
|
global $wgUser, $wgShowArchiveThumbnails;
|
2008-05-23 09:03:49 +00:00
|
|
|
$this->skin = $wgUser->getSkin();
|
|
|
|
|
$this->current = $imagePage->getFile();
|
|
|
|
|
$this->img = $imagePage->getDisplayedFile();
|
|
|
|
|
$this->title = $imagePage->getTitle();
|
|
|
|
|
$this->imagePage = $imagePage;
|
2009-09-25 14:48:44 +00:00
|
|
|
$this->showThumb = $wgShowArchiveThumbnails && $this->img->canRender();
|
2008-05-23 09:03:49 +00:00
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getImagePage() {
|
2008-05-23 09:03:49 +00:00
|
|
|
return $this->imagePage;
|
|
|
|
|
}
|
|
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getSkin() {
|
2008-05-23 09:03:49 +00:00
|
|
|
return $this->skin;
|
|
|
|
|
}
|
2007-07-29 18:41:49 +00:00
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getFile() {
|
2008-05-23 09:03:49 +00:00
|
|
|
return $this->img;
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2008-12-14 07:10:42 +00:00
|
|
|
public function beginImageHistoryList( $navLinks = '' ) {
|
2007-07-29 18:41:49 +00:00
|
|
|
global $wgOut, $wgUser;
|
2009-03-28 16:41:00 +00:00
|
|
|
return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) ) . "\n"
|
|
|
|
|
. "<div id=\"mw-imagepage-section-filehistory\">\n"
|
2007-07-29 18:41:49 +00:00
|
|
|
. $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
|
2009-03-28 16:41:00 +00:00
|
|
|
. $navLinks . "\n"
|
2009-06-17 18:05:03 +00:00
|
|
|
. Xml::openElement( 'table', array( 'class' => 'wikitable filehistory' ) ) . "\n"
|
2008-05-19 15:21:29 +00:00
|
|
|
. '<tr><td></td>'
|
2011-03-18 21:07:05 +00:00
|
|
|
. ( $this->current->isLocal() && ( $wgUser->isAllowedAny( 'delete', 'deletedhistory' ) ) ? '<td></td>' : '' )
|
2008-05-19 15:21:29 +00:00
|
|
|
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
|
2009-07-12 05:37:12 +00:00
|
|
|
. ( $this->showThumb ? '<th>' . wfMsgHtml( 'filehist-thumb' ) . '</th>' : '' )
|
2008-05-19 15:21:29 +00:00
|
|
|
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
|
2008-08-08 21:31:38 +00:00
|
|
|
. '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
|
|
|
|
|
. '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
|
2008-05-19 15:21:29 +00:00
|
|
|
. "</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-12-14 07:10:42 +00:00
|
|
|
public function endImageHistoryList( $navLinks = '' ) {
|
2009-03-28 16:41:00 +00:00
|
|
|
return "</table>\n$navLinks\n</div>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
2011-04-02 14:50:31 +00:00
|
|
|
* @param $iscur
|
|
|
|
|
* @param $file File
|
2011-03-05 17:01:33 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2008-03-19 18:09:20 +00:00
|
|
|
public function imageHistoryLine( $iscur, $file ) {
|
2010-07-24 19:11:52 +00:00
|
|
|
global $wgUser, $wgLang;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
|
2008-03-19 18:09:20 +00:00
|
|
|
$img = $iscur ? $file->getName() : $file->getArchiveName();
|
2010-03-20 22:58:48 +00:00
|
|
|
$user = $file->getUser( 'id' );
|
|
|
|
|
$usertext = $file->getUser( 'text' );
|
2008-03-19 18:09:20 +00:00
|
|
|
$description = $file->getDescription();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-05-19 18:55:48 +00:00
|
|
|
$local = $this->current->isLocal();
|
2010-08-13 08:09:52 +00:00
|
|
|
$row = $selected = '';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Deletion link
|
2011-03-18 21:07:05 +00:00
|
|
|
if ( $local && ( $wgUser->isAllowedAny( 'delete', 'deletedhistory' ) ) ) {
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '<td>';
|
2008-03-19 18:09:20 +00:00
|
|
|
# Link to remove from history
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $wgUser->isAllowed( 'delete' ) ) {
|
2009-04-07 16:37:29 +00:00
|
|
|
$q = array( 'action' => 'delete' );
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$iscur ) {
|
2009-04-07 16:37:29 +00:00
|
|
|
$q['oldimage'] = $img;
|
2011-04-02 14:50:31 +00:00
|
|
|
}
|
2009-04-07 16:37:29 +00:00
|
|
|
$row .= $this->skin->link(
|
2008-03-19 18:09:20 +00:00
|
|
|
$this->title,
|
|
|
|
|
wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
|
2009-04-07 16:37:29 +00:00
|
|
|
array(), $q, array( 'known' )
|
2008-03-19 18:09:20 +00:00
|
|
|
);
|
|
|
|
|
}
|
2009-09-28 03:09:48 +00:00
|
|
|
# Link to hide content. Don't show useless link to people who cannot hide revisions.
|
2009-10-30 02:14:22 +00:00
|
|
|
$canHide = $wgUser->isAllowed( 'deleterevision' );
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $canHide || ( $wgUser->isAllowed( 'deletedhistory' ) && $file->getVisibility() ) ) {
|
|
|
|
|
if ( $wgUser->isAllowed( 'delete' ) ) {
|
2009-11-14 20:59:15 +00:00
|
|
|
$row .= '<br />';
|
2008-05-19 15:21:29 +00:00
|
|
|
}
|
2008-03-19 18:09:20 +00:00
|
|
|
// If file is top revision or locked from this user, don't link
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $iscur || !$file->userCan( File::DELETED_RESTRICTED ) ) {
|
2009-10-30 02:14:22 +00:00
|
|
|
$del = $this->skin->revDeleteLinkDisabled( $canHide );
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2009-04-07 16:37:29 +00:00
|
|
|
list( $ts, $name ) = explode( '!', $img, 2 );
|
2009-10-29 05:58:53 +00:00
|
|
|
$query = array(
|
2009-10-30 02:14:22 +00:00
|
|
|
'type' => 'oldimage',
|
2010-06-03 19:28:13 +00:00
|
|
|
'target' => $this->title->getPrefixedText(),
|
2009-10-30 02:14:22 +00:00
|
|
|
'ids' => $ts,
|
2009-04-07 16:37:29 +00:00
|
|
|
);
|
2009-10-30 02:14:22 +00:00
|
|
|
$del = $this->skin->revDeleteLink( $query,
|
2010-03-20 22:58:48 +00:00
|
|
|
$file->isDeleted( File::DELETED_RESTRICTED ), $canHide );
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2009-10-29 05:58:53 +00:00
|
|
|
$row .= $del;
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '</td>';
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Reversion link/current indicator
|
2007-10-01 19:50:25 +00:00
|
|
|
$row .= '<td>';
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $iscur ) {
|
2008-02-05 12:40:41 +00:00
|
|
|
$row .= wfMsgHtml( 'filehist-current' );
|
2010-03-20 22:58:48 +00:00
|
|
|
} elseif ( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_FILE ) ) {
|
|
|
|
|
$row .= wfMsgHtml( 'filehist-revert' );
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2009-06-06 22:42:48 +00:00
|
|
|
$row .= $this->skin->link(
|
|
|
|
|
$this->title,
|
2008-03-19 18:09:20 +00:00
|
|
|
wfMsgHtml( 'filehist-revert' ),
|
2009-06-06 22:42:48 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'revert',
|
|
|
|
|
'oldimage' => $img,
|
|
|
|
|
'wpEditToken' => $wgUser->editToken( $img )
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2007-07-29 18:41:49 +00:00
|
|
|
}
|
|
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Date/time and image link
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->getTimestamp() === $this->img->getTimestamp() ) {
|
2008-05-19 18:55:48 +00:00
|
|
|
$selected = "class='filehistory-selected'";
|
|
|
|
|
}
|
|
|
|
|
$row .= "<td $selected style='white-space: nowrap;'>";
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$file->userCan( File::DELETED_FILE ) ) {
|
2008-03-19 18:09:20 +00:00
|
|
|
# Don't link to unviewable files
|
|
|
|
|
$row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
|
2010-03-20 22:58:48 +00:00
|
|
|
} elseif ( $file->isDeleted( File::DELETED_FILE ) ) {
|
2011-04-06 18:45:27 +00:00
|
|
|
if ( $local ) {
|
|
|
|
|
$this->preventClickjacking();
|
|
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
# Make a link to review the image
|
|
|
|
|
$url = $this->skin->link(
|
|
|
|
|
$revdel,
|
|
|
|
|
$wgLang->timeAndDate( $timestamp, true ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'target' => $this->title->getPrefixedText(),
|
|
|
|
|
'file' => $img,
|
|
|
|
|
'token' => $wgUser->editToken( $img )
|
|
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$url = $wgLang->timeAndDate( $timestamp, true );
|
|
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$row .= '<span class="history-deleted">' . $url . '</span>';
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
2008-05-19 18:55:48 +00:00
|
|
|
$url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
|
2008-05-17 00:08:31 +00:00
|
|
|
$row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) );
|
2008-03-19 18:09:20 +00:00
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= "</td>";
|
2008-03-19 18:09:20 +00:00
|
|
|
|
2008-08-29 11:54:34 +00:00
|
|
|
// Thumbnail
|
2009-07-12 05:37:12 +00:00
|
|
|
if ( $this->showThumb ) {
|
|
|
|
|
$row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
|
|
|
|
|
}
|
2008-05-17 00:08:31 +00:00
|
|
|
|
2009-04-27 11:18:49 +00:00
|
|
|
// Image dimensions + size
|
|
|
|
|
$row .= '<td>';
|
|
|
|
|
$row .= htmlspecialchars( $file->getDimensionsString() );
|
2011-04-02 14:50:31 +00:00
|
|
|
$row .= ' <span style="white-space: nowrap;">(' . $this->skin->formatSize( $file->getSize() ) . ')</span>';
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Uploading user
|
2009-04-27 11:18:49 +00:00
|
|
|
$row .= '<td>';
|
2011-04-06 18:23:07 +00:00
|
|
|
// Hide deleted usernames
|
|
|
|
|
if ( $file->isDeleted( File::DELETED_USER ) ) {
|
|
|
|
|
$row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
if ( $local ) {
|
2011-04-02 14:50:31 +00:00
|
|
|
$row .= $this->skin->userLink( $user, $usertext ) . ' <span style="white-space: nowrap;">' .
|
2011-04-06 18:23:07 +00:00
|
|
|
$this->skin->userToolLinks( $user, $usertext ) . '</span>';
|
|
|
|
|
} else {
|
|
|
|
|
$row .= htmlspecialchars( $usertext );
|
2008-05-19 15:21:29 +00:00
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '</td><td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2008-03-19 18:09:20 +00:00
|
|
|
// Don't show deleted descriptions
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->isDeleted( File::DELETED_COMMENT ) ) {
|
|
|
|
|
$row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-comment' ) . '</span>';
|
2008-05-17 00:08:31 +00:00
|
|
|
} else {
|
2011-06-14 23:50:40 +00:00
|
|
|
$row .= $this->skin->commentBlock( $description, $this->title );
|
2008-05-17 00:08:31 +00:00
|
|
|
}
|
|
|
|
|
$row .= '</td>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2010-11-25 22:22:53 +00:00
|
|
|
$rowClass = null;
|
2008-05-23 09:03:49 +00:00
|
|
|
wfRunHooks( 'ImagePageFileHistoryLine', array( $this, $file, &$row, &$rowClass ) );
|
2011-04-02 14:50:31 +00:00
|
|
|
$classAttr = $rowClass ? " class='$rowClass'" : '';
|
2008-05-19 18:55:48 +00:00
|
|
|
|
2008-05-23 09:03:49 +00:00
|
|
|
return "<tr{$classAttr}>{$row}</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
2011-04-02 14:50:31 +00:00
|
|
|
* @param $file File
|
2011-03-05 17:01:33 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2009-04-27 11:18:49 +00:00
|
|
|
protected function getThumbForLine( $file ) {
|
|
|
|
|
global $wgLang;
|
|
|
|
|
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
|
2009-04-27 11:18:49 +00:00
|
|
|
$params = array(
|
|
|
|
|
'width' => '120',
|
|
|
|
|
'height' => '120',
|
|
|
|
|
);
|
2010-03-20 22:58:48 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $file->getTimestamp() );
|
2009-04-27 11:18:49 +00:00
|
|
|
|
|
|
|
|
$thumbnail = $file->transform( $params );
|
|
|
|
|
$options = array(
|
2009-06-01 21:29:31 +00:00
|
|
|
'alt' => wfMsg( 'filehist-thumbtext',
|
|
|
|
|
$wgLang->timeAndDate( $timestamp, true ),
|
|
|
|
|
$wgLang->date( $timestamp, true ),
|
|
|
|
|
$wgLang->time( $timestamp, true ) ),
|
2009-04-27 11:18:49 +00:00
|
|
|
'file-link' => true,
|
|
|
|
|
);
|
|
|
|
|
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( !$thumbnail ) {
|
|
|
|
|
return wfMsgHtml( 'filehist-nothumb' );
|
|
|
|
|
}
|
2009-04-27 11:18:49 +00:00
|
|
|
|
|
|
|
|
return $thumbnail->toHtml( $options );
|
|
|
|
|
} else {
|
|
|
|
|
return wfMsgHtml( 'filehist-nothumb' );
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-04 06:12:33 +00:00
|
|
|
|
|
|
|
|
protected function preventClickjacking( $enable = true ) {
|
|
|
|
|
$this->preventClickjacking = $enable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPreventClickjacking() {
|
|
|
|
|
return $this->preventClickjacking;
|
|
|
|
|
}
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
|
|
|
|
|
class ImageHistoryPseudoPager extends ReverseChronologicalPager {
|
2011-01-04 06:12:33 +00:00
|
|
|
protected $preventClickjacking = false;
|
|
|
|
|
|
2011-03-05 17:01:33 +00:00
|
|
|
/**
|
|
|
|
|
* @var File
|
|
|
|
|
*/
|
|
|
|
|
protected $mImg;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
protected $mTitle;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param ImagePage $imagePage
|
|
|
|
|
*/
|
2008-12-14 07:10:42 +00:00
|
|
|
function __construct( $imagePage ) {
|
|
|
|
|
parent::__construct();
|
2008-12-23 17:58:22 +00:00
|
|
|
$this->mImagePage = $imagePage;
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mTitle = clone ( $imagePage->getTitle() );
|
2008-12-17 01:35:40 +00:00
|
|
|
$this->mTitle->setFragment( '#filehistory' );
|
2009-12-11 21:07:27 +00:00
|
|
|
$this->mImg = null;
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mHist = array();
|
|
|
|
|
$this->mRange = array( 0, 0 ); // display range
|
|
|
|
|
}
|
2008-12-23 17:58:22 +00:00
|
|
|
|
|
|
|
|
function getTitle() {
|
|
|
|
|
return $this->mTitle;
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIndexField() {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatRow( $row ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getBody() {
|
|
|
|
|
$s = '';
|
|
|
|
|
$this->doQuery();
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( count( $this->mHist ) ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$list = new ImageHistoryList( $this->mImagePage );
|
|
|
|
|
# Generate prev/next links
|
2009-04-27 11:18:49 +00:00
|
|
|
$navLink = $this->getNavigationBar();
|
2010-03-20 22:58:48 +00:00
|
|
|
$s = $list->beginImageHistoryList( $navLink );
|
2008-12-14 07:10:42 +00:00
|
|
|
// Skip rows there just for paging links
|
2010-03-20 22:58:48 +00:00
|
|
|
for ( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$file = $this->mHist[$i];
|
|
|
|
|
$s .= $list->imageHistoryLine( !$file->isOld(), $file );
|
|
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$s .= $list->endImageHistoryList( $navLink );
|
2011-01-04 06:12:33 +00:00
|
|
|
|
|
|
|
|
if ( $list->getPreventClickjacking() ) {
|
|
|
|
|
$this->preventClickjacking();
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function doQuery() {
|
2011-04-02 14:50:31 +00:00
|
|
|
if ( $this->mQueryDone ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mImg = $this->mImagePage->getFile(); // ensure loading
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->mImg->exists() ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$queryLimit = $this->mLimit + 1; // limit plus extra row
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
// Fetch the file history
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist = $this->mImg->getHistory( $queryLimit, null, $this->mOffset, false );
|
2008-12-14 07:10:42 +00:00
|
|
|
// The current rev may not meet the offset/limit
|
2010-03-20 22:58:48 +00:00
|
|
|
$numRows = count( $this->mHist );
|
|
|
|
|
if ( $numRows <= $this->mLimit && $this->mImg->getTimestamp() > $this->mOffset ) {
|
|
|
|
|
$this->mHist = array_merge( array( $this->mImg ), $this->mHist );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// The current rev may not meet the offset
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( !$this->mOffset || $this->mImg->getTimestamp() < $this->mOffset ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mHist[] = $this->mImg;
|
|
|
|
|
}
|
|
|
|
|
// Old image versions (fetch extra row for nav links)
|
2010-03-20 22:58:48 +00:00
|
|
|
$oiLimit = count( $this->mHist ) ? $this->mLimit : $this->mLimit + 1;
|
2008-12-14 07:10:42 +00:00
|
|
|
// Fetch the file history
|
|
|
|
|
$this->mHist = array_merge( $this->mHist,
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mImg->getHistory( $oiLimit, $this->mOffset, null, false ) );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
$numRows = count( $this->mHist ); // Total number of query results
|
|
|
|
|
if ( $numRows ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of top item in the list
|
|
|
|
|
$firstIndex = $this->mIsBackwards ?
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist[$numRows - 1]->getTimestamp() : $this->mHist[0]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Discard the extra result row if there is one
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $numRows > $this->mLimit && $numRows > 1 ) {
|
|
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of item past the index
|
|
|
|
|
$this->mPastTheEndIndex = $this->mHist[0]->getTimestamp();
|
|
|
|
|
# Index value of bottom item in the list
|
|
|
|
|
$lastIndex = $this->mHist[1]->getTimestamp();
|
|
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 1, $numRows - 1 );
|
2008-12-14 07:10:42 +00:00
|
|
|
} else {
|
|
|
|
|
# Index value of item past the index
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mPastTheEndIndex = $this->mHist[$numRows - 1]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Index value of bottom item in the list
|
2010-03-20 22:58:48 +00:00
|
|
|
$lastIndex = $this->mHist[$numRows - 2]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 0, $numRows - 2 );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
# Setting indexes to an empty string means that they will be
|
|
|
|
|
# omitted if they would otherwise appear in URLs. It just so
|
|
|
|
|
# happens that this is the right thing to do in the standard
|
|
|
|
|
# UI, in all the relevant cases.
|
|
|
|
|
$this->mPastTheEndIndex = '';
|
|
|
|
|
# Index value of bottom item in the list
|
|
|
|
|
$lastIndex = $this->mIsBackwards ?
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mHist[0]->getTimestamp() : $this->mHist[$numRows - 1]->getTimestamp();
|
2008-12-14 07:10:42 +00:00
|
|
|
# Display range
|
2010-03-20 22:58:48 +00:00
|
|
|
$this->mRange = array( 0, $numRows - 1 );
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$firstIndex = '';
|
|
|
|
|
$lastIndex = '';
|
|
|
|
|
$this->mPastTheEndIndex = '';
|
|
|
|
|
}
|
2010-03-20 22:58:48 +00:00
|
|
|
if ( $this->mIsBackwards ) {
|
2008-12-14 07:10:42 +00:00
|
|
|
$this->mIsFirst = ( $numRows < $queryLimit );
|
|
|
|
|
$this->mIsLast = ( $this->mOffset == '' );
|
|
|
|
|
$this->mLastShown = $firstIndex;
|
|
|
|
|
$this->mFirstShown = $lastIndex;
|
|
|
|
|
} else {
|
|
|
|
|
$this->mIsFirst = ( $this->mOffset == '' );
|
|
|
|
|
$this->mIsLast = ( $numRows < $queryLimit );
|
|
|
|
|
$this->mLastShown = $lastIndex;
|
|
|
|
|
$this->mFirstShown = $firstIndex;
|
|
|
|
|
}
|
|
|
|
|
$this->mQueryDone = true;
|
|
|
|
|
}
|
2011-01-04 06:12:33 +00:00
|
|
|
|
|
|
|
|
protected function preventClickjacking( $enable = true ) {
|
|
|
|
|
$this->preventClickjacking = $enable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPreventClickjacking() {
|
|
|
|
|
return $this->preventClickjacking;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-14 07:10:42 +00:00
|
|
|
}
|