From cda44a6cdd05ae5148c839bff94443a390d1e8b9 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Mon, 28 Apr 2008 16:28:07 +0000 Subject: [PATCH] * (bug 889) Improve conflict-handling between shared upload repository (commons) and local one --- RELEASE-NOTES | 1 + includes/DefaultSettings.php | 2 +- includes/ImagePage.php | 32 ++++++++++++++++++++ languages/messages/MessagesEn.php | 50 +++++++++++++++++-------------- skins/common/shared.css | 3 ++ 5 files changed, 64 insertions(+), 24 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 86cd3f8969..60df56f483 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -92,6 +92,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN otherwise just "log in", consistently across skins * Special:Shortpages and Special:Longpages now returns pages in all content namespaces, not just NS_MAIN. +* (bug 889) Improve conflict-handling between shared upload repository (commons) and local one === Bug fixes in 1.13 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index d696dd71bd..ed6b6a447e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1329,7 +1329,7 @@ $wgCacheEpoch = '20030516000000'; * to ensure that client-side caches don't keep obsolete copies of global * styles. */ -$wgStyleVersion = '139'; +$wgStyleVersion = '140'; # Server-side caching: diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 6206b1c046..ddb8512441 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -81,6 +81,8 @@ class ImagePage extends Article { $wgOut->addWikiText( $fol ); } $wgOut->addHTML( '
' . $this->mExtraDescription . '
' ); + } else { + $this->checkSharedConflict(); } $this->closeShowImage(); @@ -373,6 +375,36 @@ EOT } } + function checkSharedConflict() { + global $wgOut, $wgUser, $wgUseSharedUploads; + if( !$wgUseSharedUploads ) { + return; + } + if( $this->repo->getName() != 'local' ) { + return; + } + + $repo = RepoGroup::singleton()->getRepoByName( 'shared' ); + $dupfile = $repo->newFile( $this->img->getTitle() ); + if( !$dupfile->exists() ) { + return; + } + $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 ) . '
' ); + } + } + function getUploadUrl() { $uploadTitle = SpecialPage::getTitleFor( 'Upload' ); return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) ); diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 0080a72cc4..eeab3bacb7 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1698,29 +1698,33 @@ A click on a column header changes the sorting.', 'imagelist_description' => 'Description', # Image description page -'filehist' => 'File history', -'filehist-help' => 'Click on a date/time to view the file as it appeared at that time.', -'filehist-deleteall' => 'delete all', -'filehist-deleteone' => 'delete this', -'filehist-revert' => 'revert', -'filehist-current' => 'current', -'filehist-datetime' => 'Date/Time', -'filehist-user' => 'User', -'filehist-dimensions' => 'Dimensions', -'filehist-filesize' => 'File size', -'filehist-comment' => 'Comment', -'imagelinks' => 'Links', -'linkstoimage' => 'The following pages link to this file:', -'nolinkstoimage' => 'There are no pages that link to this file.', -'sharedupload' => 'This file is a shared upload and may be used by other projects.', -'shareduploadwiki' => 'Please see the $1 for further information.', -'shareduploadwiki-desc' => 'The description on its $1 there is shown below.', -'shareduploadwiki-linktext' => 'file description page', -'shareddescriptionfollows' => '-', # do not translate or duplicate this message to other languages -'noimage' => 'No file by this name exists, you can $1.', -'noimage-linktext' => 'upload it', -'uploadnewversion-linktext' => 'Upload a new version of this file', -'imagepage-searchdupe' => 'Search for duplicate files', +'filehist' => 'File history', +'filehist-help' => 'Click on a date/time to view the file as it appeared at that time.', +'filehist-deleteall' => 'delete all', +'filehist-deleteone' => 'delete this', +'filehist-revert' => 'revert', +'filehist-current' => 'current', +'filehist-datetime' => 'Date/Time', +'filehist-user' => 'User', +'filehist-dimensions' => 'Dimensions', +'filehist-filesize' => 'File size', +'filehist-comment' => 'Comment', +'imagelinks' => 'Links', +'linkstoimage' => 'The following pages link to this file:', +'nolinkstoimage' => 'There are no pages that link to this file.', +'sharedupload' => 'This file is a shared upload and may be used by other projects.', +'shareduploadwiki' => 'Please see the $1 for further information.', +'shareduploadwiki-desc' => 'The description on its $1 there is shown below.', +'shareduploadwiki-linktext' => 'file description page', +'shareddescriptionfollows' => '-', # do not translate or duplicate this message to other languages +'shareduploadduplicate' => 'This file is a duplicate of $1 from shared repository.', +'shareduploadduplicate-linktext' => 'another file', +'shareduploadconflict' => 'This file has the same name as $1 from shared repository has.', +'shareduploadconflict-linktext' => 'another file', +'noimage' => 'No file by this name exists, you can $1.', +'noimage-linktext' => 'upload it', +'uploadnewversion-linktext' => 'Upload a new version of this file', +'imagepage-searchdupe' => 'Search for duplicate files', # File reversion 'filerevert' => 'Revert $1', diff --git a/skins/common/shared.css b/skins/common/shared.css index 5d0cdfe953..ed11ec8e06 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -224,3 +224,6 @@ h4.mw-specialpagesgroup { margin: .3em 0em 0em 0em; } +#shared-image-dup, #shared-image-conflict { + font-style: italic; +} -- 2.20.1