Go to the documentation of this file.
40 wfDebug(
"DjVu is disabled, please set \$wgDjvuRenderer and \$wgDjvuDump\n" );
62 return $file->getSize() > static::EXPENSIVE_SIZE_LIMIT;
78 'img_width' =>
'width',
94 if ( in_array(
$name, [
'width',
'height',
'page' ] ) ) {
111 if ( !isset(
$params[
'width'] ) ) {
115 return "page{$page}-{$params['width']}px";
124 if ( preg_match(
'/^page(\d+)-(\d+)px$/', $str, $m ) ) {
125 return [
'width' => $m[2],
'page' => $m[1] ];
160 if ( $flags & self::TRANSFORM_LATER ) {
182 if (
$image->getSize() >= 1e7 ) {
186 return $image->getLocalRefPath();
192 $srcPath =
$image->getLocalRefPath();
195 if ( $srcPath ===
false ) {
197 sprintf(
'Thumbnail failed on %s: could not get local copy of "%s"',
206 # Use a subshell (brackets) to aggregate stderr from both pipeline commands
207 # before redirecting it to the overall stdout. This works in both Linux and Windows XP.
208 $cmd =
'(' . Shell::escape(
212 "-size={$params['physicalWidth']}x{$params['physicalHeight']}",
215 $cmd .=
" | {$wgDjvuPostProcessor}";
217 $cmd .=
' > ' . Shell::escape( $dstPath ) .
') 2>&1';
218 wfDebug( __METHOD__ .
": $cmd\n" );
223 if ( $retval != 0 || $removed ) {
246 $deja =
new DjVuImage(
$path );
247 } elseif ( !isset(
$image->dejaImage ) ) {
248 $deja =
$image->dejaImage =
new DjVuImage(
$path );
250 $deja =
$image->dejaImage;
264 $metadata =
$file->getMetadata();
265 if ( substr( $metadata, 0, 3 ) ===
'<?xml' ) {
270 Wikimedia\suppressWarnings();
272 Wikimedia\restoreWarnings();
273 if ( is_array( $unser ) ) {
274 if ( isset( $unser[
'error'] ) ) {
276 } elseif ( isset( $unser[
'xml'] ) ) {
277 return $unser[
'xml'];
280 throw new MWException(
"Error unserializing DjVu metadata." );
295 if ( $gettext && isset(
$image->djvuTextTree ) ) {
296 return $image->djvuTextTree;
298 if ( !$gettext && isset(
$image->dejaMetaTree ) ) {
299 return $image->dejaMetaTree;
304 wfDebug(
"DjVu XML metadata is invalid or missing, should have been fixed in upgradeRow\n" );
310 $image->djvuTextTree = $trees[
'TextTree'];
311 $image->dejaMetaTree = $trees[
'MetaTree'];
314 return $image->djvuTextTree;
316 return $image->dejaMetaTree;
326 Wikimedia\suppressWarnings();
331 $tree =
new SimpleXMLElement( $metadata, LIBXML_PARSEHUGE );
332 if ( $tree->getName() ==
'mw-djvu' ) {
334 foreach ( $tree->children()
as $b ) {
335 if ( $b->getName() ==
'DjVuTxt' ) {
339 } elseif ( $b->getName() ==
'DjVuXML' ) {
346 }
catch ( Exception
$e ) {
347 wfDebug(
"Bogus multipage XML metadata\n" );
349 Wikimedia\restoreWarnings();
351 return [
'MetaTree' => $metaTree,
'TextTree' => $textTree ];
361 if ( !isset( $mime ) ) {
370 wfDebug(
"Getting DjVu metadata for $path\n" );
373 if ( $xml ===
false ) {
375 return serialize( [
'error' =>
'Error extracting metadata' ] );
386 return !empty( $metadata ) && $metadata !=
serialize( [] );
392 return $info ? $info[
'pageCount'] :
false;
399 if ( $info && isset( $info[
'dimensionsByPage'][$index] ) ) {
400 return $info[
'dimensionsByPage'][$index];
407 $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
408 return $cache->getWithSetCallback(
409 $cache->makeKey(
'file-djvu',
'dimensions',
$file->getSha1() ),
410 $cache::TTL_INDEFINITE,
415 [
'pcTTL' => $cache::TTL_INDEFINITE ]
430 $count =
count( $metatree->xpath(
'//OBJECT' ) );
431 for ( $i = 0; $i < $count; $i++ ) {
432 $o = $metatree->BODY[0]->OBJECT[$i];
435 'width' => (int)$o[
'width'],
436 'height' => (
int)$o[
'height'],
439 $dimsByPage[$i] =
false;
443 return [
'pageCount' => $count,
'dimensionsByPage' => $dimsByPage ];
457 $o = $tree->BODY[0]->PAGE[$page - 1];
isMetadataValid( $image, $metadata)
Check if the metadata string is valid for this handler.
Media transform output for images.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
getDimensionInfoFromMetaTree( $metatree)
Given an XML metadata tree, returns dimension information about the document.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
extractTreesFromMetadata( $metadata)
Extracts metadata and text trees from metadata XML in string form.
$wgDjvuPostProcessor
Shell command for the DJVU post processor Default: pnmtojpeg, since ddjvu generates ppm output Set th...
getUnserializedMetadata(File $file)
Get metadata, unserializing it if necessary.
pageCount(File $image)
Page count for a multi-page document, false if unsupported or unknown.
wfHostname()
Fetch server name for use in error reporting etc.
Convenience class for dealing with PoolCounters using callbacks.
makeParamString( $params)
$wgDjvuRenderer
Path of the ddjvu DJVU renderer Enable this and $wgDjvuDump to enable djvu rendering example: $wgDjvu...
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
const EXPENSIVE_SIZE_LIMIT
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
getMetadata( $image, $path)
Get handler-specific metadata which will be saved in the img_metadata field.
getDjVuImage( $image, $path)
Cache an instance of DjVuImage in an Image object, return that instance.
Implements some public methods and some protected utility functions which are required by multiple ch...
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
$wgDjvuToXML
Path of the djvutoxml executable This works like djvudump except much, much slower as of version 3....
getPageDimensions(File $image, $page)
Get an associative array of page dimensions Currently "width" and "height" are understood,...
Media handler abstract base class for images.
isExpensiveToThumbnail( $file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
validateParam( $name, $value)
$wgDjvuOutputExtension
File extension for the DJVU post processor output.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check $image
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
normaliseParams( $image, &$params)
Allows to change the fields on the form that will be generated $name
getImageSize( $image, $path)
Get an image size array like that returned by getimagesize(), or false if it can't be determined.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
getScriptParams( $params)
unserialize( $serialized)
getThumbType( $ext, $mime, $params=null)
Get the thumbnail extension and MIME type for a given source MIME type.
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getMetaTree( $image, $gettext=false)
Cache a document tree for the DjVu XML metadata.
if(!is_readable( $file)) $ext
$wgDjvuDump
Path of the djvudump executable Enable this and $wgDjvuRenderer to enable djvu rendering example: $wg...
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
getPageText(File $image, $page)
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
getDimensionInfo(File $file)
wfShellExec( $cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...