X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FSearch%2FResults.tsv;h=3551258780b888b491fae6cc92b3de9f2d80451b;hp=977b1ea7b14a6aff17f5286535b7f699187b8e71;hb=187086c479a09629b7d180eec513fb7657f4e291;hpb=85e677b86fc37c54e6de2b06340351a28f5a5916 diff --git a/rt/share/html/Search/Results.tsv b/rt/share/html/Search/Results.tsv index 977b1ea7b..355125878 100644 --- a/rt/share/html/Search/Results.tsv +++ b/rt/share/html/Search/Results.tsv @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -54,56 +54,8 @@ $PreserveNewLines => 0 <%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 => Encode::encode_utf8(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,19 +71,5 @@ else { $Tickets->OrderBy( FIELD => $OrderBy, ORDER => $Order ); } -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; - Encode::encode_utf8($val); - } @$col)."\n"); - } -} -$m->abort(); - +$m->comp( "/Elements/TSVExport", Collection => $Tickets, Format => $Format, PreserveNewLines => $PreserveNewLines );