Go to the documentation of this file.
37 'originalwidth' =>
'ImageWidth',
38 'originalheight' =>
'ImageLength',
39 'description' =>
'ImageDescription',
40 'title' =>
'ObjectName',
44 global $wgSVGConverters, $wgSVGConverter;
45 if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
46 wfDebug(
"\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
67 # @todo Detect animated SVGs
68 $metadata =
$file->getMetadata();
71 if ( isset( $metadata[
'animated'] ) ) {
72 return $metadata[
'animated'];
92 $metadata =
$file->getMetadata();
96 if ( isset( $metadata[
'translations'] ) ) {
97 foreach ( $metadata[
'translations']
as $lang => $langType ) {
98 if ( $langType === SvgReader::LANG_FULL_MATCH ) {
130 if ( !parent::normaliseParams( $image,
$params ) ) {
133 # Don't make an image bigger than wgMaxSVGSize on the smaller side
135 if (
$params[
'physicalWidth'] > $wgSVGMaxSize ) {
136 $srcWidth = $image->getWidth(
$params[
'page'] );
137 $srcHeight = $image->getHeight(
$params[
'page'] );
138 $params[
'physicalWidth'] = $wgSVGMaxSize;
142 if (
$params[
'physicalHeight'] > $wgSVGMaxSize ) {
143 $srcWidth = $image->getWidth(
$params[
'page'] );
144 $srcHeight = $image->getHeight(
$params[
'page'] );
146 $params[
'physicalHeight'] = $wgSVGMaxSize;
165 $clientWidth =
$params[
'width'];
166 $clientHeight =
$params[
'height'];
167 $physicalWidth =
$params[
'physicalWidth'];
168 $physicalHeight =
$params[
'physicalHeight'];
171 if (
$flags & self::TRANSFORM_LATER ) {
176 if ( isset( $metadata[
'error'] ) ) {
177 $err =
wfMessage(
'svg-long-error', $metadata[
'error'][
'message'] )->text();
187 $srcPath = $image->getLocalRefPath();
188 $status = $this->
rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
189 if ( $status ===
true ) {
207 public function rasterize( $srcPath, $dstPath, $width, $height, $lang =
false ) {
208 global $wgSVGConverters, $wgSVGConverter, $wgSVGConverterPath;
211 if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
212 if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
214 $func = $wgSVGConverters[$wgSVGConverter][0];
215 $args = array_merge(
array( $srcPath, $dstPath, $width, $height, $lang ),
216 array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) );
217 if ( !is_callable( $func ) ) {
220 $err = call_user_func_array( $func,
$args );
225 array(
'$path/',
'$width',
'$height',
'$input',
'$output' ),
231 $wgSVGConverters[$wgSVGConverter]
235 if ( $lang !==
false ) {
236 $env[
'LANG'] = $lang;
240 wfDebug( __METHOD__ .
": $cmd\n" );
246 if (
$retval != 0 || $removed ) {
255 $im =
new Imagick( $srcPath );
256 $im->setImageFormat(
'png' );
257 $im->setBackgroundColor(
'transparent' );
258 $im->setImageDepth( 8 );
260 if ( !$im->thumbnailImage( intval( $width ), intval( $height ),
false ) ) {
261 return 'Could not resize image';
263 if ( !$im->writeImage( $dstPath ) ) {
264 return "Could not write to $dstPath";
275 if ( $metadata ===
false ) {
276 $metadata =
$file->getMetaData();
278 $metadata = $this->unpackMetaData( $metadata );
280 if ( isset( $metadata[
'width'] ) && isset( $metadata[
'height'] ) ) {
281 return array( $metadata[
'width'], $metadata[
'height'],
'SVG',
282 "width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" );
284 return array( 0, 0,
'SVG',
"width=\"0\" height=\"0\"" );
289 return array(
'png',
'image/png' );
305 if ( isset( $metadata[
'error'] ) ) {
306 return wfMessage(
'svg-long-error', $metadata[
'error'][
'message'] )->text();
312 $msg =
wfMessage(
'svg-long-desc-animated' );
317 $msg->numParams(
$file->getWidth(),
$file->getHeight() )->params(
$size );
319 return $msg->parse();
328 $metadata =
array(
'version' => self::SVG_METADATA_VERSION );
333 $metadata[
'error'] =
array(
334 'message' =>
$e->getMessage(),
335 'code' =>
$e->getCode()
337 wfDebug( __METHOD__ .
': ' .
$e->getMessage() .
"\n" );
340 return serialize( $metadata );
345 $unser = unserialize( $metadata );
347 if ( isset( $unser[
'version'] ) && $unser[
'version'] == self::SVG_METADATA_VERSION ) {
360 if ( $meta ===
false ) {
363 if ( !isset( $meta[
'originalWidth'] ) ) {
372 $fields =
array(
'objectname',
'imagedescription' );
383 'visible' =>
array(),
384 'collapsed' =>
array()
386 $metadata =
$file->getMetadata();
391 if ( !$metadata || isset( $metadata[
'error'] ) ) {
405 $tag = strtolower(
$name );
406 if ( isset( self::$metaConversion[$tag] ) ) {
407 $tag = strtolower( self::$metaConversion[$tag] );
414 in_array( $tag, $visibleFields ) ?
'visible' :
'collapsed',
421 return $showMeta ?
$result :
false;
430 if ( in_array(
$name,
array(
'width',
'height' ) ) ) {
433 } elseif (
$name ==
'lang' ) {
435 if (
$value ===
'' || !Language::isValidBuiltinCode(
$value ) ) {
436 wfDebug(
"Invalid user language code\n" );
456 $lang =
"lang{$params['lang']}-";
458 if ( !isset(
$params[
'width'] ) ) {
462 return "$lang{$params['width']}px";
467 if ( preg_match(
'/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/', $str, $m ) ) {
468 return array(
'width' => array_pop( $m ),
'lang' => $m[1] );
469 } elseif ( preg_match(
'/^(\d+)px$/', $str, $m ) ) {
470 return array(
'width' => $m[1],
'lang' =>
'en' );
477 return array(
'img_lang' =>
'lang',
'img_width' =>
'width' );
486 if ( isset(
$params[
'lang'] ) ) {
487 $scriptParams[
'lang'] =
$params[
'lang'];
490 return $scriptParams;
494 $metadata =
$file->getMetadata();
499 if ( !$metadata || isset( $metadata[
'error'] ) ) {
502 $stdMetadata =
array();
504 $tag = strtolower(
$name );
505 if ( $tag ===
'originalwidth' || $tag ===
'originalheight' ) {
510 if ( isset( self::$metaConversion[$tag] ) ) {
511 $tag = self::$metaConversion[$tag];
512 $stdMetadata[$tag] =
$value;
validateParam( $name, $value)
static rasterizeImagickExt( $srcPath, $dstPath, $width, $height)
Media transform output for images.
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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), 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. '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 '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) '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. '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
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
usually copyright or history_copyright This message must be in HTML not wikitext $subpages will be ignored and the rest of subPageSubtitle() will run. 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink' whether MediaWiki currently thinks this is a CSS JS page Hooks may change this value to override the return value of Title::isCssOrJsPage(). 'TitleIsAlwaysKnown' whether MediaWiki currently thinks this page is known isMovable() always returns false. $title whether MediaWiki currently thinks this page is movable Hooks may change this value to override the return value of Title::isMovable(). 'TitleIsWikitextPage' whether MediaWiki currently thinks this is a wikitext page Hooks may change this value to override the return value of Title::isWikitextPage() 'TitleMove' use UploadVerification and UploadVerifyFile instead where the first element is the message key and the remaining elements are used as parameters to the message based on mime etc Preferred in most cases over UploadVerification object with all info about the upload string $mime
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
parseParamString( $str)
Parse a param string made with makeParamString back into an array.
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
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
wfProfileIn( $functionname)
Begin profiling of a function.
canAnimateThumb( $file)
We do not support making animated svg thumbnails.
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
mustRender( $file)
True if handled types cannot be displayed directly in a browser but can be rendered.
wfShellExecWithStderr( $cmd, &$retval=null, $environ=array(), $limits=array())
Execute a shell command, returning both stdout and stderr.
getThumbType( $ext, $mime, $params=null)
Get the thumbnail extension and MIME type for a given source MIME type.
it s the revision text itself In either if gzip is the revision text is gzipped $flags
getScriptParams( $params)
getMetadata( $file, $filename)
rasterize( $srcPath, $dstPath, $width, $height, $lang=false)
Transform an SVG file to PNG This function can be called outside of thumbnail contexts.
getLongDesc( $file)
Subtitle for the image.
Implements some public methods and some protected utility functions which are required by multiple ch...
wfRestoreWarnings()
Restore error level to previous value.
normaliseParams( $image, &$params)
isEnabled()
False if the handler is disabled for all files.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Media handler abstract base class for images.
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 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 "<
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Allows to change the fields on the form that will be generated $name
wfEscapeShellArg()
Windows-compatible version of escapeshellarg() Windows doesn't recognise single-quotes in the shell,...
getAvailableLanguages(File $file)
Which languages (systemLanguage attribute) is supported.
getImageSize( $file, $path, $metadata=false)
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
if(PHP_SAPI !='cli') $file
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
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
getDefaultRenderLanguage(File $file)
What language to render file in if none selected.
visibleMetadataFields()
Get a list of metadata items which should be displayed when the metadata table is collapsed.
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
const SVG_METADATA_VERSION
unpackMetadata( $metadata)
makeParamString( $params)
getParamMap()
Get an associative array mapping magic word IDs to parameter names.
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 account incomplete not yet checked for validity & $retval
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
isMetadataValid( $image, $metadata)
Check if the metadata string is valid for this handler.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e