Bugzilla – Attachment 178488 Details for
Bug 35267
Clarify CSS options for Notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35267: Apply preferences to preview and mailing
Bug-35267-Apply-preferences-to-preview-and-mailing.patch (text/plain), 11.31 KB, created by
Martin Renvoize (ashimema)
on 2025-02-21 14:01:26 UTC
(
hide
)
Description:
Bug 35267: Apply preferences to preview and mailing
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-02-21 14:01:26 UTC
Size:
11.31 KB
patch
obsolete
>From dc5031633d8a37186823715ebe58aaf5d3562416 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 13 Nov 2023 15:31:53 +0000 >Subject: [PATCH] Bug 35267: Apply preferences to preview and mailing > >This patch applies the new style preferences to the preview display and >email sending code. > >Sponsored-by: PTFS Europe <https://ptfs-europe.com> >--- > C4/Letters.pm | 34 ++++++++++---- > Koha/Notice/Message.pm | 44 ++++++++++++++++--- > circ/transfer-slip.pl | 11 +++-- > .../prog/en/modules/circ/printslip.tt | 4 +- > .../prog/en/modules/members/printnotice.tt | 6 +-- > members/printslip.pl | 3 +- > opac/sco/printslip.pl | 2 +- > preservation/print_slip.pl | 2 +- > 8 files changed, 74 insertions(+), 32 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 0e17d4c23dd..2ffc8921900 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -342,7 +342,7 @@ sub SendAlerts { > ); > > if ( $letter->{is_html} ) { >- $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >+ $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title}, 'email' ) ); > } else { > $mail->text_body( $letter->{content} ); > } >@@ -514,7 +514,7 @@ sub SendAlerts { > ); > > if ( $letter->{is_html} ) { >- $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title} ) ); >+ $mail->html_body( _wrap_html( $letter->{content}, "" . $letter->{title}, 'email' ) ); > } else { > $mail->text_body( "" . $letter->{content} ); > } >@@ -1324,7 +1324,7 @@ sub _add_attachments { > my $message = Koha::Email->new; > > if ( $letter->{is_html} ) { >- $message->html_body( _wrap_html( $letter->{content}, $letter->{title} ) ); >+ $message->html_body( _wrap_html( $letter->{content}, $letter->{title}, 'email' ) ); > } else { > $message->text_body( $letter->{content} ); > } >@@ -1553,7 +1553,7 @@ sub _send_message_by_email { > } else { > $email = Koha::Email->create($params); > if ($is_html) { >- $email->html_body( _wrap_html( $content, $subject ) ); >+ $email->html_body( _wrap_html( $content, $subject, 'email' ) ); > } else { > $email->text_body($content); > } >@@ -1635,10 +1635,26 @@ sub _send_message_by_email { > } > > sub _wrap_html { >- my ( $content, $title ) = @_; >- >- my $css = C4::Context->preference("NoticeCSS") || ''; >- $css = qq{<link rel="stylesheet" type="text/css" href="$css">} if $css; >+ my ( $content, $title, $type ) = @_; >+ my $stylesheets = ''; >+ >+ my $all_stylesheets = C4::Context->preference("AllNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$all_stylesheets">} if $all_stylesheets; >+ my $all_style_pref = C4::Context->preference("AllNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$all_style_pref</style>} if $all_style_pref; >+ if ( $type eq 'email' ) { >+ my $email_stylesheet = C4::Context->preference("EmailNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$email_stylesheet">} if $email_stylesheet; >+ my $email_style_pref = C4::Context->preference("EmailNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$email_style_pref</style>} if $email_style_pref; >+ } >+ if ( $type eq 'print' ) { >+ my $print_stylesheet = C4::Context->preference("PrintNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$print_stylesheet">} if $print_stylesheet; >+ my $print_style_pref = C4::Context->preference("PrintNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$print_style_pref</style>} if $print_style_pref; >+ } >+ $stylesheets =~ s/\n+\z//; > return <<EOS; > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >@@ -1646,7 +1662,7 @@ sub _wrap_html { > <head> > <title>$title</title> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >-$css >+$stylesheets > </head> > <body> > $content >diff --git a/Koha/Notice/Message.pm b/Koha/Notice/Message.pm >index 56798071063..ead471c231e 100644 >--- a/Koha/Notice/Message.pm >+++ b/Koha/Notice/Message.pm >@@ -58,15 +58,12 @@ with HTML headers and CSS includes for HTML formatted notices. > sub html_content { > my ($self) = @_; > >- my $title = $self->subject; >- my $content = $self->content; >+ my $title = $self->subject; >+ my $content = $self->content; >+ my $stylesheets = $self->stylesheets; > > my $wrapped; > if ( $self->is_html ) { >- >- my $css = C4::Context->preference("NoticeCSS") || ''; >- $css = qq{<link rel="stylesheet" type="text/css" href="$css">} if $css; >- > $wrapped = <<EOS; > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >@@ -74,7 +71,7 @@ sub html_content { > <head> > <title>$title</title> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> >- $css >+ $stylesheets > </head> > <body> > $content >@@ -124,6 +121,39 @@ sub restrict_patron_when_notice_fails { > return $self; > } > >+=head3 stylesheets >+ >+ my $stylesheets = $message->stylesheets; >+ >+Returns a string of all the stylesheet links for the message >+ >+=cut >+ >+sub stylesheets { >+ my ($self) = @_; >+ my $stylesheets = ''; >+ >+ my $all_stylesheets = C4::Context->preference("AllNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$all_stylesheets">\n} if $all_stylesheets; >+ my $all_style_pref = C4::Context->preference("AllNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$all_style_pref</style>} if $all_style_pref; >+ if ( $self->message_transport_type eq 'email' ) { >+ my $email_stylesheet = C4::Context->preference("EmailNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$email_stylesheet">\n} if $email_stylesheet; >+ my $email_style_pref = C4::Context->preference("EmailNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$email_style_pref</style>} if $email_style_pref; >+ } >+ if ( $self->message_transport_type eq 'print' ) { >+ my $print_stylesheet = C4::Context->preference("PrintNoticeStylesheet") || ''; >+ $stylesheets .= qq{<link rel="stylesheet" type="text/css" href="$print_stylesheet">\n} if $print_stylesheet; >+ my $print_style_pref = C4::Context->preference("PrintNoticeCSS"); >+ $stylesheets .= qq{<style type="text/css">$print_style_pref</style>\n} if $print_style_pref; >+ } >+ $stylesheets =~ s/\n+\z//; >+ >+ return $stylesheets; >+} >+ > =head3 type > > =cut >diff --git a/circ/transfer-slip.pl b/circ/transfer-slip.pl >index ce9619499d4..ae28d823694 100755 >--- a/circ/transfer-slip.pl >+++ b/circ/transfer-slip.pl >@@ -53,12 +53,11 @@ if ( my $letter = TransferSlip( $session->param('branch') || $userenv->{branch}, > $slip = "Item not found"; > } > $template->param( >- slip => $slip, >- plain => !$is_html, >- caller => 'cud-transfer', >- stylesheet => C4::Context->preference("SlipCSS"), >- style => $style, >- id => 'transfer_slip', >+ slip => $slip, >+ plain => !$is_html, >+ caller => 'cud-transfer', >+ style => $style, >+ id => 'transfer_slip', > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >index a4d3d52f737..945ab6d7aae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/printslip.tt >@@ -32,8 +32,8 @@ > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > [% Asset.css("css/print.css") | $raw %] >-[% IF ( Koha.Preference('SlipCSS') ) %] >- <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> >+[% IF ( Koha.Preference('PrintSlipStylesheet') ) %] >+ <link rel="stylesheet" type="text/css" href="[% Koha.Preference('PrintSlipStylesheet') | $raw %]" /> > [% END %] > [% FOR slip IN slips %] > [% IF slip.style %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >index 95bb4634514..dd031b34fb2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/printnotice.tt >@@ -15,11 +15,7 @@ > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> > <link rel="shortcut icon" href="[% IF ( IntranetFavicon ) %][% IntranetFavicon | url %][% ELSE %][% interface | html %]/[% theme | html %]/img/favicon.ico[% END %]" type="image/x-icon" /> > >-[% Asset.css("css/print.css") | $raw %] >-[% IF ( Koha.Preference('SlipCSS') ) %] >- <link rel="stylesheet" type="text/css" href="[% Koha.Preference('SlipCSS') | $raw %]" /> >-[% END %] >-<!-- prettier-ignore-start --> >+[% Asset.css("css/print.css") | $raw %] <!-- prettier-ignore-start --> > [% IF style %]<style>[% style | $raw %]</style>[% END %] > <!-- prettier-ignore-end --> > </head> >diff --git a/members/printslip.pl b/members/printslip.pl >index 4b612378a60..c801fe713a1 100755 >--- a/members/printslip.pl >+++ b/members/printslip.pl >@@ -117,10 +117,11 @@ $template->param( > plain => !$is_html, > borrowernumber => $borrowernumber, > caller => 'members', >- stylesheet => C4::Context->preference("SlipCSS"), > error => $error, > style => $letter->{style}, > id => $print, >+ stylesheet => C4::Context->preference("PrintSlipStylesheet"), >+ error => $error, > ); > > $template->param( IntranetSlipPrinterJS => C4::Context->preference('IntranetSlipPrinterJS') ); >diff --git a/opac/sco/printslip.pl b/opac/sco/printslip.pl >index a43d9a29815..ec21c4765db 100755 >--- a/opac/sco/printslip.pl >+++ b/opac/sco/printslip.pl >@@ -82,7 +82,7 @@ if ( my $letter = > $template->{VARS}->{slip} = $slip; > $template->{VARS}->{plain} = !$is_html; > $template->{VARS}->{borrowernumber} = $patron->borrowernumber; >-$template->{VARS}->{stylesheet} = C4::Context->preference("SlipCSS"); >+$template->{VARS}->{stylesheet} = C4::Context->preference("PrintSlipStylesheet"); > $template->{VARS}->{error} = $error; > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/preservation/print_slip.pl b/preservation/print_slip.pl >index 5ad589d3b70..4859b6c12f7 100755 >--- a/preservation/print_slip.pl >+++ b/preservation/print_slip.pl >@@ -64,7 +64,7 @@ for my $train_item_id (@train_item_ids) { > $template->param( > slips => \@slips, > caller => 'preservation', >- stylesheet => C4::Context->preference("SlipCSS"), >+ stylesheet => C4::Context->preference("PrintSlipStylesheet"), > ); > > $template->param( IntranetSlipPrinterJS => C4::Context->preference('IntranetSlipPrinterJS') ); >-- >2.48.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35267
:
172414
|
172415
|
172416
|
172417
|
172418
|
172457
|
172458
|
172459
|
172460
|
172461
|
172462
|
172463
|
172474
|
172475
|
172476
|
172477
|
172478
|
172479
|
172480
|
172485
|
172486
|
172487
|
172488
|
172489
|
172490
|
172491
|
175531
|
175532
|
175533
|
175534
|
175535
|
175536
|
175706
|
175707
|
175708
|
175709
|
175710
|
175711
|
175715
|
175716
|
175717
|
175718
|
175719
|
175721
|
175723
|
175724
|
175725
|
175726
|
175727
|
175728
|
175729
|
178485
|
178486
|
178487
|
178488
|
178489
|
178490
|
178491
|
180574
|
180575
|
180576
|
180577
|
180578
|
180579
|
180580
|
180963
|
180964
|
180965
|
180966
|
180967
|
180968
|
180969
|
180970
|
180971