From cab3bc91ddb9aa3644a9c71a607ba1b724f958cc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sun, 24 May 2015 18:00:57 +0200 Subject: [PATCH] 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 Seen the bug. Works as described. Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi (cherry picked from commit ece2b02a57fdb692c02f00540df436af1f5ba971) Signed-off-by: Chris Cormack Signed-off-by: Liz Rea --- catalogue/itemsearch.pl | 5 ++++- .../prog/en/includes/catalogue/itemsearch_item.csv.inc | 2 +- .../prog/en/includes/csv_headers/catalogue/itemsearch.tt | 1 + koha-tmpl/intranet-tmpl/prog/en/includes/empty_line.inc | 0 .../prog/en/modules/catalogue/itemsearch_csv.tt | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/empty_line.inc diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index 34087e36f2..ed1a932207 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -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; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc index fd6e835a9d..9cc781c262 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalogue/itemsearch_item.csv.inc @@ -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' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt new file mode 100644 index 0000000000..28fabe707d --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/csv_headers/catalogue/itemsearch.tt @@ -0,0 +1 @@ +Title, Publication Date, Publisher, Collection, Barcode, Call number, Home library, Current location, Shelving location, Inventory number, Status, Checkouts diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/empty_line.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/empty_line.inc new file mode 100644 index 0000000000..e69de29bb2 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch_csv.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch_csv.tt index 45cfd3281a..49878c4870 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch_csv.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch_csv.tt @@ -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 -%] -- 2.39.5