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
|
2005-07-04 02:59:23 +00:00
|
|
|
var $mExtraDescription = false;
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
function __construct( $title ) {
|
|
|
|
|
parent::__construct( $title );
|
|
|
|
|
$this->img = wfFindFile( $this->mTitle );
|
|
|
|
|
if ( !$this->img ) {
|
|
|
|
|
$this->img = wfLocalFile( $this->mTitle );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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 );
|
2006-01-23 18:37:46 +00:00
|
|
|
$wgOut->addSecondaryWikitext( $this->getContent() );
|
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;
|
2004-01-12 00:55:01 +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()) {
|
|
|
|
|
$exif = $this->img->getExifData();
|
|
|
|
|
$showmeta = count($exif) ? true : false;
|
|
|
|
|
} else {
|
|
|
|
|
$exif = false;
|
|
|
|
|
$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 );
|
|
|
|
|
$wgOut->setRobotpolicy( 'index,follow' );
|
|
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
|
|
|
|
$this->viewUpdates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show shared description, if needed
|
|
|
|
|
if ( $this->mExtraDescription ) {
|
|
|
|
|
$fol = wfMsg( 'shareddescriptionfollows' );
|
2007-03-18 03:44:32 +00:00
|
|
|
if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) {
|
2007-01-17 05:01:54 +00:00
|
|
|
$wgOut->addWikiText( $fol );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->closeShowImage();
|
|
|
|
|
$this->imageHistory();
|
|
|
|
|
$this->imageLinks();
|
|
|
|
|
|
|
|
|
|
if ( $exif ) {
|
|
|
|
|
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-01-17 05:01:54 +00:00
|
|
|
$wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
|
|
|
|
|
$wgOut->addHTML(
|
|
|
|
|
"<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js?$wgStyleVersion\"></script>\n" .
|
|
|
|
|
"<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
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>
|
2005-08-12 17:18:53 +00:00
|
|
|
<li><a href="#filehistory">' . wfMsgHtml( 'imghistory' ) . '</a></li>
|
2005-11-28 23:56:35 +00:00
|
|
|
<li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
|
|
|
|
|
($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.
|
|
|
|
|
*
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
|
|
|
|
function makeMetadataTable( $exif ) {
|
2005-11-28 23:56:35 +00:00
|
|
|
$r = wfMsg( 'metadata-help' ) . "\n\n";
|
|
|
|
|
$r .= "{| id=mw_metadata class=mw_metadata\n";
|
|
|
|
|
$visibleFields = $this->visibleMetadataFields();
|
2005-04-30 02:37:16 +00:00
|
|
|
foreach( $exif as $k => $v ) {
|
2005-05-09 12:50:40 +00:00
|
|
|
$tag = strtolower( $k );
|
2005-09-20 18:03:08 +00:00
|
|
|
$msg = wfMsg( "exif-$tag" );
|
2005-11-28 23:56:35 +00:00
|
|
|
$class = "exif-$tag";
|
|
|
|
|
if( !in_array( $tag, $visibleFields ) ) {
|
|
|
|
|
$class .= ' collapsable';
|
|
|
|
|
}
|
|
|
|
|
$r .= "|- class=\"$class\"\n";
|
|
|
|
|
$r .= "!| $msg\n";
|
|
|
|
|
$r .= "|| $v\n";
|
|
|
|
|
}
|
|
|
|
|
$r .= '|}';
|
|
|
|
|
return $r;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-11-28 23:56:35 +00:00
|
|
|
/**
|
|
|
|
|
* Get a list of EXIF metadata items which should be displayed when
|
|
|
|
|
* the metadata table is collapsed.
|
|
|
|
|
*
|
|
|
|
|
* @return array of strings
|
|
|
|
|
* @access private
|
|
|
|
|
*/
|
|
|
|
|
function visibleMetadataFields() {
|
|
|
|
|
$fields = array();
|
|
|
|
|
$lines = explode( "\n", wfMsgForContent( 'metadata-fields' ) );
|
|
|
|
|
foreach( $lines as $line ) {
|
2006-11-23 08:25:56 +00:00
|
|
|
$matches = array();
|
2005-11-28 23:56:35 +00:00
|
|
|
if( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
|
|
|
|
|
$fields[] = $matches[1];
|
|
|
|
|
}
|
2005-04-30 01:59:51 +00:00
|
|
|
}
|
2005-11-28 23:56:35 +00:00
|
|
|
return $fields;
|
2005-04-25 23:44:16 +00:00
|
|
|
}
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2005-05-20 22:41:17 +00:00
|
|
|
/**
|
|
|
|
|
* Overloading Article's getContent method.
|
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() {
|
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() {
|
2006-09-13 20:43:04 +00:00
|
|
|
global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang;
|
2005-12-04 18:27:59 +00:00
|
|
|
|
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();
|
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 );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2007-05-16 19:52:22 +00:00
|
|
|
wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this , &$wgOut ) ) ;
|
|
|
|
|
|
2005-07-03 04:40:07 +00:00
|
|
|
if ( $this->img->allowInlineDisplay() and $width and $height) {
|
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
|
2007-02-27 18:27:11 +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',
|
|
|
|
|
array( 'parseinline' ), $width, $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 {
|
|
|
|
|
$anchorclose .=
|
2007-04-27 22:04:01 +00:00
|
|
|
$msgsmall .
|
2007-04-20 12:31:36 +00:00
|
|
|
'<br />' . Xml::tags( 'a', $linkAttribs, $msgbig ) . ' ' . $msgsize;
|
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
|
|
|
$imgAttribs = array(
|
|
|
|
|
'border' => 0,
|
|
|
|
|
'alt' => $this->img->getTitle()->getPrefixedText()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $thumbnail ) {
|
|
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file">' .
|
|
|
|
|
$thumbnail->toHtml( $imgAttribs, $linkAttribs ) .
|
|
|
|
|
$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) );
|
2007-06-04 15:58:16 +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) );
|
2007-06-04 15:57:22 +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;
|
|
|
|
|
$select = '<form name="pageselector" action="' .
|
|
|
|
|
htmlspecialchars( $wgScript ) .
|
|
|
|
|
'" method="get" onchange="document.pageselector.submit();">' .
|
|
|
|
|
Xml::hidden( 'title', $this->getTitle()->getPrefixedDbKey() );
|
2007-01-26 12:00:04 +00:00
|
|
|
$select .= $wgOut->parse( wfMsg( 'imgmultigotopre' ), false ) .
|
|
|
|
|
' <select id="pageselector" name="page">';
|
|
|
|
|
for ( $i=1; $i <= $count; $i++ ) {
|
|
|
|
|
$select .= Xml::option( $wgLang->formatNum( $i ), $i,
|
|
|
|
|
$i == $page );
|
|
|
|
|
}
|
|
|
|
|
$select .= '</select>' . $wgOut->parse( wfMsg( 'imgmultigotopost' ), false ) .
|
|
|
|
|
'<input type="submit" value="' .
|
|
|
|
|
htmlspecialchars( wfMsg( 'imgmultigo' ) ) . '"></form>';
|
|
|
|
|
|
|
|
|
|
$wgOut->addHTML( '</td><td><div class="multipageimagenavbox">' .
|
2007-04-20 12:31:36 +00:00
|
|
|
"$select<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
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file"><a href="' . $full_url . '">' .
|
|
|
|
|
$icon->toHtml() .
|
|
|
|
|
'</a></div>' );
|
|
|
|
|
}
|
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-31 17:15:00 +00:00
|
|
|
// Workaround for incorrect MIME type on SVGs uploaded in previous versions
|
2006-11-22 00:25:57 +00:00
|
|
|
if ($mime == 'image/svg') $mime = 'image/svg+xml';
|
2007-03-05 19:53:41 +00:00
|
|
|
|
|
|
|
|
$filename = wfEscapeWikiText( $this->img->getName() );
|
|
|
|
|
$info = wfMsg( 'file-info', $sk->formatSize( $this->img->getSize() ), $mime );
|
2007-02-27 18:27:11 +00:00
|
|
|
$infores = '';
|
2007-03-05 19:53:41 +00:00
|
|
|
|
|
|
|
|
// Check for MIME type. Other types may have more information in the future.
|
|
|
|
|
if (substr($mime,0,9) == 'image/svg' ) {
|
|
|
|
|
$infores = wfMsg('file-svg', $width_orig, $height_orig ) . '<br />';
|
2007-02-27 18:27:11 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-07-05 19:43:06 +00:00
|
|
|
global $wgContLang;
|
|
|
|
|
$dirmark = $wgContLang->getDirMark();
|
2005-05-21 07:46:17 +00:00
|
|
|
if (!$this->img->isSafeFile()) {
|
2005-08-12 04:44:43 +00:00
|
|
|
$warning = wfMsg( 'mediawarning' );
|
2007-05-30 21:02:32 +00:00
|
|
|
$wgOut->addWikiText( <<<EOT
|
2007-02-27 18:27:11 +00:00
|
|
|
<div class="fullMedia">$infores
|
2006-07-05 19:43:06 +00:00
|
|
|
<span class="dangerousLink">[[Media:$filename|$filename]]</span>$dirmark
|
2007-02-27 18:27:11 +00:00
|
|
|
<span class="fileInfo"> $info</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
|
2007-02-27 18:27:11 +00:00
|
|
|
<div class="fullMedia">$infores
|
|
|
|
|
[[Media:$filename|$filename]]$dirmark <span class="fileInfo"> $info</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
|
|
|
|
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
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
$descUrl = $this->img->getDescriptionUrl();
|
|
|
|
|
$descText = $this->img->getDescriptionText();
|
|
|
|
|
$s = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml("sharedupload");
|
|
|
|
|
if ( $descUrl && !$descText) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2007-05-30 21:02:32 +00:00
|
|
|
$link = $sk->makeExternalLink( $descUrl, wfMsg('shareduploadwiki-linktext') );
|
|
|
|
|
$s .= " " . wfMsgWikiHtml('shareduploadwiki', $link);
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
$s .= "</div>";
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
function getUploadUrl() {
|
|
|
|
|
global $wgServer;
|
2006-10-30 06:25:31 +00:00
|
|
|
$uploadTitle = SpecialPage::getTitleFor( 'Upload' );
|
2005-04-17 08:30:15 +00:00
|
|
|
return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
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();
|
|
|
|
|
|
2006-05-22 09:28:03 +00:00
|
|
|
$wgOut->addHtml( '<br /><ul>' );
|
|
|
|
|
|
|
|
|
|
# "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
|
|
|
}
|
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>' );
|
|
|
|
|
|
|
|
|
|
$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
|
|
|
|
2004-05-08 18:55:22 +00:00
|
|
|
$line = $this->img->nextHistoryLine();
|
|
|
|
|
|
2004-08-22 07:38:16 +00:00
|
|
|
if ( $line ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$list = new ImageHistoryList( $sk, $this->img );
|
2004-11-25 13:47:17 +00:00
|
|
|
$s = $list->beginImageHistoryList() .
|
2005-08-02 13:35:19 +00:00
|
|
|
$list->imageHistoryLine( true, wfTimestamp(TS_MW, $line->img_timestamp),
|
2004-08-22 07:38:16 +00:00
|
|
|
$this->mTitle->getDBkey(), $line->img_user,
|
2005-09-19 12:54:18 +00:00
|
|
|
$line->img_user_text, $line->img_size, $line->img_description,
|
|
|
|
|
$line->img_width, $line->img_height
|
|
|
|
|
);
|
2005-04-30 01:59:51 +00:00
|
|
|
|
2004-08-22 07:38:16 +00:00
|
|
|
while ( $line = $this->img->nextHistoryLine() ) {
|
2004-11-25 13:47:17 +00:00
|
|
|
$s .= $list->imageHistoryLine( false, $line->img_timestamp,
|
2005-09-19 12:54:18 +00:00
|
|
|
$line->oi_archive_name, $line->img_user,
|
|
|
|
|
$line->img_user_text, $line->img_size, $line->img_description,
|
|
|
|
|
$line->img_width, $line->img_height
|
|
|
|
|
);
|
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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
function imageLinks()
|
|
|
|
|
{
|
|
|
|
|
global $wgUser, $wgOut;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2007-01-17 18:42:04 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
2004-12-19 08:00:50 +00:00
|
|
|
$page = $dbr->tableName( 'page' );
|
2004-07-10 03:09:26 +00:00
|
|
|
$imagelinks = $dbr->tableName( 'imagelinks' );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-12-19 08:00:50 +00:00
|
|
|
$sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
|
2005-08-02 13:35:19 +00:00
|
|
|
$dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id";
|
|
|
|
|
$sql = $dbr->limitResult($sql, 500, 0);
|
2005-03-27 22:29:37 +00:00
|
|
|
$res = $dbr->query( $sql, "ImagePage::imageLinks" );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-07-10 03:09:26 +00:00
|
|
|
if ( 0 == $dbr->numRows( $res ) ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2004-07-10 03:09:26 +00:00
|
|
|
while ( $s = $dbr->fetchObject( $res ) ) {
|
2004-12-19 08:00:50 +00:00
|
|
|
$name = Title::MakeTitle( $s->page_namespace, $s->page_title );
|
2006-11-08 07:12:03 +00:00
|
|
|
$link = $sk->makeKnownLinkObj( $name, "" );
|
2003-09-01 09:59:53 +00:00
|
|
|
$wgOut->addHTML( "<li>{$link}</li>\n" );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( "</ul>\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delete()
|
|
|
|
|
{
|
2004-03-29 14:48:07 +00:00
|
|
|
global $wgUser, $wgOut, $wgRequest;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-11-16 08:15:36 +00:00
|
|
|
$confirm = $wgRequest->wasPosted();
|
2006-07-11 19:58:08 +00:00
|
|
|
$reason = $wgRequest->getVal( 'wpReason' );
|
2004-03-29 14:48:07 +00:00
|
|
|
$image = $wgRequest->getVal( 'image' );
|
|
|
|
|
$oldimage = $wgRequest->getVal( 'oldimage' );
|
2007-03-16 16:01:07 +00:00
|
|
|
|
2005-07-03 04:40:07 +00:00
|
|
|
# Only sysops can delete images. Previously ordinary users could delete
|
2004-03-20 15:03:26 +00:00
|
|
|
# old revisions, but this is no longer the case.
|
2004-10-24 19:14:48 +00:00
|
|
|
if ( !$wgUser->isAllowed('delete') ) {
|
2006-08-08 13:58:25 +00:00
|
|
|
$wgOut->permissionRequired( 'delete' );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-07-01 21:15:31 +00:00
|
|
|
if ( $wgUser->isBlocked() ) {
|
2007-05-04 19:17:36 +00:00
|
|
|
$wgOut->blockedPage();
|
|
|
|
|
return;
|
2005-07-01 21:15:31 +00:00
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
$wgOut->readOnlyPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Better double-check that it hasn't been deleted yet!
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->setPagetitle( wfMsg( 'confirmdelete' ) );
|
2004-12-19 08:00:50 +00:00
|
|
|
if ( ( !is_null( $image ) )
|
|
|
|
|
&& ( '' == trim( $image ) ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showFatalError( wfMsg( 'cannotdelete' ) );
|
2004-12-19 08:00:50 +00:00
|
|
|
return;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-03-20 15:03:26 +00:00
|
|
|
# Deleting old images doesn't require confirmation
|
2004-03-29 14:48:07 +00:00
|
|
|
if ( !is_null( $oldimage ) || $confirm ) {
|
2005-02-21 01:56:50 +00:00
|
|
|
if( $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
|
2007-03-16 16:01:07 +00:00
|
|
|
$this->doDelete( $reason );
|
2005-02-21 01:56:50 +00:00
|
|
|
} else {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showFatalError( wfMsg( 'sessionfailure' ) );
|
2005-02-21 01:56:50 +00:00
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-03-29 14:48:07 +00:00
|
|
|
if ( !is_null( $image ) ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$q = '&image=' . urlencode( $image );
|
2004-03-29 14:48:07 +00:00
|
|
|
} else if ( !is_null( $oldimage ) ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$q = '&oldimage=' . urlencode( $oldimage );
|
2004-04-01 12:43:40 +00:00
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$q = '';
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2004-04-01 12:43:40 +00:00
|
|
|
return $this->confirmDelete( $q, $wgRequest->getText( 'wpReason' ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-11 19:58:08 +00:00
|
|
|
/*
|
|
|
|
|
* Delete an image.
|
|
|
|
|
* @param $reason User provided reason for deletion.
|
|
|
|
|
*/
|
2007-03-16 16:01:07 +00:00
|
|
|
function doDelete( $reason ) {
|
2006-11-23 08:25:56 +00:00
|
|
|
global $wgOut, $wgRequest;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-03-29 14:48:07 +00:00
|
|
|
$oldimage = $wgRequest->getVal( 'oldimage' );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-08-22 22:03:51 +00:00
|
|
|
if ( !is_null( $oldimage ) ) {
|
2005-02-21 01:56:50 +00:00
|
|
|
if ( strlen( $oldimage ) < 16 ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
2005-02-21 01:56:50 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
2005-02-21 01:56:50 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2007-03-16 16:01:07 +00:00
|
|
|
if ( !$this->doDeleteOldImage( $oldimage ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-08-22 22:03:51 +00:00
|
|
|
$deleted = $oldimage;
|
|
|
|
|
} else {
|
2007-03-16 16:01:07 +00:00
|
|
|
$ok = $this->img->delete( $reason );
|
2006-06-16 01:16:45 +00:00
|
|
|
if( !$ok ) {
|
2004-10-10 22:56:23 +00:00
|
|
|
# If the deletion operation actually failed, bug out:
|
2006-06-16 01:16:45 +00:00
|
|
|
$wgOut->showFileDeleteError( $this->img->getName() );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2006-03-28 05:09:33 +00:00
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
# Image itself is now gone, and database is cleaned.
|
|
|
|
|
# Now we remove the image description page.
|
2006-06-16 01:16:45 +00:00
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
$article = new Article( $this->mTitle );
|
2007-03-16 16:01:07 +00:00
|
|
|
$article->doDeleteArticle( $reason ); # ignore errors
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2006-06-16 01:16:45 +00:00
|
|
|
$deleted = $this->img->getName();
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2004-08-22 22:03:51 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
|
|
|
|
|
$wgOut->setRobotpolicy( 'noindex,nofollow' );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-06-22 21:38:15 +00:00
|
|
|
$loglink = '[[Special:Log/delete|' . wfMsg( 'deletionlog' ) . ']]';
|
2004-08-22 17:24:50 +00:00
|
|
|
$text = wfMsg( 'deletedtext', $deleted, $loglink );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-06-22 21:38:15 +00:00
|
|
|
$wgOut->addWikiText( $text );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
$wgOut->returnToMain( false, $this->mTitle->getPrefixedText() );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-07 06:40:24 +00:00
|
|
|
/**
|
|
|
|
|
* @return success
|
|
|
|
|
*/
|
2007-03-16 16:01:07 +00:00
|
|
|
function doDeleteOldImage( $oldimage )
|
2003-09-01 09:59:53 +00:00
|
|
|
{
|
|
|
|
|
global $wgOut;
|
|
|
|
|
|
2007-03-16 16:01:07 +00:00
|
|
|
$ok = $this->img->deleteOld( $oldimage, '' );
|
2006-06-16 01:16:45 +00:00
|
|
|
if( !$ok ) {
|
2004-10-10 22:56:23 +00:00
|
|
|
# If we actually have a file and can't delete it, throw an error.
|
2006-06-16 01:16:45 +00:00
|
|
|
# Something went awry...
|
|
|
|
|
$wgOut->showFileDeleteError( "$oldimage" );
|
2004-08-28 12:07:05 +00:00
|
|
|
} else {
|
|
|
|
|
# Log the deletion
|
|
|
|
|
$log = new LogPage( 'delete' );
|
|
|
|
|
$log->addEntry( 'delete', $this->mTitle, wfMsg('deletedrevision',$oldimage) );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2006-06-16 01:16:45 +00:00
|
|
|
return $ok;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-04 18:27:59 +00:00
|
|
|
function revert() {
|
2005-12-26 07:14:42 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-03-29 14:48:07 +00:00
|
|
|
$oldimage = $wgRequest->getText( 'oldimage' );
|
2003-09-01 09:59:53 +00:00
|
|
|
if ( strlen( $oldimage ) < 16 ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
2004-10-14 02:56:02 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showUnexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-10-14 02:56:02 +00:00
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
$wgOut->readOnlyPage();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-02-21 12:46:37 +00:00
|
|
|
if( $wgUser->isAnon() ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
|
2005-02-08 13:55:13 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2007-01-20 17:58:38 +00:00
|
|
|
if ( ! $this->mTitle->userCan( 'edit' ) ) {
|
2006-08-08 13:58:25 +00:00
|
|
|
$wgOut->readOnlyPage( $this->getContent(), true );
|
2004-08-05 04:30:29 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-07-01 21:15:31 +00:00
|
|
|
if ( $wgUser->isBlocked() ) {
|
2007-05-04 19:17:36 +00:00
|
|
|
$wgOut->blockedPage();
|
|
|
|
|
return;
|
2005-07-01 21:15:31 +00:00
|
|
|
}
|
2005-02-21 01:56:50 +00:00
|
|
|
if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$wgOut->showErrorPage( 'internalerror', 'sessionfailure' );
|
2005-02-21 01:56:50 +00:00
|
|
|
return;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
$sourcePath = $this->img->getArchiveVirtualUrl( $oldimage );
|
|
|
|
|
$result = $this->img->publish( $sourcePath );
|
2006-07-04 14:20:52 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( WikiError::isError( $result ) ) {
|
|
|
|
|
$this->showError( $result );
|
2006-06-07 06:40:24 +00:00
|
|
|
return;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2005-03-13 15:00:59 +00:00
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
# Record upload and update metadata cache
|
2007-05-30 21:02:32 +00:00
|
|
|
$this->img->recordUpload( $result, wfMsg( "reverted" ) );
|
2005-03-13 15:00:59 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
|
|
|
|
|
$wgOut->setRobotpolicy( 'noindex,nofollow' );
|
|
|
|
|
$wgOut->addHTML( wfMsg( 'imagereverted' ) );
|
2005-04-10 18:29:30 +00:00
|
|
|
|
2007-05-30 21:02:32 +00:00
|
|
|
$descTitle = $this->img->getTitle();
|
2005-04-10 18:29:30 +00:00
|
|
|
$wgOut->returnToMain( false, $descTitle->getPrefixedText() );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2006-03-01 01:27:36 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Override handling of action=purge
|
|
|
|
|
*/
|
|
|
|
|
function doPurge() {
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Display an error from a wikitext-formatted WikiError object
|
|
|
|
|
*/
|
|
|
|
|
function showError( WikiError $error ) {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
$wgOut->setPageTitle( wfMsg( "internalerror" ) );
|
|
|
|
|
$wgOut->setRobotpolicy( "noindex,nofollow" );
|
|
|
|
|
$wgOut->setArticleRelated( false );
|
|
|
|
|
$wgOut->enableClientCache( false );
|
|
|
|
|
$wgOut->addWikiText( $error->getMessage() );
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-27 19:51:47 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
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-05-30 21:02:32 +00:00
|
|
|
var $img, $skin;
|
|
|
|
|
function ImageHistoryList( $skin, $img ) {
|
|
|
|
|
$this->skin = $skin;
|
|
|
|
|
$this->img = $img;
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-11-25 13:47:17 +00:00
|
|
|
function beginImageHistoryList() {
|
2007-01-17 18:42:04 +00:00
|
|
|
$s = "\n" .
|
|
|
|
|
Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'imghistory' ) ) .
|
|
|
|
|
"\n<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
|
2004-11-25 13:47:17 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function endImageHistoryList() {
|
|
|
|
|
$s = "</ul>\n";
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2005-09-19 12:54:18 +00:00
|
|
|
function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
|
2005-12-30 04:52:50 +00:00
|
|
|
global $wgUser, $wgLang, $wgTitle, $wgContLang;
|
2004-11-25 13:47:17 +00:00
|
|
|
|
|
|
|
|
$datetime = $wgLang->timeanddate( $timestamp, true );
|
2007-01-17 18:42:04 +00:00
|
|
|
$del = wfMsgHtml( 'deleteimg' );
|
|
|
|
|
$delall = wfMsgHtml( 'deleteimgcompletely' );
|
|
|
|
|
$cur = wfMsgHtml( 'cur' );
|
2007-05-30 21:02:32 +00:00
|
|
|
$local = $this->img->isLocal();
|
2004-11-25 13:47:17 +00:00
|
|
|
|
|
|
|
|
if ( $iscur ) {
|
2007-05-30 21:02:32 +00:00
|
|
|
$url = htmlspecialchars( $this->img->getURL() );
|
2004-11-25 13:47:17 +00:00
|
|
|
$rlink = $cur;
|
2007-05-30 21:02:32 +00:00
|
|
|
if ( $local && $wgUser->isAllowed('delete') ) {
|
2006-11-08 07:12:03 +00:00
|
|
|
$link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
|
|
|
|
|
'&action=delete' );
|
|
|
|
|
$style = $this->skin->getInternalLinkAttributes( $link, $delall );
|
|
|
|
|
|
|
|
|
|
$dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
|
2004-11-25 13:47:17 +00:00
|
|
|
} else {
|
|
|
|
|
$dlink = $del;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2007-05-30 21:02:32 +00:00
|
|
|
$url = htmlspecialchars( $this->img->getArchiveUrl( $img ) );
|
|
|
|
|
if( $local && $wgUser->getID() != 0 && $wgTitle->userCan( 'edit' ) ) {
|
2005-02-21 01:56:50 +00:00
|
|
|
$token = urlencode( $wgUser->editToken( $img ) );
|
2006-11-08 07:12:03 +00:00
|
|
|
$rlink = $this->skin->makeKnownLinkObj( $wgTitle,
|
2007-01-17 18:42:04 +00:00
|
|
|
wfMsgHtml( 'revertimg' ), 'action=revert&oldimage=' .
|
2005-02-21 01:56:50 +00:00
|
|
|
urlencode( $img ) . "&wpEditToken=$token" );
|
2006-11-08 07:12:03 +00:00
|
|
|
$dlink = $this->skin->makeKnownLinkObj( $wgTitle,
|
2005-02-21 01:56:50 +00:00
|
|
|
$del, 'action=delete&oldimage=' . urlencode( $img ) .
|
|
|
|
|
"&wpEditToken=$token" );
|
2004-11-25 13:47:17 +00:00
|
|
|
} else {
|
|
|
|
|
# Having live active links for non-logged in users
|
|
|
|
|
# means that bots and spiders crawling our site can
|
|
|
|
|
# inadvertently change content. Baaaad idea.
|
2007-01-17 18:42:04 +00:00
|
|
|
$rlink = wfMsgHtml( 'revertimg' );
|
2004-11-25 13:47:17 +00:00
|
|
|
$dlink = $del;
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-05-30 21:02:32 +00:00
|
|
|
|
|
|
|
|
if ( $local ) {
|
|
|
|
|
$userlink = $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
|
|
|
|
|
} else {
|
|
|
|
|
$userlink = htmlspecialchars( $usertext );
|
|
|
|
|
}
|
2006-05-05 12:21:12 +00:00
|
|
|
$nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
|
|
|
|
|
$wgLang->formatNum( $size ) );
|
2007-01-17 18:42:04 +00:00
|
|
|
$widthheight = wfMsgHtml( 'widthheight', $width, $height );
|
2006-11-08 07:12:03 +00:00
|
|
|
$style = $this->skin->getInternalLinkAttributes( $url, $datetime );
|
2004-11-25 13:47:17 +00:00
|
|
|
|
2006-06-16 14:20:17 +00:00
|
|
|
$s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
|
2004-11-25 13:47:17 +00:00
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$s .= $this->skin->commentBlock( $description, $wgTitle );
|
2004-11-25 13:47:17 +00:00
|
|
|
$s .= "</li>\n";
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-13 15:55:59 +00:00
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
?>
|