Shifted picktemplate out into C4::Output.pm
This commit is contained in:
parent
f490f252c2
commit
1e647ae716
37
C4/Output.pm
37
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("<html>\n");
|
||||
}
|
||||
|
|
@ -389,6 +419,9 @@ sub bold {
|
|||
return($string);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
END { } # module clean-up code here (global destructor)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue