# templates.
use strict;
-require Exporter;
use C4::Context;
use C4::Languages qw(getTranslatedLanguages get_bidi regex_lang_subtags language_get_description accept_language );
use HTML::Template::Pro;
use vars qw($VERSION @ISA @EXPORT);
-# set the version for version checking
-$VERSION = 3.00;
+BEGIN {
+ # set the version for version checking
+ $VERSION = 3.01;
+ require Exporter;
+ @ISA = qw(Exporter);
+ push @EXPORT, qw(
+ &themelanguage &gettemplate setlanguagecookie pagination_bar
+ );
+ push @EXPORT, qw(
+ &output_html_with_http_headers
+ );
+}
=head1 NAME
=cut
-@ISA = qw(Exporter);
-push @EXPORT, qw(
- &themelanguage &gettemplate setlanguagecookie pagination_bar &output_html_with_http_headers
-);
-
-
#FIXME: this is a quick fix to stop rc1 installing broken
#Still trying to figure out the correct fix.
my $path = C4::Context->config('intrahtdocs') . "/prog/en/includes/";
# FIXME - POD
sub gettemplate {
my ( $tmplbase, $interface, $query ) = @_;
- if ( !$query ) {
- warn "no query in gettemplate";
- }
+ ($query) or warn "no query in gettemplate";
my $htdocs;
if ( $interface ne "intranet" ) {
$htdocs = C4::Context->config('opachtdocs');
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/".($interface eq 'intranet'?"modules":"")."/$tmplbase";
+ my $filename = "$htdocs/$theme/$lang/modules/$tmplbase";
unless (-f $filename) {
$lang = 'en';
$filename = "$htdocs/$theme/$lang/".($interface eq 'intranet'?"modules":"")."/$tmplbase";
# FIXME - POD
sub themelanguage {
my ( $htdocs, $tmpl, $interface, $query ) = @_;
+ ($query) or warn "no query in themelanguage";
# Set some defaults for language and theme
# First, check the user's preferences
my $lang;
- $lang = accept_language($ENV{HTTP_ACCEPT_LANGUAGE},getTranslatedLanguages($interface,'prog'));
-
+ my $http_accept_language = regex_lang_subtags($ENV{HTTP_ACCEPT_LANGUAGE})->{language};
+ if ($http_accept_language) {
+ $lang = accept_language($http_accept_language,getTranslatedLanguages($interface,'prog'));
+ }
# But, if there's a cookie set, obey it
$lang = $query->cookie('KohaOpacLanguage') if $query->cookie('KohaOpacLanguage');
if ( $interface eq "intranet" ) {
@languages = split " ", C4::Context->preference("opaclanguages");
@themes = split " ", C4::Context->preference("template");
- pop @languages, $lang if $lang;
+ push @languages, $lang if $lang;
}
else {
-
# we are in the opac here, what im trying to do is let the individual user
# set the theme they want to use.
# and perhaps the them as well.
#my $lang = $query->cookie('KohaOpacLanguage');
- if ($lang) {
-
+ if ($lang) { # FIXME: if $lang always TRUE!
push @languages, $lang;
- @themes = split " ", C4::Context->preference("opacthemes");
}
else {
@languages = split " ", C4::Context->preference("opaclanguages");
- @themes = split " ", C4::Context->preference("opacthemes");
}
+ @themes = split " ", C4::Context->preference("opacthemes");
}
# searches through the themes and languages. First template it find it returns.