MediaWiki  REL1_20
generateRandomImages.php
Go to the documentation of this file.
00001 <?php
00008 // Evaluate the include path relative to this file
00009 $IP = dirname( dirname( dirname( dirname( __DIR__ ) ) ) );
00010 
00011 // Start up MediaWiki in command-line mode
00012 require_once( "$IP/maintenance/Maintenance.php" );
00013 require(  __DIR__ . "/RandomImageGenerator.php" );
00014 
00015 class GenerateRandomImages extends Maintenance {
00016 
00017         public function getDbType() {
00018                 return Maintenance::DB_NONE;
00019         }
00020 
00021         public function execute() {
00022 
00023                 $getOptSpec = array(
00024                         'dictionaryFile::',
00025                         'minWidth::',
00026                         'maxWidth::',
00027                         'minHeight::',
00028                         'maxHeight::',
00029                         'shapesToDraw::',
00030                         'shape::',
00031 
00032                         'number::',
00033                         'format::'
00034                 );
00035                 $options = getopt( null, $getOptSpec );
00036 
00037                 $format = isset( $options['format'] ) ? $options['format'] : 'jpg';
00038                 unset( $options['format'] );
00039 
00040                 $number = isset( $options['number'] ) ? intval( $options['number'] ) : 10;
00041                 unset( $options['number'] );
00042 
00043                 $randomImageGenerator = new RandomImageGenerator( $options );
00044                 $randomImageGenerator->writeImages( $number, $format );
00045         }
00046 }
00047 
00048 $maintClass = 'GenerateRandomImages';
00049 require( RUN_MAINTENANCE_IF_MAIN );
00050 
00051