Go to the documentation of this file.
26 'main' =>
'pdf-file-page-warning',
27 'header' =>
'pdf-file-page-warning-header',
28 'info' =>
'pdf-file-page-warning-info',
29 'footer' =>
'pdf-file-page-warning-footer',
36 global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfInfo;
38 if ( !isset( $wgPdfProcessor ) || !isset( $wgPdfPostProcessor ) || !isset( $wgPdfInfo ) ) {
39 wfDebug(
"PdfHandler is disabled, please set the following\n" );
40 wfDebug(
"variables in LocalSettings.php:\n" );
41 wfDebug(
"\$wgPdfProcessor, \$wgPdfPostProcessor, \$wgPdfInfo\n" );
74 if ( in_array(
$name, [
'width',
'height',
'page' ] ) ) {
86 if ( !isset(
$params[
'width'] ) ) {
89 return "page{$page}-{$params['width']}px";
99 if ( preg_match(
'/^page(\d+)-(\d+)px$/', $str, $m ) ) {
100 return [
'width' => $m[2],
'page' => $m[1] ];
122 'img_width' =>
'width',
123 'img_page' =>
'page',
135 $width, $height,
wfMessage( $msg )->inContentLanguage()->
text() );
147 global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfHandlerDpi, $wgPdfHandlerJpegQuality;
153 $width = (int)
$params[
'width'];
154 $height = (int)
$params[
'height'];
158 return $this->
doThumbError( $width, $height,
'pdf_page_error' );
161 if ( $flags & self::TRANSFORM_LATER ) {
170 return $this->
doThumbError( $width, $height,
'thumbnail_dest_directory' );
175 if (
$image->getSize() >= 1e7 ) {
179 return $image->getLocalRefPath();
185 $srcPath =
$image->getLocalRefPath();
188 if ( $srcPath ===
false ) {
189 return $this->
doThumbError( $width, $height,
'filemissing' );
196 "-dFirstPage={$page}",
197 "-dLastPage={$page}",
199 "-r{$wgPdfHandlerDpi}",
210 $wgPdfHandlerJpegQuality,
218 wfDebug( __METHOD__ .
": $cmd\n" );
224 if ( $retval != 0 || $removed ) {
226 sprintf(
'thumbnail failed on %s: error %d "%s" from "%s"',
227 wfHostname(), $retval, trim( $err ), $cmd ) );
247 } elseif ( !isset(
$image->pdfImage ) ) {
250 $pdfimg =
$image->pdfImage;
261 if ( isset(
$image->pdfMetaArray ) ) {
262 return $image->pdfMetaArray;
265 $metadata =
$image->getMetadata();
268 wfDebug(
"Pdf metadata is invalid or missing, should have been fixed in upgradeRow\n" );
273 'PdfHandler-unserialize-metadata',
279 'doWork' =>
function ()
use (
$image, $metadata ) {
280 Wikimedia\suppressWarnings();
282 Wikimedia\restoreWarnings();
288 return $image->pdfMetaArray;
307 global $wgPdfOutputExtension;
310 if ( !isset( $mime ) ) {
312 $mime = $magic->guessTypesForExtension( $wgPdfOutputExtension );
314 return [ $wgPdfOutputExtension, $mime ];
332 if ( !$metadata || $metadata ===
serialize( [] ) ) {
334 } elseif ( strpos( $metadata,
'mergedMetadata' ) ===
false ) {
346 $meta =
$image->getMetadata();
351 Wikimedia\suppressWarnings();
353 Wikimedia\restoreWarnings();
355 if ( !isset( $meta[
'mergedMetadata'] )
356 || !is_array( $meta[
'mergedMetadata'] )
357 ||
count( $meta[
'mergedMetadata'] ) < 1
373 return $info ? $info[
'pageCount'] :
false;
385 if ( $info && isset( $info[
'dimensionsByPage'][$index] ) ) {
386 return $info[
'dimensionsByPage'][$index];
394 return $cache->getWithSetCallback(
395 $cache->makeKey(
'file-pdf',
'dimensions',
$file->getSha1() ),
396 $cache::TTL_INDEFINITE,
402 unset(
$data[
'text'] );
405 $count = intval(
$data[
'Pages'] );
406 for ( $i = 1; $i <= $count; $i++ ) {
410 return [
'pageCount' => $count,
'dimensionsByPage' => $dimsByPage ];
412 [
'pcTTL' => $cache::TTL_INDEFINITE ]
423 if ( !
$data || !isset(
$data[
'text'] ) || !isset(
$data[
'text'][$page - 1] ) ) {
426 return $data[
'text'][$page - 1];
438 'link' =>
'//www.mediawiki.org/wiki/Special:MyLanguage/Help:Security/PDF_files',
439 'module' =>
'pdfhandler.messages',
Copyright © 2007 Martin Seidel (Xarax) jodeldi@gmx.de
Media transform output for images.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
isMetadataValid( $image, $metadata)
static getPageSize( $data, $page)
makeParamString( $params)
wfHostname()
Fetch server name for use in error reporting etc.
getDimensionInfo(File $file)
getWarningConfig( $file)
Adds a warning about PDFs being potentially dangerous to the file page.
getPageText(File $image, $page)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext such as when responding to a resource loader request or generating HTML output & $resourceLoader
Convenience class for dealing with PoolCounters using callbacks.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
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
inspired by djvuimage from Brion Vibber modified and written by xarax
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
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.
Media handler abstract base class for images.
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
static registerWarningModule(&$resourceLoader)
Register a module with the warning messages in it.
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)
doThumbError( $width, $height, $msg)
getMetadata( $image, $path)
formatMetadata( $image, $context=false)
getScriptParams( $params)
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
unserialize( $serialized)
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
static getMainWANInstance()
Get the main WAN cache object.
wfEscapeShellArg(... $args)
Version of escapeshellarg() that works better on Windows.
if(!is_readable( $file)) $ext
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 "<
getPageDimensions(File $image, $page)
getThumbType( $ext, $mime, $params=null)
getPdfImage( $image, $path)
wfShellExecWithStderr( $cmd, &$retval=null, $environ=[], $limits=[])
Execute a shell command, returning both stdout and stderr.
validateParam( $name, $value)