Bugzilla – Attachment 158960 Details for
Bug 35285
Centralise notice content wrapping for HTML output
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35285: Add non-html template support to html_content wrapping
Bug-35285-Add-non-html-template-support-to-htmlcon.patch (text/plain), 2.43 KB, created by
David Nind
on 2023-11-15 09:16:21 UTC
(
hide
)
Description:
Bug 35285: Add non-html template support to html_content wrapping
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-11-15 09:16:21 UTC
Size:
2.43 KB
patch
obsolete
>From 05a6554b32ae148e830ac3024f43298dbf7b12e6 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 8 Nov 2023 09:59:30 +0000 >Subject: [PATCH] Bug 35285: Add non-html template support to html_content > wrapping > >This patch adds support for messages generated using non-html formatted >notice templates to the html_content method of Koha::Notice::Message. > >We continue to wrap content for html generated messages with the >appropriate headers, css and title. > >For non-html generated content we wrap in the <div style="white-space: >pre-wrap"> block to maintain text formatting as defined in the original >plaintext template. > >Test >Follow the test plan for bug 30287, nothing should outwardly change. > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Notice/Message.pm | 31 +++++++++++++++++++++++++++---- > 1 file changed, 27 insertions(+), 4 deletions(-) > >diff --git a/Koha/Notice/Message.pm b/Koha/Notice/Message.pm >index a44107a59c..70b9e901c3 100644 >--- a/Koha/Notice/Message.pm >+++ b/Koha/Notice/Message.pm >@@ -31,6 +31,20 @@ Koha::Notice::Message - Koha notice message Object class, related to the message > > =cut > >+=head3 is_html >+ >+ my $bool = $message->is_html; >+ >+Returns a boolean denoting whether the message was generated using a preformatted html template. >+ >+=cut >+ >+sub is_html { >+ my ($self) = @_; >+ my $content_type = $self->content_type // ''; >+ return $content_type =~ m/html/io; >+} >+ > =head3 html_content > > my $wrapped_content = $message->html_content; >@@ -45,10 +59,14 @@ sub html_content { > > 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; >+ 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"> > <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> >@@ -62,7 +80,12 @@ sub html_content { > </body> > </html> > EOS >- >+ } else { >+ $wrapped = "<div style=\"white-space: pre-wrap;\">\n"; >+ $wrapped .= $content . "\n"; >+ $wrapped .= "</div>\n"; >+ } >+ return $wrapped; > } > > =head3 type >-- >2.30.2
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 35285
:
158657
|
158658
|
158889
|
158890
|
158891
|
158960
|
158961
|
158962
|
166329
|
166330
|
166331
|
166332
|
166333
|
166334
|
166348
|
166349
|
166350
|
166356
|
166357
|
166358
|
166719
|
166720
|
166721
|
166722