global $wgOut, $wgUser;
if ( !( $hash = $this->img->getSha1() ) ) return;
- // Should find a proper way to link to foreign files
- // Deprecates checkSharedConflict
- //$dupes = RepoGroup::singleton()->findBySha1( $hash );
- $dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash );
+ // Probably deprecates checkSharedConflict?
+ $dupes = RepoGroup::singleton()->findBySha1( $hash );
+ //$dupes = RepoGroup::singleton()->getLocalRepo()->findBySha1( $hash );
// Don't dupe with self
- $index = 0;
$self = $this->img->getRepoName().':'.$this->img->getName();
- foreach ( $dupes as $file ) {
+ foreach ( $dupes as $index => $file ) {
$key = $file->getRepoName().':'.$file->getName();
if ( $key == $self )
unset( $dupes[$index] );
- $index++;
}
if ( count( $dupes ) == 0 ) return;
$sk = $wgUser->getSkin();
foreach ( $dupes as $file ) {
- $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
+ if ( $file->isLocal() )
+ $link = $sk->makeKnownLinkObj( $file->getTitle(), "" );
+ else
+ $link = $sk->makeExternalLink( $file->getDescriptionUrl(),
+ $file->getTitle()->getPrefixedText() );
$wgOut->addHTML( "<li>{$link}</li>\n" );
}
$wgOut->addHTML( "</ul>\n" );
return new self( $title, $repo );
}
+ /**
+ * Create a ForeignDBFile from a title
+ * Do not call this except from inside a repo class.
+ */
+ static function newFromRow( $row, $repo ) {
+ $title = Title::makeTitle( NS_IMAGE, $row->img_name );
+ $file = new self( $title, $repo );
+ $file->loadFromRow( $row );
+ return $file;
+ }
+
function getCacheKey() {
if ( $this->repo->hasSharedCache ) {
$hashedName = md5($this->name);
var $dbConn;
var $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
+ function newFileFromRow( $row ) {
+ if ( isset( $row->img_name ) )
+ return ForeignDBFile::newFromRow( $row, $this );
+ return parent::newFileFromRow( $row );
+ }
+
function __construct( $info ) {
parent::__construct( $info );
$this->dbType = $info['dbType'];