From 93b98dda145126ed3ceca810db2c760dbdc8853d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 6 Nov 2023 14:00:21 +0000 Subject: [PATCH] Bug 30287: (follow-up) Add content wrap matching send time This patch adds a new method to the Koha::Notice::Message class to wrap content in the same way we currently do at email send time. We then update the notice preview to use this method so we're embedding NoticeCSS into that iframe. This means the generated preview should now exactly match how your notice will display in email clients including any CSS you may have placed within NoticeCSS. Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Fixed typo in POD of html_content Signed-off-by: Katrin Fischer (cherry picked from commit a09986ea51eb0104b006fac40d1dc7e2f6cdeeab) Signed-off-by: Fridolin Somers (cherry picked from commit 1dc33325041b5c2f94bc0d7acdecb101de16b98c) Signed-off-by: Lucas Gass --- Koha/Notice/Message.pm | 35 ++++++++++++++++++- .../prog/en/modules/members/notices.tt | 2 +- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Koha/Notice/Message.pm b/Koha/Notice/Message.pm index fcf7eca2a6..b7e30e509f 100644 --- a/Koha/Notice/Message.pm +++ b/Koha/Notice/Message.pm @@ -17,7 +17,6 @@ package Koha::Notice::Message; use Modern::Perl; - use Koha::Database; use base qw(Koha::Object); @@ -32,6 +31,40 @@ Koha::Notice::Message - Koha notice message Object class, related to the message =cut +=head3 html_content + + my $wrapped_content = $message->html_content; + +This method returns the message content appropriately wrapped +with HTML headers and CSS includes for HTML formatted notices. + +=cut + +sub html_content { + my ($self) = @_; + + my $title = $self->subject; + my $content = $self->content; + my $css = C4::Context->preference("NoticeCSS") || ''; + $css = qq{} if $css; + + return < + + + $title + + $css + + + $content + + +EOS + +} + =head3 type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt index df3235e302..e2d6e3c58d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt @@ -62,7 +62,7 @@ [% QUEUED_MESSAGE.subject | html %] [% IF QUEUED_MESSAGE.content_type.search('html') %] - + [% ELSE %] [% END %] -- 2.39.5