From d81f562b712f2387fa02290bf2ca86392ab356f2 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 20:21:25 +0000 Subject: Aktualisierung auf Version 1.8.1 --- maintenance/importImages.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'maintenance/importImages.php') diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 925c64b7..2cf8bd19 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -26,13 +26,25 @@ 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 ) { - $base = basename( $file ); + $base = wfBaseName( $file ); # Validate a title $title = Title::makeTitleSafe( NS_IMAGE, $base ); @@ -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(); } -- cgit v1.2.3-54-g00ecf