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 <david@davidnind.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Fixed typo in POD of html_content
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit a09986ea51
)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
ebf8e267ac
commit
1dc3332504
2 changed files with 35 additions and 2 deletions
|
@ -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{<link rel="stylesheet" type="text/css" href="$css">} if $css;
|
||||
|
||||
return <<EOS;
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>$title</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
$css
|
||||
</head>
|
||||
<body>
|
||||
$content
|
||||
</body>
|
||||
</html>
|
||||
EOS
|
||||
|
||||
}
|
||||
|
||||
=head3 type
|
||||
|
||||
=cut
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<td>
|
||||
<a class="notice-title" data-noticeid="[% QUEUED_MESSAGE.message_id | html %]" href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber | uri %]&noticeid=[% QUEUED_MESSAGE.message_id | uri %]">[% QUEUED_MESSAGE.subject | html %]</a>
|
||||
[% IF QUEUED_MESSAGE.content_type.search('html') %]
|
||||
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.content | html %]"></iframe>
|
||||
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.html_content | html %]"></iframe>
|
||||
[% ELSE %]
|
||||
<iframe class="notice" id="notice[% QUEUED_MESSAGE.message_id | html %]" srcdoc="[% QUEUED_MESSAGE.content | html | html_line_break %]"></iframe>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue