From efc8f6980021cb1a789f413678d889d02a2368e9 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Tue, 25 Aug 2009 23:56:18 +0200 Subject: [PATCH] C4::Output adding getlanguagecookie + other enhancements required for language stemming management Adding also some filters for NSB NSE characters Now, get_template can be used even when query->cookie not set Signed-off-by: Galen Charlton --- C4/Output.pm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 5bebf6c0c6..731cb7e39d 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -26,7 +26,6 @@ package C4::Output; # templates. use strict; -use warnings; use C4::Context; use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language_get_description accept_language ); @@ -46,7 +45,7 @@ BEGIN { html =>[qw(&output_with_http_headers &output_html_with_http_headers)] ); push @EXPORT, qw( - &themelanguage &gettemplate setlanguagecookie pagination_bar + &themelanguage &gettemplate setlanguagecookie getlanguagecookie pagination_bar ); push @EXPORT, qw( &output_html_with_http_headers &output_with_http_headers @@ -81,6 +80,7 @@ sub gettemplate { } my $path = C4::Context->preference('intranet_includes') || 'includes'; my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, $interface, $query ); + my $opacstylesheet = C4::Context->preference('opacstylesheet'); # if the template doesn't exist, load the English one as a last resort my $filename = "$htdocs/$theme/$lang/modules/$tmplbase"; @@ -141,7 +141,7 @@ sub themelanguage { getTranslatedLanguages($interface,'prog') ) if $http_accept_language; # But, if there's a cookie set, obey it - $lang = $query->cookie('KohaOpacLanguage') if $query->cookie('KohaOpacLanguage'); + $lang = $query->cookie('KohaOpacLanguage') if (defined $query and $query->cookie('KohaOpacLanguage')); # Fall back to English my @languages; if ($interface eq 'intranet') { @@ -202,6 +202,20 @@ sub setlanguagecookie { ); } +sub getlanguagecookie { + my ($query) = @_; + my $lang; + if ($query->cookie('KohaOpacLanguage')){ + $lang = $query->cookie('KohaOpacLanguage') ; + }else{ + $lang = $ENV{HTTP_ACCEPT_LANGUAGE}; + + } + $lang = substr($lang, 0, 2); + + return $lang; +} + =item pagination_bar pagination_bar($base_url, $nb_pages, $current_page, $startfrom_name) @@ -392,6 +406,9 @@ sub output_with_http_headers($$$$;$) { $options->{'Content-Style-Type' } = 'text/css'; $options->{'Content-Script-Type'} = 'text/javascript'; } + # remove SUDOC specific NSB NSE + $data =~ s/\x{C2}\x{98}|\x{C2}\x{9C}/ /g; + $data =~ s/\x{C2}\x{88}|\x{C2}\x{89}/ /g; print $query->header($options), $data; } -- 2.39.5