* (bug 889) Improve conflict-handling between shared upload repository (commons)...
authorVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 28 Apr 2008 16:28:07 +0000 (16:28 +0000)
committerVictor Vasiliev <vasilievvv@users.mediawiki.org>
Mon, 28 Apr 2008 16:28:07 +0000 (16:28 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/ImagePage.php
languages/messages/MessagesEn.php
skins/common/shared.css

index 86cd3f8..60df56f 100644 (file)
@@ -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 ===
 
index d696dd7..ed6b6a4 100644 (file)
@@ -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:
index 6206b1c..ddb8512 100644 (file)
@@ -81,6 +81,8 @@ class ImagePage extends Article {
                                $wgOut->addWikiText( $fol );
                        }
                        $wgOut->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . '</div>' );
+               } 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( '<div id="shared-image-dup">' . wfMsgWikiHtml( 'shareduploadduplicate', $link ) . '</div>' );
+               } else {
+                       $link = $sk->makeExternalLink( $descUrl, wfMsg( 'shareduploadconflict-linktext' ) );
+                       $wgOut->addHTML( '<div id="shared-image-conflict">' . wfMsgWikiHtml( 'shareduploadconflict', $link ) . '</div>' );
+               }
+       }
+
        function getUploadUrl() {
                $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
                return $uploadTitle->getFullUrl( 'wpDestFile=' . urlencode( $this->img->getName() ) );
index 0080a72..eeab3ba 100644 (file)
@@ -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',
index 5d0cdfe..ed11ec8 100644 (file)
@@ -224,3 +224,6 @@ h4.mw-specialpagesgroup {
        margin: .3em 0em 0em 0em;
 }
 
+#shared-image-dup, #shared-image-conflict {
+       font-style: italic;
+}