r25620 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25619‎ | r25620 | r25621 >
Date:08:42, 7 September 2007
Author:raymond
Status:old
Tags:
Comment:
* Add a warning for non-descriptive filenames at Special:Upload
* Some tweaks to RELEASE-NOTES
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -824,6 +824,8 @@
825825 'destfilename',
826826 'watchthisupload',
827827 'filewasdeleted',
 828+ 'filename-prefix',
 829+ 'filename-prefix-list',
828830 ),
829831 'upload-errors' => array(
830832 'upload-proto-error',
Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -204,6 +204,7 @@
205205 'filerevert-backlink',
206206 'filedelete-backlink',
207207 'pagetitle',
 208+ 'filename-prefix-list',
208209 );
209210
210211 /** 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 @@
543543 substr( $partname , 0, strpos( $partname , '-' ) +1 ) ) . '</li>';
544544 }
545545 }
 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+
546558 if ( $file->wasDeleted() ) {
547559 # If the file existed before and was deleted, warn the user of this
548560 # Don't bother doing so if the image exists now, however
@@ -553,6 +565,12 @@
554566 return $warning;
555567 }
556568
 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+ */
557575 static function ajaxGetExistsWarning( $filename ) {
558576 $file = wfFindFile( $filename );
559577 if( !$file ) {
@@ -590,6 +608,34 @@
591609 }
592610
593611 /**
 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+ /**
594640 * Stash a file in a temporary directory for later processing
595641 * after the user has confirmed it.
596642 *
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1422,6 +1422,21 @@
14231423 'destfilename' => 'Destination filename',
14241424 'watchthisupload' => 'Watch this page',
14251425 '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
14261441
14271442 'upload-proto-error' => 'Incorrect protocol',
14281443 '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 @@
10741074 'destfilename' => 'Zielname',
10751075 'watchthisupload' => 'Diese Seite beobachten',
10761076 '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.',
10771079
10781080 'upload-proto-error' => 'Falsches Protokoll',
10791081 '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 @@
1919 Those wishing to use the latest code instead of a branch release can obtain
2020 it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
2121
22 -=== Configuration changes since 1.11 ===
 22+=== Configuration changes in 1.12 ===
2323
2424 === New features in 1.12 ===
 25+* Add a warning for non-descriptive filenames at Special:Upload
2526
2627 === Bug fixes in 1.12 ===
2728
@@ -50,7 +51,7 @@
5152
5253 == Upgrading ==
5354
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
5556 updates.
5657
5758 If upgrading from before 1.7, you may want to run refreshLinks.php to ensure

Follow-up revisions

RevisionCommit summaryAuthorDate
r25637Some naming cleanup of the filename prefix blacklist added in r25620:...brion13:52, 7 September 2007
r25754Merged revisions 25607-25751 via svnmerge from...david23:02, 10 September 2007

Status & tagging log