2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*/
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2004-12-03 10:57:19 +00:00
|
|
|
if( !defined( 'MEDIAWIKI' ) )
|
2006-06-07 06:40:24 +00:00
|
|
|
die( 1 );
|
2004-12-03 10:57:19 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Special handling for image description pages
|
2007-04-24 06:53:31 +00:00
|
|
|
*
|
|
|
|
|
* @addtogroup Media
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-09-01 09:59:53 +00:00
|
|
|
class ImagePage extends Article {
|
|
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
/* private */ var $img; // Image object this page is shown for
|
2008-05-20 03:26:59 +00:00
|
|
|
/* private */ var $current;
|
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
|
|
|
/* private */ var $repo;
|
2008-05-20 03:26:59 +00:00
|
|
|
/* private */ var $time;
|
|
|
|
|
/* private */ var $fileLoaded;
|
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-20 03:15:07 +00:00
|
|
|
function __construct( $title, $time = null ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
parent::__construct( $title );
|
2008-05-19 18:55:48 +00:00
|
|
|
|
|
|
|
|
global $wgRequest;
|
2008-05-20 03:15:07 +00:00
|
|
|
$time = is_null($time) ? $time : $wgRequest->getVal( 'filetimestamp' );
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->time = $time;
|
|
|
|
|
$this->dupes = null;
|
|
|
|
|
$this->repo = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function loadFile() {
|
|
|
|
|
if( $this->fileLoaded ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
$this->img = wfFindFile( $this->mTitle, $this->time );
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( !$this->img ) {
|
2008-02-03 08:10:05 +00:00
|
|
|
$this->img = wfLocalFile( $this->mTitle );
|
2008-02-03 08:43:58 +00:00
|
|
|
$this->current = $this->img;
|
|
|
|
|
} else {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->current = $this->time ? wfLocalFile( $this->mTitle ) : $this->img;
|
2007-05-30 21:02:32 +00:00
|
|
|
}
|
2008-05-15 19:17:21 +00:00
|
|
|
$this->repo = $this->img->getRepo();
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->fileLoaded = true;
|
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
|
|
|
|
|
*/
|
2005-07-03 04:56:53 +00:00
|
|
|
function render() {
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
function view() {
|
2007-01-17 05:01:54 +00:00
|
|
|
global $wgOut, $wgShowEXIF, $wgRequest, $wgUser;
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2008-05-14 11:52:59 +00:00
|
|
|
if ( $this->mTitle->getNamespace() == NS_IMAGE && $this->img->getRedirected() ) {
|
2008-05-11 19:49:08 +00:00
|
|
|
if ( $this->mTitle->getDBkey() == $this->img->getName() ) {
|
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.
|
2008-05-11 19:49:08 +00:00
|
|
|
return Article::view();
|
|
|
|
|
} 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() );
|
|
|
|
|
$this->viewRedirect( Title::makeTitle( NS_IMAGE, $this->img->getName() ),
|
|
|
|
|
/* $overwriteSubtitle */ true, /* $forceKnown */ true );
|
|
|
|
|
$this->viewUpdates();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-05-08 20:55:13 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
$diff = $wgRequest->getVal( 'diff' );
|
|
|
|
|
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
|
2005-05-05 02:39:21 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
if ( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) )
|
|
|
|
|
return Article::view();
|
2005-05-05 02:39:21 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
if ($wgShowEXIF && $this->img->exists()) {
|
2008-04-14 07:45:50 +00:00
|
|
|
// FIXME: bad interface, see note on MediaHandler::formatMetadata().
|
2007-07-28 01:15:35 +00:00
|
|
|
$formattedMetadata = $this->img->formatMetadata();
|
|
|
|
|
$showmeta = $formattedMetadata !== false;
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
$showmeta = false;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
if ($this->img->exists())
|
|
|
|
|
$wgOut->addHTML($this->showTOC($showmeta));
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-01-17 05:01:54 +00:00
|
|
|
$this->openShowImage();
|
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()
|
|
|
|
|
if ( $this->getID() ) {
|
2005-04-17 08:30:15 +00:00
|
|
|
Article::view();
|
2007-01-17 05:01:54 +00:00
|
|
|
} else {
|
|
|
|
|
# Just need to set the right headers
|
|
|
|
|
$wgOut->setArticleFlag( true );
|
2008-02-06 00:55:52 +00:00
|
|
|
$wgOut->setRobotpolicy( 'noindex,nofollow' );
|
2007-01-17 05:01:54 +00:00
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
|
|
|
|
$this->viewUpdates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show shared description, if needed
|
|
|
|
|
if ( $this->mExtraDescription ) {
|
2008-02-18 07:25:35 +00:00
|
|
|
$fol = wfMsgNoTrans( 'shareddescriptionfollows' );
|
2007-03-18 03:44:32 +00:00
|
|
|
if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
|
2008-02-18 07:47:46 +00:00
|
|
|
$wgOut->addWikiText( $fol );
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
|
2008-04-28 16:28:07 +00:00
|
|
|
} else {
|
|
|
|
|
$this->checkSharedConflict();
|
2007-01-17 05:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->closeShowImage();
|
|
|
|
|
$this->imageHistory();
|
2008-05-14 15:11:48 +00:00
|
|
|
// TODO: Cleanup the following
|
2008-05-15 19:17:21 +00:00
|
|
|
|
|
|
|
|
$wgOut->addHTML( Xml::element( 'h2',
|
|
|
|
|
array( 'id' => 'filelinks' ),
|
|
|
|
|
wfMsg( 'imagelinks' ) ) . "\n" );
|
2008-05-14 15:11:48 +00:00
|
|
|
$this->imageDupes();
|
|
|
|
|
// TODO: We may want to find local images redirecting to a foreign
|
|
|
|
|
// file: "The following local files redirect to this file"
|
2008-05-15 19:17:21 +00:00
|
|
|
if ( $this->img->isLocal() ) $this->imageRedirects();
|
|
|
|
|
$this->imageLinks();
|
2007-01-17 05:01:54 +00:00
|
|
|
|
2007-07-28 01:15:35 +00:00
|
|
|
if ( $showmeta ) {
|
2007-01-17 05:01:54 +00:00
|
|
|
global $wgStylePath, $wgStyleVersion;
|
|
|
|
|
$expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
|
|
|
|
|
$collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
|
2007-01-17 18:42:04 +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 ) );
|
2008-05-10 11:21:16 +00:00
|
|
|
$wgOut->addScriptFile( 'metadata.js' );
|
2007-01-17 05:01:54 +00:00
|
|
|
$wgOut->addHTML(
|
|
|
|
|
"<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
|
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();
|
|
|
|
|
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();
|
2008-05-20 03:26:59 +00:00
|
|
|
if ( $from == $to ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2008-05-10 11:12:53 +00:00
|
|
|
return $this->mRedirectTarget = Title::makeTitle( NS_IMAGE, $to );
|
2008-05-08 20:55:13 +00:00
|
|
|
}
|
2008-05-08 21:25:12 +00:00
|
|
|
public function followRedirect() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
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();
|
2008-05-20 03:26:59 +00:00
|
|
|
if ( $from == $to ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2008-05-10 11:12:53 +00:00
|
|
|
return Title::makeTitle( NS_IMAGE, $to );
|
2008-05-08 21:25:12 +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();
|
2008-05-09 10:42:49 +00:00
|
|
|
if ( $this->img->isLocal() )
|
2008-05-09 19:48:32 +00:00
|
|
|
return parent::isRedirect( $text );
|
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
|
|
|
|
|
|
|
|
public function getDuplicates() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
if ( !is_null($this->dupes) ) {
|
|
|
|
|
return $this->dupes;
|
|
|
|
|
}
|
|
|
|
|
if ( !( $hash = $this->img->getSha1() ) ) {
|
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
|
|
|
|
|
$self = $this->img->getRepoName().':'.$this->img->getName();
|
|
|
|
|
$size = $this->img->getSize();
|
|
|
|
|
foreach ( $dupes as $index => $file ) {
|
|
|
|
|
$key = $file->getRepoName().':'.$file->getName();
|
|
|
|
|
if ( $key == $self )
|
|
|
|
|
unset( $dupes[$index] );
|
|
|
|
|
if ( $file->getSize() != $size )
|
|
|
|
|
unset( $dupes[$index] );
|
|
|
|
|
}
|
|
|
|
|
return $this->dupes = $dupes;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-29 19:45:49 +00:00
|
|
|
|
2005-05-05 02:39:21 +00:00
|
|
|
/**
|
|
|
|
|
* Create the TOC
|
|
|
|
|
*
|
|
|
|
|
* @access private
|
|
|
|
|
*
|
|
|
|
|
* @param bool $metadata Whether or not to show the metadata link
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function showTOC( $metadata ) {
|
|
|
|
|
global $wgLang;
|
2005-05-05 01:44:17 +00:00
|
|
|
$r = '<ul id="filetoc">
|
2005-11-28 23:56:35 +00:00
|
|
|
<li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
|
2007-07-29 18:51:36 +00:00
|
|
|
<li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
|
2008-05-05 22:14:55 +00:00
|
|
|
<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
|
2007-07-07 02:00:02 +00:00
|
|
|
($metadata ? ' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
|
2005-05-09 09:50:45 +00:00
|
|
|
</ul>';
|
2005-05-05 02:39:21 +00:00
|
|
|
return $r;
|
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.
|
|
|
|
|
*
|
2008-04-14 07:45:50 +00:00
|
|
|
* 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
|
|
|
*
|
2005-05-05 02:39:21 +00:00
|
|
|
* @access private
|
2005-07-03 04:40:07 +00:00
|
|
|
*
|
2005-05-05 02:39:21 +00:00
|
|
|
* @param array $exif The array containing the EXIF data
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2007-07-28 01:15:35 +00:00
|
|
|
function makeMetadataTable( $metadata ) {
|
2005-11-28 23:56:35 +00:00
|
|
|
$r = wfMsg( 'metadata-help' ) . "\n\n";
|
|
|
|
|
$r .= "{| 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 ) {
|
2007-07-28 01:15:35 +00:00
|
|
|
$class = Sanitizer::escapeId( $v['id'] );
|
|
|
|
|
if( $type == 'collapsed' ) {
|
|
|
|
|
$class .= ' collapsable';
|
|
|
|
|
}
|
|
|
|
|
$r .= "|- class=\"$class\"\n";
|
|
|
|
|
$r .= "!| {$v['name']}\n";
|
|
|
|
|
$r .= "|| {$v['value']}\n";
|
2005-11-28 23:56:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$r .= '|}';
|
|
|
|
|
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
|
|
|
*/
|
2006-01-13 00:29:20 +00:00
|
|
|
function getContent() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2007-05-30 21:02:32 +00:00
|
|
|
if( $this->img && !$this->img->isLocal() && 0 == $this->getID() ) {
|
2005-05-20 22:41:17 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
2006-01-13 00:29:20 +00:00
|
|
|
return Article::getContent();
|
2005-05-20 22:41:17 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-04 18:27:59 +00:00
|
|
|
function openShowImage() {
|
2007-10-30 09:40:35 +00:00
|
|
|
global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgContLang;
|
2005-12-04 18:27:59 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
|
|
|
|
|
2005-09-13 01:27:21 +00:00
|
|
|
$full_url = $this->img->getURL();
|
2007-04-20 12:31:36 +00:00
|
|
|
$linkAttribs = false;
|
2006-12-14 20:28:38 +00:00
|
|
|
$sizeSel = intval( $wgUser->getOption( 'imagesize') );
|
2004-12-21 03:21:41 +00:00
|
|
|
if( !isset( $wgImageLimits[$sizeSel] ) ) {
|
|
|
|
|
$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).
|
|
|
|
|
if( !isset( $wgImageLimits[$sizeSel] ) ) {
|
|
|
|
|
// 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
|
|
|
|
2004-05-08 18:55:22 +00:00
|
|
|
if ( $this->img->exists() ) {
|
2005-05-21 07:46:17 +00:00
|
|
|
# image
|
2006-08-13 17:34:48 +00:00
|
|
|
$page = $wgRequest->getIntOrNull( 'page' );
|
2007-04-20 12:31:36 +00:00
|
|
|
if ( is_null( $page ) ) {
|
|
|
|
|
$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
|
|
|
}
|
2007-02-27 18:27:11 +00:00
|
|
|
$width_orig = $this->img->getWidth();
|
|
|
|
|
$width = $width_orig;
|
|
|
|
|
$height_orig = $this->img->getHeight();
|
|
|
|
|
$height = $height_orig;
|
|
|
|
|
$mime = $this->img->getMimeType();
|
2005-05-21 07:46:17 +00:00
|
|
|
$showLink = false;
|
2007-04-20 12:31:36 +00:00
|
|
|
$linkAttribs = array( 'href' => $full_url );
|
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
|
|
|
$longDesc = $this->img->getLongDesc();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
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
|
|
|
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
|
2007-05-16 19:52:22 +00:00
|
|
|
|
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
|
|
|
if ( $this->img->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
|
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
|
|
|
#$msgsize = wfMsgHtml('file-info-size', $width_orig, $height_orig, $sk->formatSize( $this->img->getSize() ), $mime );
|
2005-12-04 08:52:01 +00:00
|
|
|
# We'll show a thumbnail of this image
|
|
|
|
|
if ( $width > $maxWidth || $height > $maxHeight ) {
|
|
|
|
|
# Calculate the thumbnail size.
|
|
|
|
|
# First case, the limiting factor is the width, not the height.
|
|
|
|
|
if ( $width / $height >= $maxWidth / $maxHeight ) {
|
|
|
|
|
$height = round( $height * $maxWidth / $width);
|
|
|
|
|
$width = $maxWidth;
|
|
|
|
|
# Note that $height <= $maxHeight now.
|
|
|
|
|
} else {
|
|
|
|
|
$newwidth = floor( $width * $maxHeight / $height);
|
|
|
|
|
$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' );
|
|
|
|
|
$msgsmall = wfMsgExt( 'show-big-image-thumb',
|
2007-10-30 11:57:39 +00:00
|
|
|
array( 'parseinline' ), $wgLang->formatNum( $width ), $wgLang->formatNum( $height ) );
|
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
|
|
|
$msgbig = htmlspecialchars( $this->img->getName() );
|
|
|
|
|
$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;
|
|
|
|
|
$thumbnail = $this->img->transform( $params );
|
2005-12-04 08:52:01 +00:00
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
$anchorclose = "<br />";
|
|
|
|
|
if( $this->img->mustRender() ) {
|
2005-09-13 01:27:21 +00:00
|
|
|
$showLink = true;
|
2007-04-20 12:31:36 +00:00
|
|
|
} else {
|
2008-04-14 07:45:50 +00:00
|
|
|
$anchorclose .=
|
2007-04-27 22:04:01 +00:00
|
|
|
$msgsmall .
|
2007-10-30 09:40:35 +00:00
|
|
|
'<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . "$dirmark " . $longDesc;
|
2004-08-17 21:07:14 +00:00
|
|
|
}
|
2006-08-13 17:34:48 +00:00
|
|
|
|
|
|
|
|
if ( $this->img->isMultipage() ) {
|
|
|
|
|
$wgOut->addHTML( '<table class="multipageimage"><tr><td>' );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-20 12:31:36 +00:00
|
|
|
if ( $thumbnail ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$options = array(
|
2007-08-31 02:51:23 +00:00
|
|
|
'alt' => $this->img->getTitle()->getPrefixedText(),
|
|
|
|
|
'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 ) .
|
2007-04-20 12:31:36 +00:00
|
|
|
$anchorclose . '</div>' );
|
|
|
|
|
}
|
2006-08-13 17:34:48 +00:00
|
|
|
|
|
|
|
|
if ( $this->img->isMultipage() ) {
|
2007-01-26 12:00:04 +00:00
|
|
|
$count = $this->img->pageCount();
|
|
|
|
|
|
|
|
|
|
if ( $page > 1 ) {
|
|
|
|
|
$label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
|
2007-05-04 14:27:52 +00:00
|
|
|
$link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
|
2008-04-14 07:45:50 +00:00
|
|
|
$thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $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 = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $page < $count ) {
|
|
|
|
|
$label = wfMsg( 'imgmultipagenext' );
|
2007-05-04 14:27:52 +00:00
|
|
|
$link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) );
|
2008-04-14 07:45:50 +00:00
|
|
|
$thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $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();',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$option = array();
|
2007-01-26 12:00:04 +00:00
|
|
|
for ( $i=1; $i <= $count; $i++ ) {
|
2008-05-10 11:56:02 +00:00
|
|
|
$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 ) .
|
|
|
|
|
Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
|
|
|
|
|
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 {
|
2005-05-21 07:46:17 +00:00
|
|
|
#if direct link is allowed but it's not a renderable image, show an icon.
|
|
|
|
|
if ($this->img->isSafeFile()) {
|
|
|
|
|
$icon= $this->img->iconThumb();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-08-31 02:51:23 +00:00
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file">' .
|
|
|
|
|
$icon->toHtml( array( 'desc-link' => true ) ) .
|
|
|
|
|
'</div>' );
|
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
|
|
|
|
|
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
if ($showLink) {
|
2007-03-05 19:53:41 +00:00
|
|
|
$filename = wfEscapeWikiText( $this->img->getName() );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
if (!$this->img->isSafeFile()) {
|
2008-02-18 07:25:35 +00:00
|
|
|
$warning = wfMsgNoTrans( 'mediawarning' );
|
2007-05-30 21:02:32 +00:00
|
|
|
$wgOut->addWikiText( <<<EOT
|
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
|
|
|
<div class="fullMedia">
|
2006-07-05 19:43:06 +00:00
|
|
|
<span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
|
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
|
|
|
<span class="fileInfo"> $longDesc</span>
|
2005-08-12 04:44:43 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<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
|
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
|
|
|
<div class="fullMedia">
|
|
|
|
|
[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $longDesc</span>
|
2005-08-12 04:44:43 +00:00
|
|
|
</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
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
if(!$this->img->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
|
2005-08-12 17:18:53 +00:00
|
|
|
|
2006-10-30 06:25:31 +00:00
|
|
|
$title = SpecialPage::getTitleFor( 'Upload' );
|
2006-11-08 07:12:03 +00:00
|
|
|
$link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
|
2005-08-12 17:18:53 +00:00
|
|
|
'wpDestFile=' . urlencode( $this->img->getName() ) );
|
|
|
|
|
$wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) );
|
2004-01-12 00:55:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
*/
|
2005-07-03 04:46:44 +00:00
|
|
|
function printSharedImageText() {
|
2007-05-30 21:02:32 +00:00
|
|
|
global $wgOut, $wgUser;
|
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();
|
2008-02-19 16:29:28 +00:00
|
|
|
$s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml( 'sharedupload' );
|
|
|
|
|
if ( $descUrl ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2008-02-19 16:29:28 +00:00
|
|
|
$link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) );
|
|
|
|
|
$msg = ( $descText ) ? 'shareduploadwiki-desc' : 'shareduploadwiki';
|
|
|
|
|
$msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link );
|
|
|
|
|
if ( $msg != '-' ) {
|
|
|
|
|
# Show message only if not voided by local sysops
|
|
|
|
|
$s .= $msg;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
$s .= "</div>";
|
2008-02-19 16:29:28 +00:00
|
|
|
$wgOut->addHTML( $s );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $descText ) {
|
|
|
|
|
$this->mExtraDescription = $descText;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-15 19:17:21 +00:00
|
|
|
/*
|
|
|
|
|
* Check for files with the same name on the foreign repos.
|
|
|
|
|
*/
|
2008-04-28 16:28:07 +00:00
|
|
|
function checkSharedConflict() {
|
2008-05-01 22:16:23 +00:00
|
|
|
global $wgOut, $wgUser;
|
2008-05-20 03:26:59 +00:00
|
|
|
|
2008-05-01 22:16:23 +00:00
|
|
|
$repoGroup = RepoGroup::singleton();
|
|
|
|
|
if( !$repoGroup->hasForeignRepos() ) {
|
2008-04-28 16:28:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-05-20 03:26:59 +00:00
|
|
|
|
|
|
|
|
$this->loadFile();
|
2008-05-01 22:16:23 +00:00
|
|
|
if( !$this->img->isLocal() ) {
|
2008-04-28 16:28:07 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-01 22:16:23 +00:00
|
|
|
$this->dupFile = null;
|
|
|
|
|
$repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) );
|
|
|
|
|
|
|
|
|
|
if( !$this->dupFile )
|
2008-04-28 16:28:07 +00:00
|
|
|
return;
|
2008-05-01 22:16:23 +00:00
|
|
|
$dupfile = $this->dupFile;
|
2008-04-28 16:28:07 +00:00
|
|
|
$same = (
|
|
|
|
|
($this->img->getSha1() == $dupfile->getSha1()) &&
|
|
|
|
|
($this->img->getSize() == $dupfile->getSize())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
$descUrl = $dupfile->getDescriptionUrl();
|
|
|
|
|
if( $same ) {
|
|
|
|
|
$link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) );
|
|
|
|
|
$wgOut->addHTML( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
|
|
|
|
|
} else {
|
|
|
|
|
$link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
|
|
|
|
|
$wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-01 22:16:23 +00:00
|
|
|
function checkSharedConflictCallback( $repo ) {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2008-05-01 22:16:23 +00:00
|
|
|
$dupfile = $repo->newFile( $this->img->getTitle() );
|
2008-05-20 03:26:59 +00:00
|
|
|
if( $dupfile->exists() ) {
|
2008-05-01 22:16:23 +00:00
|
|
|
$this->dupFile = $dupfile;
|
2008-05-20 03:26:59 +00:00
|
|
|
}
|
2008-05-01 22:16:23 +00:00
|
|
|
return $dupfile->exists();
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
function getUploadUrl() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2006-10-30 06:25:31 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2008-02-13 05:59:14 +00:00
|
|
|
return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
|
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.
|
|
|
|
|
*/
|
|
|
|
|
function uploadLinksBox() {
|
2005-07-03 05:21:06 +00:00
|
|
|
global $wgUser, $wgOut;
|
|
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2007-05-30 21:02:32 +00:00
|
|
|
if( !$this->img->isLocal() )
|
2005-07-03 05:21:06 +00:00
|
|
|
return;
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
$wgOut->addHtml( '<br /><ul>' );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# "Upload a new version of this file" link
|
2007-05-22 02:22:59 +00:00
|
|
|
if( UploadForm::userCanReUpload($wgUser,$this->img->name) ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$ulink = $sk->makeExternalLink( $this->getUploadUrl(), wfMsg( 'uploadnewversion-linktext' ) );
|
2007-02-09 22:19:54 +00:00
|
|
|
$wgOut->addHtml( "<li><div class='plainlinks'>{$ulink}</div></li>" );
|
2005-09-05 06:16:48 +00:00
|
|
|
}
|
2008-03-19 16:58:56 +00:00
|
|
|
|
|
|
|
|
# Link to Special:FileDuplicateSearch
|
|
|
|
|
$dupeLink = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'FileDuplicateSearch', $this->mTitle->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) );
|
|
|
|
|
$wgOut->addHtml( "<li>{$dupeLink}</li>" );
|
|
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
# External editing link
|
2007-01-17 18:42:04 +00:00
|
|
|
$elink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' );
|
2006-05-22 09:28:03 +00:00
|
|
|
$wgOut->addHtml( '<li>' . $elink . '<div>' . wfMsgWikiHtml( 'edit-externally-help' ) . '</div></li>' );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
$wgOut->addHtml( '</ul>' );
|
2005-03-24 13:30:09 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-01-12 00:55:01 +00:00
|
|
|
function closeShowImage()
|
|
|
|
|
{
|
2004-01-29 23:06:01 +00:00
|
|
|
# For overloading
|
2005-07-03 04:40:07 +00:00
|
|
|
|
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.
|
|
|
|
|
*/
|
2006-11-08 07:12:03 +00:00
|
|
|
function imageHistory()
|
|
|
|
|
{
|
|
|
|
|
global $wgUser, $wgOut, $wgUseExternalEditor;
|
|
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2008-01-20 11:05:30 +00:00
|
|
|
if ( $this->img->exists() ) {
|
2008-05-19 18:55:48 +00:00
|
|
|
$list = new ImageHistoryList( $sk, $this->current, $this->img );
|
2008-02-03 08:43:58 +00:00
|
|
|
$file = $this->current;
|
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
|
|
|
$dims = $file->getDimensionsString();
|
2008-05-17 00:08:31 +00:00
|
|
|
$s = $list->beginImageHistoryList();
|
|
|
|
|
$s .= $list->imageHistoryLine( true, $file );
|
2008-03-19 18:09:20 +00:00
|
|
|
// old image versions
|
2008-01-20 06:48:57 +00:00
|
|
|
$hist = $this->img->getHistory();
|
|
|
|
|
foreach( $hist as $file ) {
|
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
|
|
|
$dims = $file->getDimensionsString();
|
2008-03-19 18:09:20 +00:00
|
|
|
$s .= $list->imageHistoryLine( false, $file );
|
2004-08-22 07:38:16 +00:00
|
|
|
}
|
2004-11-25 13:47:17 +00:00
|
|
|
$s .= $list->endImageHistoryList();
|
2004-08-22 17:24:50 +00:00
|
|
|
} else { $s=''; }
|
2003-09-01 09:59:53 +00:00
|
|
|
$wgOut->addHTML( $s );
|
2005-04-30 01:59:51 +00:00
|
|
|
|
2007-07-07 03:04:20 +00:00
|
|
|
$this->img->resetHistory(); // free db resources
|
|
|
|
|
|
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
|
|
|
|
|
if( $wgUseExternalEditor && $this->img->exists() ) {
|
2005-04-30 01:59:51 +00:00
|
|
|
$this->uploadLinksBox();
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-05 22:14:55 +00:00
|
|
|
function imageLinks()
|
|
|
|
|
{
|
|
|
|
|
global $wgUser, $wgOut;
|
2008-05-09 11:31:00 +00:00
|
|
|
|
|
|
|
|
$limit = 100;
|
2008-05-05 22:14:55 +00:00
|
|
|
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
|
2008-05-09 11:31:00 +00:00
|
|
|
$res = $dbr->select(
|
|
|
|
|
array( 'imagelinks', 'page' ),
|
|
|
|
|
array( 'page_namespace', 'page_title' ),
|
|
|
|
|
array( 'il_to' => $this->mTitle->getDBkey(), 'il_from = page_id' ),
|
|
|
|
|
__METHOD__,
|
|
|
|
|
array( 'LIMIT' => $limit + 1)
|
|
|
|
|
);
|
2008-05-05 22:14:55 +00:00
|
|
|
|
|
|
|
|
if ( 0 == $dbr->numRows( $res ) ) {
|
2008-05-09 18:40:52 +00:00
|
|
|
$wgOut->addWikiMsg( 'nolinkstoimage' );
|
2008-05-05 22:14:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-05-15 18:38:39 +00:00
|
|
|
$wgOut->addWikiMsg( 'linkstoimage' );
|
2008-05-15 07:16:22 +00:00
|
|
|
$wgOut->addHTML( "<ul class='mw-imagepage-linktoimage'>\n" );
|
2008-05-05 22:14:55 +00:00
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
2008-05-09 11:31:00 +00:00
|
|
|
$count = 0;
|
|
|
|
|
while ( $s = $res->fetchObject() ) {
|
|
|
|
|
$count++;
|
|
|
|
|
if ( $count <= $limit ) {
|
|
|
|
|
// We have not yet reached the extra one that tells us there is more to fetch
|
|
|
|
|
$name = Title::makeTitle( $s->page_namespace, $s->page_title );
|
|
|
|
|
$link = $sk->makeKnownLinkObj( $name, "" );
|
|
|
|
|
$wgOut->addHTML( "<li>{$link}</li>\n" );
|
|
|
|
|
}
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
2008-05-09 11:31:00 +00:00
|
|
|
$res->free();
|
|
|
|
|
|
|
|
|
|
// Add a links to [[Special:Whatlinkshere]]
|
|
|
|
|
if ( $count > $limit )
|
2008-05-09 18:40:52 +00:00
|
|
|
$wgOut->addWikiMsg( 'morelinkstoimage', $this->mTitle->getPrefixedDBkey() );
|
2008-05-05 22:14:55 +00:00
|
|
|
}
|
2008-05-08 21:53:39 +00:00
|
|
|
|
|
|
|
|
function imageRedirects()
|
|
|
|
|
{
|
|
|
|
|
global $wgUser, $wgOut;
|
|
|
|
|
|
2008-05-15 19:17:21 +00:00
|
|
|
$redirects = $this->getTitle()->getRedirectsHere( NS_IMAGE );
|
|
|
|
|
if ( count( $redirects ) == 0 ) return;
|
2008-05-15 18:38:39 +00:00
|
|
|
|
2008-05-08 21:53:39 +00:00
|
|
|
|
2008-05-15 18:38:39 +00:00
|
|
|
$wgOut->addWikiMsg( 'redirectstofile' );
|
2008-05-15 07:16:22 +00:00
|
|
|
$wgOut->addHTML( "<ul class='mw-imagepage-redirectstofile'>\n" );
|
2008-05-08 21:53:39 +00:00
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
2008-05-15 19:17:21 +00:00
|
|
|
foreach ( $redirects as $title ) {
|
|
|
|
|
$link = $sk->makeKnownLinkObj( $title, "" );
|
2008-05-08 21:53:39 +00:00
|
|
|
$wgOut->addHTML( "<li>{$link}</li>\n" );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
2008-05-15 19:17:21 +00:00
|
|
|
|
2008-05-08 21:53:39 +00:00
|
|
|
}
|
2008-05-14 15:11:48 +00:00
|
|
|
|
|
|
|
|
function imageDupes() {
|
|
|
|
|
global $wgOut, $wgUser;
|
2008-05-20 03:26:59 +00:00
|
|
|
|
|
|
|
|
$this->loadFile();
|
|
|
|
|
|
2008-05-15 19:17:21 +00:00
|
|
|
$dupes = $this->getDuplicates();
|
2008-05-14 15:11:48 +00:00
|
|
|
if ( count( $dupes ) == 0 ) return;
|
2008-05-15 07:16:22 +00:00
|
|
|
|
2008-05-15 18:38:39 +00:00
|
|
|
$wgOut->addWikiMsg( 'duplicatesoffile' );
|
2008-05-15 07:16:22 +00:00
|
|
|
$wgOut->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
|
|
|
|
|
|
2008-05-14 15:11:48 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
foreach ( $dupes as $file ) {
|
2008-05-14 17:29:38 +00:00
|
|
|
if ( $file->isLocal() )
|
|
|
|
|
$link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
|
|
|
|
|
else
|
|
|
|
|
$link = $sk->makeExternalLink( $file->getDescriptionUrl(),
|
|
|
|
|
$file->getTitle()->getPrefixedText() );
|
2008-05-14 15:11:48 +00:00
|
|
|
$wgOut->addHTML( "<li>{$link}</li>\n" );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
|
|
|
|
}
|
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() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2007-08-17 20:53:17 +00:00
|
|
|
if( !$this->img->exists() || !$this->img->isLocal() ) {
|
|
|
|
|
// Standard article deletion
|
|
|
|
|
Article::delete();
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
function doPurge() {
|
2008-05-20 03:26:59 +00:00
|
|
|
$this->loadFile();
|
2006-03-01 01:27:36 +00:00
|
|
|
if( $this->img->exists() ) {
|
|
|
|
|
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 {
|
|
|
|
|
wfDebug( "ImagePage::doPurge no image\n" );
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
$wgOut->setPageTitle( wfMsg( "internalerror" ) );
|
|
|
|
|
$wgOut->setRobotpolicy( "noindex,nofollow" );
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
*
|
2007-04-24 06:53:31 +00:00
|
|
|
* @addtogroup 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
|
|
|
|
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
|
|
|
protected $img, $skin, $title, $repo;
|
2007-07-29 18:41:49 +00:00
|
|
|
|
2008-05-19 18:55:48 +00:00
|
|
|
public function __construct( $skin, $curimg, $img ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$this->skin = $skin;
|
2008-05-19 18:55:48 +00:00
|
|
|
$this->current = $curimg;
|
2007-05-30 21:02:32 +00:00
|
|
|
$this->img = $img;
|
2007-07-29 18:41:49 +00:00
|
|
|
$this->title = $img->getTitle();
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
public function beginImageHistoryList() {
|
|
|
|
|
global $wgOut, $wgUser;
|
|
|
|
|
return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
|
|
|
|
|
. $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
|
2008-05-19 15:21:29 +00:00
|
|
|
. Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
|
|
|
|
|
. '<tr><td></td>'
|
2008-05-19 18:55:48 +00:00
|
|
|
. ( $this->current->isLocal() && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deleterevision') ) ? '<td></td>' : '' )
|
2008-05-19 15:21:29 +00:00
|
|
|
. '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
|
|
|
|
|
. '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
|
|
|
|
|
. '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
|
|
|
|
|
. '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
|
|
|
|
|
. "</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
public function endImageHistoryList() {
|
|
|
|
|
return "</table>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-19 18:09:20 +00:00
|
|
|
public function imageHistoryLine( $iscur, $file ) {
|
|
|
|
|
global $wgUser, $wgLang, $wgContLang, $wgTitle;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-19 18:09:20 +00:00
|
|
|
$timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
|
|
|
|
|
$img = $iscur ? $file->getName() : $file->getArchiveName();
|
|
|
|
|
$user = $file->getUser('id');
|
|
|
|
|
$usertext = $file->getUser('text');
|
|
|
|
|
$size = $file->getSize();
|
|
|
|
|
$description = $file->getDescription();
|
|
|
|
|
$dims = $file->getDimensionsString();
|
|
|
|
|
$sha1 = $file->getSha1();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-05-19 18:55:48 +00:00
|
|
|
$local = $this->current->isLocal();
|
|
|
|
|
$row = $css = $selected = '';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Deletion link
|
2008-03-19 18:09:20 +00:00
|
|
|
if( $local && ($wgUser->isAllowed('delete') || $wgUser->isAllowed('deleterevision') ) ) {
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '<td>';
|
2008-03-19 18:09:20 +00:00
|
|
|
# Link to remove from history
|
|
|
|
|
if( $wgUser->isAllowed( 'delete' ) ) {
|
|
|
|
|
$q = array();
|
|
|
|
|
$q[] = 'action=delete';
|
|
|
|
|
if( !$iscur )
|
|
|
|
|
$q[] = 'oldimage=' . urlencode( $img );
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= $this->skin->makeKnownLinkObj(
|
2008-03-19 18:09:20 +00:00
|
|
|
$this->title,
|
|
|
|
|
wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
|
|
|
|
|
implode( '&', $q )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
# Link to hide content
|
|
|
|
|
if( $wgUser->isAllowed( 'deleterevision' ) ) {
|
2008-05-19 15:21:29 +00:00
|
|
|
if( $wgUser->isAllowed('delete') ) {
|
|
|
|
|
$row .= '<br/>';
|
|
|
|
|
}
|
2008-03-19 18:09:20 +00:00
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
// If file is top revision or locked from this user, don't link
|
|
|
|
|
if( $iscur || !$file->userCan(File::DELETED_RESTRICTED) ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$del = wfMsgHtml( 'rev-delundel' );
|
2008-03-19 18:09:20 +00:00
|
|
|
} else {
|
|
|
|
|
// If the file was hidden, link to sha-1
|
|
|
|
|
list($ts,$name) = explode('!',$img,2);
|
|
|
|
|
$del = $this->skin->makeKnownLinkObj( $revdel, wfMsg( 'rev-delundel' ),
|
|
|
|
|
'target=' . urlencode( $wgTitle->getPrefixedText() ) .
|
|
|
|
|
'&oldimage=' . urlencode( $ts ) );
|
|
|
|
|
// Bolden oversighted content
|
|
|
|
|
if( $file->isDeleted(File::DELETED_RESTRICTED) )
|
|
|
|
|
$del = "<strong>$del</strong>";
|
|
|
|
|
}
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= "<tt style='white-space: nowrap;'><small>$del</small></tt>";
|
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>';
|
2007-07-29 18:41:49 +00:00
|
|
|
if( $iscur ) {
|
2008-02-05 12:40:41 +00:00
|
|
|
$row .= wfMsgHtml( 'filehist-current' );
|
2007-07-29 18:41:49 +00:00
|
|
|
} elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
|
2008-03-19 18:09:20 +00:00
|
|
|
if( $file->isDeleted(File::DELETED_FILE) ) {
|
|
|
|
|
$row .= wfMsgHtml('filehist-revert');
|
|
|
|
|
} else {
|
|
|
|
|
$q = array();
|
|
|
|
|
$q[] = 'action=revert';
|
|
|
|
|
$q[] = 'oldimage=' . urlencode( $img );
|
|
|
|
|
$q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
|
|
|
|
|
$row .= $this->skin->makeKnownLinkObj( $this->title,
|
|
|
|
|
wfMsgHtml( 'filehist-revert' ),
|
|
|
|
|
implode( '&', $q ) );
|
|
|
|
|
}
|
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
|
2008-05-19 18:55:48 +00:00
|
|
|
if( $file->getTimestamp() === $this->img->getTimestamp() ) {
|
|
|
|
|
$selected = "class='filehistory-selected'";
|
|
|
|
|
}
|
|
|
|
|
$row .= "<td $selected style='white-space: nowrap;'>";
|
2008-03-19 18:09:20 +00:00
|
|
|
if( !$file->userCan(File::DELETED_FILE) ) {
|
|
|
|
|
# Don't link to unviewable files
|
|
|
|
|
$row .= '<span class="history-deleted">' . $wgLang->timeAndDate( $timestamp, true ) . '</span>';
|
|
|
|
|
} else if( $file->isDeleted(File::DELETED_FILE) ) {
|
|
|
|
|
$revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
|
|
|
|
|
# Make a link to review the image
|
2008-04-14 07:45:50 +00:00
|
|
|
$url = $this->skin->makeKnownLinkObj( $revdel, $wgLang->timeAndDate( $timestamp, true ),
|
2008-05-19 18:55:48 +00:00
|
|
|
"target=".$wgTitle->getPrefixedText()."&file=$sha1.".$this->current->getExtension() );
|
2008-03-19 18:09:20 +00:00
|
|
|
$row .= '<span class="history-deleted">'.$url.'</span>';
|
|
|
|
|
} 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
|
|
|
}
|
|
|
|
|
|
2008-05-17 00:08:31 +00:00
|
|
|
$row .= "</td><td>";
|
|
|
|
|
|
|
|
|
|
// Image dimensions
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= htmlspecialchars( $dims );
|
2008-05-17 00:08:31 +00:00
|
|
|
|
|
|
|
|
// File size
|
2008-05-19 02:34:42 +00:00
|
|
|
$row .= " <span style='white-space: nowrap;'>(" . $this->skin->formatSize( $size ) . ')</span>';
|
2007-07-30 21:09:31 +00:00
|
|
|
|
2007-07-29 18:41:49 +00:00
|
|
|
// Uploading user
|
2008-05-17 00:08:31 +00:00
|
|
|
$row .= '</td><td>';
|
2007-07-29 18:41:49 +00:00
|
|
|
if( $local ) {
|
2008-03-19 18:09:20 +00:00
|
|
|
// Hide deleted usernames
|
2008-05-19 15:21:29 +00:00
|
|
|
if( $file->isDeleted(File::DELETED_USER) ) {
|
2008-03-19 18:09:20 +00:00
|
|
|
$row .= '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
|
2008-05-19 15:21:29 +00:00
|
|
|
} else {
|
|
|
|
|
$row .= $this->skin->userLink( $user, $usertext ) . " <span style='white-space: nowrap;'>" .
|
|
|
|
|
$this->skin->userToolLinks( $user, $usertext ) . "</span>";
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
} else {
|
2007-07-29 18:41:49 +00:00
|
|
|
$row .= htmlspecialchars( $usertext );
|
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
|
2008-05-17 00:08:31 +00:00
|
|
|
if ( $file->isDeleted(File::DELETED_COMMENT) ) {
|
2008-05-19 15:21:29 +00:00
|
|
|
$row .= '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>';
|
2008-05-17 00:08:31 +00:00
|
|
|
} else {
|
2008-05-19 15:21:29 +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
|
|
|
|
2008-05-17 00:08:31 +00:00
|
|
|
wfRunHooks( 'ImagePageFileHistoryLine', array( &$file, &$row, &$css ) );
|
2008-05-19 18:55:48 +00:00
|
|
|
$trCSS = $css ? " class='$css'" : "";
|
|
|
|
|
|
|
|
|
|
return "<tr{$trCSS}>{$row}</tr>\n";
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
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
|
|
|
}
|