improving Search :

* adding "suggestion", that popup a windows. The popup windows shows, for each word entered in the search form, the 10 words that sounds like the word entered, and that are used most often.
* fixes some minor bugs

Still to do :
* good support of ' and ,
This commit is contained in:
tipaul 2004-04-16 07:28:22 +00:00
parent d12acee214
commit a2f1bf834f
6 changed files with 350 additions and 209 deletions

View File

@ -52,10 +52,28 @@ on what is passed to it, it calls the appropriate search function.
=cut
@ISA = qw(Exporter);
@EXPORT = qw(&catalogsearch &findseealso);
@EXPORT = qw(&catalogsearch &findseealso &findsuggestion);
# make all your functions, whether exported or not;
sub findsuggestion {
my ($dbh,$values) = @_;
my $sth = $dbh->prepare("SELECT count( * ) AS total, word FROM marc_word WHERE sndx_word = soundex( ? ) AND word <> ? GROUP BY word ORDER BY total DESC");
my @results;
for(my $i = 0 ; $i <= $#{$values} ; $i++) {
if (length(@$values[$i]) >=5) {
$sth->execute(@$values[$i],@$values[$i]);
my $resfound = 1;
my @resline;
while ((my ($count,$word) = $sth->fetchrow) and $resfound <=10) {
push @results, "@$values[$i]|$word|$count";
# $results{@$values[$i]} = \@resline;
$resfound++;
}
}
}
return \@results;
}
sub findseealso {
my ($dbh, $fields) = @_;
my $tagslib = MARCgettagslib ($dbh,1);

View File

@ -4,86 +4,72 @@
<!-- TMPL_INCLUDE NAME="cat-top.inc" -->
<!-- /TMPL_IF -->
<div id="mainbloc">
<span style="font-size:2em; text-align:left;">MARC search results</span>
<br>
<center>
<table align=middle border=0 cellpadding=0 cellspacing=0 width="80%">
<tr>
</tr>
<tr><tr height=20></tr>
<td align=middle>
<h1 class="catalogue">MARC search results</h1>
<div id="resultnumber">
<p>
<!-- TMPL_IF NAME=displayprev -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search>
<img src="/intranet-tmpl/default/images/numbers/prev.gif" border=0>
</a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME=numbers -->
<!-- TMPL_IF NAME=highlight -->
<img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->-highlight.gif">
<!-- TMPL_ELSE -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->.gif" border=0></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME=displaynext -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/next.gif" border=0></a>
<!-- /TMPL_IF -->
</p>
<p>
<!-- TMPL_IF name=total -->
&nbsp<b>Results <!-- TMPL_VAR name="from" --> to <!-- TMPL_VAR name="to" --> of <!-- TMPL_VAR name="total" --></b><br><br>
<!-- TMPL_ELSE -->
&nbsp No results found.<br>
<!-- /TMPL_IF -->
</p>
</div>
<div id="resultlist">
<table>
<thead>
<!-- TMPL_IF NAME="opac" -->
<tr>
<!-- TMPL_ELSE -->
<tr>
<!-- /TMPL_IF -->
<th class="catalogue">Biblio #</th>
<th class="catalogue">Author</th>
<th class="catalogue">Title</th>
</tr>
<tbody>
<!-- TMPL_LOOP name="result" -->
<tr>
<td><a href="../MARCdetail.pl?bibid=<!-- TMPL_VAR name="bibid" -->"><!-- TMPL_VAR name="bibid" --></a></td>
<td><!-- TMPL_VAR name="author" --></td>
<td><!-- TMPL_VAR name="title" --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
</div>
<div id="resultnumber">
<p>
<!-- TMPL_IF NAME=displayprev -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/prev.gif" border=0></a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME=numbers -->
<!-- TMPL_IF NAME=highlight -->
<img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->-highlight.gif">
<img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->-highlight.gif">
<!-- TMPL_ELSE -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->.gif" border=0></a>
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->.gif" border=0></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME=displaynext -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/next.gif" border=0></a>
<!-- /TMPL_IF -->
</td>
</tr>
</table>
</center>
<!-- TMPL_IF name=total -->
&nbsp<b>Results <!-- TMPL_VAR name="from" --> to <!-- TMPL_VAR name="to" --> of <!-- TMPL_VAR name="total" --></b><br><br>
<!-- TMPL_ELSE -->
&nbsp No results found.<br>
<!-- /TMPL_IF -->
<center>
<table border=0 cellspacing=0 cellpadding=2 width="90%">
<thead>
<!-- TMPL_IF NAME="opac" -->
<tr bgcolor="#99cccc" background="/images/background-opac.gif">
<!-- TMPL_ELSE -->
<tr bgcolor="#ad11ad">
<!-- /TMPL_IF -->
<th align="left"><span style="color:#FFFFFF;">Biblio #</span></th>
<th align="left"><span style="color:#FFFFFF;">Author</span></th>
<th align="left"><span style="color:#FFFFFF;">Title</span></th>
</tr>
<tbody>
<!-- TMPL_LOOP name="result" -->
<tr>
<td><a href="../MARCdetail.pl?bibid=<!-- TMPL_VAR name="bibid" -->"><!-- TMPL_VAR name="bibid" --></a></td>
<td><!-- TMPL_VAR name="author" --></td>
<td><!-- TMPL_VAR name="title" --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<table align=middle border=0 cellpadding=0 cellspacing=0 width="80%">
<tr>
</tr>
<tr><tr height=20></tr>
<td align=middle>
<!-- TMPL_IF NAME=displayprev -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromprev" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/prev.gif" border=0></a>
<!-- /TMPL_IF -->
<!-- TMPL_LOOP NAME=numbers -->
<!-- TMPL_IF NAME=highlight -->
<img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->-highlight.gif">
<!-- TMPL_ELSE -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME=startfrom -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/<!-- TMPL_VAR NAME=number -->.gif" border=0></a>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
<!-- TMPL_IF NAME=displaynext -->
<a href=search.pl?startfrom=<!-- TMPL_VAR NAME="startfromnext" -->&<!-- TMPL_LOOP NAME=searchdata --><!-- TMPL_VAR NAME="term" -->=<!-- TMPL_VAR name="val" ESCAPE=URL -->&<!-- /TMPL_LOOP -->&resultsperpage=<!-- TMPL_VAR NAME="resultsperpage" -->&type=intranet&op=do_search><img src="/intranet-tmpl/default/images/numbers/next.gif" border=0></a>
<!-- /TMPL_IF -->
</td>
</tr>
</table>
</center>
</p>
</div>
</div>
<!-- TMPL_IF NAME="opac" -->
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->

View File

@ -5,118 +5,93 @@
<!-- /TMPL_IF -->
<div id="mainbloc">
<h1>Catalogue search</h1>
<h1 class="catalogue">Catalogue search</h1>
<form name="f" method="post">
<input type="hidden" name="op" value="do_search">
<input type="hidden" name="type" value="intranet">
<input type="hidden" name="nbstatements" value="<!-- TMPL_VAR NAME="nbstatements" -->">
<table class="noborder">
<tr>
<th colspan=4>
Quick search
</th>
</tr>
<tr>
<td>
Keyword <input type="hidden" name="marclist" value="">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</td>
<td>
Illustrator<input type="hidden" name="marclist" value="biblioitems.illus">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</td>
</tr>
<tr>
<td>
Title <input type="hidden" name="marclist" value="biblio.title">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</td>
<td>
Dewey<input type="hidden" name="marclist" value="biblioitems.dewey">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</td>
</tr>
<tr>
<td>
author <input type="hidden" name="marclist" value="biblio.author">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</td>
<td>
Item Type <input type="hidden" name="marclist" value="items.itemtype">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
</td>
<td>
<input type="hidden" name="operator" value="=">
<input type="text" name="value" onchange="sql_update()">
</td>
</tr>
<tr>
<td>
barcode
</td>
<td>
<div id="bloc25">
<h2 class="catalogue">Search on</h2>
<p>
<label class="label20">Keyword</label>
<input type="hidden" name="marclist" value="">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</p>
<p>
<label class="label20">Title</label>
<input type="hidden" name="marclist" value="biblio.title">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</p>
<p>
<label class="label20">author</label> <input type="hidden" name="marclist" value="biblio.author">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</p>
<p>
<label class="label20">barcode</label>
<input type="hidden" name="marclist" value="items.barcode">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value">
</td>
</tr>
</table>
<input type="text" name="value" onchange="sql_update()">
</p>
</div>
<div id="bloc25">
<h2 class="catalogue">Search on</h2>
<p>
<label class="label20">Illustrator</label>
<input type="hidden" name="marclist" value="biblioitems.illus">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</p>
<p>
<label class="label20">Dewey</label><input type="hidden" name="marclist" value="biblioitems.dewey">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="contains">
<input type="text" name="value" onchange="sql_update()">
</p>
<p>
<label class="label20">Item Type</label> <input type="hidden" name="marclist" value="biblioitems.itemtype">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="=">
<!-- TMPL_VAR name="CGIitemtype" -->
</p>
<p>
<label class="label20">branch</label>
<input type="hidden" name="marclist" value="items.holdingbranch">
<input type="hidden" name="and_or" value="and">
<input type="hidden" name="excluding" value="">
<input type="hidden" name="operator" value="=">
<!-- TMPL_VAR name="CGIbranch" -->
</p>
<table class="noborder">
<tr>
<th colspan=5>
Complete (MARC) search
</th>
</tr>
</div>
<div id="bloc25">
<h2 class="catalogue">More fields</h2>
<!-- TMPL_LOOP NAME="statements" -->
<tr>
<td>
<!-- TMPL_IF NAME="first" -->
<input type="hidden" name="and_or" value="">&nbsp;
<!-- TMPL_ELSE -->
<select name="and_or" size="1" onchange="sql_update()">
<option value="and">and</option>
<option <!-- TMPL_IF NAME="or" -->selected <!-- /TMPL_IF -->value="or">or</option>
</select>
<!-- /TMPL_IF -->
</td>
<td><!-- TMPL_VAR name="marclist" --></td>
<td>
<p>
<select name="and_or" size="1" onchange="sql_update()">
<option value="and">and</option>
<option <!-- TMPL_IF NAME="or" -->selected <!-- /TMPL_IF -->value="or">or</option>
</select>
<!-- TMPL_VAR name="marclist" -->
<select name="excluding" size="1" onchange="sql_update()">
<option value="0"> </option>
<option <!-- TMPL_IF NAME="not" -->selected <!-- /TMPL_IF -->value="1">not</option>
</select>
</td>
<td>
<select name="operator" size="1" onchange="sql_update()">
<option <!-- TMPL_IF NAME="contains" -->selected<!-- /TMPL_IF --> value="contains">Contains</option>
<option <!-- TMPL_IF NAME="eq" -->selected<!-- /TMPL_IF --> value="=">Is equal to</option>
@ -126,54 +101,46 @@
<option <!-- TMPL_IF NAME="lt" -->selected<!-- /TMPL_IF --> value="<">Is lower than</option>
<option <!-- TMPL_IF NAME="le" -->selected<!-- /TMPL_IF --> value="<=">Is lower or equal to</option>
</select>
</td>
<td>
<input type="text" name="value" onChange="sql_update()" <!-- TMPL_IF NAME="value" -->value="<!-- TMPL_VAR NAME="value" -->"<!-- /TMPL_IF -->>
</td>
</tr>
</p>
<!-- /TMPL_LOOP -->
<tr>
<td align="left" colspan=2><input type="button" value="Add criteria" onClick="AddStatement()" class="button"></td>
<td colspan=3>Warning : the "contains" statement does NOT work if you enter 2 or less letters</td>
</tr>
<tr align="center">
<td colspan="5">
<div name="sql">
<p>
<input type="button catalogue" value="Add criteria" onClick="AddStatement()" class="button catalogue">
Warning : the "contains" statement does NOT work if you enter 2 or less letters
</div>
<div id="bloc25">
<p>
<div name="sql">
<textarea name="sql" rows=3 cols=70 disabled readonly></textarea>
</div>
</td>
</tr>
</table>
<br>
<table class="noborder">
<tr>
<td align="right">Results per page :
<select align="right" name="resultsperpage" size="1">
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</td>
<td>Ordered by
<select name="orderby" size="1">
<option value="biblio.title">Title</option>
<option value="biblio.author">Author</option>
<option value="biblioitems.dewey">Dewey</option>
<option value="biblioitems.publicationyear">Publication Year</option>
<option value="biblioitems.publishercode">Publisher</option>
</select>
<td align="middle"><input type="submit" value="Start search" class="button"></td>
</tr>
</table>
</div>
</p>
<p>Results per page :
<select align="right" name="resultsperpage" size="1">
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
Ordered by
<select name="orderby" size="1">
<option value="biblio.title">Title</option>
<option value="biblio.author">Author</option>
<option value="biblioitems.dewey">Dewey</option>
<option value="biblioitems.publicationyear">Publication Year</option>
<option value="biblioitems.publishercode">Publisher</option>
</select>
</p>
<p>
<input type="submit" value="Start search" class="button catalogue">
<a href="javascript:PopupSuggestion()" class="button catalogue">Suggestions</a>
</p>
</div>
</form>
<script>
function sql_update() {
document.f.sql.value="";
for (i=0 ; i<document.f.marclist.length ; i++) {
if (document.f.marclist[i].value != '') {
if (document.f.value[i].value.length>0) {
document.f.sql.value = document.f.sql.value+
document.f.and_or[i].value + ' (' +
document.f.excluding[i].value + ' ' +
@ -190,6 +157,16 @@ function AddStatement() {
document.f.submit();
}
function PopupSuggestion() {
var strQuery="";
for (i=0 ; i<document.f.marclist.length ; i++) {
if (document.f.value[i].value.length>0) {
strQuery += " "+document.f.value[i].value;
}
}
newin=window.open("suggest.pl?Q="+strQuery,"Suggestions",'width=500,height=400,toolbar=false,scrollbars=yes');
}
</script>
</div>
<!-- TMPL_IF NAME="opac" -->

View File

@ -0,0 +1,58 @@
<!-- TMPL_IF NAME="opac" -->
<!-- TMPL_INCLUDE NAME="opac-top.inc" -->
<!-- TMPL_ELSE -->
<!-- TMPL_INCLUDE NAME="cat-top.inc" -->
<!-- /TMPL_IF -->
<div id="mainbloc">
<h1 class="catalogue">Catalogue search</h1>
<div id="bloc25">
<table>
<tr>
<th class="catalogue">
Initial word
</th>
<th class="catalogue">
Suggested
</th>
<th class="catalogue">
Used X times
</th>
</tr>
<!-- TMPL_LOOP name="loop" -->
<tr>
<td>
<!-- TMPL_VAR name="word" -->
</td>
<td>
<a href="javascript:Import('<!-- TMPL_VAR name="word" -->','<!-- TMPL_VAR name="suggestion" -->')">
<!-- TMPL_VAR name="suggestion" -->
</a>
</td>
<td>
<!-- TMPL_VAR name="count" -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
</div>
</div>
<script>
function Import(Replaced,ReplaceBy) {
for (i=0 ; i<opener.document.f.value.length ; i++) {
opener.document.forms[0].value[i].value = opener.document.forms[0].value[i].value.replace(Replaced,ReplaceBy);
// if (document.forms[0].kohafield[i].value == "biblioitems.isbn" && document.forms[0].field_value[i].value.length>0) {
// strQuery += "&isbn="+document.forms[0].field_value[i].value;
// }
// opener.document.location= "../acqui.simple/addbiblio.pl?z3950=1&oldbiblionumber=<!-- TMPL_VAR name="oldbiblionumber" -->&breedingid="+GetThisOne;
// self.close();
// return false;
}
}
</script>
<!-- TMPL_IF NAME="opac" -->
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
<!-- TMPL_ELSE -->
<!-- TMPL_INCLUDE NAME="cat-bottom.inc" -->
<!-- /TMPL_IF -->

View File

@ -30,6 +30,7 @@ use C4::Output;
use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::SearchMarc;
use C4::Catalogue;
use C4::Koha; # XXX subfield_is_koha_internal_p
# Creates the list of active tags using the active MARC configuration
@ -182,7 +183,6 @@ if ($op eq "do_search") {
} else {
$to = (($startfrom+1)*$resultsperpage);
}
$template->param(result => $results,
startfrom=> $startfrom,
displaynext=> $displaynext,
@ -194,7 +194,7 @@ if ($op eq "do_search") {
total=>$total,
from=>$from,
to=>$to,
numbers=>\@numbers
numbers=>\@numbers,
);
} elsif ($op eq "AddStatement") {
@ -297,8 +297,47 @@ else {
push @statements, { "marclist" => $marclist, "first" => 1 };
push @statements, { "marclist" => $marclist, "first" => 0 };
push @statements, { "marclist" => $marclist, "first" => 0 };
my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
$sth->execute;
my @itemtype;
my %itemtypes;
push @itemtype, "";
$itemtypes{''} = "";
while (my ($value,$lib) = $sth->fetchrow_array) {
push @itemtype, $value;
$itemtypes{$value}=$lib;
}
$template->param("statements" => \@statements, "nbstatements" => 3);
my $CGIitemtype=CGI::scrolling_list( -name => 'value',
-values => \@itemtype,
-labels => \%itemtypes,
-size => 1,
-multiple => 0 );
$sth->finish;
my @branches;
my @select_branch;
my %select_branches;
my ($count2,@branches)=branches();
push @select_branch, "";
$select_branches{''} = "";
for (my $i=0;$i<$count2;$i++){
push @select_branch, $branches[$i]->{'branchcode'};#
$select_branches{$branches[$i]->{'branchcode'}} = $branches[$i]->{'branchname'};
}
my $CGIbranch=CGI::scrolling_list( -name => 'value',
-values => \@select_branch,
-labels => \%select_branches,
-size => 1,
-multiple => 0 );
$sth->finish;
$template->param("statements" => \@statements,
"nbstatements" => 3,
CGIitemtype => $CGIitemtype,
CGIbranch => $CGIbranch,
);
}

63
search.marc/suggest.pl Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/perl
# WARNING: 4-character tab stops here
# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307 USA
use strict;
require Exporter;
use CGI;
use C4::Auth;
use HTML::Template;
use C4::Context;
use C4::Search;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::SearchMarc;
use C4::Catalogue;
use C4::Koha; # XXX subfield_is_koha_internal_p
# Creates the list of active tags using the active MARC configuration
my $query=new CGI;
my $Q=$query->param('Q');
my @words = split / /,$Q;
my $dbh = C4::Context->dbh;
my $suggestions = findsuggestion($dbh,\@words);
my @loop_suggests;
foreach my $line (@$suggestions) {
my ($word,$suggestion,$count) = split /\|/,$line;
push @loop_suggests, { word => $word, suggestion =>$suggestion, count => $count };
}
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "search.marc/suggest.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => {editcatalogue => 1},
debug => 1,
});
$template->param("loop" => \@loop_suggests);
output_html_with_http_headers $query, $cookie, $template->output;
1;
# Local Variables:
# tab-width: 4
# End: