From 72e90545454c0e014318fa3c81658e035aac58c1 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 10 Jun 2009 13:00:47 +0200 Subject: applying patch to version 1.15.0 --- includes/ImagePage.php | 84 ++++++++++---------------------------------------- 1 file changed, 16 insertions(+), 68 deletions(-) (limited to 'includes/ImagePage.php') diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 314d478e..4f3b859a 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -105,7 +105,6 @@ class ImagePage extends Article { } else { # Just need to set the right headers $wgOut->setArticleFlag( true ); - $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); $this->viewUpdates(); } @@ -117,8 +116,6 @@ class ImagePage extends Article { $wgOut->addWikiText( $fol ); } $wgOut->addHTML( '
' . $this->mExtraDescription . '
' ); - } else { - $this->checkSharedConflict(); } $this->closeShowImage(); @@ -129,11 +126,9 @@ class ImagePage extends Article { array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" ); $this->imageDupes(); - // TODO: We may want to find local images redirecting to a foreign - // file: "The following local files redirect to this file" - if( $this->img->isLocal() ) { - $this->imageRedirects(); - } + # TODO! FIXME! For some freaky reason, we can't redirect to foreign images. + # Yet we return metadata about the target. Definitely an issue in the FileRepo + $this->imageRedirects(); $this->imageLinks(); if( $showmeta ) { @@ -473,6 +468,7 @@ EOT $title = SpecialPage::getTitleFor( 'Upload' ); $link = $sk->makeKnownLinkObj($title, wfMsgHtml('noimage-linktext'), 'wpDestFile=' . urlencode( $this->displayImg->getName() ) ); + $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->addHTML( wfMsgWikiHtml( 'noimage', $link ) ); } } @@ -487,17 +483,18 @@ EOT $descUrl = $this->img->getDescriptionUrl(); $descText = $this->img->getDescriptionText(); - $s = "
" . wfMsgWikiHtml( 'sharedupload' ); + $msg = ''; if( $descUrl ) { $sk = $wgUser->getSkin(); $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadwiki-linktext' ) ); $msg = ( $descText ) ? 'shareduploadwiki-desc' : 'shareduploadwiki'; $msg = wfMsgExt( $msg, array( 'parseinline', 'replaceafter' ), $link ); - if( $msg != '-' ) { - # Show message only if not voided by local sysops - $s .= $msg; + if( $msg == '-' ) { + $msg = ''; } } + $s = "
"; + $s .= wfMsgWikiHtml( 'sharedupload', $this->img->getRepo()->getDisplayName(), $msg ); $s .= "
"; $wgOut->addHTML( $s ); @@ -506,58 +503,10 @@ EOT } } - /* - * Check for files with the same name on the foreign repos. - */ - protected function checkSharedConflict() { - global $wgOut, $wgUser; - - $repoGroup = RepoGroup::singleton(); - if( !$repoGroup->hasForeignRepos() ) { - return; - } - - $this->loadFile(); - if( !$this->img->isLocal() ) { - return; - } - - $this->dupFile = null; - $repoGroup->forEachForeignRepo( array( $this, 'checkSharedConflictCallback' ) ); - - if( !$this->dupFile ) - return; - $dupfile = $this->dupFile; - $same = ( - ($this->img->getSha1() == $dupfile->getSha1()) && - ($this->img->getSize() == $dupfile->getSize()) - ); - - $sk = $wgUser->getSkin(); - $descUrl = $dupfile->getDescriptionUrl(); - if( $same ) { - $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadduplicate-linktext' ) ); - $wgOut->addHTML( '
' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '
' ); - } else { - $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) ); - $wgOut->addHTML( '
' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '
' ); - } - } - - public function checkSharedConflictCallback( $repo ) { - $this->loadFile(); - $dupfile = $repo->newFile( $this->img->getTitle() ); - if( $dupfile && $dupfile->exists() ) { - $this->dupFile = $dupfile; - return $dupfile->exists(); - } - return false; - } - public function getUploadUrl() { $this->loadFile(); $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); - return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); + return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) . '&wpForReUpload=1' ); } /** @@ -581,10 +530,6 @@ EOT $wgOut->addHTML( "
  • " ); } - # Link to Special:FileDuplicateSearch - $dupeLink = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'FileDuplicateSearch', $this->mTitle->getDBkey() ), wfMsgHtml( 'imagepage-searchdupe' ) ); - $wgOut->addHTML( "
  • {$dupeLink}
  • " ); - # External editing link $elink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'edit-externally' ), 'action=edit&externaledit=true&mode=file' ); $wgOut->addHTML( '
  • ' . $elink . ' ' . wfMsgExt( 'edit-externally-help', array( 'parseinline' ) ) . '
  • ' ); @@ -698,19 +643,21 @@ EOT $wgOut->addHTML( "
    \n" ); $wgOut->addWikiMsg( 'duplicatesoffile', - $wgLang->formatNum( count( $dupes ) ) + $wgLang->formatNum( count( $dupes ) ), $this->mTitle->getDBkey() ); $wgOut->addHTML( "
      \n" ); $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" ); } @@ -922,7 +869,8 @@ class ImageHistoryList { 'alt' => wfMsg( 'filehist-thumbtext', $wgLang->timeAndDate( $timestamp, true ) ), 'file-link' => true, ); - $row .= '' . $thumbnail->toHtml( $options ); + $row .= '' . ( $thumbnail ? $thumbnail->toHtml( $options ) : + wfMsgHtml( 'filehist-nothumb' ) ); } else { $row .= '' . wfMsgHtml( 'filehist-nothumb' ); } -- cgit v1.2.2