diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 53746866c..71dcaa44f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -10,6 +10,7 @@ - fixed #11033: Calendar, recurring dates - fixed #11038: My Carousel Broke - fixed ExpireIncompleteSurveyResponses workflow sending one email per asset revision + - fixed #10994: Gallery: Problems with uploading ZIP-archives 7.8.0 - upgraded YUI to 2.8.0r4 diff --git a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm index b8f8e90a3..d339d2cba 100644 --- a/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm +++ b/lib/WebGUI/Asset/Wobject/GalleryAlbum.pm @@ -21,6 +21,7 @@ use Tie::IxHash; use WebGUI::International; use WebGUI::Utility; use WebGUI::HTML; +use WebGUI::ProgressBar; use Archive::Any; @@ -84,7 +85,7 @@ sub definition { #---------------------------------------------------------------------------- -=head2 addArchive ( filename, properties ) +=head2 addArchive ( filename, properties, [$outputSub] ) Add an archive of Files to this Album. C is the full path of the archive. C is a hash reference of properties to assign to the @@ -95,12 +96,27 @@ a directory outside of the storage location. Will only handle file types handled by the parent Gallery. +=head3 filename + +The name of the file archive to import. + +=head3 properties + +A base set of properties to add to each file in the archive. + +=head3 $outputSub + +A callback to use for outputting data, most likely to a progress bar. It expects the +callback to accept an i18n key for use in sprintf, and then any extra fields to stuff +into the translated key. + =cut sub addArchive { my $self = shift; my $filename = shift; my $properties = shift; + my $outputSub = shift || sub {}; my $gallery = $self->getParent; my $archive = Archive::Any->new( $filename ); @@ -109,11 +125,12 @@ sub addArchive { if $archive->is_naughty; my $tempdirName = tempdir( "WebGUI-Gallery-XXXXXXXX", TMPDIR => 1, CLEANUP => 1); + $outputSub->('Extracting archive'); $archive->extract( $tempdirName ); # Get all the files in the archive my @files; - my $wanted = sub { push @files, $File::Find::name }; + my $wanted = sub { push @files, $File::Find::name; $outputSub->('Found file: %s', $File::Find::name); }; find( { wanted => $wanted, }, $tempdirName ); @@ -127,7 +144,8 @@ sub addArchive { next unless $class; # class is undef for those files the Gallery can't handle $self->session->errorHandler->info( "Adding $filename to album!" ); - # Remove the file extention + $outputSub->('Adding %s to album', $filename); + # Remove the file extension $filename =~ s{\.[^.]+}{}; $properties->{ className } = $class; @@ -143,6 +161,7 @@ sub addArchive { $versionTag->set({ "workflowId" => $self->getParent->get("workflowIdCommit"), }); + $outputSub->('Requesting commit for version tag'); $versionTag->requestCommit; return undef; @@ -918,7 +937,7 @@ sub www_addArchive { my $i18n = WebGUI::International->new($session); - $var->{ error } = $params->{ error }; + $var->{ error } = $params->{ error } || $form->get('error'); $var->{ form_start } = WebGUI::Form::formHeader( $session, { @@ -973,32 +992,27 @@ sub www_addArchiveSave { my $session = $self->session; my $form = $self->session->form; my $i18n = WebGUI::International->new( $session, 'Asset_GalleryAlbum' ); + my $pb = WebGUI::ProgressBar->new($session); my $properties = { keywords => $form->get("keywords"), friendsOnly => $form->get("friendsOnly"), }; + $pb->start($i18n->get('Uploading archive'), $session->url->extras('adminConsole/assets.gif')); my $storageId = $form->get("archive", "File"); my $storage = WebGUI::Storage->get( $session, $storageId ); if (!$storage) { - return $self->www_addArchive({ - error => sprintf $i18n->get('addArchive error too big'), - }); + return $pb->finish($self->getUrl('func=addArchive;error='.$i18n->get('addArchive error too big'))); } my $filename = $storage->getPath( $storage->getFiles->[0] ); - eval { $self->addArchive( $filename, $properties ) }; + eval { $self->addArchive( $filename, $properties, sub{ $pb->update(sprintf $i18n->get(shift), @_); }); }; + $storage->delete; if ( my $error = $@ ) { - return $self->www_addArchive({ - error => sprintf( $i18n->get('addArchive error generic'), $error ), - }); + return $pb->finish($self->getUrl('func=addArchive;error='.sprintf $i18n->get('addArchive error generic'), $error )); } - $storage->delete; - - return $self->processStyle( - sprintf $i18n->get('addArchive message'), $self->getUrl, - ); + return $pb->finish($self->getUrl); } #---------------------------------------------------------------------------- diff --git a/lib/WebGUI/ProgressBar.pm b/lib/WebGUI/ProgressBar.pm index a8dd0c0df..6fb9990eb 100644 --- a/lib/WebGUI/ProgressBar.pm +++ b/lib/WebGUI/ProgressBar.pm @@ -82,6 +82,7 @@ sub finish { parent.location.href='%s'; EOJS + local $| = 1; $self->session->output->print($text . $self->{_foot}, 1); # skipMacros return 'chunked'; } diff --git a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm index fed27ccc7..662b4847d 100644 --- a/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm +++ b/lib/WebGUI/i18n/English/Asset_GalleryAlbum.pm @@ -597,6 +597,36 @@ our $I18N = { context => 'Label for URL to add an album Description.', }, + 'Uploading archive' => { + message => 'Uploading archive', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + + 'Extracting archive' => { + message => 'Extracting archive', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + + 'Found file: %s' => { + message => 'Found file %s', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + + 'Adding %s to album' => { + message => 'Adding %s to album', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + + 'Requesting commit for version tag' => { + message => 'Requesting commit for version tag', + lastUpdated => 1237403498, + context => 'label for progress bar in addArchive', + }, + }; 1;