* 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 ==
$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 ) {
$image->loadFromFile();
# Record the upload
- if( $image->recordUpload( '', 'Importing image file' ) ) {
+ if( $image->recordUpload( '', $comment, $license ) ) {
# We're done!
echo( "done.\n" );
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();
}