- templates are expected to be found in
    INCLUDESDIR/templates/catalogue/searchresults/default.tmpl
 - Works with default Search.pm from cvs
This commit is contained in:
tonnesen 2002-05-13 23:05:45 +00:00
parent 4e4ff04a0e
commit f1afbb56f2
5 changed files with 145 additions and 21 deletions

33
html-template/cmsd.tmpl Normal file
View File

@ -0,0 +1,33 @@
<TMPL_INCLUDE NAME="/usr/share/koha/intranet/htdocs/includes/cat-top.inc">
<center>
<table border=0 cellspacing=0 cellpadding=2>
<tr bgcolor=#ccccff background="/images/background-mem.gif">
<th>Title</th>
<th>Author</th>
<th>Dewey</th></tr>
<TMPL_LOOP NAME=SEARCH_RESULTS>
<tr>
<td><a href=/cgi-bin/koha/detail.pl?type=intra&bib=<TMPL_VAR NAME=biblionumber ESCAPE=HTML>><TMPL_VAR NAME=title></a></td>
<td><a href=/cgi-bin/koha/search.pl?type=intra&author=<TMPL_VAR NAME=author ESCAPE=HTML>><TMPL_VAR NAME=author></a></td>
<td align=right><TMPL_VAR NAME=dewey></td>
</tr>
</TMPL_LOOP>
<tr background="/images/background-mem.gif"><td colspan=3 bgcolor=#ccccff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td align=left>
<a href=newsearch.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="prevstartfrom">>Previous Records</a>
</td><td align=right>
<a href=newsearch.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a>
</td></tr>
</table>
</td></tr>
</table>
<br>
Results <TMPL_VAR NAME="startfrom"> through <TMPL_VAR NAME="endat"> of <TMPL_VAR NAME="numrecords"> records.
<hr>
<TMPL_INCLUDE NAME="/usr/share/koha/intranet/htdocs/includes/cat-bottom.inc">

View File

@ -12,8 +12,18 @@
<td align=right><TMPL_VAR NAME=dewey></td>
</tr>
</TMPL_LOOP>
<tr><td colspan=3 bgcolor=#ccccff><a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a></td></tr>
<tr><td colspan=3 bgcolor=#ccccff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td align=left>
<a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="prevstartfrom">>Previous Records</a>
</td><td align=right>
<a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a>
</td></tr>
</table>
</td></tr>
</table>
<br>
Results <TMPL_VAR NAME="startfrom"> through <TMPL_VAR NAME="endat"> of <TMPL_VAR NAME="numrecords"> records.
<hr>
</body>
</html>

View File

@ -0,0 +1,27 @@
<TMPL_INCLUDE NAME="/usr/share/koha/intranet/htdocs/includes/cat-top.inc">
<center>
<table border=0 cellspacing=0 cellpadding=0>
<tr bgcolor=#ccccff><th>Title</th><th>Author</th><th>Item Count</th><th>Biblionumber</th></tr>
<TMPL_LOOP NAME=SEARCH_RESULTS>
<tr>
<td><a href=/cgi-bin/koha/detail.pl?type=intra&bib=<TMPL_VAR NAME=biblionumber ESCAPE=HTML>><TMPL_VAR NAME=title></a></td>
<td> <TMPL_VAR NAME=author> </td>
<td align=center> <TMPL_VAR NAME=itemcount> </td>
<td> <TMPL_VAR NAME=biblionumber> </td>
</tr>
</TMPL_LOOP>
<tr><td colspan=4 bgcolor=#ccccff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td align=left>
<a href=newsearch.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="prevstartfrom">>Previous Records</a>
</td><td align=right>
<a href=newsearch.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a>
</td></tr>
</table>
</td></tr>
</table>
<br>
Results <TMPL_VAR NAME="startfrom"> through <TMPL_VAR NAME="endat"> of <TMPL_VAR NAME="numrecords"> records.
<hr>
<TMPL_INCLUDE NAME="/usr/share/koha/intranet/htdocs/includes/cat-bottom.inc">

View File

