37 if ( !$wgDjvuRenderer || ( !$wgDjvuDump && !$wgDjvuToXML ) ) {
38 wfDebug(
"DjVu is disabled, please set \$wgDjvuRenderer and \$wgDjvuDump\n" );
60 return $file->getSize() > static::EXPENSIVE_SIZE_LIMIT;
76 'img_width' =>
'width',
92 if ( in_array(
$name, [
'width',
'height',
'page' ] ) ) {
109 if ( !isset(
$params[
'width'] ) ) {
113 return "page{$page}-{$params['width']}px";
122 if ( preg_match(
'/^page(\d+)-(\d+)px$/', $str, $m ) ) {
123 return [
'width' => $m[2],
'page' => $m[1] ];
158 if (
$flags & self::TRANSFORM_LATER ) {
180 if (
$image->getSize() >= 1e7 ) {
184 return $image->getLocalRefPath();
190 $srcPath =
$image->getLocalRefPath();
193 if ( $srcPath ===
false ) {
195 sprintf(
'Thumbnail failed on %s: could not get local copy of "%s"',
204 # Use a subshell (brackets) to aggregate stderr from both pipeline commands
205 # before redirecting it to the overall stdout. This works in both Linux and Windows XP.
210 "-size={$params['physicalWidth']}x{$params['physicalHeight']}",
212 if ( $wgDjvuPostProcessor ) {
213 $cmd .=
" | {$wgDjvuPostProcessor}";
216 wfDebug( __METHOD__ .
": $cmd\n" );
221 if (
$retval != 0 || $removed ) {
245 } elseif ( !isset(
$image->dejaImage ) ) {
248 $deja =
$image->dejaImage;
263 if ( substr( $metadata, 0, 3 ) ===
'<?xml' ) {
268 MediaWiki\suppressWarnings();
270 MediaWiki\restoreWarnings();
271 if ( is_array( $unser ) ) {
272 if ( isset( $unser[
'error'] ) ) {
274 } elseif ( isset( $unser[
'xml'] ) ) {
275 return $unser[
'xml'];
278 throw new MWException(
"Error unserializing DjVu metadata." );
293 if ( $gettext && isset(
$image->djvuTextTree ) ) {
294 return $image->djvuTextTree;
296 if ( !$gettext && isset(
$image->dejaMetaTree ) ) {
297 return $image->dejaMetaTree;
302 wfDebug(
"DjVu XML metadata is invalid or missing, should have been fixed in upgradeRow\n" );
307 MediaWiki\suppressWarnings();
310 $image->dejaMetaTree =
false;
311 $image->djvuTextTree =
false;
312 $tree =
new SimpleXMLElement( $metadata, LIBXML_PARSEHUGE );
313 if ( $tree->getName() ==
'mw-djvu' ) {
315 foreach ( $tree->children()
as $b ) {
316 if ( $b->getName() ==
'DjVuTxt' ) {
319 $image->djvuTextTree = $b;
320 } elseif ( $b->getName() ==
'DjVuXML' ) {
321 $image->dejaMetaTree = $b;
325 $image->dejaMetaTree = $tree;
328 wfDebug(
"Bogus multipage XML metadata on '{$image->getName()}'\n" );
330 MediaWiki\restoreWarnings();
332 return $image->djvuTextTree;
334 return $image->dejaMetaTree;
345 if ( !isset(
$mime ) ) {
347 $mime = $magic->guessTypesForExtension( $wgDjvuOutputExtension );
354 wfDebug(
"Getting DjVu metadata for $path\n" );
357 if ( $xml ===
false ) {
359 return serialize( [
'error' =>
'Error extracting metadata' ] );
370 return !empty( $metadata ) && $metadata !=
serialize( [] );
376 return $info ? $info[
'pageCount'] :
false;
383 if ( $info && isset( $info[
'dimensionsByPage'][$index] ) ) {
384 return $info[
'dimensionsByPage'][$index];
392 return $cache->getWithSetCallback(
393 $cache->makeKey(
'file-djvu',
'dimensions', $file->
getSha1() ),
394 $cache::TTL_INDEFINITE,
395 function ()
use ( $file ) {
402 $count = count( $tree->xpath(
'//OBJECT' ) );
403 for ( $i = 0; $i <
$count; $i++ ) {
404 $o = $tree->BODY[0]->OBJECT[$i];
407 'width' => (int)$o[
'width'],
408 'height' => (
int)$o[
'height'],
411 $dimsByPage[$i] =
false;
415 return [
'pageCount' =>
$count,
'dimensionsByPage' => $dimsByPage ];
417 [
'pcTTL' => $cache::TTL_INDEFINITE ]
432 $o = $tree->BODY[0]->PAGE[
$page - 1];
static getMainWANInstance()
Get the main WAN cache object.
getPageText(File $image, $page)
getDimensionInfo(File $file)
getUnserializedMetadata(File $file)
Get metadata, unserializing it if neccessary.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfMkdirParents($dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
static singleton()
Get an instance of this class.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
execute($skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
wfHostname()
Fetch server name for use in error reporting etc.
getMetadata($image, $path)
if($ext== 'php'||$ext== 'php5') $mime
it s the revision text itself In either if gzip is the revision text is gzipped $flags
getThumbType($ext, $mime, $params=null)
wfShellExec($cmd, &$retval=null, $environ=[], $limits=[], $options=[])
Execute a shell command, with time and memory limits mirrored from the PHP configuration if supported...
when a variable name is used in a it is silently declared as a new local masking the global
getPageDimensions(File $image, $page)
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
getImageSize($image, $path)
Support for detecting/validating DjVu image files and getting some basic file metadata (resolution et...
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
Convenience class for dealing with PoolCounters using callbacks.
getDjVuImage($image, $path)
Cache an instance of DjVuImage in an Image object, return that instance.
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 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 unsetoffset-wrap String Wrap the message in html(usually something like"<
const EXPENSIVE_SIZE_LIMIT
getMetaTree($image, $gettext=false)
Cache a document tree for the DjVu XML metadata.
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Media transform output for images.
isMetadataValid($image, $metadata)
$wgDjvuRenderer
Path of the ddjvu DJVU renderer Enable this and $wgDjvuDump to enable djvu rendering example: $wgDjvu...
$wgDjvuOutputExtension
File extension for the DJVU post processor output.
getSha1()
Get the SHA-1 base 36 hash of the file.
validateParam($name, $value)
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
isExpensiveToThumbnail($file)
True if creating thumbnails from the file is large or otherwise resource-intensive.
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
$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 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
Media handler abstract base class for images.
$wgDjvuToXML
Path of the djvutoxml executable This works like djvudump except much, much slower as of version 3...
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
doTransform($image, $dstPath, $dstUrl, $params, $flags=0)
normaliseParams($image, &$params)
Implements some public methods and some protected utility functions which are required by multiple ch...
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account incomplete not yet checked for validity & $retval
$wgDjvuPostProcessor
Shell command for the DJVU post processor Default: pnmtojpeg, since ddjvu generates ppm output Set th...
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Allows to change the fields on the form that will be generated $name