* @ingroup Media
*/
class DjVuHandler extends ImageHandler {
-
/**
* @return bool
*/
global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML;
if ( !$wgDjvuRenderer || ( !$wgDjvuDump && !$wgDjvuToXML ) ) {
wfDebug( "DjVu is disabled, please set \$wgDjvuRenderer and \$wgDjvuDump\n" );
+
return false;
} else {
return true;
if ( !isset( $params['width'] ) ) {
return false;
}
+
return "page{$page}-{$params['width']}px";
}
if ( !$xml ) {
$width = isset( $params['width'] ) ? $params['width'] : 0;
$height = isset( $params['height'] ) ? $params['height'] : 0;
+
return new MediaTransformError( 'thumbnail_error', $width, $height,
wfMessage( 'djvu_no_xml' )->text() );
}
'height' => $height,
'page' => $page
);
+
return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
}
$removed = $this->removeBadFile( $dstPath, $retval );
if ( $retval != 0 || $removed ) {
- wfDebugLog( 'thumbnail',
- sprintf( 'thumbnail failed on %s: error %d "%s" from "%s"',
- wfHostname(), $retval, trim( $err ), $cmd ) );
+ $this->logErrorForExternalProcess( $retval, $err, $cmd );
return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
} else {
$params = array(
'height' => $height,
'page' => $page
);
+
return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
}
}
} else {
$deja = $image->dejaImage;
}
+
return $deja;
}
$metadata = $image->getMetadata();
if ( !$this->isMetadataValid( $image, $metadata ) ) {
wfDebug( "DjVu XML metadata is invalid or missing, should have been fixed in upgradeRow\n" );
+
return false;
}
wfProfileIn( __METHOD__ );
$image->dejaMetaTree = false;
$image->djvuTextTree = false;
$tree = new SimpleXMLElement( $metadata );
- if( $tree->getName() == 'mw-djvu' ) {
- foreach( $tree->children() as $b ) {
- if( $b->getName() == 'DjVuTxt' ) {
+ if ( $tree->getName() == 'mw-djvu' ) {
+ foreach ( $tree->children() as $b ) {
+ if ( $b->getName() == 'DjVuTxt' ) {
$image->djvuTextTree = $b;
- }
- elseif ( $b->getName() == 'DjVuXML' ) {
+ } elseif ( $b->getName() == 'DjVuXML' ) {
$image->dejaMetaTree = $b;
}
}
} else {
$image->dejaMetaTree = $tree;
}
- } catch( Exception $e ) {
+ } catch ( Exception $e ) {
wfDebug( "Bogus multipage XML metadata on '{$image->getName()}'\n" );
}
wfRestoreWarnings();
wfProfileOut( __METHOD__ );
- if( $gettext ) {
+ if ( $gettext ) {
return $image->djvuTextTree;
} else {
return $image->dejaMetaTree;
$magic = MimeMagic::singleton();
$mime = $magic->guessTypesForExtension( $wgDjvuOutputExtension );
}
+
return array( $wgDjvuOutputExtension, $mime );
}
function getMetadata( $image, $path ) {
wfDebug( "Getting DjVu metadata for $path\n" );
+
return $this->getDjVuImage( $image, $path )->retrieveMetaData();
}
if ( !$tree ) {
return false;
}
+
return count( $tree->xpath( '//OBJECT' ) );
}
$o = $tree->BODY[0]->PAGE[$page - 1];
if ( $o ) {
$txt = $o['value'];
+
return $txt;
} else {
return false;
}
-
}
-
}