}
/**
- * @param $file
+ * @param File $file
* @return bool
*/
function mustRender( $file ) {
}
/**
- * @param $file
+ * @param File $file
* @return bool
*/
function isMultiPage( $file ) {
}
/**
- * @param $name
- * @param $value
+ * @param string $name
+ * @param mixed $value
* @return bool
*/
function validateParam( $name, $value ) {
}
/**
- * @param $params
+ * @param array $params
* @return bool|string
*/
function makeParamString( $params ) {
}
/**
- * @param $str
+ * @param string $str
* @return array|bool
*/
function parseParamString( $str ) {
}
/**
- * @param $params
+ * @param array $params
* @return array
*/
function getScriptParams( $params ) {
}
/**
- * @param $image File
- * @param $dstPath
- * @param $dstUrl
- * @param $params
+ * @param File $image
+ * @param string $dstPath
+ * @param string $dstUrl
+ * @param array $params
* @param int $flags
* @return MediaTransformError|ThumbnailImage|TransformParameterError
*/
$srcPath = $image->getLocalRefPath();
# Use a subshell (brackets) to aggregate stderr from both pipeline commands
# before redirecting it to the overall stdout. This works in both Linux and Windows XP.
- $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page}" .
- " -size={$params['physicalWidth']}x{$params['physicalHeight']} " .
- wfEscapeShellArg( $srcPath );
+ $cmd = '(' . wfEscapeShellArg(
+ $wgDjvuRenderer,
+ "-format=ppm",
+ "-page={$page}",
+ "-size={$params['physicalWidth']}x{$params['physicalHeight']}",
+ $srcPath );
if ( $wgDjvuPostProcessor ) {
$cmd .= " | {$wgDjvuPostProcessor}";
}
/**
* Cache an instance of DjVuImage in an Image object, return that instance
*
+ * @param File $image
+ * @param string $path
* @return DjVuImage
*/
function getDjVuImage( $image, $path ) {
/**
* Cache a document tree for the DjVu XML metadata
- * @param $image File
- * @param $gettext Boolean: DOCUMENT (Default: false)
- * @return bool
+ * @param File $image
+ * @param bool $gettext DOCUMENT (Default: false)
+ * @return bool|SimpleXMLElement
*/
function getMetaTree( $image, $gettext = false ) {
- if ( isset( $image->dejaMetaTree ) ) {
+ if ( $gettext && isset( $image->djvuTextTree ) ) {
+ return $image->djvuTextTree;
+ }
+ if ( !$gettext && isset( $image->dejaMetaTree ) ) {
return $image->dejaMetaTree;
}
$image->djvuTextTree = false;
$tree = new SimpleXMLElement( $metadata );
if ( $tree->getName() == 'mw-djvu' ) {
+ /** @var SimpleXMLElement $b */
foreach ( $tree->children() as $b ) {
if ( $b->getName() == 'DjVuTxt' ) {
+ // @todo File::djvuTextTree and File::dejaMetaTree are declared
+ // dynamically. Add a public File::$data to facilitate this?
$image->djvuTextTree = $b;
} elseif ( $b->getName() == 'DjVuXML' ) {
$image->dejaMetaTree = $b;
}
}
+ /**
+ * @param File $image
+ * @param string $path
+ * @return bool|array False on failure
+ */
function getImageSize( $image, $path ) {
return $this->getDjVuImage( $image, $path )->getImageSize();
}
}
}
+ /**
+ * @param File $image
+ * @param int $page Page number to get information for
+ * @return bool|string Page text or false when no text found.
+ */
function getPageText( $image, $page ) {
$tree = $this->getMetaTree( $image, true );
if ( !$tree ) {