[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Database.pm,1.7,1.8 Output.pm,1.18,1.19
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/C4 Database.pm,1.7,1.8 Output.pm,1.18,1.19 |
Date: |
Wed, 02 Oct 2002 09:26:17 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv8958
Modified Files:
Database.pm Output.pm
Log Message:
templating modifications to rspect finlay structure
Index: Database.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Database.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** Database.pm 20 Sep 2002 12:49:47 -0000 1.7
--- Database.pm 2 Oct 2002 16:26:14 -0000 1.8
***************
*** 30,36 ****
@ISA = qw(Exporter);
@EXPORT = qw(
! &C4Connect &requireDBI
);
sub C4Connect {
--- 30,55 ----
@ISA = qw(Exporter);
@EXPORT = qw(
! &C4Connect &requireDBI &configfile
);
+ sub configfile {
+ my $configfile;
+ open (KC, "/etc/koha.conf");
+ while (<KC>) {
+ chomp;
+ (next) if (/^\s*#/);
+ if (/(.*)\s*=\s*(.*)/) {
+ my $variable=$1;
+ my $value=$2;
+ # Clean up white space at beginning and end
+ $variable=~s/^\s*//g;
+ $variable=~s/\s*$//g;
+ $value=~s/^\s*//g;
+ $value=~s/\s*$//g;
+ $configfile->{$variable}=$value;
+ }
+ }
+ return $configfile;
+ }
sub C4Connect {
Index: Output.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Output.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -r1.18 -r1.19
*** Output.pm 22 Sep 2002 04:04:22 -0000 1.18
--- Output.pm 2 Oct 2002 16:26:15 -0000 1.19
***************
*** 65,69 ****
&getkeytableselectoptions
&pathtotemplate
! &picktemplate);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
--- 65,70 ----
&getkeytableselectoptions
&pathtotemplate
! &themelanguage &gettemplate
! );
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
***************
*** 98,171 ****
# into a separate file. Better yet, put "use C4::Config;" inside the
# &import method of any package that requires the config file.
- my %configfile;
- open (KC, "/etc/koha.conf");
- while (<KC>) {
- chomp;
- (next) if (/^\s*#/);
- if (/(.*)\s*=\s*(.*)/) {
- my $variable=$1;
- my $value=$2;
-
- $variable =~ s/^\s*//g;
- $variable =~ s/\s*$//g;
- $value =~ s/^\s*//g;
- $value =~ s/\s*$//g;
- $configfile{$variable}=$value;
- } # if
- } # while
- close(KC);
! my $path=$configfile{'includes'};
! ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
! # make all your functions, whether exported or not;
! =item picktemplate
! $template = &picktemplate($includes, $base);
! Returns the preferred template for a given page. C<$base> is the
! basename of the script that will generate the page (with the C<.pl>
! extension stripped off), and C<$includes> is the directory in which
! HTML include files are located.
!
! The preferred template is given by the C<template> entry in the
! C<systempreferences> table in the Koha database. If
! C<$includes>F</templates/preferred-template/>C<$base.tmpl> exists,
! C<&picktemplate> returns the preferred template; otherwise, it returns
! the string C<default>.
! =cut
! #'
! sub picktemplate {
! my ($includes, $base) = @_;
my $dbh=C4Connect;
! my $templates;
! # FIXME - Instead of generating the list of possible templates, and
! # then querying the database to see if, by chance, one of them has
! # been selected, wouldn't it be better to query the database first,
! # and then see whether the selected template file exists?
! opendir (D, "$includes/templates");
! my @dirlist=readdir D;
! foreach (@dirlist) {
! (next) if (/^\./);
! #(next) unless (/\.tmpl$/);
! (next) unless (-e "$includes/templates/$_/$base");
! $templates->{$_}=1;
! }
! my $sth=$dbh->prepare("select value from systempreferences where
! variable='template'");
$sth->execute;
! my ($preftemplate) = $sth->fetchrow;
$sth->finish;
$dbh->disconnect;
! if ($templates->{$preftemplate}) {
! return $preftemplate;
} else {
! return 'default';
}
-
}
=item pathtotemplate
--- 99,173 ----
# into a separate file. Better yet, put "use C4::Config;" inside the
# &import method of any package that requires the config file.
! my $configfile=configfile();
! my $path=$configfile->{'includes'};
! ($path) || ($path="/usr/local/www/hdl/htdocs/includes");
!
#---------------------------------------------------------------------------------------------------------
! sub gettemplate {
! my ($tmplbase, $opac) = @_;
!
! my $htdocs;
! if ($opac) {
! $htdocs = $configfile->{'opachtdocs'};
! } else {
! $htdocs = $configfile->{'intrahtdocs'};
! }
!
! my ($theme, $lang) = themelanguage($htdocs, $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");
! return $template;
! }
!
#---------------------------------------------------------------------------------------------------------
! 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;
!
! # 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;
+
$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');
}
}
+
=item pathtotemplate
***************
*** 257,261 ****
#where to search for templates
my @tmpldirs = ("$path/templates", $path);
! unshift (@tmpldirs, $configfile{'templatedirectory'}) if
$configfile{'templatedirectory'};
unshift (@tmpldirs, $params{'path'}) if $params{'path'};
--- 259,263 ----
#where to search for templates
my @tmpldirs = ("$path/templates", $path);
! unshift (@tmpldirs, $configfile->{'templatedirectory'}) if
$configfile->{'templatedirectory'};
unshift (@tmpldirs, $params{'path'}) if $params{'path'};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Database.pm,1.7,1.8 Output.pm,1.18,1.19,
Paul POULAIN <=