use C4::Context;
use C4::Database;
+use HTML::Template;
use vars qw($VERSION @ISA @EXPORT);
&themelanguage &gettemplate
);
-my $path = C4::Context->config('includes') ||
- "/usr/local/www/hdl/htdocs/includes";
+#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')."/default/en/includes/";
#---------------------------------------------------------------------------------------------------------
# FIXME - POD
sub gettemplate {
- my ($tmplbase, $opac) = @_;
+ my ($tmplbase, $opac) = @_;
- my $htdocs;
- if ($opac ne "intranet") {
- $htdocs = C4::Context->config('opachtdocs');
- } else {
- $htdocs = C4::Context->config('intrahtdocs');
- }
+ my $htdocs;
+ if ($opac ne "intranet") {
+ $htdocs = C4::Context->config('opachtdocs');
+ } else {
+ $htdocs = C4::Context->config('intrahtdocs');
+ }
- my ($theme, $lang) = themelanguage($htdocs, $tmplbase);
+ my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $opac);
- my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$tmplbase",
+ my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$tmplbase",
die_on_bad_params => 0,
global_vars => 1,
path => ["$htdocs/$theme/$lang/includes"]);
- $template->param(themelang => "/$theme/$lang",
- theme => $theme,
+ # XXX temporary patch for Bug 182 for themelang
+ $template->param(themelang => ($opac ne 'intranet'? '/opac-tmpl': '/intranet-tmpl') . "/$theme/$lang",
+ interface => ($opac ne 'intranet'? '/opac-tmpl': '/intranet-tmpl'),
+ theme => $theme,
lang => $lang);
- return $template;
+ return $template;
}
#---------------------------------------------------------------------------------------------------------
# FIXME - POD
sub themelanguage {
- my ($htdocs, $tmpl) = @_;
+ my ($htdocs, $tmpl, $section) = @_;
my $dbh = C4::Context->dbh;
- my @languages = split " ", C4::Context->preference("opaclanguages");
- # language preference
- my @themes = split " ", C4::Context->preference("opacthemes");
- # theme preferences
+ my @languages;
+ my @themes;
+ if ( $section eq "intranet")
+ {
+ @languages = split " ", C4::Context->preference("opaclanguages");
+ @themes = split " ", C4::Context->preference("template");
+ }
+ else
+ {
+ @languages = split " ", C4::Context->preference("opaclanguages");
+ @themes = split " ", C4::Context->preference("opacthemes");
+ }
my ($theme, $lang);
# searches through the themes and languages. First template it find it returns.
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;
+ for (my $pass = 1; $pass <= 2; $pass += 1) {
+ $la =~ s/([-_])/ $1 eq '-'? '_': '-' /eg if $pass == 2;
+ if (-e "$htdocs/$th/$la/$tmpl") {
+ $theme = $th;
+ $lang = $la;
+ last THEME;
+ }
+ last unless $la =~ /[-_]/;
}
}
}
# edit the paths in here
my ($type)=shift;
if ($type eq 'issue') {
- open (FILE,"$path/issues-top.inc") || die;
+ open (FILE,"$path/issues-top.inc") || die "could not find : $path/issues-top.inc";
} elsif ($type eq 'opac') {
- open (FILE,"$path/opac-top.inc") || die;
+ open (FILE,"$path/opac-top.inc") || die "could not find : $path/opac-top.inc";
} elsif ($type eq 'member') {
- open (FILE,"$path/members-top.inc") || die;
+ open (FILE,"$path/members-top.inc") || die "could not find : $path/members-top.inc";
} elsif ($type eq 'acquisitions'){
- open (FILE,"$path/acquisitions-top.inc") || die;
+ open (FILE,"$path/acquisitions-top.inc") || die "could not find : $path/acquisition-top.inc";
} elsif ($type eq 'report'){
- open (FILE,"$path/reports-top.inc") || die;
+ open (FILE,"$path/reports-top.inc") || die "could not find : $path/reports-top.inc";
} elsif ($type eq 'circulation') {
- open (FILE,"$path/circulation-top.inc") || die;
+ open (FILE,"$path/circulation-top.inc") || die "could not find : $path/circulation-top.inc";
+ } elsif ($type eq 'admin') {
+ open (FILE,"$path/parameters-top.inc") || die "could not find : $path/parameters-top.inc";
} else {
- open (FILE,"$path/cat-top.inc") || die;
+ open (FILE,"$path/cat-top.inc") || die "could not find : $path/cat-top.inc";
}
my @string=<FILE>;
close FILE;
# FIXME - It's bad form to die in a CGI script. It's even worse form
# to die without issuing an error message.
if ($type eq 'issue') {
- open (FILE,"$path/issues-bottom.inc") || die;
+ open (FILE,"<$path/issues-bottom.inc") || die;
} elsif ($type eq 'opac') {
- open (FILE,"$path/opac-bottom.inc") || die;
+ open (FILE,"<$path/opac-bottom.inc") || die;
} elsif ($type eq 'member') {
- open (FILE,"$path/members-bottom.inc") || die;
+ open (FILE,"<$path/members-bottom.inc") || die;
} elsif ($type eq 'acquisitions') {
- open (FILE,"$path/acquisitions-bottom.inc") || die;
+ open (FILE,"<$path/acquisitions-bottom.inc") || die;
} elsif ($type eq 'report') {
- open (FILE,"$path/reports-bottom.inc") || die;
+ open (FILE,"<$path/reports-bottom.inc") || die;
} elsif ($type eq 'circulation') {
- open (FILE,"$path/circulation-bottom.inc") || die;
+ open (FILE,"<$path/circulation-bottom.inc") || die;
+ } elsif ($type eq 'admin') {
+ open (FILE,"<$path/parameters-bottom.inc") || die;
} else {
- open (FILE,"$path/cat-bottom.inc") || die;
+ open (FILE,"<$path/cat-bottom.inc") || die;
}
my @string=<FILE>;
close FILE;