From 7bb89fbf2bf78a4c0741f0de9a93abc7ea1b9be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Tue, 24 Sep 2013 18:34:48 +0200 Subject: [PATCH] [SIGNED-OFF] Bug 8368 List email broken for non english templates This patch ports to list sending by email, the technic used in sending cart, ie (1) format email in HTML, and (2) transform it into Text with TT filter html2text. Signed-off-by: Bernardo Gonzalez Kriegel Comment: Work as described. No koha-qa errors Test 1) Installed language other than english 2) Create new list, add a few books 3) Send list in english, subject Ok 4) Swith opac lang, send list, No subject 5) Apply patch 6) Send list in english, subject Ok 7) Switch opac lang, send list, subject Ok --- .../opac-tmpl/prog/en/modules/opac-sendshelf.tt | 174 ++++++++++++++++---- opac/opac-sendshelf.pl | 30 ++-- 2 files changed, 154 insertions(+), 50 deletions(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt index c43affb..d461411 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-sendshelf.tt @@ -2,45 +2,153 @@ Your list : [% shelfname %] +[% USE HtmlToText %] +[% myhtml FILTER html2text(leftmargin => 0, rightmargin => 0) %] +[% myhtmltext | html2text %] +
-Hi, +[% FILTER html2text %] +

Hi,

+ +

[% firstname %] [% surname %] sent you from our online catalog, the + virtual shelf called : [% shelfname %].

-[% firstname %] [% surname %], sent you from our online catalog, the virtual shelf called : [% shelfname %]. +

Please note that the attached file is a MARC bibliographic records file + which can be imported into personal bibliographic software like EndNote, + Reference Manager or ProCite.

+
+[% END %] -Please note that the attached file is a MARC bibliographic records file -which can be imported into personal bibliographic software like EndNote, -Reference Manager or ProCite. ---------------------------------------------- -[% IF ( comment ) %] -[% comment %] -[% END %] -[% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %][% BIBLIO_RESULT.title %][% IF ( BIBLIO_RESULT.subtitle.size ) %] [% FOREACH subtitle IN BIBLIO_RESULT.subtitle %][% subtitle.subfield %][% END %][% END %][% IF ( BIBLIO_RESULT.author ) %] - -by [% BIBLIO_RESULT.author %][% END %] -[% IF ( BIBLIO_RESULT.MARCAUTHORS.size ) %] -Additional author(s): [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %][% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %][% MARCAUTHOR_SUBFIELDS_LOO.separator %] [% MARCAUTHOR_SUBFIELDS_LOO.value %][% END %][% UNLESS ( loop.last ) %]; [% ELSE %] -[% END %][% END %][% END %][% IF ( BIBLIO_RESULT.ISBN ) %] -ISBN: [% BIBLIO_RESULT.ISBN %][% END %] -[% IF ( BIBLIO_RESULT.publishercode ) %]Published by: [% BIBLIO_RESULT.publishercode %][% END %][% IF ( BIBLIO_RESULT.publicationyear ) %] in [% END %][% BIBLIO_RESULT.publicationyear %][% IF ( BIBLIO_RESULT.pages ) %], [% END %][% BIBLIO_RESULT.pages %][% IF ( BIBLIO_RESULT.size ) %], [% END %][% BIBLIO_RESULT.size %][% IF ( BIBLIO_RESULT.collection ) %] -Collection: [% BIBLIO_RESULT.seriestitle %][% END %][% IF ( BIBLIO_RESULT.subject ) %] -Subject: [% BIBLIO_RESULT.subject %][% END %][% IF ( BIBLIO_RESULT.copyrightdate ) %] -Copyright year: [% BIBLIO_RESULT.copyrightdate %][% END %][% IF ( BIBLIO_RESULT.notes ) %] -Notes : [% BIBLIO_RESULT.notes %][% END %][% IF ( BIBLIO_RESULT.unititle ) %] -Unified title: [% BIBLIO_RESULT.unititle %][% END %][% IF ( BIBLIO_RESULT.serial ) %] -Serial: [% BIBLIO_RESULT.serial %][% END %][% IF ( BIBLIO_RESULT.dewey ) %] -Dewey: [% BIBLIO_RESULT.dewey %][% END %][% IF ( BIBLIO_RESULT.classification ) %] -Classification: [% BIBLIO_RESULT.classification %][% END %][% IF ( BIBLIO_RESULT.lccn ) %] -LCCN: [% BIBLIO_RESULT.lccn %][% END %][% IF ( BIBLIO_RESULT.url ) %] -URL: [% BIBLIO_RESULT.url %][% END %][% IF ( OPACBaseURL ) %] -In the online catalog: - http://[% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber |url %][% END %] -Items: [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %] - [% ITEM_RESULT.branchname %] [% ITEM_RESULT.location %] [% IF ( ITEM_RESULT.itemcallnumber ) %]([% ITEM_RESULT.itemcallnumber %])[% END %] [% ITEM_RESULT.barcode %][% END %] - ---------------------------------------------- +[% FILTER html2text %] + + [% IF comment %] +

[% comment %]

+
+ [% END %] +
    + [% FOREACH BIBLIO_RESULT IN BIBLIO_RESULTS %] +
  1. + + [% BIBLIO_RESULT.title %] + [% IF ( BIBLIO_RESULT.subtitle ) %] [% BIBLIO_RESULT.subtitle %][% END %] + + +

    + [% IF ( BIBLIO_RESULT.HASAUTHORS ) %] + Author(s): [% IF ( BIBLIO_RESULT.author ) %][% BIBLIO_RESULT.author %][% END %] + + [% IF ( BIBLIO_RESULT.MARCAUTHORS ) %] + [% IF ( BIBLIO_RESULT.author ) %]; [% END %] + [% FOREACH MARCAUTHOR IN BIBLIO_RESULT.MARCAUTHORS %] + [% FOREACH MARCAUTHOR_SUBFIELDS_LOO IN MARCAUTHOR.MARCAUTHOR_SUBFIELDS_LOOP %] + [% MARCAUTHOR_SUBFIELDS_LOO.separator %][% MARCAUTHOR_SUBFIELDS_LOO.value %] + [% END %] + [% UNLESS ( loop.last ) %];[% END %] + [% END %] + [% END %] +
    + [% END %] + + [% IF BIBLIO_RESULT.publishercode %] + + Published by: [% BIBLIO_RESULT.publishercode %] + [% IF ( BIBLIO_RESULT.publicationyear ) %] + in [% BIBLIO_RESULT.publicationyear %] + [% END %] + [% IF ( BIBLIO_RESULT.pages ) %] + , [% BIBLIO_RESULT.pages %] + [% END %] + [% IF BIBLIO_RESULT.size %] + , [% BIBLIO_RESULT.size %] + [% END %] +
    + [% END %] + + [% IF BIBLIO_RESULT.collection %] + + Collection: [% BIBLIO_RESULT.seriestitle %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.subject ) %] + + Subject: [% BIBLIO_RESULT.subject %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.copyrightdate ) %] + + Copyright year: [% BIBLIO_RESULT.copyrightdate %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.notes ) %] + + Notes : [% BIBLIO_RESULT.notes %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.unititle ) %] + + Unified title: [% BIBLIO_RESULT.unititle %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.serial ) %] + + Serial: [% BIBLIO_RESULT.serial %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.dewey ) %] + + Dewey: [% BIBLIO_RESULT.dewey %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.classification ) %] + + Classification: [% BIBLIO_RESULT.classification %] +
    + [% END %] + + [% IF ( BIBLIO_RESULT.lccn ) %] + + LCCN: [% BIBLIO_RESULT.lccn %] +
    + [% END %] + [% IF ( BIBLIO_RESULT.url ) %] + + URL: [% BIBLIO_RESULT.url |url %] + + [% END %] +

    + + [% IF ( OPACBaseURL ) %] +

    + In online catalog: [% OPACBaseURL %]/cgi-bin/koha/opac-detail.pl?biblionumber=[% BIBLIO_RESULT.biblionumber %] +

    + [% END %] + [% IF ( BIBLIO_RESULT.ITEM_RESULTS.size ) %] +

    Items: +

      + [% FOREACH ITEM_RESULT IN BIBLIO_RESULT.ITEM_RESULTS %]
    • + [% ITEM_RESULT.branchname %] + [% ITEM_RESULT.location %] + [% IF ITEM_RESULT.itemcallnumber %]([% ITEM_RESULT.itemcallnumber %])[% END %] + [% ITEM_RESULT.barcode %] +
    • [% END %] +
    +

    + [% END %] +
    +
  2. + [% END %] +
