2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
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' ) )
|
|
|
|
|
die();
|
|
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
require_once( 'Image.php' );
|
2004-08-13 15:55:59 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Special handling for image description pages
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
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
|
|
|
|
2005-07-03 04:56:53 +00:00
|
|
|
function render() {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
$wgOut->setArticleBodyOnly(true);
|
|
|
|
|
$wgOut->addWikitext($this->getContent(true));
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
function view() {
|
2005-05-05 02:39:21 +00:00
|
|
|
global $wgUseExternalEditor, $wgOut, $wgShowEXIF;
|
2004-01-12 00:55:01 +00:00
|
|
|
|
2005-05-08 16:19:12 +00:00
|
|
|
$this->img = new Image( $this->mTitle );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
if( $this->mTitle->getNamespace() == NS_IMAGE ) {
|
2005-05-05 02:39:21 +00:00
|
|
|
if ($wgShowEXIF && $this->img->exists()) {
|
|
|
|
|
$exif = $this->img->getExifData();
|
|
|
|
|
$showmeta = count($exif) ? true : false;
|
|
|
|
|
} else {
|
|
|
|
|
$exif = false;
|
|
|
|
|
$showmeta = false;
|
2005-04-30 01:59:51 +00:00
|
|
|
}
|
2005-05-05 02:39:21 +00:00
|
|
|
|
|
|
|
|
if ($this->img->exists())
|
|
|
|
|
$wgOut->addHTML($this->showTOC($showmeta));
|
|
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
$this->openShowImage();
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
# No need to display noarticletext, we use our own message, output in openShowImage()
|
2005-04-30 02:37:16 +00:00
|
|
|
if( $this->getID() ) {
|
2005-04-17 08:30:15 +00:00
|
|
|
Article::view();
|
|
|
|
|
} else {
|
|
|
|
|
# Just need to set the right headers
|
|
|
|
|
$wgOut->setArticleFlag( true );
|
|
|
|
|
$wgOut->setRobotpolicy( 'index,follow' );
|
|
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
|
|
|
|
$wgOut->addMetaTags();
|
|
|
|
|
$this->viewUpdates();
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-07-04 03:10:20 +00:00
|
|
|
if ($this->mExtraDescription) {
|
|
|
|
|
$fol = wfMsg('shareddescriptionfollows');
|
|
|
|
|
if ($fol != '-')
|
|
|
|
|
$wgOut->addWikiText(wfMsg('shareddescriptionfollows'));
|
|
|
|
|
$wgOut->addHTML($this->mExtraDescription);
|
|
|
|
|
}
|
2005-07-04 02:59:23 +00:00
|
|
|
|
2005-04-30 01:59:51 +00:00
|
|
|
$this->closeShowImage();
|
2003-09-01 09:59:53 +00:00
|
|
|
$this->imageHistory();
|
|
|
|
|
$this->imageLinks();
|
2005-11-28 23:56:35 +00:00
|
|
|
if( $exif ) {
|
|
|
|
|
global $wgStylePath;
|
|
|
|
|
$expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) );
|
|
|
|
|
$collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) );
|
|
|
|
|
$wgOut->addHTML( "<h2 id=\"metadata\">" . wfMsgHtml( 'metadata' ) . "</h2>\n" );
|
|
|
|
|
$wgOut->addWikiText( $this->makeMetadataTable( $exif ) );
|
|
|
|
|
$wgOut->addHTML(
|
|
|
|
|
"<script type=\"text/javascript\" src=\"$wgStylePath/common/metadata.js\"></script>\n" .
|
|
|
|
|
"<script type=\"text/javascript\">attachMetadataToggle('mw_metadata', '$expand', '$collapse');</script>\n" );
|
|
|
|
|
}
|
2005-04-17 08:30:15 +00:00
|
|
|
} else {
|
|
|
|
|
Article::view();
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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 ) {
|
|
|
|
|
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.
|
2005-07-03 04:40:07 +00:00
|
|
|
* Omit noarticletext if sharedupload
|
2005-05-20 22:41:17 +00:00
|
|
|
*
|
|
|
|
|
* @param $noredir If true, do not follow redirects
|
|
|
|
|
*/
|
|
|
|
|
function getContent( $noredir )
|
|
|
|
|
{
|
|
|
|
|
if ( $this->img && $this->img->fromSharedDirectory && 0 == $this->getID() ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
return Article::getContent( $noredir );
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 00:55:01 +00:00
|
|
|
function openShowImage()
|
|
|
|
|
{
|
2005-07-03 04:40:07 +00:00
|
|
|
global $wgOut, $wgUser, $wgImageLimits, $wgRequest,
|
|
|
|
|
$wgUseImageResize, $wgRepositoryBaseUrl,
|
|
|
|
|
$wgUseExternalEditor, $wgServer, $wgFetchCommonsDescriptions;
|
2005-09-13 01:27:21 +00:00
|
|
|
$full_url = $this->img->getURL();
|
2004-08-22 17:24:50 +00:00
|
|
|
$anchoropen = '';
|
|
|
|
|
$anchorclose = '';
|
2004-12-21 03:21:41 +00:00
|
|
|
|
|
|
|
|
if( $wgUser->getOption( 'imagesize' ) == '' ) {
|
|
|
|
|
$sizeSel = User::getDefaultOption( 'imagesize' );
|
|
|
|
|
} else {
|
2005-08-16 23:36:16 +00:00
|
|
|
$sizeSel = intval( $wgUser->getOption( 'imagesize' ) );
|
2004-12-21 03:21:41 +00:00
|
|
|
}
|
|
|
|
|
if( !isset( $wgImageLimits[$sizeSel] ) ) {
|
|
|
|
|
$sizeSel = User::getDefaultOption( 'imagesize' );
|
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];
|
2005-04-17 08:30:15 +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
|
|
|
|
|
$width = $this->img->getWidth();
|
|
|
|
|
$height = $this->img->getHeight();
|
|
|
|
|
$showLink = false;
|
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
|
2005-08-12 17:18:53 +00:00
|
|
|
$msg = wfMsgHtml('showbigimage', $width, $height, intval( $this->img->getSize()/1024 ) );
|
2004-12-21 03:21:41 +00:00
|
|
|
if ( $width > $maxWidth ) {
|
2004-09-10 00:53:31 +00:00
|
|
|
$height = floor( $height * $maxWidth / $width );
|
|
|
|
|
$width = $maxWidth;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2004-12-21 03:21:41 +00:00
|
|
|
if ( $height > $maxHeight ) {
|
2004-09-10 00:53:31 +00:00
|
|
|
$width = floor( $width * $maxHeight / $height );
|
|
|
|
|
$height = $maxHeight;
|
2004-12-07 21:19:02 +00:00
|
|
|
}
|
2005-09-10 23:01:27 +00:00
|
|
|
if ( $width != $this->img->getWidth() || $height != $this->img->getHeight() ) {
|
2004-12-21 03:21:41 +00:00
|
|
|
if( $wgUseImageResize ) {
|
2004-12-28 12:31:33 +00:00
|
|
|
$thumbnail = $this->img->getThumbnail( $width );
|
2005-06-13 06:38:02 +00:00
|
|
|
if ( $thumbnail == null ) {
|
2005-10-07 21:43:55 +00:00
|
|
|
$url = $this->img->getViewURL();
|
2005-06-13 06:38:02 +00:00
|
|
|
} else {
|
2005-09-13 01:27:21 +00:00
|
|
|
$url = $thumbnail->getURL();
|
2005-06-13 06:38:02 +00:00
|
|
|
}
|
2004-12-21 03:21:41 +00:00
|
|
|
} else {
|
|
|
|
|
# No resize ability? Show the full image, but scale
|
|
|
|
|
# it down in the browser so it fits on the page.
|
2005-10-07 21:43:55 +00:00
|
|
|
$url = $this->img->getViewURL();
|
2004-12-21 03:21:41 +00:00
|
|
|
}
|
2004-12-07 21:19:02 +00:00
|
|
|
$anchoropen = "<a href=\"{$full_url}\">";
|
2005-09-13 01:27:21 +00:00
|
|
|
$anchorclose = "</a><br />";
|
|
|
|
|
if( $this->img->mustRender() ) {
|
|
|
|
|
$showLink = true;
|
|
|
|
|
} else {
|
|
|
|
|
$anchorclose .= "\n$anchoropen{$msg}</a>";
|
|
|
|
|
}
|
2004-12-07 21:19:02 +00:00
|
|
|
} else {
|
2005-09-13 01:27:21 +00:00
|
|
|
$url = $this->img->getViewURL();
|
|
|
|
|
$showLink = true;
|
2004-08-17 21:07:14 +00:00
|
|
|
}
|
2005-05-21 07:46:17 +00:00
|
|
|
$wgOut->addHTML( '<div class="fullImageLink" id="file">' . $anchoropen .
|
2004-08-17 21:07:14 +00:00
|
|
|
"<img border=\"0\" src=\"{$url}\" width=\"{$width}\" height=\"{$height}\" alt=\"" .
|
2005-05-21 07:46:17 +00:00
|
|
|
htmlspecialchars( $wgRequest->getVal( 'image' ) ).'" />' . $anchorclose . '</div>' );
|
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>' );
|
|
|
|
|
}
|
2005-09-13 01:27:21 +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) {
|
2005-08-12 04:44:43 +00:00
|
|
|
$filename = wfEscapeWikiText( $this->img->getName() );
|
|
|
|
|
$info = wfMsg( 'fileinfo',
|
|
|
|
|
ceil($this->img->getSize()/1024.0),
|
|
|
|
|
$this->img->getMimeType() );
|
2005-09-13 01:27:21 +00:00
|
|
|
|
2005-05-21 07:46:17 +00:00
|
|
|
if (!$this->img->isSafeFile()) {
|
2005-08-12 04:44:43 +00:00
|
|
|
$warning = wfMsg( 'mediawarning' );
|
|
|
|
|
$wgOut->addWikiText( <<<END
|
|
|
|
|
<div class="fullMedia">
|
|
|
|
|
<span class="dangerousLink">[[Media:$filename|$filename]]</span>
|
|
|
|
|
<span class="fileInfo"> ($info)</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mediaWarning">$warning</div>
|
|
|
|
|
END
|
|
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
} else {
|
2005-08-12 04:44:43 +00:00
|
|
|
$wgOut->addWikiText( <<<END
|
|
|
|
|
<div class="fullMedia">
|
|
|
|
|
[[Media:$filename|$filename]] <span class="fileInfo"> ($info)</span>
|
|
|
|
|
</div>
|
|
|
|
|
END
|
|
|
|
|
);
|
2005-05-21 07:46:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-10-21 05:04:14 +00:00
|
|
|
if($this->img->fromSharedDirectory) {
|
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
|
|
|
|
|
|
|
|
$title = Title::makeTitle( NS_SPECIAL, 'Upload' );
|
|
|
|
|
$link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'),
|
|
|
|
|
'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() {
|
2005-08-12 17:18:53 +00:00
|
|
|
global $wgRepositoryBaseUrl, $wgFetchCommonsDescriptions, $wgOut, $wgUser;
|
2005-07-03 04:40:07 +00:00
|
|
|
|
|
|
|
|
$url = $wgRepositoryBaseUrl . urlencode($this->mTitle->getDBkey());
|
2005-08-20 10:49:46 +00:00
|
|
|
$sharedtext = "<div class='sharedUploadNotice'>" . wfMsgWikiHtml("sharedupload");
|
2005-07-03 06:06:57 +00:00
|
|
|
if ($wgRepositoryBaseUrl && !$wgFetchCommonsDescriptions) {
|
2005-08-12 17:18:53 +00:00
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
$title = Title::makeTitle( NS_SPECIAL, 'Upload' );
|
|
|
|
|
$link = $sk->makeKnownLinkObj($title, wfMsgHtml('shareduploadwiki-linktext'),
|
|
|
|
|
array( 'wpDestFile' => urlencode( $this->img->getName() )));
|
2005-08-20 12:01:08 +00:00
|
|
|
$sharedtext .= " " . wfMsgWikiHtml('shareduploadwiki', $link);
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
$sharedtext .= "</div>";
|
2005-08-12 17:18:53 +00:00
|
|
|
$wgOut->addHTML($sharedtext);
|
2005-07-03 04:40:07 +00:00
|
|
|
|
|
|
|
|
if ($wgRepositoryBaseUrl && $wgFetchCommonsDescriptions) {
|
2005-07-13 15:35:22 +00:00
|
|
|
require_once("HttpFunctions.php");
|
2005-07-03 04:40:07 +00:00
|
|
|
$ur = ini_set('allow_url_fopen', true);
|
2005-07-04 02:59:23 +00:00
|
|
|
$text = wfGetHTTP($url . '?action=render');
|
2005-07-03 04:46:44 +00:00
|
|
|
ini_set('allow_url_fopen', $ur);
|
2005-07-03 04:40:07 +00:00
|
|
|
if ($text)
|
2005-07-04 02:59:23 +00:00
|
|
|
$this->mExtraDescription = $text;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
function getUploadUrl() {
|
|
|
|
|
global $wgServer;
|
|
|
|
|
$uploadTitle = Title::makeTitle( NS_SPECIAL, 'Upload' );
|
|
|
|
|
return $wgServer . $uploadTitle->getLocalUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-29 19:45:49 +00:00
|
|
|
function uploadLinksBox()
|
2005-03-24 13:30:09 +00:00
|
|
|
{
|
2005-07-03 05:21:06 +00:00
|
|
|
global $wgUser, $wgOut;
|
|
|
|
|
|
|
|
|
|
if ($this->img->fromSharedDirectory)
|
|
|
|
|
return;
|
|
|
|
|
|
2005-03-24 13:30:09 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2005-09-05 06:16:48 +00:00
|
|
|
$wgOut->addHTML( '<br /><ul>' );
|
|
|
|
|
if( $wgUser->isAllowed( 'reupload' ) ) {
|
|
|
|
|
$wgOut->addWikiText( "<li>\n<div>". wfMsg( 'uploadnewversion', $this->getUploadUrl() ) ."</div>\n</li>\n" );
|
|
|
|
|
}
|
|
|
|
|
$wgOut->addHTML( '<li>' );
|
2005-04-29 20:52:23 +00:00
|
|
|
$wgOut->addHTML( $sk->makeKnownLinkObj( $this->mTitle,
|
|
|
|
|
wfMsg( 'edit-externally' ), "action=edit&externaledit=true&mode=file" ) );
|
|
|
|
|
$wgOut->addWikiText( '<div>' . wfMsg('edit-externally-help') . '</div>' );
|
|
|
|
|
$wgOut->addHTML( '</li></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.
|
|
|
|
|
*/
|
2003-09-01 09:59:53 +00:00
|
|
|
function imageHistory()
|
|
|
|
|
{
|
2005-04-29 19:45:49 +00:00
|
|
|
global $wgUser, $wgOut, $wgUseExternalEditor;
|
2003-09-01 09:59:53 +00:00
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
|
2004-05-08 18:55:22 +00:00
|
|
|
$line = $this->img->nextHistoryLine();
|
|
|
|
|
|
2004-08-22 07:38:16 +00:00
|
|
|
if ( $line ) {
|
2004-11-25 13:47:17 +00:00
|
|
|
$list =& new ImageHistoryList( $sk );
|
|
|
|
|
$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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function imageLinks()
|
|
|
|
|
{
|
|
|
|
|
global $wgUser, $wgOut;
|
|
|
|
|
|
2005-05-05 01:44:17 +00:00
|
|
|
$wgOut->addHTML( '<h2 id="filelinks">' . wfMsg( 'imagelinks' ) . "</h2>\n" );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-07-18 08:48:43 +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
|
|
|
|
|
|
|
|
$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 );
|
2004-03-11 09:06:13 +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();
|
2004-03-29 14:48:07 +00:00
|
|
|
$image = $wgRequest->getVal( 'image' );
|
|
|
|
|
$oldimage = $wgRequest->getVal( 'oldimage' );
|
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') ) {
|
2003-09-01 09:59:53 +00:00
|
|
|
$wgOut->sysopRequired();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-07-01 21:15:31 +00:00
|
|
|
if ( $wgUser->isBlocked() ) {
|
|
|
|
|
return $this->blockedIPpage();
|
|
|
|
|
}
|
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 ) ) ) {
|
|
|
|
|
$wgOut->fatalError( wfMsg( 'cannotdelete' ) );
|
|
|
|
|
return;
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
$this->img = new Image( $this->mTitle );
|
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 ) ) {
|
|
|
|
|
$this->doDelete();
|
|
|
|
|
} else {
|
|
|
|
|
$wgOut->fatalError( wfMsg( 'sessionfailure' ) );
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function doDelete()
|
|
|
|
|
{
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgOut, $wgUser, $wgContLang, $wgRequest;
|
2005-04-17 08:30:15 +00:00
|
|
|
global $wgUseSquid, $wgInternalServer, $wgPostCommitUpdateList;
|
2004-08-28 12:07:05 +00:00
|
|
|
$fname = 'ImagePage::doDelete';
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2004-03-29 14:48:07 +00:00
|
|
|
$reason = $wgRequest->getVal( 'wpReason' );
|
|
|
|
|
$oldimage = $wgRequest->getVal( 'oldimage' );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbw =& wfGetDB( DB_MASTER );
|
2004-03-29 14:48: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 ) {
|
|
|
|
|
$wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
|
|
|
|
|
$wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
# Invalidate description page cache
|
|
|
|
|
$this->mTitle->invalidateCache();
|
|
|
|
|
|
2004-08-22 22:03:51 +00:00
|
|
|
# Squid purging
|
|
|
|
|
if ( $wgUseSquid ) {
|
|
|
|
|
$urlArr = Array(
|
2005-04-10 18:29:30 +00:00
|
|
|
$wgInternalServer.wfImageArchiveUrl( $oldimage ),
|
|
|
|
|
$wgInternalServer.$this->mTitle->getFullURL()
|
2004-08-22 22:03:51 +00:00
|
|
|
);
|
|
|
|
|
wfPurgeSquidServers($urlArr);
|
|
|
|
|
}
|
|
|
|
|
$this->doDeleteOldImage( $oldimage );
|
|
|
|
|
$dbw->delete( 'oldimage', array( 'oi_archive_name' => $oldimage ) );
|
|
|
|
|
$deleted = $oldimage;
|
|
|
|
|
} else {
|
2005-02-21 01:56:50 +00:00
|
|
|
$image = $this->mTitle->getDBkey();
|
2003-09-01 09:59:53 +00:00
|
|
|
$dest = wfImageDir( $image );
|
|
|
|
|
$archive = wfImageDir( $image );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-10-10 22:56:23 +00:00
|
|
|
# Delete the image file if it exists; due to sync problems
|
|
|
|
|
# or manual trimming sometimes the file will be missing.
|
|
|
|
|
$targetFile = "{$dest}/{$image}";
|
|
|
|
|
if( file_exists( $targetFile ) && ! @unlink( $targetFile ) ) {
|
|
|
|
|
# If the deletion operation actually failed, bug out:
|
|
|
|
|
$wgOut->fileDeleteError( $targetFile );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-07-10 03:09:26 +00:00
|
|
|
$dbw->delete( 'image', array( 'img_name' => $image ) );
|
2005-07-03 04:40:07 +00:00
|
|
|
$res = $dbw->select( 'oldimage', array( 'oi_archive_name' ), array( 'oi_name' => $image ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
# Purge archive URLs from the squid
|
2004-02-20 12:10:00 +00:00
|
|
|
$urlArr = Array();
|
2004-08-22 22:03:51 +00:00
|
|
|
while ( $s = $dbw->fetchObject( $res ) ) {
|
2003-09-01 09:59:53 +00:00
|
|
|
$this->doDeleteOldImage( $s->oi_archive_name );
|
2004-02-20 12:10:00 +00:00
|
|
|
$urlArr[] = $wgInternalServer.wfImageArchiveUrl( $s->oi_archive_name );
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2005-04-17 08:30:15 +00:00
|
|
|
|
|
|
|
|
# And also the HTML of all pages using this image
|
|
|
|
|
$linksTo = $this->img->getLinksTo();
|
2004-02-20 12:10:00 +00:00
|
|
|
if ( $wgUseSquid ) {
|
2005-04-17 08:30:15 +00:00
|
|
|
$u = SquidUpdate::newFromTitles( $linksTo, $urlArr );
|
|
|
|
|
array_push( $wgPostCommitUpdateList, $u );
|
2004-02-20 12:10:00 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-07-10 03:09:26 +00:00
|
|
|
$dbw->delete( 'oldimage', array( 'oi_name' => $image ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
|
|
|
|
# Image itself is now gone, and database is cleaned.
|
|
|
|
|
# Now we remove the image description page.
|
|
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
$article = new Article( $this->mTitle );
|
2004-03-29 14:48:07 +00:00
|
|
|
$article->doDeleteArticle( $reason ); # ignore errors
|
2003-09-01 09:59:53 +00:00
|
|
|
|
2005-04-17 08:30:15 +00:00
|
|
|
# Invalidate parser cache and client cache for pages using this image
|
|
|
|
|
# This is left until relatively late to reduce lock time
|
|
|
|
|
Title::touchArray( $linksTo );
|
|
|
|
|
|
2005-04-16 11:05:41 +00:00
|
|
|
/* Delete thumbnails and refresh image metadata cache */
|
2005-04-17 08:30:15 +00:00
|
|
|
$this->img->purgeCache();
|
|
|
|
|
|
2005-03-13 15:00:59 +00:00
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
$deleted = $image;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function doDeleteOldImage( $oldimage )
|
|
|
|
|
{
|
|
|
|
|
global $wgOut;
|
|
|
|
|
|
|
|
|
|
$name = substr( $oldimage, 15 );
|
|
|
|
|
$archive = wfImageArchiveDir( $name );
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-10-10 22:56:23 +00:00
|
|
|
# Delete the image if it exists. Sometimes the file will be missing
|
|
|
|
|
# due to manual intervention or weird sync problems; treat that
|
|
|
|
|
# condition gracefully and continue to delete the database entry.
|
|
|
|
|
# Also some records may end up with an empty oi_archive_name field
|
|
|
|
|
# if the original file was missing when a new upload was made;
|
|
|
|
|
# don't try to delete the directory then!
|
|
|
|
|
#
|
|
|
|
|
$targetFile = "{$archive}/{$oldimage}";
|
|
|
|
|
if( $oldimage != '' && file_exists( $targetFile ) && !@unlink( $targetFile ) ) {
|
|
|
|
|
# If we actually have a file and can't delete it, throw an error.
|
2003-09-01 09:59:53 +00:00
|
|
|
$wgOut->fileDeleteError( "{$archive}/{$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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function revert()
|
|
|
|
|
{
|
2005-02-21 01:56:50 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser;
|
2004-02-20 12:10:00 +00:00
|
|
|
global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList;
|
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 ) {
|
2004-10-14 02:56:02 +00:00
|
|
|
$wgOut->unexpectedValueError( 'oldimage', htmlspecialchars($oldimage) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( strstr( $oldimage, "/" ) || strstr( $oldimage, "\\" ) ) {
|
|
|
|
|
$wgOut->unexpectedValueError( '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() ) {
|
2005-02-08 13:55:13 +00:00
|
|
|
$wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-08-05 04:30:29 +00:00
|
|
|
if ( ! $this->mTitle->userCanEdit() ) {
|
|
|
|
|
$wgOut->sysopRequired();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-07-01 21:15:31 +00:00
|
|
|
if ( $wgUser->isBlocked() ) {
|
|
|
|
|
return $this->blockedIPpage();
|
|
|
|
|
}
|
2005-02-21 01:56:50 +00:00
|
|
|
if( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $oldimage ) ) {
|
|
|
|
|
$wgOut->errorpage( 'internalerror', 'sessionfailure' );
|
|
|
|
|
return;
|
2005-07-03 04:40:07 +00:00
|
|
|
}
|
2003-09-01 09:59:53 +00:00
|
|
|
$name = substr( $oldimage, 15 );
|
|
|
|
|
|
|
|
|
|
$dest = wfImageDir( $name );
|
|
|
|
|
$archive = wfImageArchiveDir( $name );
|
|
|
|
|
$curfile = "{$dest}/{$name}";
|
|
|
|
|
|
|
|
|
|
if ( ! is_file( $curfile ) ) {
|
2004-10-14 02:56:02 +00:00
|
|
|
$wgOut->fileNotFoundError( htmlspecialchars( $curfile ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$oldver = wfTimestampNow() . "!{$name}";
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-07-18 08:48:43 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
2005-04-10 18:29:30 +00:00
|
|
|
$size = $dbr->selectField( 'oldimage', 'oi_size', array( 'oi_archive_name' => $oldimage ) );
|
2003-09-01 09:59:53 +00:00
|
|
|
|
|
|
|
|
if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) {
|
|
|
|
|
$wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) {
|
|
|
|
|
$wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile );
|
|
|
|
|
}
|
2005-03-13 15:00:59 +00:00
|
|
|
|
2005-04-10 18:29:30 +00:00
|
|
|
# Record upload and update metadata cache
|
|
|
|
|
$img = Image::newFromName( $name );
|
|
|
|
|
$img->recordUpload( $oldver, 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
|
|
|
|
|
|
|
|
$descTitle = $img->getTitle();
|
|
|
|
|
$wgOut->returnToMain( false, $descTitle->getPrefixedText() );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2005-07-01 21:15:31 +00:00
|
|
|
function blockedIPpage() {
|
|
|
|
|
require_once( 'EditPage.php' );
|
|
|
|
|
$edit = new EditPage( $this );
|
|
|
|
|
return $edit->blockedIPpage();
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
|
|
|
|
|
2005-01-27 19:51:47 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
* @package MediaWiki
|
|
|
|
|
*/
|
2004-11-25 13:47:17 +00:00
|
|
|
class ImageHistoryList {
|
|
|
|
|
function ImageHistoryList( &$skin ) {
|
|
|
|
|
$this->skin =& $skin;
|
|
|
|
|
}
|
2005-07-03 04:40:07 +00:00
|
|
|
|
2004-11-25 13:47:17 +00:00
|
|
|
function beginImageHistoryList() {
|
2005-05-05 01:44:17 +00:00
|
|
|
$s = "\n<h2 id=\"filehistory\">" . wfMsg( 'imghistory' ) . "</h2>\n" .
|
2004-11-25 13:47:17 +00:00
|
|
|
"<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
|
|
|
|
|
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 ) {
|
2004-11-25 13:47:17 +00:00
|
|
|
global $wgUser, $wgLang, $wgContLang, $wgTitle;
|
|
|
|
|
|
|
|
|
|
$datetime = $wgLang->timeanddate( $timestamp, true );
|
|
|
|
|
$del = wfMsg( 'deleteimg' );
|
|
|
|
|
$delall = wfMsg( 'deleteimgcompletely' );
|
|
|
|
|
$cur = wfMsg( 'cur' );
|
|
|
|
|
|
|
|
|
|
if ( $iscur ) {
|
2005-04-10 18:29:30 +00:00
|
|
|
$url = Image::imageUrl( $img );
|
2004-11-25 13:47:17 +00:00
|
|
|
$rlink = $cur;
|
|
|
|
|
if ( $wgUser->isAllowed('delete') ) {
|
|
|
|
|
$link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
|
|
|
|
|
'&action=delete' );
|
|
|
|
|
$style = $this->skin->getInternalLinkAttributes( $link, $delall );
|
|
|
|
|
|
|
|
|
|
$dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
|
|
|
|
|
} else {
|
|
|
|
|
$dlink = $del;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$url = htmlspecialchars( wfImageArchiveUrl( $img ) );
|
|
|
|
|
if( $wgUser->getID() != 0 && $wgTitle->userCanEdit() ) {
|
2005-02-21 01:56:50 +00:00
|
|
|
$token = urlencode( $wgUser->editToken( $img ) );
|
2005-04-02 20:55:19 +00:00
|
|
|
$rlink = $this->skin->makeKnownLinkObj( $wgTitle,
|
2004-11-25 13:47:17 +00:00
|
|
|
wfMsg( 'revertimg' ), 'action=revert&oldimage=' .
|
2005-02-21 01:56:50 +00:00
|
|
|
urlencode( $img ) . "&wpEditToken=$token" );
|
2005-04-02 20:55:19 +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.
|
|
|
|
|
$rlink = wfMsg( 'revertimg' );
|
|
|
|
|
$dlink = $del;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( 0 == $user ) {
|
|
|
|
|
$userlink = $usertext;
|
|
|
|
|
} else {
|
2005-02-21 12:23:52 +00:00
|
|
|
$userlink = $this->skin->makeLinkObj(
|
|
|
|
|
Title::makeTitle( NS_USER, $usertext ),
|
|
|
|
|
$usertext );
|
2004-11-25 13:47:17 +00:00
|
|
|
}
|
|
|
|
|
$nbytes = wfMsg( 'nbytes', $size );
|
2005-09-19 12:54:18 +00:00
|
|
|
$widthheight = wfMsg( 'widthheight', $width, $height );
|
2004-11-25 13:47:17 +00:00
|
|
|
$style = $this->skin->getInternalLinkAttributes( $url, $datetime );
|
|
|
|
|
|
2005-09-19 12:54:18 +00:00
|
|
|
$s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
|
2004-11-25 13:47:17 +00:00
|
|
|
|
2005-02-21 12:23:52 +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
|
|
|
?>
|