mTitle->getNamespace() ) {
$this->openShowImage();
}
Article::view();
# If the article we've just shown is in the "Image" namespace,
# follow it with the history list and link list for the image
# it describes.
if ( Namespace::getImage() == $this->mTitle->getNamespace() ) {
$this->closeShowImage();
$this->imageHistory();
$this->imageLinks();
}
}
function openShowImage()
{
global $wgOut, $wgUser,$wgRequest;
$name = $this->mTitle->getText();
$path = wfImagePath( $name );
$url = wfImageUrl( $name );
if ( file_exists( $path ) ) {
list($width, $height, $type, $attr) = getimagesize( $path );
$sk = $wgUser->getSkin();
if ( $type != "" ) {
# image
$s = "getVal( 'image' )."\" />";
} else {
$s = "".$sk->makeMediaLink($name,"")."";
}
$wgOut->addHTML( $s );
}
}
function closeShowImage()
{
# For overloading
}
# 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.
function imageHistory()
{
global $wgUser, $wgOut, $wgLang;
$fname = "Article::imageHistory";
$sql = "SELECT img_size,img_description,img_user," .
"img_user_text,img_timestamp FROM image WHERE " .
"img_name='" . wfStrencode( $this->mTitle->getDBkey() ) . "'";
$res = wfQuery( $sql, DB_READ, $fname );
if ( 0 == wfNumRows( $res ) ) { return; }
$sk = $wgUser->getSkin();
$s = $sk->beginImageHistoryList();
$line = wfFetchObject( $res );
$s .= $sk->imageHistoryLine( true, $line->img_timestamp,
$this->mTitle->getText(), $line->img_user,
$line->img_user_text, $line->img_size, $line->img_description );
$sql = "SELECT oi_size,oi_description,oi_user," .
"oi_user_text,oi_timestamp,oi_archive_name FROM oldimage WHERE " .
"oi_name='" . wfStrencode( $this->mTitle->getDBkey() ) . "' " .
"ORDER BY oi_timestamp DESC";
$res = wfQuery( $sql, DB_READ, $fname );
while ( $line = wfFetchObject( $res ) ) {
$s .= $sk->imageHistoryLine( false, $line->oi_timestamp,
$line->oi_archive_name, $line->oi_user,
$line->oi_user_text, $line->oi_size, $line->oi_description );
}
$s .= $sk->endImageHistoryList();
$wgOut->addHTML( $s );
}
function imageLinks()
{
global $wgUser, $wgOut;
$wgOut->addHTML( "
" . wfMsg( "nolinkstoimage" ) . "
\n" ); return; } $wgOut->addHTML( "" . wfMsg( "linkstoimage" ) . "
\n" . $text . "
\n" ); $wgOut->returnToMain( false ); } function doDeleteOldImage( $oldimage ) { global $wgOut; $name = substr( $oldimage, 15 ); $archive = wfImageArchiveDir( $name ); if ( ! unlink( "{$archive}/{$oldimage}" ) ) { $wgOut->fileDeleteError( "{$archive}/{$oldimage}" ); } } function revert() { global $wgOut, $wgRequest; global $wgUseSquid, $wgInternalServer, $wgDeferredUpdateList; $oldimage = $wgRequest->getText( 'oldimage' ); if ( strlen( $oldimage ) < 16 ) { $wgOut->unexpectedValueError( "oldimage", $oldimage ); return; } if ( wfReadOnly() ) { $wgOut->readOnlyPage(); return; } $name = substr( $oldimage, 15 ); $dest = wfImageDir( $name ); $archive = wfImageArchiveDir( $name ); $curfile = "{$dest}/{$name}"; if ( ! is_file( $curfile ) ) { $wgOut->fileNotFoundError( $curfile ); return; } $oldver = wfTimestampNow() . "!{$name}"; $size = wfGetSQL( "oldimage", "oi_size", "oi_archive_name='" . wfStrencode( $oldimage ) . "'" ); if ( ! rename( $curfile, "${archive}/{$oldver}" ) ) { $wgOut->fileRenameError( $curfile, "${archive}/{$oldver}" ); return; } if ( ! copy( "{$archive}/{$oldimage}", $curfile ) ) { $wgOut->fileCopyError( "${archive}/{$oldimage}", $curfile ); } wfRecordUpload( $name, $oldver, $size, wfMsg( "reverted" ) ); # Squid purging if ( $wgUseSquid ) { $urlArr = Array( $wgInternalServer.wfImageArchiveUrl( $name ), $wgInternalServer.wfImageUrl( $name ) ); wfPurgeSquidServers($urlArr); } $wgOut->setPagetitle( wfMsg( "actioncomplete" ) ); $wgOut->setRobotpolicy( "noindex,nofollow" ); $wgOut->addHTML( wfMsg( "imagereverted" ) ); $wgOut->returnToMain( false ); } } ?>