From 063401f94e3f5ad380085d0062261474189fef0d Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 9 Nov 1999 22:41:41 +0000 Subject: [PATCH] Work in progress --- C4/Output.pm | 21 ++++++++++++++++++++- C4/Search.pm | 41 +++++++++++++++++++++++++++++++++++++++-- addbiblio.pl | 12 ++++++++++-- search.pl | 19 +++++++++++++++++-- 4 files changed, 86 insertions(+), 7 deletions(-) diff --git a/C4/Output.pm b/C4/Output.pm index dad6e50..0f5254e 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -12,7 +12,7 @@ $VERSION = 0.01; @ISA = qw(Exporter); @EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink -&startmenu &endmenu &mkheadr ¢er &endcenter); +&startmenu &endmenu &mkheadr ¢er &endcenter &mkform &bold); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -94,6 +94,19 @@ sub mktableft { return($string); } +sub mkform{ + my ($action,%inputs)=@_; + my $string="
\n"; + $string=$string.mktablehdr(); + my $key; + while ( my ($key, $value) = each %inputs) { + $string=$string.mktablerow(2,'white',$key,""); + } + $string=$string.mktablerow(2,'white','',''); + $string=$string.mktableft; + $string=$string."
"; +} + sub endpage{ my $string="\n"; return($string); @@ -126,5 +139,11 @@ sub endcenter { return ($string); } +sub bold { + my ($text)=@_; + my $string="$text"; + return($string); +} + END { } # module clean-up code here (global destructor) diff --git a/C4/Search.pm b/C4/Search.pm index fe85659..03a258b 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -14,7 +14,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 0.01; @ISA = qw(Exporter); -@EXPORT = qw(&CatSearch &BornameSearch &ItemInfo); +@EXPORT = qw(&CatSearch &BornameSearch &ItemInfo &KeywordSearch); %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], # your exported package globals go here, @@ -50,6 +50,40 @@ my $priv_func = sub { # make all your functions, whether exported or not; +sub KeywordSearch { + my ($env,$type,$search,$num,$offset)=@_; + my $dbh = &C4Connect; + my $query="Select * from biblio,catalogueentry + where (catalogueentry.catalogueentry=biblio.author and + catalogueentry.entrytype='a' and catalogueentry.catalogueentry like + '$search->{'keyword'}%') union select * from biblio,catalogueentry where + (catalogueentry.catalogueentry=biblio.title and + catalogueentry.entrytype='t' and catalogueentry.catalogueentry like + '%$search->{'keyword'}%') order by biblio.title"; + my $sth=$dbh->prepare($query); +# print $query; + $sth->execute; + my $i=0; + my $count=0; + my @results; + while (my $data=$sth->fetchrow_hashref){ + $count++; + } + $sth->finish; + $query=$query." limit $num,$offset"; + $sth=$dbh->prepare($query); + $sth->execute; +# print $query; + while (my $data=$sth->fetchrow_hashref){ + $results[$i]="$data->{'biblionumber'}\t$data->{'title'}\t + $data->{'author'}"; + $i++; + } + $sth->finish; + $dbh->disconnect; + return($count,@results); +} + sub CatSearch { my ($env,$type,$search,$num,$offset)=@_; my $dbh = &C4Connect; @@ -61,7 +95,10 @@ sub CatSearch { and (catalogueentry.catalogueentry like '$search->{'author'}%') and (entrytype = 'a'))"; if ($search->{'title'} ne ''){ - $query=$query."((catalogueentry.catalogueentry = biblio.title) + $query= "Select biblionumber from biblio,catalogueentry where ((catalogueentry.catalogueentry = biblio.author) + and (catalogueentry.catalogueentry like '$search->{'author'}%') + and (entrytype = 'a')) intersect select biblionumber from + biblio,catalogueentry where ((catalogueentry.catalogueentry = biblio.title) and (catalogueentry.catalogueentry like '%$search->{'title'}%') and (entrytype = 't'))"; } diff --git a/addbiblio.pl b/addbiblio.pl index 71dc994..e4e738a 100755 --- a/addbiblio.pl +++ b/addbiblio.pl @@ -12,7 +12,15 @@ my $input = new CGI; print $input->header; print startpage(); print startmenu(); -print mktablehdr(); -print mktableft(); +my %inputs; + +$inputs{'Title'}=''; +$inputs{'Unititle'}=''; +$inputs{'Notes'}=''; +$inputs{'Author'}=''; +$inputs{'Series Title'}=''; +print mkform('wah',%inputs); +#print mktablehdr(); +#print mktableft(); print endmenu(); print endpage(); diff --git a/search.pl b/search.pl index 92df301..c26331f 100755 --- a/search.pl +++ b/search.pl @@ -47,10 +47,20 @@ if ($itemnumber ne '' || $isbn ne ''){ if ($subject ne ''){ ($count,@results)=&CatSearch(\$blah,'subject',\%search,$num,$offset); } else { - ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset); + if ($keyword ne ''){ + ($count,@results)=&KeywordSearch(\$blah,'intra',\%search,$num,$offset); + } else { + ($count,@results)=&CatSearch(\$blah,'loose',\%search,$num,$offset); + } } } -print "You searched on $title $author $keyword $subject $itemnumber $isbn, $count results found"; +print "You searched on "; +while ( my ($key, $value) = each %search) { + if ($value ne ''){ + print bold("$key $value,"); + } +} +print " $count results found"; my $offset2=$num+$offset; print "
Results $offset to $offset2 displayed"; print mktablehdr; @@ -103,6 +113,11 @@ if ($offset < $count){ $author=~ s/ /%20/g; $search=$search."&author=$author"; } + if ($keyword ne ''){ + $keyword=~ s/ /%20/g; + $search=$search."&keyword=$keyword"; + } + my $stuff=mklink("/cgi-bin/kumara/search.pl?$search",'More'); print $stuff; }