diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 3a23b57af..c25f9a7ea 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -4,6 +4,7 @@ - fixed #11922: Help tempalte is squatting on a good URL - fixed #11923: Collaboration System Mail Cron Errors - fixed #11925: Some problems in Thingy export (metaData values in CSV export) + - fixed #11925: Some problems in Thingy export (export times out on Things with many rows) 7.10.3 - fixed #11903: Unnecessary debug in Thingy diff --git a/lib/WebGUI/Asset/Wobject/Thingy.pm b/lib/WebGUI/Asset/Wobject/Thingy.pm index 98496fdd9..e6737e080 100644 --- a/lib/WebGUI/Asset/Wobject/Thingy.pm +++ b/lib/WebGUI/Asset/Wobject/Thingy.pm @@ -21,6 +21,7 @@ use WebGUI::DateTime; use base 'WebGUI::Asset::Wobject'; use Data::Dumper; use PerlIO::eol qw/NATIVE/; +use WebGUI::ProgressBar; #------------------------------------------------------------------- @@ -2686,6 +2687,11 @@ sub www_export { my $thingProperties = $self->getThing($thingId); return $session->privilege->insufficient() unless $self->hasPrivileges($thingProperties->{groupIdExport}); + my $i18n = WebGUI::International->new($session, 'Asset_Thingy'); + my $pb = WebGUI::ProgressBar->new($session); + $pb->start($i18n->get('export label').' '.$thingProperties->{label}, $session->url->extras('assets/thingy.gif')); + $pb->update($i18n->get('Creating column headers')); + my $tempStorage = WebGUI::Storage->createTemp($session); $fields = $session->db->read('select * from Thingy_fields where assetId =? and thingId = ? order by sequenceNumber', [$self->get("assetId"),$thingId]); while (my $field = $fields->hashRef) { @@ -2707,9 +2713,13 @@ sub www_export { ### Loop through the returned structure and put it through Text::CSV # Column heads - $out = WebGUI::Text::joinCSV(@fieldLabels); + my $csv_filename = 'export_'.$thingProperties->{label}.'.csv'; + $tempStorage->addFileFromScalar($csv_filename, WebGUI::Text::joinCSV(@fieldLabels)); + open my $CSV, '>', $tempStorage->getPath($csv_filename); # Data lines + $pb->update($i18n->get('Writing data')); + my $rowCounter = 0; while (my $data = $sth->hashRef) { my @fieldValues; foreach my $field (@fields){ @@ -2723,14 +2733,15 @@ sub www_export { push(@fieldValues,$data->{$metaDataField}); } } - $out .= "\n".WebGUI::Text::joinCSV( @fieldValues ); + print $CSV "\n".WebGUI::Text::joinCSV( @fieldValues ); + #if (! ++$rowCounter % 25) { + $pb->update($i18n->get('Writing data')); + #} } - - $fileName = "export_".$thingProperties->{label}.".csv"; - $self->session->http->setFilename($fileName,"application/octet-stream"); - $self->session->http->sendHeader; - return $out; + close $CSV; + $pb->update(sprintf q|%s|, $self->getUrl, sprintf($i18n->get('Return to %s'), $thingProperties->{label})); + return $pb->finish($tempStorage->getUrl($csv_filename)); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/i18n/English/Asset_Thingy.pm b/lib/WebGUI/i18n/English/Asset_Thingy.pm index ccf77e1aa..ae615b2d6 100644 --- a/lib/WebGUI/i18n/English/Asset_Thingy.pm +++ b/lib/WebGUI/i18n/English/Asset_Thingy.pm @@ -1127,6 +1127,24 @@ search has been done.|, lastUpdated => 1231180362, }, + 'Creating column headers' => { + message => q|Creating column headers.|, + lastUpdated => 1231180362, + context => q|Status message in the Export Thingy progress bar.|, + }, + + 'Writing data' => { + message => q|Writing data.|, + lastUpdated => 1231180362, + context => q|Status message in the Export Thingy progress bar.|, + }, + + 'Return to %s' => { + message => q|Return to %s.|, + lastUpdated => 1231180362, + context => q|Status message in the Export Thingy progress bar. %s is the name of the Thing that is being exported.|, + }, + }; 1;