From f1afbb56f29780bcd3a7e5bb96db0cf2af6a514d Mon Sep 17 00:00:00 2001 From: tonnesen Date: Mon, 13 May 2002 23:05:45 +0000 Subject: [PATCH] Changes: - templates are expected to be found in INCLUDESDIR/templates/catalogue/searchresults/default.tmpl - Works with default Search.pm from cvs --- html-template/cmsd.tmpl | 33 +++++++++++++ html-template/cmsdsearchresults.tmpl | 12 ++++- html-template/default.tmpl | 27 ++++++++++ html-template/search.pl | 74 ++++++++++++++++++++++------ html-template/searchresults.tmpl | 20 +++++--- 5 files changed, 145 insertions(+), 21 deletions(-) create mode 100644 html-template/cmsd.tmpl create mode 100644 html-template/default.tmpl diff --git a/html-template/cmsd.tmpl b/html-template/cmsd.tmpl new file mode 100644 index 0000000000..f62a2027e4 --- /dev/null +++ b/html-template/cmsd.tmpl @@ -0,0 +1,33 @@ + + + +
+ + + + + + + + + + + + + + + + +
TitleAuthorDewey
>>
+ + +
+ &startfrom=>Previous Records + + &startfrom=>Next Records +
+
+
+Results through of records. +
+ diff --git a/html-template/cmsdsearchresults.tmpl b/html-template/cmsdsearchresults.tmpl index 12a19db370..62650ba124 100644 --- a/html-template/cmsdsearchresults.tmpl +++ b/html-template/cmsdsearchresults.tmpl @@ -12,8 +12,18 @@ -&startfrom=>Next Records + + + +
+ &startfrom=>Previous Records + + &startfrom=>Next Records +
+ +
+Results through of records.
diff --git a/html-template/default.tmpl b/html-template/default.tmpl new file mode 100644 index 0000000000..1a9320ffd7 --- /dev/null +++ b/html-template/default.tmpl @@ -0,0 +1,27 @@ + +
+ + + + + + + + + + + + +
TitleAuthorItem CountBiblionumber
>
+ + +
+ &startfrom=>Previous Records + + &startfrom=>Next Records +
+
+
+Results through of records. +
+ diff --git a/html-template/search.pl b/html-template/search.pl index 6815bd0b5f..406e14c981 100755 --- a/html-template/search.pl +++ b/html-template/search.pl @@ -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 () { + 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'; + } + +} diff --git a/html-template/searchresults.tmpl b/html-template/searchresults.tmpl index 9ccff83804..8a3e3dfecd 100644 --- a/html-template/searchresults.tmpl +++ b/html-template/searchresults.tmpl @@ -1,19 +1,27 @@ - -Search Results - - + - + + - +
TitleAuthorBiblionumber
TitleAuthorItem CountBiblionumber
&startfrom=>Next Records
+ + +
+ &startfrom=>Previous Records + + &startfrom=>Next Records +
+
+
+Results through of records.
-- 2.39.5