summaryrefslogtreecommitdiff
path: root/maintenance/importImages.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
commitd81f562b712f2387fa02290bf2ca86392ab356f2 (patch)
treed666cdefbe6ac320827a2c6cb473581b46e22c4c /maintenance/importImages.php
parent183851b06bd6c52f3cae5375f433da720d410447 (diff)
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'maintenance/importImages.php')
-rw-r--r--maintenance/importImages.php35
1 files changed, 28 insertions, 7 deletions
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 <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();
}