[% END %] + diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl index 6e60bc9..cc70765 100755 --- a/opac/opac-sendshelf.pl +++ b/opac/opac-sendshelf.pl @@ -21,7 +21,7 @@ use strict; use warnings; use CGI; -use Encode qw(encode); +use Encode; use Carp; use Mail::Sendmail; @@ -91,12 +91,14 @@ if ( $email ) { my @items = GetItemsInfo( $biblionumber ); + $dat->{ISBN} = GetMarcISBN($record, $marcflavour); $dat->{MARCNOTES} = $marcnotesarray; $dat->{MARCSUBJCTS} = $marcsubjctsarray; $dat->{MARCAUTHORS} = $marcauthorsarray; $dat->{'biblionumber'} = $biblionumber; $dat->{ITEM_RESULTS} = \@items; $dat->{subtitle} = $subtitle; + $dat->{HASAUTHORS} = $dat->{'author'} || @$marcauthorsarray; $iso2709 .= $record->as_usmarc(); @@ -120,25 +122,18 @@ if ( $email ) { # Getting template result my $template_res = $template2->output(); - my $body; # Analysing information and getting mail properties - if ( $template_res =~ /\n(.*)\n/s ) { - $mail{'subject'} = $1; - } - else { $mail{'subject'} = "no subject"; } + $mail{'subject'} = $template_res =~ /\n(.*)\n?/s + ? $1 : "no subject"; - my $email_header = ""; - if ( $template_res =~ /
\n(.*)\n/s ) { - $email_header = $1; - } + my ($email_header) = $template_res =~ /
\n(.*)\n?/s; - my $email_file = "basket.txt"; - if ( $template_res =~ /\n(.*)\n/s ) { - $email_file = $1; - } + my $email_file = $template_res =~ /\n(.*)\n?/s + ? $1 + : "list.txt"; - if ( $template_res =~ /\n(.*)\n/s ) { $body = encode_qp($1); } + my ($body) = $template_res =~ /\n(.*)\n?/s; my $boundary = "====" . time() . "===="; @@ -150,15 +145,16 @@ if ( $email ) { $mail{body} = <