diff options
Diffstat (limited to 'rt/share/html/Search/Results.tsv')
-rw-r--r-- | rt/share/html/Search/Results.tsv | 66 |
1 files changed, 1 insertions, 65 deletions
diff --git a/rt/share/html/Search/Results.tsv b/rt/share/html/Search/Results.tsv index b28ea4816..1e45a33cf 100644 --- a/rt/share/html/Search/Results.tsv +++ b/rt/share/html/Search/Results.tsv @@ -54,56 +54,8 @@ $PreserveNewLines => 0 </%ARGS> <%INIT> -$r->content_type('text/tab-separated-values'); $r->header_out('Content-Disposition' => 'attachment;filename="Results.tsv"'); -my $DisplayFormat = $m->comp('/Elements/ScrubHTML', Content => $Format); - -my @Format = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $DisplayFormat); - -my @columns; - -my $should_loc = { map { $_ => 1 } qw(Status) }; - -my $col_entry = sub { - my $col = shift; - # in tsv output, "#" is often a comment character but we use it for "id" - delete $col->{title} - if $col->{title} and $col->{title} =~ /^\s*#\s*$/; - return { - header => loc($col->{title} || $col->{attribute}), - map => $m->comp( - "/Elements/ColumnMap", - Name => $col->{attribute}, - Attr => 'value' - ), - should_loc => $should_loc->{$col->{attribute}}, - } -}; - -if ($PreserveNewLines) { - my $col = []; - push @columns, $col; - for (@Format) { - if ($_->{title} eq 'NEWLINE') { - $col = []; - push @columns, $col; - } - else { - push @$col, $col_entry->($_); - } - } -} -else { - push @columns, [map { $_->{attribute} - ? $col_entry->($_) - : () } @Format]; -} - -for (@columns) { - $m->out(join("\t", map { $_->{header} } @$_)."\n"); -} - my $Tickets = RT::Tickets->new( $session{'CurrentUser'} ); $Tickets->FromSQL( $Query ); if ( $OrderBy =~ /\|/ ) { @@ -119,21 +71,5 @@ else { $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); } -my $i = 0; -my $ii = 0; -while (my $row = $Tickets->Next) { - for my $col (@columns) { - $m->out(join("\t", map { - my $val = ProcessColumnMapValue($_->{map}, Arguments => [$row, $ii++], Escape => 0); - $val = loc($val) if $_->{should_loc}; - # remove tabs from all field values, they screw up the tsv - $val = '' unless defined $val; - $val =~ s/(?:\n|\r)//g; $val =~ s{\t}{ }g; - $val; - } @$col)."\n"); - } - $m->flush_buffer unless ++$i % 10; -} -$m->abort(); - +$m->comp( "/Elements/TSVExport", Collection => $Tickets, Format => $Format, PreserveNewLines => $PreserveNewLines ); </%INIT> |