From 1e647ae7163a0c8e85ebb1ff3e3ebb1afc3b024f Mon Sep 17 00:00:00 2001 From: rangi Date: Tue, 14 May 2002 23:13:23 +0000 Subject: [PATCH] Shifted picktemplate out into C4::Output.pm --- C4/Output.pm | 37 +++++++++++++++++++++++++++++++++++-- html-template/search.pl | 32 +++++++------------------------- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index ad20d2586f..a5393de007 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -5,6 +5,8 @@ package C4::Output; #asummes C4/Output #set the value of path to be where your html lives use strict; +use warnings; +use C4::Database; require Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @@ -15,7 +17,7 @@ $VERSION = 0.01; @ISA = qw(Exporter); @EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink &startmenu &endmenu &mkheadr ¢er &endcenter &mkform &mkform2 &bold -&gotopage &mkformnotable &mkform3); +&gotopage &mkformnotable &mkform3 picktemplate); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -70,7 +72,35 @@ my $priv_func = sub { }; # make all your functions, whether exported or not; - + +sub picktemplate { + my ($includes, $base) = @_; + my $dbh=C4Connect; + my $templates; + 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'; + } + +} + + + sub startpage{ return("\n"); } @@ -389,6 +419,9 @@ sub bold { return($string); } + + + END { } # module clean-up code here (global destructor) diff --git a/html-template/search.pl b/html-template/search.pl index 19187756a9..1cc1494a46 100755 --- a/html-template/search.pl +++ b/html-template/search.pl @@ -5,12 +5,13 @@ require Exporter; use C4::Database; use CGI; use C4::Search; - +use C4::Output; # no contains picktemplate + my $query=new CGI; my $language='french'; -my $dbh=&C4Connect; + my %configfile; open (KC, "/etc/koha.conf"); @@ -37,6 +38,9 @@ my $startfrom=$query->param('startfrom'); ($startfrom) || ($startfrom=0); my $theme=picktemplate($includes, $templatebase); +my $subject=$query->param('subject'); +# if its a subject we need to use the subject.tmpl +$templatebase=~ s/searchresults\.tmpl/subject\.tmpl/; my $template = HTML::Template->new(filename => "$includes/templates/$theme/$templatebase", die_on_bad_params => 0, path => [$includes]); @@ -48,7 +52,7 @@ $env->{itemcount}=1; my %search; my $keyword=$query->param('keyword'); $search{'keyword'}=$keyword; -my $subject=$query->param('subject'); + $search{'subject'}=$subject; my $author=$query->param('author'); $search{'author'}=$author; @@ -115,25 +119,3 @@ $template->param(includesdir => $includes); print "Content-Type: text/html\n\n", $template->output; - -sub picktemplate { - my ($includes, $base) = @_; - my $templates; - 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; - if ($templates->{$preftemplate}) { - return $preftemplate; - } else { - return 'default'; - } - -} -- 2.39.5