From 8f3d9991866a3c1816f4d4cfe4d782ae77d05bb1 Mon Sep 17 00:00:00 2001 From: Bryan Tong Minh Date: Thu, 8 May 2008 21:53:39 +0000 Subject: [PATCH] Show pages that redirect to this image on ImagePage --- includes/ImagePage.php | 35 +++++++++++++++++++++++++++++++ languages/messages/MessagesEn.php | 1 + 2 files changed, 36 insertions(+) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 887f2dc2f8..bbc1745c33 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -91,6 +91,7 @@ class ImagePage extends Article { $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); + if ( $this->img->isLocal() ) $this->imageRedirects(); if ( $showmeta ) { global $wgStylePath, $wgStyleVersion; @@ -540,6 +541,40 @@ EOT } $wgOut->addHTML( "\n" ); } + + function imageRedirects() + { + global $wgUser, $wgOut; + + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( + array( 'redirect', 'page' ), + array( 'page_title' ), + array( + 'rd_namespace' => NS_IMAGE, + 'rd_title' => $this->mTitle->getDBkey(), + 'page_namespace' => NS_IMAGE, + 'rd_from = page_id' + ) + ); + + + if ( 0 == $dbr->numRows( $res ) ) + return; + + $wgOut->addHTML( '

' . wfMsg( 'redirectstofile' ) . "

\n\n" ); + + $res->free(); + } /** * Delete the file, or an earlier version of it diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index d11dcd9bb2..8198f81314 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1710,6 +1710,7 @@ A click on a column header changes the sorting.', 'imagelinks' => 'Links', 'linkstoimage' => 'The following pages link to this file:', 'nolinkstoimage' => 'There are no pages that link to this file.', +'redirectstofile' => 'The following files redirect to this file:', 'sharedupload' => 'This file is a shared upload and may be used by other projects.', 'shareduploadwiki' => 'Please see the $1 for further information.', 'shareduploadwiki-desc' => 'The description on its $1 there is shown below.', -- 2.20.1