(Quite a few of these issues are my fault from
65c27ddeb19757cb8a)
*All fields were starting as collapsed, which was not the intent of the code
*Animated field used non-existent messages, and displayed a value of "1" instead
of something meaningful to the user. Both (A)PNG and GIF handlers put
the animated status in the long description which feels more natural to me
so move the animated status to the long desc (long desc = subtitle under
the image on the description page).
*Use human readable file sizes in the long description instead of
total number of bytes. This bring it in line with the implementation
in the parent class.
*Correctly mark scripted SVG's as animated. Mostly a moot point
since we do not allow animated svgs past the upload checks
but for completeness and for people who totally
disable all upload verification.
(Note: This would miss event attributes (onclick, etc)
I didn't see much point in adding that since almost
always there will be a script tag)
Patchset 3: trailing whitespace (d'oh)
patchset 4: rebasing so jenkins is happy
Change-Id: Ic58efbf2bf1e4b14e3129e5bce9ea920d9804111
* (bug 22749) Create Special:MostInterwikis.
* Show change tags when transclude Special:Recentchanges(linked) or Special:Newpages.
* (bug 23226) Add |class= parameter to image links in order to add class(es) to HTML img tag.
+* (bug 39431) SVG animated status is now shown in long description
=== Bug fixes in 1.20 ===
* (bug 30245) Use the correct way to construct a log page title.
}
/**
+ * Subtitle for the image. Different from the base
+ * class so it can be denoted that SVG's have
+ * a "nominal" resolution, and not a fixed one,
+ * as well as so animation can be denoted.
+ *
* @param $file File
* @return string
*/
function getLongDesc( $file ) {
global $wgLang;
- return wfMessage( 'svg-long-desc' )->numParams( $file->getWidth(), $file->getHeight() )
- ->params( $wgLang->formatSize( $file->getSize() ) )->parse();
+ $size = $wgLang->formatSize( $file->getSize() );
+
+ if ( $this->isAnimatedImage( $file ) ) {
+ $msg = wfMessage( 'svg-long-desc-animated' );
+ } else {
+ $msg = wfMessage( 'svg-long-desc' );
+ }
+
+ $msg->numParams(
+ $file->getWidth(),
+ $file->getHeight()
+ );
+ $msg->Params( $size );
+ return $msg->parse();
}
function getMetadata( $file, $filename ) {
}
function visibleMetadataFields() {
- $fields = array( 'title', 'description', 'animated' );
+ $fields = array( 'objectname', 'imagedescription' );
return $fields;
}
if ( !$metadata ) {
return false;
}
- unset( $metadata['version'] );
- unset( $metadata['metadata'] ); /* non-formatted XML */
/* TODO: add a formatter
$format = new FormatSVG( $metadata );
$visibleFields = $this->visibleMetadataFields();
// Rename fields to be compatible with exif, so that
- // the labels for these fields work.
- $conversion = array( 'width' => 'imagewidth',
+ // the labels for these fields work and reuse existing messages.
+ $conversion = array(
+ 'width' => 'imagewidth',
'height' => 'imagelength',
'description' => 'imagedescription',
'title' => 'objectname',
$tag = strtolower( $name );
if ( isset( $conversion[$tag] ) ) {
$tag = $conversion[$tag];
+ } else {
+ // Do not output other metadata not in list
+ continue;
}
self::addMeta( $result,
in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
$this->readField( $tag, 'description' );
} elseif ( $isSVG && $tag == 'metadata' && $type == XmlReader::ELEMENT ) {
$this->readXml( $tag, 'metadata' );
+ } elseif ( $isSVG && $tag == 'script' ) {
+ // We normally do not allow scripted svgs.
+ // However its possible to configure MW to let them
+ // in, and such files should be considered animated.
+ $this->metadata['animated'] = true;
} elseif ( $tag !== '#text' ) {
$this->debug( "Unhandled top-level XML tag $tag" );
break;
} elseif ( $this->reader->namespaceURI == self::NS_SVG && $this->reader->nodeType == XmlReader::ELEMENT ) {
switch( $this->reader->localName ) {
+ case 'script':
+ // Normally we disallow files with
+ // <script>, but its possible
+ // to configure MW to disable
+ // such checks.
case 'animate':
case 'set':
case 'animateMotion':
'file-info-size-pages' => '$1 × $2 pixels, file size: $3, MIME type: $4, $5 {{PLURAL:$5|page|pages}}',
'file-nohires' => 'No higher resolution available.',
'svg-long-desc' => 'SVG file, nominally $1 × $2 pixels, file size: $3',
+'svg-long-desc-animated' => 'Animated SVG file, nominally $1 × $2 pixels, file size: $3',
'show-big-image' => 'Full resolution',
'show-big-image-preview' => 'Size of this preview: $1.',
'show-big-image-other' => 'Other {{PLURAL:$2|resolution|resolutions}}: $1.',
* $5 is the total number of pages in the document.',
'file-nohires' => 'File info displayed on file description page. For example of message in use see [[:File:Mouse10.gif]].',
'svg-long-desc' => 'Displayed under an SVG image at the image description page. Note that argument 3 is a string that includes the file size unit symbol. See for example [[:File:Yes check.svg]].',
+'svg-long-desc-animated' => 'Displayed under an SVG image at the image description page if the image is animated. Non-animated images use {{msg-mw|svg-long-desc}}. $1 is width, $2 is height, and $3 is file size, including unit (for example "10 KB").',
'show-big-image' => 'Displayed under an image at the image description page, when it is displayed smaller there than it was uploaded.',
'show-big-image-size' => '
Parameters:
'file-info-size-pages',
'file-nohires',
'svg-long-desc',
+ 'svg-long-desc-animated',
'show-big-image',
'show-big-image-preview',
'show-big-image-other',