Index: trunk/extensions/PagedTiffHandler/tests/ShowMetadata.php |
— | — | @@ -0,0 +1,54 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * To get this working you must |
| 5 | + * - set a valid path to PEAR |
| 6 | + * - check upload size in php.ini: Multipage.tiff needs at least 3M |
| 7 | + * - Upload the image truncated.tiff without PagedTiffHandler being active |
| 8 | + * Caution: you need to allow tiff for upload: |
| 9 | + * $wgFileExtensions[] = 'tiff'; |
| 10 | + * $wgFileExtensions[] = 'tif'; |
| 11 | + * - Upload multipage.tiff when PagedTiffHandler is active |
| 12 | + */ |
| 13 | + |
| 14 | +if ( getenv( 'MW_INSTALL_PATH' ) ) { |
| 15 | + $IP = getenv( 'MW_INSTALL_PATH' ); |
| 16 | +} else { |
| 17 | + $IP = dirname( __FILE__ ) . '/../../..'; |
| 18 | +} |
| 19 | +require_once( "$IP/maintenance/Maintenance.php" ); |
| 20 | + |
| 21 | +error_reporting( E_ALL ); |
| 22 | + |
| 23 | +$wgShowExceptionDetails = true; |
| 24 | + |
| 25 | +class ShowMetadata extends Maintenance { |
| 26 | + public function __construct() { |
| 27 | + parent::__construct(); |
| 28 | + } |
| 29 | + |
| 30 | + public function execute() { |
| 31 | + $handler = new PagedTiffHandler(); |
| 32 | + |
| 33 | + $path = $this->mArgs[0]; |
| 34 | + $file = UnregisteredLocalFile::newFromPath($path, "image/tiff"); |
| 35 | + |
| 36 | + $metadata = $handler->getMetadata( $file, $path ); |
| 37 | + |
| 38 | + if ( !$metadata ) { |
| 39 | + print "FAILED! \n"; |
| 40 | + return; |
| 41 | + } |
| 42 | + |
| 43 | + $metadata = unserialize( $metadata ); |
| 44 | + |
| 45 | + if ( !$metadata ) { |
| 46 | + print "BROKEN! \n"; |
| 47 | + return; |
| 48 | + } |
| 49 | + |
| 50 | + print_r($metadata); |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +$maintClass = "ShowMetadata"; |
| 55 | +require_once( DO_MAINTENANCE ); |