From fd6201da55ef3c0f34e013945c231e9123a82c08 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Tue, 20 Mar 2007 17:29:35 +0000 Subject: [PATCH] * (bug 3069) Warning on upload of scaled down images 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 | 3 ++ includes/SpecialUpload.php | 53 +++++++++++++++++++++++++------ languages/messages/MessagesDe.php | 10 +++++- languages/messages/MessagesEn.php | 18 ++++++++--- maintenance/language/messages.inc | 3 ++ 5 files changed, 71 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 54f01c967e..f91d62074e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 9b58cefcd5..9b110d5a39 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -410,26 +410,59 @@ class UploadForm { $warning .= '
  • '.wfMsgHtml( 'emptyfile' ).'
  • '; } + 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) == '' . $dlink2; - } else { + $warning .= '
  • ' . wfMsgExt( 'fileexists', 'parseline', $dlink ) . '
  • ' . $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) == '
    ' . $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) == '' . $dlink2; + } else { + # Image w/o '180px-' does not exists, but we do not like these filenames + $warning .= '
  • ' . wfMsgExt( 'file-thumbnail-no', 'parseinline' , substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '
  • '; + } + } + 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 != '' ) { diff --git a/languages/messages/MessagesDe.php b/languages/messages/MessagesDe.php index b2dc2bad99..9a12e4a418 100644 --- a/languages/messages/MessagesDe.php +++ b/languages/messages/MessagesDe.php @@ -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 $1, wenn Sie sich nicht sicher sind.', +'fileexists-extension' => "Eine Datei mit ähnlichem Namen existiert bereits:
    +Name der hochzuladenden Datei: $1
    +Name der vorhandenen Datei: $2
    +Nur die Dateiendung unterscheidet sich in Groß-/Kleinschreibung. Bitte prüfen Sie, ob die Dateien inhaltlich identisch sind.", 'fileexists-thumb' => "'''
    Vorhandenes Bild
    '''", +'fileexists-thumbnail-yes' => "Bei der Datei scheint es sich um ein Bild verringerter Größe (thumbnail) zu handeln. Bitte prüfen Sie die Datei $1.
    +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 $1. Dies deutet auf ein Bild verringerter Größe (thumbnail) 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', diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b848d2584e..7ab0302651 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' => "'''
    Existing image
    '''", -'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 $1 if you are not sure if you want to change it.', +'fileexists-extension' => 'A file with a similiar name exists:
    +Name of the uploading file: $1
    +Name of the existing file: $2
    +The only difference is in the lower/uppercase of the extension. Please check the files for identity.', +'fileexists-thumb' => "'''
    Existing image
    '''", +'fileexists-thumbnail-yes' => "The file seems to be an image of reduced size (thumbnail) zu handeln. Please check the file $1.
    +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 $1. It seems to be an image of reduced size (thumbnail). +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 diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 5468a67eb6..8913201158 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', -- 2.20.1