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" );
69 if ( $name ===
'page' && trim(
$value ) !== (
string)intval(
$value ) ) {
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 ) {
166 return $this->
doThumbError( $width, $height,
'thumbnail_dest_directory' );
171 if (
$image->getSize() >= 1e7 ) {
175 return $image->getLocalRefPath();
181 $srcPath =
$image->getLocalRefPath();
184 if ( $srcPath ===
false ) {
185 return $this->
doThumbError( $width, $height,
'filemissing' );
192 "-dFirstPage={$page}",
193 "-dLastPage={$page}",
195 "-r{$wgPdfHandlerDpi}",
206 $wgPdfHandlerJpegQuality,
214 wfDebug( __METHOD__ .
": $cmd\n" );
220 if (
$retval != 0 || $removed ) {
222 sprintf(
'thumbnail failed on %s: error %d "%s" from "%s"',
238 } elseif ( !isset(
$image->pdfImage ) ) {
241 $pdfimg =
$image->pdfImage;
252 if ( isset(
$image->pdfMetaArray ) ) {
253 return $image->pdfMetaArray;
256 $metadata =
$image->getMetadata();
259 wfDebug(
"Pdf metadata is invalid or missing, should have been fixed in upgradeRow\n" );
264 'PdfHandler-unserialize-metadata',
276 return $image->pdfMetaArray;
295 global $wgPdfOutputExtension;
298 if ( !isset(
$mime ) ) {
300 $mime = $magic->guessTypesForExtension( $wgPdfOutputExtension );
302 return [ $wgPdfOutputExtension,
$mime ];
320 if ( !$metadata || $metadata ===
serialize( [] ) ) {
322 } elseif ( strpos( $metadata,
'mergedMetadata' ) ===
false ) {
334 $meta =
$image->getMetadata();
343 if ( !isset( $meta[
'mergedMetadata'] )
344 || !is_array( $meta[
'mergedMetadata'] )
345 || count( $meta[
'mergedMetadata'] ) < 1
361 return $info ? $info[
'pageCount'] :
false;
373 if ( $info && isset( $info[
'dimensionsByPage'][$index] ) ) {
374 return $info[
'dimensionsByPage'][$index];
381 $cache = ObjectCache::getMainWANInstance();
382 return $cache->getWithSetCallback(
383 $cache->makeKey(
'file-pdf',
'dimensions', $file->getSha1() ),
384 $cache::TTL_INDEFINITE,
387 if ( !$data || !isset( $data[
'Pages'] ) ) {
390 unset( $data[
'text'] );
393 $count = intval( $data[
'Pages'] );
394 for ( $i = 1; $i <= $count; $i++ ) {
398 return [
'pageCount' => $count,
'dimensionsByPage' => $dimsByPage ];
400 [
'pcTTL' => $cache::TTL_INDEFINITE ]
411 if ( !$data || !isset( $data[
'text'] ) || !isset( $data[
'text'][$page - 1] ) ) {
414 return $data[
'text'][$page - 1];
426 'link' =>
'//www.mediawiki.org/wiki/Special:MyLanguage/Help:Security/PDF_files',
427 'module' =>
'pdfhandler.messages',
437 'messages' => array_values( self::$messages ),
unserialize( $serialized)
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfHostname()
Fetch server name for use in error reporting etc.
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
wfShellExecWithStderr( $cmd, &$retval=null, $environ=[], $limits=[])
Execute a shell command, returning both stdout and stderr.
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
Implements some public methods and some protected utility functions which are required by multiple ch...
Media handler abstract base class for images.
normaliseParams( $image, &$params)
static singleton()
Get an instance of this class.
Copyright © 2007 Martin Seidel (Xarax) jodeldi@gmx.de
getThumbType( $ext, $mime, $params=null)
getPdfImage( $image, $path)
static registerWarningModule(&$resourceLoader)
Register a module with the warning messages in it.
validateParam( $name, $value)
getPageDimensions(File $image, $page)
getDimensionInfo(File $file)
getMetadata( $image, $path)
isMetadataValid( $image, $metadata)
formatMetadata( $image, $context=false)
getImageSize( $image, $path)
getWarningConfig( $file)
Adds a warning about PDFs being potentially dangerous to the file page.
getScriptParams( $params)
getPageText(File $image, $page)
makeParamString( $params)
doThumbError( $width, $height, $msg)
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
inspired by djvuimage from Brion Vibber modified and written by xarax
static getPageSize( $data, $page)
Convenience class for dealing with PoolCounters using callbacks.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
Media transform output for images.
when a variable name is used in a function
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
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
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
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
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 unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
it s the revision text itself In either if gzip is the revision text is gzipped $flags
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
if( $ext=='php'|| $ext=='php5') $mime