From 884a7a80f4441ca06edca42ac8bc4e538e4bb432 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 17 Feb 2009 22:27:10 +0000 Subject: [PATCH] * Add method to FileRepo to get the human-readable name of the repository (getDisplayName()) * Use this in ImagePage to show what repo the dupes are from * Added default "shared repository" message for shared repos without names. --- includes/ImagePage.php | 4 +++- includes/filerepo/FileRepo.php | 16 ++++++++++++++++ languages/messages/MessagesEn.php | 2 ++ maintenance/language/messages.inc | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 88d0b5ce38..afa1d9abd9 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -646,13 +646,15 @@ EOT $sk = $wgUser->getSkin(); foreach ( $dupes as $file ) { + $fromSrc = ''; if( $file->isLocal() ) $link = $sk->makeKnownLinkObj( $file->getTitle(), "" ); else { $link = $sk->makeExternalLink( $file->getDescriptionUrl(), $file->getTitle()->getPrefixedText() ); + $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() ); } - $wgOut->addHTML( "
  • {$link}
  • \n" ); + $wgOut->addHTML( "
  • {$link} {$fromSrc}
  • \n" ); } $wgOut->addHTML( "\n" ); } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index 44f909f482..fb586e0592 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -538,4 +538,20 @@ abstract class FileRepo { function findBySha1( $hash ) { return array(); } + + /** + * Get the human-readable name of the repo. + * @return string + */ + public function getDisplayName() { + // We don't name our own repo, return nothing + if ( $this->name == 'local' ) { + return null; + } + $repoName = wfMsg( 'shared-repo-' . $this->name ); + if ( !wfEmptyMsg( 'shared-repo-' . $this->name, $repoName ) ) { + return $repoName; + } + return wfMsg( 'shared-repo' ); + } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index f6023dbd7d..f8687758dc 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1989,6 +1989,8 @@ A [[Special:WhatLinksHere/$2|full list]] is available.', 'noimage' => 'No file by this name exists, but you can $1.', 'noimage-linktext' => 'upload one', 'uploadnewversion-linktext' => 'Upload a new version of this file', +'shared-repo-from' => 'from $1', // $1 is the repository name +'shared-repo' => 'shared repository', // used when shared-repo-NAME doesn't exist # File reversion 'filerevert' => 'Revert $1', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index cdd9061e28..41185357f6 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1246,6 +1246,8 @@ $wgMessageStructure = array( 'noimage', 'noimage-linktext', 'uploadnewversion-linktext', + 'shared-repo-from', + 'shared-repo', ), 'filerevert' => array( 'filerevert', -- 2.20.1