* (bug 3069) Warning on upload of scaled down images
authorRaimond Spekking <raymond@users.mediawiki.org>
Tue, 20 Mar 2007 17:29:35 +0000 (17:29 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Tue, 20 Mar 2007 17:29:35 +0000 (17:29 +0000)
  Warning on upload of images with uppercase extension if image with lowercase
  extension exists

Please check the new English messages for typos and grammar. Thks.

RELEASE-NOTES
includes/SpecialUpload.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 54f01c9..f91d620 100644 (file)
@@ -279,6 +279,9 @@ lighter making things easier to read.
 * (bug 8716) Change math_inputhash and math_outputhash to byte for Postgres
 * (bug 8558) Correct display of timestamps on some pages when using Postgres
 * (bug 9343) Correct Wolof interwiki links
+* (bug 3069) Warning on upload of scaled down images
+  Warning on upload of images with uppercase extension if image with lowercase
+  extension exists
 
 == Languages updated ==
 
index 9b58cef..9b110d5 100644 (file)
@@ -410,26 +410,59 @@ class UploadForm {
                                $warning .= '<li>'.wfMsgHtml( 'emptyfile' ).'</li>';
                        }
 
+                       global $wgUser;
+                       $sk = $wgUser->getSkin();
                        $image = new Image( $nt );
+
+                       // Check for uppercase extension. We allow these filenames but check if an image
+                       // with lowercase extension exists already
+                       if ( $finalExt != strtolower( $finalExt ) ) {
+                               $nt_lc = Title::newFromText( $partname . '.' . strtolower( $finalExt ) );
+                               $image_lc = new Image( $nt_lc );
+                       }
+
                        if( $image->exists() ) {
-                               global $wgUser;
-                               $sk = $wgUser->getSkin();
                                $dlink = $sk->makeKnownLinkObj( $nt );
                                $dlink2 = $sk->makeImageLinkObj( $nt, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ), $nt->getText(), 'right', false, false, false, true );
 
                                # when $dlink2 begins with a normal href it is not a thumbnail -> do not show the link twice
                                if ( substr( $dlink2, 0, 7) == '<a href' ) $dlink2 = '';
 
-                               $warning .= '<li>' . wfMsgHtml( 'fileexists', $dlink ) . '</li>' . $dlink2;
-                       } else {
+                               $warning .= '<li>' . wfMsgExt( 'fileexists', 'parseline', $dlink ) . '</li>' . $dlink2;
+
+                       } elseif ( isset( $image_lc) && $image_lc->exists() ) {
+                               # Check if image with lowercase extension exists.
+                               # It's not forbidden but in 99% it makes no sense to upload the same filename with uppercase extension
+                               $dlink = $sk->makeKnownLinkObj( $nt_lc );
+                               $dlink2 = $sk->makeImageLinkObj( $nt_lc, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ), $nt_lc->getText(), 'right', false, false, false, true );
+
+                               # when $dlink2 begins with a normal href it is not a thumbnail -> do not show the link twice
+                               if ( substr( $dlink2, 0, 7) == '<a href' ) $dlink2 = '';
+
+                               $warning .= '<li>' . wfMsgExt( 'fileexists-extension', 'parsemag' , $partname . '.' . $finalExt , $dlink ) . '</li>' . $dlink2;                         
+
+                       } elseif ( ( substr( $partname , 3, 3 ) == 'px-' || substr( $partname , 2, 3 ) == 'px-' ) && ereg( "[0-9]{2}" , substr( $partname , 0, 2) ) ) {
+                               # Check for filenames like 50px- or 180px-, these are mostly thumbnails
+                               $nt_thb = Title::newFromText( substr( $partname , strpos( $partname , '-' ) +1 ) . '.' . $finalExt );
+                               $image_thb = new Image( $nt_thb );
+                               if ($image_thb->exists() ) {
+                                       # Check if an image without leading '180px-' (or similiar) exists
+                                       $dlink = $sk->makeKnownLinkObj( $nt_thb);
+                                       $dlink2 = $sk->makeImageLinkObj( $nt_thb, wfMsgExt( 'fileexists-thumb', 'parseinline', $dlink ), $nt_thb->getText(), 'right', false, false, false, true );
+                                       # when $dlink2 begins with a normal href it is not a thumbnail -> do not show the link twice
+                                       if ( substr( $dlink2, 0, 7) == '<a href' ) $dlink2 = '';
+                                       $warning .= '<li>' . wfMsgExt( 'fileexists-thumbnail-yes', 'parsemag', $dlink ) . '</li>' . $dlink2;    
+                               } else {
+                                       # Image w/o '180px-' does not exists, but we do not like these filenames
+                                       $warning .= '<li>' . wfMsgExt( 'file-thumbnail-no', 'parseinline' , substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '</li>';
+                               }
+                       }
+                       if ( $image->wasDeleted() ) {
                                # If the file existed before and was deleted, warn the user of this
                                # Don't bother doing so if the image exists now, however
-                               if( $image->wasDeleted() ) {
-                                       $skin = $wgUser->getSkin();
-                                       $ltitle = SpecialPage::getTitleFor( 'Log' );
-                                       $llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
-                                       $warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
-                               }
+                               $ltitle = SpecialPage::getTitleFor( 'Log' );
+                               $llink = $sk->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
+                               $warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
                        }
 
                        if( $warning != '' ) {
index b2dc2ba..9a12e4a 100644 (file)
@@ -980,8 +980,16 @@ Bitte beachten Sie, dass, genau wie bei normalen Seiteninhalten, andere Benutzer
 'large-file'                  => 'Die Dateigröße sollte nach Möglichkeit $1 nicht überschreiten. Diese Datei ist $2 groß.',
 'largefileserver'             => 'Die Datei ist größer als die vom Server eingestellte Maximalgröße.',
 'emptyfile'                   => 'Die hochgeladene Datei ist leer. Der Grund kann ein Tippfehler im Dateinamen sein. Bitte kontrollieren Sie, ob Sie die Datei wirklich hochladen wollen.',
-'fileexists'                  => 'Eine Datei mit diesem Namen existiert bereits. Wenn Sie auf „Datei speichern“ klicken, wird die Datei überschrieben. Bitte prüfen Sie $1, wenn Sie sich nicht sicher sind.',
+'fileexists'                  => 'Eine Datei mit diesem Namen existiert bereits. Wenn Sie auf „Datei speichern“ klicken, wird die Datei überschrieben. Bitte prüfen Sie <strong><tt>$1</tt></strong>, wenn Sie sich nicht sicher sind.',
+'fileexists-extension'        => "Eine Datei mit ähnlichem Namen existiert bereits:<br />
+Name der hochzuladenden Datei: <strong><tt>$1</tt></strong><br />
+Name der vorhandenen Datei: <strong><tt>$2</tt></strong><br />
+Nur die Dateiendung unterscheidet sich in Groß-/Kleinschreibung. Bitte prüfen Sie, ob die Dateien inhaltlich identisch sind.",
 'fileexists-thumb'            => "'''<center>Vorhandenes Bild</center>'''",
+'fileexists-thumbnail-yes'    => "Bei der Datei scheint es sich um ein Bild verringerter Größe <i>(thumbnail)</i> zu handeln. Bitte prüfen Sie die Datei <strong><tt>$1</tt></strong>.<br />
+Wenn es sich um das Bild in Originalgröße handelt, so braucht kein separates Vorschaubild hochgeladen zu werden.",
+'file-thumbnail-no'           => "Der Dateiname beginnt mit <strong><tt>$1</tt></strong>. Dies deutet auf ein Bild verringerter Größe <i>(thumbnail)</i> hin.
+Bitte prüfen Sie, ob Sie das Bild in voller Auflösung vorliegen haben und laden Sie dieses unter dem Originalnamen hoch.",
 'fileexists-forbidden'        => 'Mit diesem Namen existiert bereits eine Datei. Bitte gehen Sie zurück und laden Ihre Datei unter einem anderen Namen hoch. [[Image:$1|thumb|center|$1]]',
 'fileexists-shared-forbidden' => 'Mit diesem Namen existiert bereits eine Datei. Bitte gehen Sie zurück und laden Sie diese Datei unter einem anderen Namen hoch. [[Image:$1|thumb|center|$1]]',
 'successfulupload'            => 'Erfolgreich hochgeladen',
index b848d25..7ab0302 100644 (file)
@@ -1357,11 +1357,19 @@ To include the image in a page, use a link in the form
 'filetype-missing'            => 'The file has no extension (like ".jpg").',
 'large-file' => 'It is recommended that files are no larger than $1; this file is $2.',
 'largefileserver' => 'This file is bigger than the server is configured to allow.',
-'emptyfile'            => 'The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file.',
-'fileexists'           => 'A file with this name exists already, please check $1 if you are not sure if you want to change it.',
-'fileexists-thumb'      => "'''<center>Existing image</center>'''",
-'fileexists-forbidden' => 'A file with this name exists already; please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
-'fileexists-shared-forbidden' => 'A file with this name exists already in the shared file repository; please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
+'emptyfile'                  => 'The file you uploaded seems to be empty. This might be due to a typo in the file name. Please check whether you really want to upload this file.',
+'fileexists'                 => 'A file with this name exists already, please check <strong><tt>$1</tt></strong> if you are not sure if you want to change it.',
+'fileexists-extension'        => 'A file with a similiar name exists:<br />
+Name of the uploading file: <strong><tt>$1</tt></strong><br />
+Name of the existing file: <strong><tt>$2</tt></strong><br />
+The only difference is in the lower/uppercase of the extension. Please check the files for identity.',
+'fileexists-thumb'             => "'''<center>Existing image</center>'''",
+'fileexists-thumbnail-yes'     => "The file seems to be an image of reduced size <i>(thumbnail)</i> zu handeln. Please check the file <strong><tt>$1</tt></strong>.<br />
+If the checked file is the same image of original size it is not necessary to upload an extra thumbnail.",
+'file-thumbnail-no'            => "The filename begins with <strong><tt>$1</tt></strong>. It seems to be an image of reduced size <i>(thumbnail)</i>.
+If you have this image in full resolution upload this one, otherwise change the file name please.",
+'fileexists-forbidden'         => 'A file with this name exists already; please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
+'fileexists-shared-forbidden'  => 'A file with this name exists already in the shared file repository; please go back and upload this file under a new name. [[Image:$1|thumb|center|$1]]',
 'successfulupload' => 'Successful upload',
 'fileuploaded' => "File $1 uploaded successfully.
 Please follow this link: $2 to the description page and fill
index 5468a67..8913201 100644 (file)
@@ -778,7 +778,10 @@ $wgMessageStructure = array(
                'largefileserver',
                'emptyfile',
                'fileexists',
+               'fileexists-extension',
                'fileexists-thumb',
+               'fileexists-thumbnail-yes',
+               'file-thumbnail-no',
                'fileexists-forbidden',
                'fileexists-shared-forbidden',
                'successfulupload',