* Add --user, --comment, and --license options to importImages.php
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 11 Sep 2006 13:12:52 +0000 (13:12 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 11 Sep 2006 13:12:52 +0000 (13:12 +0000)
RELEASE-NOTES
maintenance/importImages.php

index 42eeb15..827fa5c 100644 (file)
@@ -194,6 +194,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Clear newtalk marker on diff links with explicit current revision number
 * (bug 7064) Replace hard-coded empty message checks with wfEmptyMsg calls
 * (bug 6777) Remove some PHP 4 compat cruft
+* Add --user, --comment, and --license options to importImages.php
 
 
 == Languages updated ==
index a2b889e..2cf8bd1 100644 (file)
@@ -26,8 +26,20 @@ if( count( $args ) > 1 ) {
        $files = findFiles( $dir, $exts );
 
        # Set up a fake user for this operation
-       $wgUser = User::newFromName( 'Image import script' );
-       $wgUser->setLoaded( true );
+       if( isset( $options['user'] ) ) {
+               $wgUser = User::newFromName( $options['user'] );
+       } else {
+               $wgUser = User::newFromName( 'Image import script' );
+               $wgUser->setLoaded( true );
+       }
+       
+       # Get the upload comment
+       $comment = isset( $options['comment'] )
+               ? $options['comment']
+               : 'Importing image file';
+       
+       # Get the license specifier
+       $license = isset( $options['license'] ) ? $options['license'] : '';
        
        # Batch "upload" operation
        foreach( $files as $file ) {
@@ -59,7 +71,7 @@ if( count( $args ) > 1 ) {
                                        $image->loadFromFile();
                                        
                                        # Record the upload
-                                       if( $image->recordUpload( '', 'Importing image file' ) ) {
+                                       if( $image->recordUpload( '', $comment, $license ) ) {
                                        
                                                # We're done!
                                                echo( "done.\n" );
@@ -92,9 +104,18 @@ exit();
 function showUsage( $reason = false ) {
        if( $reason )
                echo( $reason . "\n" );
-       echo( "USAGE: php importImages.php <dir> <ext1> <ext2>\n\n" );
-       echo( "<dir> : Path to the directory containing images to be imported\n" );
-       echo( "<ext1+> File extensions to import\n\n" );                
+       echo <<<END
+USAGE: php importImages.php [options] <dir> <ext1> ...
+
+<dir> : Path to the directory containing images to be imported
+<ext1+> File extensions to import
+
+Options:
+--user=<username> Set username of uploader, default 'Image import script'
+--comment=<text>  Set upload summary comment, default 'Importing image file'
+--license=<code>  Use an optional license template
+
+END;
        exit();
 }