@ -1,4 +1,4 @@
#!/usr/bin/perl -w
#!/usr/bin/perl
use HTML::Template;
use strict;
require Exporter;
@ -8,20 +8,39 @@ use C4::Search;
my $query=new CGI;
# temporary variable for testing. Replace from /etc/koha.conf
my $templatedir="/usr/share/koha/intranet/htdocs/includes/templates";
my $language='french';
my $dbh=&C4Connect;
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;
}
}
my $includes=$configfile{'includes'};
($includes) || ($includes="/usr/local/www/hdl/htdocs/includes");
my $templatebase="$includes/templates/catalogue/searchresults/";
my $templatename=$query->param('template');
my $startfrom=$query->param('startfrom');
($startfrom) || ($startfrom=0);
($templatename) || ($templatename="$templatedir/searchresults.tmpl");
($templatename) || ($templatename='default.tmpl');
$templatename=picktemplate($templatebase);
my $dbh=&C4Connect;
my $template = HTML::Template->new(filename => $templatename, die_on_bad_params => 0);
my $template = HTML::Template->new(filename => "$templatebase$templatename", die_on_bad_params => 0);
##my @results;
#my $sth=$dbh->prepare("select * from biblio where author like 's%' order by author limit $startfrom,20");
@ -30,20 +49,47 @@ my $template = HTML::Template->new(filename => $templatename, die_on_bad_params
# push @results, $data;
#}
my $blah;
my $env;
$env->{itemcount}=1;
my %search;
my $keyword='bear';
my $keyword='tree';
$search{'keyword'}=$keyword;
my ($count, @results) = &KeywordSearch(\$blah, 'intra', \%search, 20, $startfrom);
my $resultshash=\@results;
my ($count, @results) = &KeywordSearch($env, 'intra', \%search, 20, $startfrom);
my $resultsarray=\@results;
$template->param(startfrom => $startfrom);
$startfrom+=20;
$template->param(nextstartfrom => $startfrom);
$template->param(startfrom => $startfrom+1);
$template->param(endat => $startfrom+20);
$template->param(numrecords => $count);
my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20);
my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0);
$template->param(nextstartfrom => $nextstartfrom);
$template->param(prevstartfrom => $prevstartfrom);
$template->param(template => $templatename);
$template->param(SEARCH_RESULTS => $resultshash);
$template->param(SEARCH_RESULTS => $resultsarray);
print "Content-Type: text/html\n\n", $template->output;
sub picktemplate {
my ($base) = @_;
my $templates;
opendir (D, $base);
my @dirlist=readdir D;
foreach (@dirlist) {
(next) unless (/\.tmpl$/);
$templates->{$_}=1;
}
my $sth=$dbh->prepare("select value from systempreferences where variable='template'");
$sth->execute;
my ($preftemplate) = $sth->fetchrow;
$preftemplate.='.tmpl';
if ($templates->{$preftemplate}) {
return $preftemplate;
} else {
return 'default.tmpl';
}
}

View File

@ -1,19 +1,27 @@
<html>
<head><title>Search Results</title>
</head>
<body>
<TMPL_INCLUDE NAME="/usr/share/koha/intranet/htdocs/includes/cat-top.inc">
<TMPL_INCLUDE NAME="searchheader.tmpl">
<table border=0 cellspacing=0 cellpadding=0>
<tr bgcolor=#ccccff><th>Title</th><th>Author</th><th>Biblionumber</th></tr>
<tr bgcolor=#ccccff><th>Title</th><th>Author</th><th>Item Count</th><th>Biblionumber</th></tr>
<TMPL_LOOP NAME=SEARCH_RESULTS>
<tr>
<td> <TMPL_VAR NAME=title> </td>
<td> <TMPL_VAR NAME=author> </td>
<td align=center> <TMPL_VAR NAME=itemcount> </td>
<td> <TMPL_VAR NAME=biblionumber> </td>
</tr>
</TMPL_LOOP>
<tr><td colspan=3 bgcolor=#ccccff><a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a></td></tr>
<tr><td colspan=4 bgcolor=#ccccff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr><td align=left>
<a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="prevstartfrom">>Previous Records</a>
</td><td align=right>
<a href=search.pl?template=<TMPL_VAR NAME="template">&startfrom=<TMPL_VAR NAME="nextstartfrom">>Next Records</a>
</td></tr>
</table>
</td></tr>
</table>
<br>
Results <TMPL_VAR NAME="startfrom"> through <TMPL_VAR NAME="endat"> of <TMPL_VAR NAME="numrecords"> records.
<hr>
</body>
</html>