[Koha-cvs] CVS: koha/C4 Output.pm,1.48,1.49
Chris Cormack
rangi at users.sourceforge.net
Fri Jul 16 02:36:59 CEST 2004
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31150
Modified Files:
Output.pm
Log Message:
Code to set a cookie which stores which language is displayed to the user
Index: Output.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Output.pm,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -r1.48 -r1.49
*** Output.pm 3 Jun 2004 10:02:08 -0000 1.48
--- Output.pm 16 Jul 2004 00:36:56 -0000 1.49
***************
*** 52,56 ****
@ISA = qw(Exporter);
@EXPORT = qw(
! &themelanguage &gettemplate
);
--- 52,56 ----
@ISA = qw(Exporter);
@EXPORT = qw(
! &themelanguage &gettemplate setlanguagecookie
);
***************
*** 62,67 ****
# FIXME - POD
sub gettemplate {
! my ($tmplbase, $opac) = @_;
!
my $htdocs;
if ($opac ne "intranet") {
--- 62,69 ----
# FIXME - POD
sub gettemplate {
! my ($tmplbase, $opac, $query) = @_;
! if (!$query){
! warn "no query in gettemplate";
! }
my $htdocs;
if ($opac ne "intranet") {
***************
*** 71,75 ****
}
! my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $opac);
my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$tmplbase",
--- 73,77 ----
}
! my ($theme, $lang) = themelanguage($htdocs, $tmplbase, $opac, $query);
my $template = HTML::Template->new(filename => "$htdocs/$theme/$lang/$tmplbase",
***************
*** 79,86 ****
--- 81,91 ----
# XXX temporary patch for Bug 182 for themelang
+ warn "theme is $theme lang is $lang";
$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;
}
***************
*** 89,94 ****
# FIXME - POD
sub themelanguage {
! my ($htdocs, $tmpl, $section) = @_;
!
my $dbh = C4::Context->dbh;
my @languages;
--- 94,102 ----
# FIXME - POD
sub themelanguage {
! my ($htdocs, $tmpl, $section, $query) = @_;
! if (!$query) {
! warn "no query";
!
! }
my $dbh = C4::Context->dbh;
my @languages;
***************
*** 101,106 ****
--- 109,125 ----
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){
+
+ push @languages,$lang;
+ @themes = split " ", C4::Context->preference("opacthemes");
+ }
+ else {
@languages = split " ", C4::Context->preference("opaclanguages");
@themes = split " ", C4::Context->preference("opacthemes");
+ }
}
***************
*** 129,132 ****
--- 148,160 ----
}
+ sub setlanguagecookie {
+ my ($query,$language,$uri)=@_;
+ my $cookie=$query->cookie(-name => 'KohaOpacLanguage',
+ -value => $language,
+ -expires => '');
+ print $query->redirect(-uri=>$uri,
+ -cookie=>$cookie);
+ }
+
END { } # module clean-up code here (global destructor)
More information about the Koha-cvs
mailing list