From 9181636874a03cf43e7c26a89364279bfe2aa2ee Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 14 Nov 2013 14:00:46 +0100 Subject: [PATCH] Bug 11248: fix encoding issue on emailing a list (INTRANET) Test plan: - send a list via email with the english version. - translate templates and retry with another language. Signed-off-by: Katrin Fischer Sending an intranet list from translated templates requires a new list template for the intranet. I have added the needed changes in a follow-up. Signed-off-by: Kyle M Hall Signed-off-by: Galen Charlton --- .../en/modules/virtualshelves/sendshelf.tt | 185 +++++++++++++++--- virtualshelves/sendshelf.pl | 21 +- 2 files changed, 167 insertions(+), 39 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt index 12e53eeda9..644e7d9f23 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/sendshelf.tt @@ -2,44 +2,165 @@ Your List : [% shelfname %] +[% USE HtmlToText %] +[% myhtml FILTER html2text(leftmargin => 0, rightmargin => 0) %] +[% myhtmltext | html2text %] +
-Hi, +[% FILTER html2text %] +

Hi,

+ +

Here is your list called [% shelfname %], sent from our online catalog.

-Here is your list called [% shelfname %], sent from our online catalog. +

Please note that the attached file is a MARC bibliographic records file + which can be imported into a 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 a 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 ) %];[% 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.size ) %] + [% FOREACH subtitle IN BIBLIO_RESULT.subtitle %] + [% subtitle.subfield %] + [% END %] + [% 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.ISBN && BIBLIO_RESULT.size > 0 ) %] + + ISBN: [% FOREACH isbn IN BIBLIO_RESULT.ISBN %] + [% isbn.marcisbn %] + [% UNLESS ( loop.last ) %]; [% 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 %] + + [% 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/virtualshelves/sendshelf.pl b/virtualshelves/sendshelf.pl index 37a98ec887..cc3afde3fb 100755 --- a/virtualshelves/sendshelf.pl +++ b/virtualshelves/sendshelf.pl @@ -21,7 +21,7 @@ use strict; use warnings; use CGI; -use Encode qw(encode); +use Encode qw(decode encode); use Carp; use Mail::Sendmail; @@ -116,22 +116,29 @@ if ( $email ) { my $body; # Analysing information and getting mail properties - if ( $template_res =~ /\n(.*)\n/s ) { - $mail{'subject'} = $1; + if ( $template_res =~ /(.*)/s ) { + $mail{subject} = $1; + $mail{subject} =~ s|\n?(.*)\n?|$1|; } else { $mail{'subject'} = "no subject"; } my $email_header = ""; - if ( $template_res =~ /
\n(.*)\n/s ) { + if ( $template_res =~ /
(.*)/s ) { $email_header = $1; + $email_header =~ s|\n?(.*)\n?|$1|; } - my $email_file = "basket.txt"; - if ( $template_res =~ /\n(.*)\n/s ) { + my $email_file = "list.txt"; + if ( $template_res =~ /(.*)/s ) { $email_file = $1; + $email_file =~ s|\n?(.*)\n?|$1|; } - if ( $template_res =~ /\n(.*)\n/s ) { $body = encode_qp($1); } + if ( $template_res =~ /(.*)/s ) { + $body = $1; + $body =~ s|\n?(.*)\n?|$1|; + $body = encode("UTF-8", encode_qp($body)); + } my $boundary = "====" . time() . "===="; -- 2.39.5