Index: trunk/phase3/includes/ImagePage.php |
— | — | @@ -639,19 +639,16 @@ |
640 | 640 | global $wgOut, $wgUser; |
641 | 641 | |
642 | 642 | if ( !( $hash = $this->img->getSha1() ) ) return; |
643 | | - // Should find a proper way to link to foreign files |
644 | | - // Deprecates checkSharedConflict |
645 | | - //$dupes = RepoGroup::singleton()->findBySha1( $hash ); |
646 | | - $dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash ); |
| 643 | + // Probably deprecates checkSharedConflict? |
| 644 | + $dupes = RepoGroup::singleton()->findBySha1( $hash ); |
| 645 | + //$dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash ); |
647 | 646 | |
648 | 647 | // Don't dupe with self |
649 | | - $index = 0; |
650 | 648 | $self = $this->img->getRepoName().':'.$this->img->getName(); |
651 | | - foreach ( $dupes as $file ) { |
| 649 | + foreach ( $dupes as $index => $file ) { |
652 | 650 | $key = $file->getRepoName().':'.$file->getName(); |
653 | 651 | if ( $key == $self ) |
654 | 652 | unset( $dupes[$index] ); |
655 | | - $index++; |
656 | 653 | } |
657 | 654 | if ( count( $dupes ) == 0 ) return; |
658 | 655 | |
— | — | @@ -660,7 +657,11 @@ |
661 | 658 | |
662 | 659 | $sk = $wgUser->getSkin(); |
663 | 660 | foreach ( $dupes as $file ) { |
664 | | - $link = $sk->makeKnownLinkObj( $file->getTitle(), "" ); |
| 661 | + if ( $file->isLocal() ) |
| 662 | + $link = $sk->makeKnownLinkObj( $file->getTitle(), "" ); |
| 663 | + else |
| 664 | + $link = $sk->makeExternalLink( $file->getDescriptionUrl(), |
| 665 | + $file->getTitle()->getPrefixedText() ); |
665 | 666 | $wgOut->addHTML( "<li>{$link}</li>\n" ); |
666 | 667 | } |
667 | 668 | $wgOut->addHTML( "</ul>\n" ); |
Index: trunk/phase3/includes/filerepo/ForeignDBFile.php |
— | — | @@ -5,6 +5,17 @@ |
6 | 6 | return new self( $title, $repo ); |
7 | 7 | } |
8 | 8 | |
| 9 | + /** |
| 10 | + * Create a ForeignDBFile from a title |
| 11 | + * Do not call this except from inside a repo class. |
| 12 | + */ |
| 13 | + static function newFromRow( $row, $repo ) { |
| 14 | + $title = Title::makeTitle( NS_IMAGE, $row->img_name ); |
| 15 | + $file = new self( $title, $repo ); |
| 16 | + $file->loadFromRow( $row ); |
| 17 | + return $file; |
| 18 | + } |
| 19 | + |
9 | 20 | function getCacheKey() { |
10 | 21 | if ( $this->repo->hasSharedCache ) { |
11 | 22 | $hashedName = md5($this->name); |
Index: trunk/phase3/includes/filerepo/ForeignDBRepo.php |
— | — | @@ -13,6 +13,12 @@ |
14 | 14 | var $dbConn; |
15 | 15 | var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' ); |
16 | 16 | |
| 17 | + function newFileFromRow( $row ) { |
| 18 | + if ( isset( $row->img_name ) ) |
| 19 | + return ForeignDBFile::newFromRow( $row, $this ); |
| 20 | + return parent::newFileFromRow( $row ); |
| 21 | + } |
| 22 | + |
17 | 23 | function __construct( $info ) { |
18 | 24 | parent::__construct( $info ); |
19 | 25 | $this->dbType = $info['dbType']; |