Browse Source

Work in progress

master
chris 25 years ago
parent
commit
063401f94e
  1. 21
      C4/Output.pm
  2. 41
      C4/Search.pm
  3. 12
      addbiblio.pl
  4. 19
      search.pl

21
C4/Output.pm

@ -12,7 +12,7 @@ $VERSION = 0.01;
@ISA = qw(Exporter);
@EXPORT = qw(&startpage &endpage &mktablehdr &mktableft &mktablerow &mklink
&startmenu &endmenu &mkheadr &center &endcenter);
&startmenu &endmenu &mkheadr &center &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="<form action=$action method=post>\n";
$string=$string.mktablehdr();
my $key;
while ( my ($key, $value) = each %inputs) {
$string=$string.mktablerow(2,'white',$key,"<input type=text name=$key value=\"$value\">");
}
$string=$string.mktablerow(2,'white','<input type=submit>','<input type=reset>');
$string=$string.mktableft;
$string=$string."</form>";
}
sub endpage{
my $string="</body></html>\n";
return($string);
@ -126,5 +139,11 @@ sub endcenter {
return ($string);
}
sub bold {
my ($text)=@_;
my $string="<b>$text</b>";
return($string);
}
END { } # module clean-up code here (global destructor)

41
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'))";
}

12
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();

19
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 "<br> 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;
}

Loading…
Cancel
Save