diff options
author | ivan <ivan> | 2009-05-03 22:45:40 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-05-03 22:45:40 +0000 |
commit | b9ec1f7c51efb5122b7dc88ccadb34e9e99a3b6f (patch) | |
tree | 731dcc11ee1ad72923d10a88259d233cb7bbdde1 /httemplate/search/elements/search-csv.html | |
parent | d557c2a3bf895d17c7d9fcfa2f5fb0c99b9e989f (diff) |
break down search.html into components, RT#5108
Diffstat (limited to 'httemplate/search/elements/search-csv.html')
-rw-r--r-- | httemplate/search/elements/search-csv.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/httemplate/search/elements/search-csv.html b/httemplate/search/elements/search-csv.html new file mode 100644 index 000000000..cd4ea63f5 --- /dev/null +++ b/httemplate/search/elements/search-csv.html @@ -0,0 +1,48 @@ +% $csv->combine(@$header); #or die $csv->status; +% +<% $csv->string %>\ +% +% foreach my $row ( @$rows ) { +% +% if ( $opt{'fields'} ) { +% +% my @line = (); +% +% foreach my $field ( @{$opt{'fields'}} ) { +% if ( ref($field) eq 'CODE' ) { +% push @line, map { +% ref($_) eq 'ARRAY' +% ? '(N/A)' #unimplemented +% : $_; +% } +% &{$field}($row); +% } else { +% push @line, $row->$field(); +% } +% } +% +% $csv->combine(@line); #or die $csv->status; +% +% } else { +% $csv->combine(@$row); #or die $csv->status; +% } +% +% +<% $csv->string %>\ +% +% } +<%init> + +my %args = @_; +my $header = $args{'header'}; +my $rows = $args{'rows'}; +my %opt = %{ $args{'opt'} }; + +#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes +http_header('Content-Type' => 'text/plain' ); + +my $csv = new Text::CSV_XS { 'always_quote' => 1, + 'eol' => "\n", #"\015\012", #"\012" + }; + +</%init> |