[Koha-patches] [PATCH] Working on filters for output
Chris Cormack
chris at bigballofwax.co.nz
Tue Mar 31 04:28:29 CEST 2009
From: Chris Cormack <chrisc at catalyst.net.nz>
---
C4/Output.pm | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/C4/Output.pm b/C4/Output.pm
index fd32541..443383c 100644
--- a/C4/Output.pm
+++ b/C4/Output.pm
@@ -364,6 +364,15 @@ sub output_html_with_http_headers ($$$;$) {
my $query = shift;
my $cookie = shift;
my $html = shift;
+
+ # strip new lines or whitespace
+ if (C4::Context->preference('FilterWhiteSpace') eq 'stripwhitespace'){
+ $html = remove_white_space($html);
+ }
+ elsif (C4::Context->preference('FilterWhiteSpace') eq 'stripnewlines'){
+ $html = remove_newline($html);
+ }
+
my $content_type = @_ ? shift : "text/html";
$content_type = "text/html" unless $content_type =~ m!/!; # very basic sanity check
print $query->header(
@@ -391,6 +400,18 @@ sub is_ajax () {
return ($x_req and $x_req =~ /XMLHttpRequest/i) ? 1 : 0;
}
+sub remove_white_space {
+ $_[0] =~ s/^\s+$//mgo;
+ return $_[0];
+}
+
+sub remove_newline {
+ $_[0] =~ s/\s*\n\s*//go;
+ return $_[0];
+}
+
+
+
END { } # module clean-up code here (global destructor)
1;
--
1.5.6.3
More information about the Koha-patches
mailing list