Changes:
authortonnesen <tonnesen>
Mon, 13 May 2002 23:05:45 +0000 (23:05 +0000)
committertonnesen <tonnesen>
Mon, 13 May 2002 23:05:45 +0000 (23:05 +0000)
 - templates are expected to be found in
    INCLUDESDIR/templates/catalogue/searchresults/default.tmpl
 - Works with default Search.pm from cvs

html-template/cmsd.tmpl [new file with mode: 0644]
html-template/cmsdsearchresults.tmpl
html-template/default.tmpl [new file with mode: 0644]
html-template/search.pl
html-template/searchresults.tmpl

diff --git a/html-template/cmsd.tmpl b/html-template/cmsd.tmpl
new file mode 100644 (file)
index 0000000..f62a202
--- /dev/null
@@ -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">
index 12a19db..62650ba 100644 (file)
   <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>
diff --git a/html-template/default.tmpl b/html-template/default.tmpl
new file mode 100644 (file)
index 0000000..1a9320f
--- /dev/null
@@ -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">
index 6815bd0..406e14c 100755 (executable)
@@ -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';
+    }
+    
+}
index 9ccff83..8a3e3df 100644 (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>