From a0de95edbda2f4c8971419e62efe02c97adf50fe Mon Sep 17 00:00:00 2001 From: finlayt Date: Wed, 11 Sep 2002 03:55:30 +0000 Subject: [PATCH] added a themelanguage subroutine that searchs for templates according to the opacthemes and opaclanguages fields in the systempreferences table. These fields can be space seperated names. Templates are searched for in those orders, over themes first. --- C4/Output.pm | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index 1f46b5a3e6..902932660c 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -43,7 +43,7 @@ $VERSION = 0.01; &mkform &mkform2 &bold &gotopage &mkformnotable &mkform3 &getkeytableselectoptions - &picktemplate + &picktemplate &themelanguage ); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], @@ -102,8 +102,51 @@ sub picktemplate { } else { return 'default'; } - } + +sub themelanguage { + my ($htdocs, $tmpl) = @_; + +# language preferences.... + my $dbh=C4Connect; + my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='opaclanguages'"); + $sth->execute; + my ($lang) = $sth->fetchrow; + $sth->finish; + my @languages = split " ", $lang; + warn "Lang = @languages\n"; + +# theme preferences.... + my $sth=$dbh->prepare("SELECT value FROM systempreferences WHERE variable='opacthemes'"); + $sth->execute; + my ($theme) = $sth->fetchrow; + $sth->finish; + my @themes = split " ", $theme; + warn "Theme = @themes \n"; + + $dbh->disconnect; + + my ($theme, $lang); +# searches through the themes and languages. First template it find it returns. +# Priority is for getting the theme right. + THEME: + foreach my $th (@themes) { + foreach my $la (@languages) { + warn "File = $htdocs/$th/$la/$tmpl\n"; + if (-e "$htdocs/$th/$la/$tmpl") { + $theme = $th; + $lang = $la; + last THEME; + } + } + } + if ($theme and $lang) { + return ($theme, $lang); + } else { + return ('default', 'en'); + } +} + sub startpage() { return("\n");