Bug 14263: Fix export of item search results when translated

This csv does not use the correct way to display headers.
They should be put in a separate file to get a correct display.
Without this patch, the first line of the generated file contains the
headers + data

Test plan:
1/ choose a language and update + translate the templates
for instance:
  cd misc/translate;
  ./translate update es-ES; ./translate install es-ES
2/ Go to the item search form using this language
3/ Launch a search and select CSV to display the results.
The CSV headers should be correct

Signed-off-by: Frederic Demians <f.demians@tamil.fr>
  Seen the bug. Works as described.

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
Jonathan Druart 2015-05-24 18:00:57 +02:00 committed by Tomas Cohen Arazi
parent 0fa0297d7d
commit ece2b02a57
5 changed files with 7 additions and 3 deletions

View file

@ -303,7 +303,10 @@ if ($format eq 'csv') {
type => 'text/csv',
attachment => 'items.csv',
});
print $template->output;
for my $line ( split '\n', $template->output ) {
print "$line\n" unless $line =~ m|^\s*$|;
}
} else {
output_with_http_headers $cgi, $cookie, $template->output, $content_type;
}

View file

@ -1,4 +1,4 @@
[%- USE Branches -%]
[%- biblio = item.biblio -%]
[%- biblioitem = item.biblioitem -%]
"[% biblio.title |html %] by [% biblio.author |html %]", "[% biblioitem.publicationyear |html %]", "[% biblioitem.publishercode |html %]", "[% biblioitem.collectiontitle |html %]", "[% item.barcode |html %]", "[% item.itemcallnumber |html %]", "[% Branches.GetName(item.homebranch) |html %]", "[% Branches.GetName(item.holdingbranch) |html %]", "[% item.location |html %]", "[% item.stocknumber |html %]", "[% item.status |html %]", "[% (item.issues || 0) |html %]"
"[% biblio.title |html %] by [% biblio.author |html %]", "[% biblioitem.publicationyear |html %]", "[% biblioitem.publishercode |html %]", "[% biblioitem.collectiontitle |html %]", "[% item.barcode |html %]", "[% item.itemcallnumber |html %]", "[% Branches.GetName(item.homebranch) |html %]", "[% Branches.GetName(item.holdingbranch) |html %]", "[% item.location |html %]", "[% item.stocknumber |html %]", "[% item.status |html %]", "[% (item.issues || 0) |html %]"[% INCLUDE 'empty_line.inc' %]

View file

@ -0,0 +1 @@
Title, Publication Date, Publisher, Collection, Barcode, Call number, Home library, Current location, Shelving location, Inventory number, Status, Checkouts

View file

@ -1,4 +1,4 @@
Title, Publication Date, Publisher, Collection, Barcode, Call number, Home library, Current location, Shelving location, Inventory number, Status, Checkouts
[% INCLUDE csv_headers/catalogue/itemsearch.tt %]
[% FOREACH item IN results -%]
[%- INCLUDE 'catalogue/itemsearch_item.csv.inc' item = item -%]
[%- END -%]