+require_once __DIR__ . '/Maintenance.php';
+
+class ImportImages extends Maintenance {
+
+ public function __construct() {
+ parent::__construct();
+
+ $this->addDescription( 'Imports images and other media files into the wiki' );
+ $this->addArg( 'dir', 'Path to the directory containing images to be imported' );
+
+ $this->addOption( 'extensions',
+ 'Comma-separated list of allowable extensions, defaults to $wgFileExtensions',
+ false,
+ true
+ );
+ $this->addOption( 'overwrite',
+ 'Overwrite existing images with the same name (default is to skip them)' );
+ $this->addOption( 'limit',
+ 'Limit the number of images to process. Ignored or skipped images are not counted',
+ false,
+ true
+ );
+ $this->addOption( 'from',
+ "Ignore all files until the one with the given name. Useful for resuming aborted "
+ . "imports. The name should be the file's canonical database form.",
+ false,
+ true
+ );
+ $this->addOption( 'skip-dupes',
+ 'Skip images that were already uploaded under a different name (check SHA1)' );
+ $this->addOption( 'search-recursively', 'Search recursively for files in subdirectories' );
+ $this->addOption( 'sleep',
+ 'Sleep between files. Useful mostly for debugging',
+ false,
+ true
+ );
+ $this->addOption( 'user',
+ "Set username of uploader, default 'Maintenance script'",
+ false,
+ true
+ );
+ // This parameter can optionally have an argument. If none specified, getOption()
+ // returns 1 which is precisely what we need.
+ $this->addOption( 'check-userblock', 'Check if the user got blocked during import' );
+ $this->addOption( 'comment',
+ "Set file description, default 'Importing file'",
+ false,
+ true
+ );
+ $this->addOption( 'comment-file',
+ 'Set description to the content of this file',
+ false,
+ true
+ );
+ $this->addOption( 'comment-ext',
+ 'Causes the description for each file to be loaded from a file with the same name, but '
+ . 'the extension provided. If a global description is also given, it is appended.',
+ false,
+ true
+ );
+ $this->addOption( 'summary',
+ 'Upload summary, description will be used if not provided',
+ false,
+ true
+ );
+ $this->addOption( 'license',
+ 'Use an optional license template',
+ false,
+ true
+ );
+ $this->addOption( 'timestamp',
+ 'Override upload time/date, all MediaWiki timestamp formats are accepted',
+ false,
+ true
+ );
+ $this->addOption( 'protect',
+ 'Specify the protect value (autoconfirmed,sysop)',
+ false,
+ true
+ );
+ $this->addOption( 'unprotect', 'Unprotects all uploaded images' );
+ $this->addOption( 'source-wiki-url',
+ 'If specified, take User and Comment data for each imported file from this URL. '
+ . 'For example, --source-wiki-url="http://en.wikipedia.org/',
+ false,
+ true
+ );
+ $this->addOption( 'dry', "Dry run, don't import anything" );
+ }