Index: trunk/phase3/maintenance/language/messages.inc |
— | — | @@ -824,6 +824,8 @@ |
825 | 825 | 'destfilename', |
826 | 826 | 'watchthisupload', |
827 | 827 | 'filewasdeleted', |
| 828 | + 'filename-prefix', |
| 829 | + 'filename-prefix-list', |
828 | 830 | ), |
829 | 831 | 'upload-errors' => array( |
830 | 832 | 'upload-proto-error', |
Index: trunk/phase3/maintenance/language/messageTypes.inc |
— | — | @@ -204,6 +204,7 @@ |
205 | 205 | 'filerevert-backlink', |
206 | 206 | 'filedelete-backlink', |
207 | 207 | 'pagetitle', |
| 208 | + 'filename-prefix-list', |
208 | 209 | ); |
209 | 210 | |
210 | 211 | /** EXIF messages, which may be set as optional in several checks, but are generally mandatory */ |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -542,6 +542,18 @@ |
543 | 543 | substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '</li>'; |
544 | 544 | } |
545 | 545 | } |
| 546 | + |
| 547 | + $filenamePrefix = self::getFilenamePrefix(); |
| 548 | + if ( count( $filenamePrefix ) ) { |
| 549 | + # Do the match |
| 550 | + foreach( $filenamePrefix as $prefix ) { |
| 551 | + if ( substr( $partname, 0, strlen( $prefix ) ) == $prefix ) { |
| 552 | + $warning .= '<li>' . wfMsgExt( 'filename-prefix', 'parseinline', $prefix ) . '</li>'; |
| 553 | + break; |
| 554 | + } |
| 555 | + } |
| 556 | + } |
| 557 | + |
546 | 558 | if ( $file->wasDeleted() ) { |
547 | 559 | # If the file existed before and was deleted, warn the user of this |
548 | 560 | # Don't bother doing so if the image exists now, however |
— | — | @@ -553,6 +565,12 @@ |
554 | 566 | return $warning; |
555 | 567 | } |
556 | 568 | |
| 569 | + /** |
| 570 | + * Get a list of warnings |
| 571 | + * |
| 572 | + * @param string local filename, e.g. 'file exists', 'non-descriptive filename' |
| 573 | + * @return array list of warning messages |
| 574 | + */ |
557 | 575 | static function ajaxGetExistsWarning( $filename ) { |
558 | 576 | $file = wfFindFile( $filename ); |
559 | 577 | if( !$file ) { |
— | — | @@ -590,6 +608,34 @@ |
591 | 609 | } |
592 | 610 | |
593 | 611 | /** |
| 612 | + * Get a list of filename prefixes from [[MediaWiki:filename-prefix-list]] |
| 613 | + * |
| 614 | + * @return array list of prefixes |
| 615 | + */ |
| 616 | + public static function getFilenamePrefix() { |
| 617 | + $message = wfMsgForContent( 'filename-prefix-list' ); |
| 618 | + if( $message && !( wfEmptyMsg( 'filename-prefix-list', $message ) || $message == '-' ) ) { |
| 619 | + $lines = explode( "\n", $message ); |
| 620 | + foreach( $lines as $line ) { |
| 621 | + // Remove comment lines |
| 622 | + $comment = substr( trim( $line ), 0, 1 ); |
| 623 | + if ( $comment == '#' || $comment == '' ) { |
| 624 | + continue; |
| 625 | + } |
| 626 | + // Remove additional comments after a prefix |
| 627 | + $comment = strpos( $line, '#' ); |
| 628 | + if ( $comment > 0 ) { |
| 629 | + $line = substr( $line, 0, $comment-1 ); |
| 630 | + } |
| 631 | + $filenamePrefix[] = trim( $line ); |
| 632 | + } |
| 633 | + } else { |
| 634 | + $filenamePrefix = array(); |
| 635 | + } |
| 636 | + return $filenamePrefix; |
| 637 | + } |
| 638 | + |
| 639 | + /** |
594 | 640 | * Stash a file in a temporary directory for later processing |
595 | 641 | * after the user has confirmed it. |
596 | 642 | * |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1422,6 +1422,21 @@ |
1423 | 1423 | 'destfilename' => 'Destination filename', |
1424 | 1424 | 'watchthisupload' => 'Watch this page', |
1425 | 1425 | 'filewasdeleted' => 'A file of this name has been previously uploaded and subsequently deleted. You should check the $1 before proceeding to upload it again.', |
| 1426 | +'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.', |
| 1427 | +'filename-prefix-list' => ' #<!-- leave this line exactly as it is --> <pre> |
| 1428 | +# Syntax is as follows: |
| 1429 | +# * Everything from a "#" character to the end of the line is a comment |
| 1430 | +# * Every non-blank line is a prefix for typical file names assigned automatically by digital cameras |
| 1431 | +CIMG # Casio |
| 1432 | +DSC_ # Nikon |
| 1433 | +DSCF # Fuji |
| 1434 | +DSCN # Nikon |
| 1435 | +DUW # some mobil phones |
| 1436 | +IMG # generic |
| 1437 | +JD # Jenoptik |
| 1438 | +MGP # Pentax |
| 1439 | +PICT # misc. |
| 1440 | + #</pre> <!-- leave this line exactly as it is -->', # only translate this message to other languages if you have to change it |
1426 | 1441 | |
1427 | 1442 | 'upload-proto-error' => 'Incorrect protocol', |
1428 | 1443 | 'upload-proto-error-text' => 'Remote upload requires URLs beginning with <code>http://</code> or <code>ftp://</code>.', |
Index: trunk/phase3/languages/messages/MessagesDe.php |
— | — | @@ -1073,6 +1073,8 @@ |
1074 | 1074 | 'destfilename' => 'Zielname', |
1075 | 1075 | 'watchthisupload' => 'Diese Seite beobachten', |
1076 | 1076 | '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.', |
| 1077 | +'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. |
| 1078 | +Bitte gebe der Datei einen Namen, der den Inhalt besser beschreibt.', |
1077 | 1079 | |
1078 | 1080 | 'upload-proto-error' => 'Falsches Protokoll', |
1079 | 1081 | 'upload-proto-error-text' => 'Die URL muss mit <code>http://</code> oder <code>ftp://</code> beginnen.', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -18,9 +18,10 @@ |
19 | 19 | Those wishing to use the latest code instead of a branch release can obtain |
20 | 20 | it from source control: http://www.mediawiki.org/wiki/Download_from_SVN |
21 | 21 | |
22 | | -=== Configuration changes since 1.11 === |
| 22 | +=== Configuration changes in 1.12 === |
23 | 23 | |
24 | 24 | === New features in 1.12 === |
| 25 | +* Add a warning for non-descriptive filenames at Special:Upload |
25 | 26 | |
26 | 27 | === Bug fixes in 1.12 === |
27 | 28 | |
— | — | @@ -50,7 +51,7 @@ |
51 | 52 | |
52 | 53 | == Upgrading == |
53 | 54 | |
54 | | -1.12 has several database changes since 1.10, and will not work without schema |
| 55 | +1.12 has several database changes since 1.11, and will not work without schema |
55 | 56 | updates. |
56 | 57 | |
57 | 58 | If upgrading from before 1.7, you may want to run refreshLinks.php to ensure |