MediaWiki  1.27.2
SVG.php
Go to the documentation of this file.
1 <?php
29 class SvgHandler extends ImageHandler {
31 
36  private static $metaConversion = [
37  'originalwidth' => 'ImageWidth',
38  'originalheight' => 'ImageLength',
39  'description' => 'ImageDescription',
40  'title' => 'ObjectName',
41  ];
42 
43  function isEnabled() {
45  if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
46  wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
47 
48  return false;
49  } else {
50  return true;
51  }
52  }
53 
54  public function mustRender( $file ) {
55  return true;
56  }
57 
58  function isVectorized( $file ) {
59  return true;
60  }
61 
66  function isAnimatedImage( $file ) {
67  # @todo Detect animated SVGs
68  $metadata = $file->getMetadata();
69  if ( $metadata ) {
70  $metadata = $this->unpackMetadata( $metadata );
71  if ( isset( $metadata['animated'] ) ) {
72  return $metadata['animated'];
73  }
74  }
75 
76  return false;
77  }
78 
91  public function getAvailableLanguages( File $file ) {
92  $metadata = $file->getMetadata();
93  $langList = [];
94  if ( $metadata ) {
95  $metadata = $this->unpackMetadata( $metadata );
96  if ( isset( $metadata['translations'] ) ) {
97  foreach ( $metadata['translations'] as $lang => $langType ) {
98  if ( $langType === SVGReader::LANG_FULL_MATCH ) {
99  $langList[] = $lang;
100  }
101  }
102  }
103  }
104  return $langList;
105  }
106 
113  public function getDefaultRenderLanguage( File $file ) {
114  return 'en';
115  }
116 
122  function canAnimateThumbnail( $file ) {
123  return false;
124  }
125 
133  if ( !parent::normaliseParams( $image, $params ) ) {
134  return false;
135  }
136  # Don't make an image bigger than wgMaxSVGSize on the smaller side
137  if ( $params['physicalWidth'] <= $params['physicalHeight'] ) {
138  if ( $params['physicalWidth'] > $wgSVGMaxSize ) {
139  $srcWidth = $image->getWidth( $params['page'] );
140  $srcHeight = $image->getHeight( $params['page'] );
141  $params['physicalWidth'] = $wgSVGMaxSize;
142  $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
143  }
144  } else {
145  if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
146  $srcWidth = $image->getWidth( $params['page'] );
147  $srcHeight = $image->getHeight( $params['page'] );
148  $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
149  $params['physicalHeight'] = $wgSVGMaxSize;
150  }
151  }
152 
153  return true;
154  }
155 
164  function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
165  if ( !$this->normaliseParams( $image, $params ) ) {
166  return new TransformParameterError( $params );
167  }
168  $clientWidth = $params['width'];
169  $clientHeight = $params['height'];
170  $physicalWidth = $params['physicalWidth'];
171  $physicalHeight = $params['physicalHeight'];
172  $lang = isset( $params['lang'] ) ? $params['lang'] : $this->getDefaultRenderLanguage( $image );
173 
174  if ( $flags & self::TRANSFORM_LATER ) {
175  return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
176  }
177 
178  $metadata = $this->unpackMetadata( $image->getMetadata() );
179  if ( isset( $metadata['error'] ) ) { // sanity check
180  $err = wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
181 
182  return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
183  }
184 
185  if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
186  return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight,
187  wfMessage( 'thumbnail_dest_directory' )->text() );
188  }
189 
190  $srcPath = $image->getLocalRefPath();
191  if ( $srcPath === false ) { // Failed to get local copy
192  wfDebugLog( 'thumbnail',
193  sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"',
194  wfHostname(), $image->getName() ) );
195 
196  return new MediaTransformError( 'thumbnail_error',
197  $params['width'], $params['height'],
198  wfMessage( 'filemissing' )->text()
199  );
200  }
201 
202  // Make a temp dir with a symlink to the local copy in it.
203  // This plays well with rsvg-convert policy for external entities.
204  // https://git.gnome.org/browse/librsvg/commit/?id=f01aded72c38f0e18bc7ff67dee800e380251c8e
205  $tmpDir = wfTempDir() . '/svg_' . wfRandomString( 24 );
206  $lnPath = "$tmpDir/" . basename( $srcPath );
207  $ok = mkdir( $tmpDir, 0771 ) && symlink( $srcPath, $lnPath );
209  $cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) {
210  MediaWiki\suppressWarnings();
211  unlink( $lnPath );
212  rmdir( $tmpDir );
213  MediaWiki\restoreWarnings();
214  } );
215  if ( !$ok ) {
216  wfDebugLog( 'thumbnail',
217  sprintf( 'Thumbnail failed on %s: could not link %s to %s',
218  wfHostname(), $lnPath, $srcPath ) );
219  return new MediaTransformError( 'thumbnail_error',
220  $params['width'], $params['height'],
221  wfMessage( 'thumbnail-temp-create' )->text()
222  );
223  }
224 
225  $status = $this->rasterize( $lnPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
226  if ( $status === true ) {
227  return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
228  } else {
229  return $status; // MediaTransformError
230  }
231  }
232 
244  public function rasterize( $srcPath, $dstPath, $width, $height, $lang = false ) {
246  $err = false;
247  $retval = '';
248  if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
249  if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
250  // This is a PHP callable
251  $func = $wgSVGConverters[$wgSVGConverter][0];
252  $args = array_merge( [ $srcPath, $dstPath, $width, $height, $lang ],
253  array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) );
254  if ( !is_callable( $func ) ) {
255  throw new MWException( "$func is not callable" );
256  }
257  $err = call_user_func_array( $func, $args );
258  $retval = (bool)$err;
259  } else {
260  // External command
261  $cmd = str_replace(
262  [ '$path/', '$width', '$height', '$input', '$output' ],
263  [ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
264  intval( $width ),
265  intval( $height ),
266  wfEscapeShellArg( $srcPath ),
267  wfEscapeShellArg( $dstPath ) ],
268  $wgSVGConverters[$wgSVGConverter]
269  );
270 
271  $env = [];
272  if ( $lang !== false ) {
273  $env['LANG'] = $lang;
274  }
275 
276  wfDebug( __METHOD__ . ": $cmd\n" );
277  $err = wfShellExecWithStderr( $cmd, $retval, $env );
278  }
279  }
280  $removed = $this->removeBadFile( $dstPath, $retval );
281  if ( $retval != 0 || $removed ) {
282  $this->logErrorForExternalProcess( $retval, $err, $cmd );
283  return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
284  }
285 
286  return true;
287  }
288 
289  public static function rasterizeImagickExt( $srcPath, $dstPath, $width, $height ) {
290  $im = new Imagick( $srcPath );
291  $im->setImageFormat( 'png' );
292  $im->setBackgroundColor( 'transparent' );
293  $im->setImageDepth( 8 );
294 
295  if ( !$im->thumbnailImage( intval( $width ), intval( $height ), /* fit */ false ) ) {
296  return 'Could not resize image';
297  }
298  if ( !$im->writeImage( $dstPath ) ) {
299  return "Could not write to $dstPath";
300  }
301  }
302 
309  function getImageSize( $file, $path, $metadata = false ) {
310  if ( $metadata === false ) {
311  $metadata = $file->getMetadata();
312  }
313  $metadata = $this->unpackMetadata( $metadata );
314 
315  if ( isset( $metadata['width'] ) && isset( $metadata['height'] ) ) {
316  return [ $metadata['width'], $metadata['height'], 'SVG',
317  "width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" ];
318  } else { // error
319  return [ 0, 0, 'SVG', "width=\"0\" height=\"0\"" ];
320  }
321  }
322 
323  function getThumbType( $ext, $mime, $params = null ) {
324  return [ 'png', 'image/png' ];
325  }
326 
336  function getLongDesc( $file ) {
337  global $wgLang;
338 
339  $metadata = $this->unpackMetadata( $file->getMetadata() );
340  if ( isset( $metadata['error'] ) ) {
341  return wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
342  }
343 
344  $size = $wgLang->formatSize( $file->getSize() );
345 
346  if ( $this->isAnimatedImage( $file ) ) {
347  $msg = wfMessage( 'svg-long-desc-animated' );
348  } else {
349  $msg = wfMessage( 'svg-long-desc' );
350  }
351 
352  $msg->numParams( $file->getWidth(), $file->getHeight() )->params( $size );
353 
354  return $msg->parse();
355  }
356 
362  function getMetadata( $file, $filename ) {
363  $metadata = [ 'version' => self::SVG_METADATA_VERSION ];
364  try {
365  $metadata += SVGMetadataExtractor::getMetadata( $filename );
366  } catch ( Exception $e ) { // @todo SVG specific exceptions
367  // File not found, broken, etc.
368  $metadata['error'] = [
369  'message' => $e->getMessage(),
370  'code' => $e->getCode()
371  ];
372  wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
373  }
374 
375  return serialize( $metadata );
376  }
377 
378  function unpackMetadata( $metadata ) {
379  MediaWiki\suppressWarnings();
380  $unser = unserialize( $metadata );
381  MediaWiki\restoreWarnings();
382  if ( isset( $unser['version'] ) && $unser['version'] == self::SVG_METADATA_VERSION ) {
383  return $unser;
384  } else {
385  return false;
386  }
387  }
388 
389  function getMetadataType( $image ) {
390  return 'parsed-svg';
391  }
392 
393  function isMetadataValid( $image, $metadata ) {
394  $meta = $this->unpackMetadata( $metadata );
395  if ( $meta === false ) {
396  return self::METADATA_BAD;
397  }
398  if ( !isset( $meta['originalWidth'] ) ) {
399  // Old but compatible
400  return self::METADATA_COMPATIBLE;
401  }
402 
403  return self::METADATA_GOOD;
404  }
405 
406  protected function visibleMetadataFields() {
407  $fields = [ 'objectname', 'imagedescription' ];
408 
409  return $fields;
410  }
411 
417  function formatMetadata( $file, $context = false ) {
418  $result = [
419  'visible' => [],
420  'collapsed' => []
421  ];
422  $metadata = $file->getMetadata();
423  if ( !$metadata ) {
424  return false;
425  }
426  $metadata = $this->unpackMetadata( $metadata );
427  if ( !$metadata || isset( $metadata['error'] ) ) {
428  return false;
429  }
430 
431  /* @todo Add a formatter
432  $format = new FormatSVG( $metadata );
433  $formatted = $format->getFormattedData();
434  */
435 
436  // Sort fields into visible and collapsed
437  $visibleFields = $this->visibleMetadataFields();
438 
439  $showMeta = false;
440  foreach ( $metadata as $name => $value ) {
441  $tag = strtolower( $name );
442  if ( isset( self::$metaConversion[$tag] ) ) {
443  $tag = strtolower( self::$metaConversion[$tag] );
444  } else {
445  // Do not output other metadata not in list
446  continue;
447  }
448  $showMeta = true;
449  self::addMeta( $result,
450  in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
451  'exif',
452  $tag,
453  $value
454  );
455  }
456 
457  return $showMeta ? $result : false;
458  }
459 
465  public function validateParam( $name, $value ) {
466  if ( in_array( $name, [ 'width', 'height' ] ) ) {
467  // Reject negative heights, widths
468  return ( $value > 0 );
469  } elseif ( $name == 'lang' ) {
470  // Validate $code
471  if ( $value === '' || !Language::isValidBuiltInCode( $value ) ) {
472  wfDebug( "Invalid user language code\n" );
473 
474  return false;
475  }
476 
477  return true;
478  }
479 
480  // Only lang, width and height are acceptable keys
481  return false;
482  }
483 
488  public function makeParamString( $params ) {
489  $lang = '';
490  if ( isset( $params['lang'] ) && $params['lang'] !== 'en' ) {
491  $params['lang'] = strtolower( $params['lang'] );
492  $lang = "lang{$params['lang']}-";
493  }
494  if ( !isset( $params['width'] ) ) {
495  return false;
496  }
497 
498  return "$lang{$params['width']}px";
499  }
500 
501  public function parseParamString( $str ) {
502  $m = false;
503  if ( preg_match( '/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/', $str, $m ) ) {
504  return [ 'width' => array_pop( $m ), 'lang' => $m[1] ];
505  } elseif ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
506  return [ 'width' => $m[1], 'lang' => 'en' ];
507  } else {
508  return false;
509  }
510  }
511 
512  public function getParamMap() {
513  return [ 'img_lang' => 'lang', 'img_width' => 'width' ];
514  }
515 
520  function getScriptParams( $params ) {
521  $scriptParams = [ 'width' => $params['width'] ];
522  if ( isset( $params['lang'] ) ) {
523  $scriptParams['lang'] = $params['lang'];
524  }
525 
526  return $scriptParams;
527  }
528 
529  public function getCommonMetaArray( File $file ) {
530  $metadata = $file->getMetadata();
531  if ( !$metadata ) {
532  return [];
533  }
534  $metadata = $this->unpackMetadata( $metadata );
535  if ( !$metadata || isset( $metadata['error'] ) ) {
536  return [];
537  }
538  $stdMetadata = [];
539  foreach ( $metadata as $name => $value ) {
540  $tag = strtolower( $name );
541  if ( $tag === 'originalwidth' || $tag === 'originalheight' ) {
542  // Skip these. In the exif metadata stuff, it is assumed these
543  // are measured in px, which is not the case here.
544  continue;
545  }
546  if ( isset( self::$metaConversion[$tag] ) ) {
547  $tag = self::$metaConversion[$tag];
548  $stdMetadata[$tag] = $value;
549  }
550  }
551 
552  return $stdMetadata;
553  }
554 }
static getMetadata($filename)
getAvailableLanguages(File $file)
Which languages (systemLanguage attribute) is supported.
Definition: SVG.php:91
removeBadFile($dstPath, $retval=0)
Check for zero-sized thumbnails.
$context
Definition: load.php:44
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.
getImageSize($file, $path, $metadata=false)
Definition: SVG.php:309
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:1932
wfHostname()
Fetch server name for use in error reporting etc.
if(!isset($args[0])) $lang
$value
if($ext== 'php'||$ext== 'php5') $mime
Definition: router.php:65
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition: hooks.txt:2548
formatMetadata($file, $context=false)
Definition: SVG.php:417
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
normaliseParams($image, &$params)
Definition: SVG.php:131
getParamMap()
Definition: SVG.php:512
getMetadata($file, $filename)
Definition: SVG.php:362
wfRandomString($length=32)
Get a random string containing a number of pseudo-random hex characters.
doTransform($image, $dstPath, $dstUrl, $params, $flags=0)
Definition: SVG.php:164
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
validateParam($name, $value)
Definition: SVG.php:465
logErrorForExternalProcess($retval, $err, $cmd)
Log an error that occurred in an external process.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message.Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item.Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page.Return false to stop further processing of the tag $reader:XMLReader object &$pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision.Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag.Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload.Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports.&$fullInterwikiPrefix:Interwiki prefix, may contain colons.&$pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable.Can be used to lazy-load the import sources list.&$importSources:The value of $wgImportSources.Modify as necessary.See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page.$context:IContextSource object &$pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect.&$title:Title object for the current page &$request:WebRequest &$ignoreRedirect:boolean to skip redirect check &$target:Title/string of redirect target &$article:Article object 'InternalParseBeforeLinks':during Parser's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InternalParseBeforeSanitize':during Parser's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments.&$parser:Parser object &$text:string containing partially parsed text &$stripState:Parser's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not.Return true without providing an interwiki to continue interwiki search.$prefix:interwiki prefix we are looking for.&$iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user's email has been invalidated successfully.$user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification.Callee may modify $url and $query, URL will be constructed as $url.$query &$url:URL to index.php &$query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) &$article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() &$ip:IP being check &$result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from &$allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn't match your organization.$addr:The e-mail address entered by the user &$result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user &$result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we're looking for a messages file for &$file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED!Use $magicWords in a file listed in $wgExtensionMessagesFiles instead.Use this to define synonyms of magic words depending of the language &$magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces.Do not use this hook to add namespaces.Use CanonicalNamespaces for that.&$namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED!Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead.Use to define aliases of special pages names depending of the language &$specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names.&$names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page's language links.This is called in various places to allow extensions to define the effective language links for a page.$title:The page's Title.&$links:Associative array mapping language codes to prefixed links of the form"language:title".&$linkFlags:Associative array mapping prefixed links to arrays of flags.Currently unused, but planned to provide support for marking individual language links in the UI, e.g.for featured articles. 'LanguageSelector':Hook to change the language selector available on a page.$out:The output page.$cssClassName:CSS class name of the language selector. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts.Return false to skip default processing and return $ret.See documentation for Linker::link() for details on the expected meanings of parameters.$skin:the Skin object $target:the Title that the link is pointing to &$html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1796
if($line===false) $args
Definition: cdb.php:64
Shortcut class for parameter validation errors.
canAnimateThumbnail($file)
We do not support making animated svg thumbnails.
Definition: SVG.php:122
Class for asserting that a callback happens when an dummy object leaves scope.
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
getScriptParams($params)
Definition: SVG.php:520
wfTempDir()
Tries to get the system directory for temporary files.
$wgSVGConverterPath
If not in the executable PATH, specify the SVG converter path.
unserialize($serialized)
Definition: ApiMessage.php:102
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition: File.php:638
$wgSVGConverters
Scalable Vector Graphics (SVG) may be uploaded as images.
Media transform output for images.
isMetadataValid($image, $metadata)
Definition: SVG.php:393
getCommonMetaArray(File $file)
Definition: SVG.php:529
makeParamString($params)
Definition: SVG.php:488
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing 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"&lt
static isValidBuiltInCode($code)
Returns true if a language code is of a valid form for the purposes of internal customisation of Medi...
Definition: Language.php:358
$params
getMetadataType($image)
Definition: SVG.php:389
parseParamString($str)
Definition: SVG.php:501
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
Definition: design.txt:12
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
Definition: hooks.txt:965
isVectorized($file)
Definition: SVG.php:58
static array isEnabled()
Definition: SVG.php:43
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
Definition: distributors.txt:9
mustRender($file)
Definition: SVG.php:54
$wgSVGMaxSize
Don't scale a SVG larger than this.
const SVG_METADATA_VERSION
Definition: SVG.php:30
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
Definition: injection.txt:35
visibleMetadataFields()
Definition: SVG.php:406
getLongDesc($file)
Subtitle for the image.
Definition: SVG.php:336
Media handler abstract base class for images.
static rasterizeImagickExt($srcPath, $dstPath, $width, $height)
Definition: SVG.php:289
unpackMetadata($metadata)
Definition: SVG.php:378
static scaleHeight($srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition: File.php:1990
getDefaultRenderLanguage(File $file)
What language to render file in if none selected.
Definition: SVG.php:113
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
Definition: hooks.txt:1004
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
Definition: hooks.txt:762
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell...
static array $metaConversion
A list of metadata tags that can be converted to the commonly used exif tags.
Definition: SVG.php:36
serialize()
Definition: ApiMessage.php:94
getThumbType($ext, $mime, $params=null)
Definition: SVG.php:323
wfShellExecWithStderr($cmd, &$retval=null, $environ=[], $limits=[])
Execute a shell command, returning both stdout and stderr.
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:50
$wgSVGConverter
Pick a converter defined in $wgSVGConverters.
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
Definition: hooks.txt:242
Handler for SVG images.
Definition: SVG.php:29
rasterize($srcPath, $dstPath, $width, $height, $lang=false)
Transform an SVG file to PNG This function can be called outside of thumbnail contexts.
Definition: SVG.php:244
Basic media transform error class.
isAnimatedImage($file)
Definition: SVG.php:66
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310