* @file
* @ingroup Media
*/
+
+use MediaWiki\Shell\Shell;
use Wikimedia\ScopedCallback;
/**
'title' => 'ObjectName',
];
- function isEnabled() {
+ public function isEnabled() {
global $wgSVGConverters, $wgSVGConverter;
if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
$params['physicalWidth'] = $wgSVGMaxSize;
$params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
}
- } else {
- if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
- $srcWidth = $image->getWidth( $params['page'] );
- $srcHeight = $image->getHeight( $params['page'] );
- $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
- $params['physicalHeight'] = $wgSVGMaxSize;
- }
+ } elseif ( $params['physicalHeight'] > $wgSVGMaxSize ) {
+ $srcWidth = $image->getWidth( $params['page'] );
+ $srcHeight = $image->getHeight( $params['page'] );
+ $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
+ $params['physicalHeight'] = $wgSVGMaxSize;
}
// To prevent the proliferation of thumbnails in languages not present in SVGs, unless
// explicitly forced by user.
- if ( isset( $params['targetlang'] ) ) {
- if ( !$image->getMatchedLanguage( $params['targetlang'] ) ) {
- unset( $params['targetlang'] );
- }
+ if ( isset( $params['targetlang'] ) && !$image->getMatchedLanguage( $params['targetlang'] ) ) {
+ unset( $params['targetlang'] );
}
return $params;
// External command
$cmd = str_replace(
[ '$path/', '$width', '$height', '$input', '$output' ],
- [ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
+ [ $wgSVGConverterPath ? Shell::escape( "$wgSVGConverterPath/" ) : "",
intval( $width ),
intval( $height ),
- wfEscapeShellArg( $srcPath ),
- wfEscapeShellArg( $dstPath ) ],
+ Shell::escape( $srcPath ),
+ Shell::escape( $dstPath ) ],
$wgSVGConverters[$wgSVGConverter]
);
}
}
- function getThumbType( $ext, $mime, $params = null ) {
+ public function getThumbType( $ext, $mime, $params = null ) {
return [ 'png', 'image/png' ];
}
* @param File $file
* @return string
*/
- function getLongDesc( $file ) {
+ public function getLongDesc( $file ) {
global $wgLang;
$metadata = $this->unpackMetadata( $file->getMetadata() );
* @param string $filename
* @return string Serialised metadata
*/
- function getMetadata( $file, $filename ) {
+ public function getMetadata( $file, $filename ) {
$metadata = [ 'version' => self::SVG_METADATA_VERSION ];
try {
$metadata += SVGMetadataExtractor::getMetadata( $filename );
return 'parsed-svg';
}
- function isMetadataValid( $image, $metadata ) {
+ public function isMetadataValid( $image, $metadata ) {
$meta = $this->unpackMetadata( $metadata );
if ( $meta === false ) {
return self::METADATA_BAD;
* @param bool|IContextSource $context Context to use (optional)
* @return array|bool
*/
- function formatMetadata( $file, $context = false ) {
+ public function formatMetadata( $file, $context = false ) {
$result = [
'visible' => [],
'collapsed' => []
* @param array $params
* @return array
*/
- function getScriptParams( $params ) {
+ protected function getScriptParams( $params ) {
$scriptParams = [ 'width' => $params['width'] ];
if ( isset( $params['lang'] ) ) {
$scriptParams['lang'] = $params['lang'];