From 0da252934ffd9cf6a1bcea91656dc5aa64e5cbbb Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 11 Sep 2006 13:12:52 +0000 Subject: [PATCH] * Add --user, --comment, and --license options to importImages.php --- RELEASE-NOTES | 1 + maintenance/importImages.php | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 42eeb15c44..827fa5c536 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/maintenance/importImages.php b/maintenance/importImages.php index a2b889ee80..2cf8bd1966 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -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 \n\n" ); - echo( " : Path to the directory containing images to be imported\n" ); - echo( " File extensions to import\n\n" ); + echo << ... + + : Path to the directory containing images to be imported + File extensions to import + +Options: +--user= Set username of uploader, default 'Image import script' +--comment= Set upload summary comment, default 'Importing image file' +--license= Use an optional license template + +END; exit(); } -- 2.20.1