r47385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47384‎ | r47385 | r47386 >
Date:22:27, 17 February 2009
Author:demon
Status:deferred
Tags:
Comment:
* 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.
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FileRepo.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1246,6 +1246,8 @@
12471247 'noimage',
12481248 'noimage-linktext',
12491249 'uploadnewversion-linktext',
 1250+ 'shared-repo-from',
 1251+ 'shared-repo',
12501252 ),
12511253 'filerevert' => array(
12521254 'filerevert',
Index: trunk/phase3/includes/ImagePage.php
@@ -646,13 +646,15 @@
647647
648648 $sk = $wgUser->getSkin();
649649 foreach ( $dupes as $file ) {
 650+ $fromSrc = '';
650651 if( $file->isLocal() )
651652 $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
652653 else {
653654 $link = $sk->makeExternalLink( $file->getDescriptionUrl(),
654655 $file->getTitle()->getPrefixedText() );
 656+ $fromSrc = wfMsg( 'shared-repo-from', $file->getRepo()->getDisplayName() );
655657 }
656 - $wgOut->addHTML( "<li>{$link}</li>\n" );
 658+ $wgOut->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
657659 }
658660 $wgOut->addHTML( "</ul></div>\n" );
659661 }
Index: trunk/phase3/includes/filerepo/FileRepo.php
@@ -538,4 +538,20 @@
539539 function findBySha1( $hash ) {
540540 return array();
541541 }
 542+
 543+ /**
 544+ * Get the human-readable name of the repo.
 545+ * @return string
 546+ */
 547+ public function getDisplayName() {
 548+ // We don't name our own repo, return nothing
 549+ if ( $this->name == 'local' ) {
 550+ return null;
 551+ }
 552+ $repoName = wfMsg( 'shared-repo-' . $this->name );
 553+ if ( !wfEmptyMsg( 'shared-repo-' . $this->name, $repoName ) ) {
 554+ return $repoName;
 555+ }
 556+ return wfMsg( 'shared-repo' );
 557+ }
542558 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1989,6 +1989,8 @@
19901990 'noimage' => 'No file by this name exists, but you can $1.',
19911991 'noimage-linktext' => 'upload one',
19921992 'uploadnewversion-linktext' => 'Upload a new version of this file',
 1993+'shared-repo-from' => 'from $1', // $1 is the repository name
 1994+'shared-repo' => 'shared repository', // used when shared-repo-NAME doesn't exist
19931995
19941996 # File reversion
19951997 'filerevert' => 'Revert $1',

Status & tagging log