Some naming cleanup of the filename prefix blacklist added in r25620:
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Sep 2007 13:52:55 +0000 (13:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 7 Sep 2007 13:52:55 +0000 (13:52 +0000)
* Dropped a redundant if(count()) around a foreach().
* Renamed SpecialUpload::getFilenamePrefix() to getFilenamePrefixBlacklist(), since it returns a blacklist of filename prefixes, not the prefix of a filename. :)
* Renamed some local variables to match
* Renamed 'filename-prefix' message to 'filename-bad-prefix' and 'filename-prefix-list' to 'filename-prefix-blacklist' to clarify usage.

includes/SpecialUpload.php
languages/messages/MessagesDa.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 14338d6..0360d33 100644 (file)
@@ -543,14 +543,12 @@ class UploadForm {
                        }
                }
 
-               $filenamePrefix = self::getFilenamePrefix();
-               if ( count( $filenamePrefix ) ) {
-                       # Do the match
-                       foreach( $filenamePrefix as $prefix ) {
-                               if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) {
-                                       $warning .= '<li>' . wfMsgExt( 'filename-prefix', 'parseinline', $prefix ) . '</li>';
-                                       break;
-                               }
+               $filenamePrefixBlacklist = self::getFilenamePrefixBlacklist();
+               # Do the match
+               foreach( $filenamePrefixBlacklist as $prefix ) {
+                       if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) {
+                               $warning .= '<li>' . wfMsgExt( 'filename-bad-prefix', 'parseinline', $prefix ) . '</li>';
+                               break;
                        }
                }
 
@@ -608,13 +606,14 @@ class UploadForm {
        }
 
        /**
-        * Get a list of filename prefixes from [[MediaWiki:filename-prefix-list]]
+        * Get a list of blacklisted filename prefixes from [[MediaWiki:filename-prefix-blacklist]]
         *
         * @return array list of prefixes
         */
-       public static function getFilenamePrefix() {
-               $message = wfMsgForContent( 'filename-prefix-list' );
-               if( $message && !( wfEmptyMsg( 'filename-prefix-list', $message ) || $message == '-' ) ) {
+       public static function getFilenamePrefixBlacklist() {
+               $blacklist = array();
+               $message = wfMsgForContent( 'filename-prefix-blacklist' );
+               if( $message && !( wfEmptyMsg( 'filename-prefix-blacklist', $message ) || $message == '-' ) ) {
                        $lines = explode( "\n", $message );
                        foreach( $lines as $line ) {
                                // Remove comment lines
@@ -627,12 +626,10 @@ class UploadForm {
                                if ( $comment > 0 ) {
                                        $line = substr( $line, 0, $comment-1 );
                                }
-                               $filenamePrefix[] = trim( $line );
+                               $blacklist[] = trim( $line );
                        }
-               } else {
-                       $filenamePrefix = array();
                }
-               return $filenamePrefix;
+               return $blacklist;
        }
 
        /**
index 5f3c3a1..c54cea2 100644 (file)
@@ -1045,7 +1045,7 @@ Kontroller om du har billedet i fuld størrelse og upload det under det original
 'destfilename'                => 'Målnavn',
 'watchthisupload'             => 'Overvåge denne side',
 'filewasdeleted'              => 'En fil med dette navn er tidligere uploadet og i mellemtiden slettet igen. Kontroller først indførslen i $1, før du gemmer filen.',
-'filename-prefix'             => 'Navnet på filen du er ved at lægge op begynder med <strong>"$1"</strong>. Dette er et ikkebeskrivende navn, der typisk er skabt automatisk af et digitalkamera. Vær venlig at vælge et mere beskrivende navn på dit billede.',
+'filename-bad-prefix'         => 'Navnet på filen du er ved at lægge op begynder med <strong>"$1"</strong>. Dette er et ikkebeskrivende navn, der typisk er skabt automatisk af et digitalkamera. Vær venlig at vælge et mere beskrivende navn på dit billede.',
 
 'upload-proto-error'      => 'Forkert protokol',
 'upload-proto-error-text' => 'Adressen skal begynde med <code>http://</code> eller <code>ftp://</code>.',
index df53966..a99cd7c 100644 (file)
@@ -1073,7 +1073,7 @@ Bitte prüfe, ob du das Bild in voller Auflösung vorliegen hast und lade dieses
 'destfilename'                => 'Zielname',
 'watchthisupload'             => 'Diese Seite beobachten',
 'filewasdeleted'              => 'Eine Datei mit diesem Namen wurde schon einmal hochgeladen und zwischenzeitlich wieder gelöscht. Bitte prüfe zuerst den Eintrag im $1, bevor du die Datei wirklich speicherst.',
-'filename-prefix'             => 'Der Dateiname beginnt mit <strong>„$1“</strong>. Dies ist im allgemeinen der von einer Digitalkamera vorgegebener Dateiname und daher nicht sehr aussagekräftig.
+'filename-bad-prefix'         => 'Der Dateiname beginnt mit <strong>„$1“</strong>. Dies ist im allgemeinen der von einer Digitalkamera vorgegebener Dateiname und daher nicht sehr aussagekräftig.
 Bitte gebe der Datei einen Namen, der den Inhalt besser beschreibt.',
 
 'upload-proto-error'      => 'Falsches Protokoll',
index 6e6763e..a7ea07a 100644 (file)
@@ -1422,8 +1422,8 @@ If you have this image in full resolution upload this one, otherwise change the
 'destfilename'                => 'Destination filename',
 'watchthisupload'             => 'Watch this page',
 'filewasdeleted'              => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.',
-'filename-prefix'             => 'The name of the file you are uploading begins with <strong>"$1"</strong>, which is a non-descriptive name typically assigned automatically by digital cameras. Please choose a more descriptive name for your file.',
-'filename-prefix-list'        => ' #<!-- leave this line exactly as it is --> <pre>
+'filename-bad-prefix'             => 'The name of the file you are uploading begins with <strong>"$1"</strong>, which is a non-descriptive name typically assigned automatically by digital cameras. Please choose a more descriptive name for your file.',
+'filename-prefix-blacklist'        => ' #<!-- leave this line exactly as it is --> <pre>
 # Syntax is as follows: 
 #   * Everything from a "#" character to the end of the line is a comment
 #   * Every non-blank line is a prefix for typical file names assigned automatically by digital cameras
index 3fafbac..c782a68 100644 (file)
@@ -824,8 +824,8 @@ $wgMessageStructure = array(
                'destfilename',
                'watchthisupload',
                'filewasdeleted',
-               'filename-prefix',
-               'filename-prefix-list',
+               'filename-bad-prefix',
+               'filename-prefix-blacklist',
        ),
        'upload-errors' => array(
                'upload-proto-error',