* Add method to FileRepo to get the human-readable name of the repository (getDisplay...
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 17 Feb 2009 22:27:10 +0000 (22:27 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 17 Feb 2009 22:27:10 +0000 (22:27 +0000)
* 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
includes/filerepo/FileRepo.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 88d0b5c..afa1d9a 100644 (file)
@@ -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( "<li>{$link}</li>\n" );
+                       $wgOut->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
                }
                $wgOut->addHTML( "</ul></div>\n" );
        }
index 44f909f..fb586e0 100644 (file)
@@ -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' ); 
+       }
 }
index f6023db..f868775 100644 (file)
@@ -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',
index cdd9061..4118535 100644 (file)
@@ -1246,6 +1246,8 @@ $wgMessageStructure = array(
                'noimage',
                'noimage-linktext',
                'uploadnewversion-linktext',
+               'shared-repo-from',
+               'shared-repo',
        ),
        'filerevert' => array(
                'filerevert',