fixed #10158: Matrix 2.0 - Screenshots rendering poorly

This commit is contained in:
Yung Han Khoe 2009-04-21 17:28:05 +00:00
parent c3ea6d4683
commit ad6352d1eb
5 changed files with 77 additions and 0 deletions

View file

@ -35,6 +35,7 @@
- fixed: #10109: Matrix 2.0 - Updates to product listing by maintainer account require admin approval
- fixed #10146: Thingy duplicate errors
- Added Survey back button
- fixed #10158: Matrix 2.0 - Screenshots rendering poorly
7.7.3
- fixed #10094: double explanation in thread help

View file

@ -37,10 +37,21 @@ allMaintenanceSingleton($session);
unsetPackageFlags($session);
installThingyRecord( $session );
installPluggableTax( $session );
addMatrixMaxScreenshotWidthHeight($session);
addSurveyBackButtonColumn( $session );
finish($session); # this line required
#----------------------------------------------------------------------------
sub addMatrixMaxScreenshotWidthHeight {
my $session = shift;
print "\tAdding maximum screenshot width and height property to the Matrix." unless $quiet;
$session->db->write("alter table Matrix add maxScreenshotWidth int(11), add maxScreenshotHeight int(11);");
$session->db->write("update Matrix set maxScreenshotWidth = 800, maxScreenshotHeight = 600;");
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub unsetPackageFlags {
my $session = shift;

View file

@ -509,6 +509,34 @@ sub processPropertiesFromFormPost {
}
$self->update({score => $score});
if ( $self->get('screenshots') ) {
my $fileObject = WebGUI::Form::File->new($self->session,{ value=>$self->get('screenshots') });
my $storage = $fileObject->getStorageLocation;
my @files;
@files = @{ $storage->getFiles } if (defined $storage);
foreach my $file (@files) {
unless ($file =~ m/^thumb-/){
my ($resizeWidth,$resizeHeight);
my ($width, $height) = $storage->getSizeInPixels($file);
my $maxWidth = $self->getParent->get('maxScreenshotWidth');
my $maxHeight = $self->getParent->get('maxScreenshotHeight');
if ($width > $maxWidth){
my $newHeight = $height * ($maxWidth / $width);
if ($newHeight > $maxHeight){
# Heigth requires more resizing so use maxHeight
$storage->resize($file, 0, $maxHeight);
}
else{
$storage->resize($file, $maxWidth);
}
}
elsif($height > $maxHeight){
$storage->resize($file, 0, $maxHeight);
}
}
}
}
$self->requestAutoCommit;
return undef;
}
@ -979,6 +1007,7 @@ sub www_getScreenshots {
@files = @{ $storage->getFiles } if (defined $storage);
foreach my $file (@files) {
unless ($file =~ m/^thumb-/){
my ($width, $height) = $storage->getSizeInPixels($file);
my $thumb = 'thumb-'.$file;
$xml .= "
<slide>
@ -987,6 +1016,8 @@ sub www_getScreenshots {
<image_source>".$storage->getUrl($file)."</image_source>
<duration>5</duration>
<thumb_source>".$storage->getUrl($thumb)."</thumb_source>
<width>".$width."</width>
<height>".$height."</height>
</slide>
";
}

View file

@ -194,6 +194,20 @@ sub definition {
hoverHelp =>$i18n->get('compare color yes description'),
label =>$i18n->get('compare color yes label'),
},
maxScreenshotWidth=>{
fieldType =>"integer",
tab =>"display",
defaultValue =>"800",
hoverHelp =>$i18n->get('max screenshot width description'),
label =>$i18n->get('max screenshot width label'),
},
maxScreenshotHeight=>{
fieldType =>"integer",
tab =>"display",
defaultValue =>"600",
hoverHelp =>$i18n->get('max screenshot height description'),
label =>$i18n->get('max screenshot height label'),
},
categories=>{
fieldType =>"textarea",
tab =>"properties",

View file

@ -387,6 +387,16 @@ listing,|,
lastUpdated => 0,
},
'max screenshot width description' => {
message => q|Select the maximum width of the screenshots in this matrix. Screenshots that are larger will be resized.|,
lastUpdated => 0,
},
'max screenshot height description' => {
message => q|Select the maximum height of the screenshots in this matrix. Screenshots that are larger will be resized.|,
lastUpdated => 0,
},
'compare color no description' => {
message => q|Select the color for compare result 'No' in the compare display.|,
lastUpdated => 0,
@ -528,6 +538,16 @@ to increase performance. How long should we cache them?|,
lastUpdated => 0,
},
'max screenshot height label' => {
message => q|Maximum Screenshot Height|,
lastUpdated => 0,
},
'max screenshot width label' => {
message => q|Maximum Screenshot Width|,
lastUpdated => 0,
},
'sort by score label' => {
message => q|Score|,
lastUpdated => 0,