mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PdfHandler
synced 2024-11-11 17:08:08 +00:00
Add method scope visibility
Change-Id: If65af857042ee67122b2bc623176efb177cbe0bb
This commit is contained in:
parent
5252e4d4b7
commit
8a7814ba47
|
@ -3,7 +3,6 @@
|
||||||
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
|
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
|
||||||
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
|
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
|
||||||
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
|
||||||
<exclude name="Squiz.Scope.MethodScope.Missing" />
|
|
||||||
</rule>
|
</rule>
|
||||||
<file>.</file>
|
<file>.</file>
|
||||||
<arg name="extensions" value="php,php5,inc" />
|
<arg name="extensions" value="php,php5,inc" />
|
||||||
|
|
|
@ -32,7 +32,7 @@ class PdfHandler extends ImageHandler {
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isEnabled() {
|
public function isEnabled() {
|
||||||
global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfInfo;
|
global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfInfo;
|
||||||
|
|
||||||
if ( !isset( $wgPdfProcessor ) || !isset( $wgPdfPostProcessor ) || !isset( $wgPdfInfo ) ) {
|
if ( !isset( $wgPdfProcessor ) || !isset( $wgPdfPostProcessor ) || !isset( $wgPdfInfo ) ) {
|
||||||
|
@ -48,7 +48,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param File $file
|
* @param File $file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function mustRender( $file ) {
|
public function mustRender( $file ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param File $file
|
* @param File $file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isMultiPage( $file ) {
|
public function isMultiPage( $file ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function validateParam( $name, $value ) {
|
public function validateParam( $name, $value ) {
|
||||||
if ( $name === 'page' && trim( $value ) !== (string)intval( $value ) ) {
|
if ( $name === 'page' && trim( $value ) !== (string)intval( $value ) ) {
|
||||||
// Extra junk on the end of page, probably actually a caption
|
// Extra junk on the end of page, probably actually a caption
|
||||||
// e.g. [[File:Foo.pdf|thumb|Page 3 of the document shows foo]]
|
// e.g. [[File:Foo.pdf|thumb|Page 3 of the document shows foo]]
|
||||||
|
@ -81,7 +81,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
function makeParamString( $params ) {
|
public function makeParamString( $params ) {
|
||||||
$page = isset( $params['page'] ) ? $params['page'] : 1;
|
$page = isset( $params['page'] ) ? $params['page'] : 1;
|
||||||
if ( !isset( $params['width'] ) ) {
|
if ( !isset( $params['width'] ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -93,7 +93,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param string $str
|
* @param string $str
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function parseParamString( $str ) {
|
public function parseParamString( $str ) {
|
||||||
$m = [];
|
$m = [];
|
||||||
|
|
||||||
if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) {
|
if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) {
|
||||||
|
@ -107,7 +107,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getScriptParams( $params ) {
|
public function getScriptParams( $params ) {
|
||||||
return [
|
return [
|
||||||
'width' => $params['width'],
|
'width' => $params['width'],
|
||||||
'page' => $params['page'],
|
'page' => $params['page'],
|
||||||
|
@ -117,7 +117,7 @@ class PdfHandler extends ImageHandler {
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getParamMap() {
|
public function getParamMap() {
|
||||||
return [
|
return [
|
||||||
'img_width' => 'width',
|
'img_width' => 'width',
|
||||||
'img_page' => 'page',
|
'img_page' => 'page',
|
||||||
|
@ -143,7 +143,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @return MediaTransformError|MediaTransformOutput|ThumbnailImage|TransformParameterError
|
* @return MediaTransformError|MediaTransformOutput|ThumbnailImage|TransformParameterError
|
||||||
*/
|
*/
|
||||||
function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
|
||||||
global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfHandlerDpi, $wgPdfHandlerJpegQuality;
|
global $wgPdfProcessor, $wgPdfPostProcessor, $wgPdfHandlerDpi, $wgPdfHandlerJpegQuality;
|
||||||
|
|
||||||
if ( !$this->normaliseParams( $image, $params ) ) {
|
if ( !$this->normaliseParams( $image, $params ) ) {
|
||||||
|
@ -241,7 +241,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @return PdfImage
|
* @return PdfImage
|
||||||
* @suppress PhanUndeclaredProperty
|
* @suppress PhanUndeclaredProperty
|
||||||
*/
|
*/
|
||||||
function getPdfImage( $image, $path ) {
|
private function getPdfImage( $image, $path ) {
|
||||||
if ( !$image ) {
|
if ( !$image ) {
|
||||||
$pdfimg = new PdfImage( $path );
|
$pdfimg = new PdfImage( $path );
|
||||||
} elseif ( !isset( $image->pdfImage ) ) {
|
} elseif ( !isset( $image->pdfImage ) ) {
|
||||||
|
@ -258,7 +258,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
* @suppress PhanUndeclaredProperty
|
* @suppress PhanUndeclaredProperty
|
||||||
*/
|
*/
|
||||||
function getMetaArray( $image ) {
|
private function getMetaArray( $image ) {
|
||||||
if ( isset( $image->pdfMetaArray ) ) {
|
if ( isset( $image->pdfMetaArray ) ) {
|
||||||
return $image->pdfMetaArray;
|
return $image->pdfMetaArray;
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function getImageSize( $image, $path ) {
|
public function getImageSize( $image, $path ) {
|
||||||
return $this->getPdfImage( $image, $path )->getImageSize();
|
return $this->getPdfImage( $image, $path )->getImageSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param null $params
|
* @param null $params
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getThumbType( $ext, $mime, $params = null ) {
|
public function getThumbType( $ext, $mime, $params = null ) {
|
||||||
global $wgPdfOutputExtension;
|
global $wgPdfOutputExtension;
|
||||||
static $mime;
|
static $mime;
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getMetadata( $image, $path ) {
|
public function getMetadata( $image, $path ) {
|
||||||
return serialize( $this->getPdfImage( $image, $path )->retrieveMetaData() );
|
return serialize( $this->getPdfImage( $image, $path )->retrieveMetaData() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param string $metadata
|
* @param string $metadata
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function isMetadataValid( $image, $metadata ) {
|
public function isMetadataValid( $image, $metadata ) {
|
||||||
if ( !$metadata || $metadata === serialize( [] ) ) {
|
if ( !$metadata || $metadata === serialize( [] ) ) {
|
||||||
return self::METADATA_BAD;
|
return self::METADATA_BAD;
|
||||||
} elseif ( strpos( $metadata, 'mergedMetadata' ) === false ) {
|
} elseif ( strpos( $metadata, 'mergedMetadata' ) === false ) {
|
||||||
|
@ -343,7 +343,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param bool|IContextSource $context Context to use (optional)
|
* @param bool|IContextSource $context Context to use (optional)
|
||||||
* @return bool|array
|
* @return bool|array
|
||||||
*/
|
*/
|
||||||
function formatMetadata( $image, $context = false ) {
|
public function formatMetadata( $image, $context = false ) {
|
||||||
$meta = $image->getMetadata();
|
$meta = $image->getMetadata();
|
||||||
|
|
||||||
if ( !$meta ) {
|
if ( !$meta ) {
|
||||||
|
@ -368,7 +368,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param File $image
|
* @param File $image
|
||||||
* @return bool|int
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
function pageCount( File $image ) {
|
public function pageCount( File $image ) {
|
||||||
$info = $this->getDimensionInfo( $image );
|
$info = $this->getDimensionInfo( $image );
|
||||||
|
|
||||||
return $info ? $info['pageCount'] : false;
|
return $info ? $info['pageCount'] : false;
|
||||||
|
@ -379,7 +379,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param int $page
|
* @param int $page
|
||||||
* @return array|bool
|
* @return array|bool
|
||||||
*/
|
*/
|
||||||
function getPageDimensions( File $image, $page ) {
|
public function getPageDimensions( File $image, $page ) {
|
||||||
$index = $page; // MW starts pages at 1, as they are stored here
|
$index = $page; // MW starts pages at 1, as they are stored here
|
||||||
|
|
||||||
$info = $this->getDimensionInfo( $image );
|
$info = $this->getDimensionInfo( $image );
|
||||||
|
@ -419,7 +419,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param int $page
|
* @param int $page
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function getPageText( File $image, $page ) {
|
public function getPageText( File $image, $page ) {
|
||||||
$data = $this->getMetaArray( $image );
|
$data = $this->getMetaArray( $image );
|
||||||
if ( !$data || !isset( $data['text'] ) || !isset( $data['text'][$page - 1] ) ) {
|
if ( !$data || !isset( $data['text'] ) || !isset( $data['text'][$page - 1] ) ) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -433,7 +433,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* @param File $file
|
* @param File $file
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getWarningConfig( $file ) {
|
public function getWarningConfig( $file ) {
|
||||||
return [
|
return [
|
||||||
'messages' => self::$messages,
|
'messages' => self::$messages,
|
||||||
'link' => '//www.mediawiki.org/wiki/Special:MyLanguage/Help:Security/PDF_files',
|
'link' => '//www.mediawiki.org/wiki/Special:MyLanguage/Help:Security/PDF_files',
|
||||||
|
@ -445,7 +445,7 @@ class PdfHandler extends ImageHandler {
|
||||||
* Register a module with the warning messages in it.
|
* Register a module with the warning messages in it.
|
||||||
* @param ResourceLoader &$resourceLoader
|
* @param ResourceLoader &$resourceLoader
|
||||||
*/
|
*/
|
||||||
static function registerWarningModule( &$resourceLoader ) {
|
public static function registerWarningModule( &$resourceLoader ) {
|
||||||
$resourceLoader->register( 'pdfhandler.messages', [
|
$resourceLoader->register( 'pdfhandler.messages', [
|
||||||
'messages' => array_values( self::$messages ),
|
'messages' => array_values( self::$messages ),
|
||||||
] );
|
] );
|
||||||
|
|
|
@ -39,7 +39,7 @@ class PdfImage {
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
*/
|
*/
|
||||||
function __construct( $filename ) {
|
public function __construct( $filename ) {
|
||||||
$this->mFilename = $filename;
|
$this->mFilename = $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue