[Koha-cvs] koha/z3950 search.pl [dev_week]
Joshua Ferraro
jmf at kados.org
Fri Nov 3 03:39:36 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Joshua Ferraro <kados> 06/11/03 02:39:36
Modified files:
z3950 : search.pl
Log message:
just cleaning up the tabs, no changes
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/z3950/search.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.3.2.6.2.1&r2=1.3.2.6.2.2
Patches:
Index: search.pl
===================================================================
RCS file: /sources/koha/koha/z3950/search.pl,v
retrieving revision 1.3.2.6.2.1
retrieving revision 1.3.2.6.2.2
diff -u -b -r1.3.2.6.2.1 -r1.3.2.6.2.2
--- search.pl 3 Nov 2006 00:29:49 -0000 1.3.2.6.2.1
+++ search.pl 3 Nov 2006 02:39:36 -0000 1.3.2.6.2.2
@@ -62,10 +62,9 @@
my @breeding_loop = ();
unless ($random) { # this var is not useful anymore just kept to keep rel2_2 compatibility
-$random =rand(1000000000);
+ $random =rand(1000000000);
}
-
my ($template, $loggedinuser, $cookie)= get_template_and_user({template_name => "z3950/searchresult.tmpl",
query => $input,
type => "intranet",
@@ -74,35 +73,32 @@
debug => 1,
});
- $template->param( intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+$template->param( intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
intranetstylesheet => C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"));
if ($op ne "do_search"){
-
-my $sth=$dbh->prepare("select id,host,checked from z3950servers order by host");
-$sth->execute();
-while ($server=$sth->fetchrow_hashref) {
-my %temploop;
-$temploop{server}=$server->{host};
-$temploop{id}=$server->{id};
-$temploop{checked}=$server->{checked};
-push (@serverloop, \%temploop);
-}
-
-$template->param(isbn=>$isbn, issn=>$issn,title=>$title,author=>$author,
+ my $sth=$dbh->prepare("select id,host,checked from z3950servers order by host");
+ $sth->execute();
+ while ($server=$sth->fetchrow_hashref) {
+ my %temploop;
+ $temploop{server}=$server->{host};
+ $temploop{id}=$server->{id};
+ $temploop{checked}=$server->{checked};
+ push (@serverloop, \%temploop);
+ }
+ $template->param(isbn=>$isbn, issn=>$issn,title=>$title,author=>$author,
serverloop => \@serverloop,
opsearch => "search",
oldbiblionumber => $oldbiblionumber,
);
-output_html_with_http_headers $input, $cookie, $template->output;
-
+ output_html_with_http_headers $input, $cookie, $template->output;
}else{
+ my @id=$input->param('id');
+ my @oConnection;
+ my @oResult;
+ my $s=0;
-my @id=$input->param('id');
-my @oConnection;
-my @oResult;
-my $s=0;
if ($isbn ne "/" || $issn ne "/") {
$attr='1=7';
$term=$isbn if ($isbn ne"/");
@@ -115,60 +111,56 @@
$term=$author;
}
-
-my $query="\@attr $attr \"$term\"";
-
+ my $query="\@attr $attr \"$term\"";
foreach my $servid ( @id){
my $sth=$dbh->prepare("select * from z3950servers where id=?");
$sth->execute($servid);
-
while ($server=$sth->fetchrow_hashref) {
my $noconnection=0;
my $option1=new ZOOM::Options();
$option1->option(async=>1);
$option1->option('elementSetName', 'F');
$option1->option('databaseName',$server->{db}) ;
- $option1->option('user',$server->{userid}) ;
- $option1->option('password',$server->{password}) ;
+ $option1->option('user',$server->{userid}) if $server->{userid};
+ $option1->option('password',$server->{password}) if $server->{password};
$option1->option('preferredRecordSyntax', $server->{syntax});
- $oConnection[$s]=create ZOOM::Connection($option1);
- $oConnection[$s]->connect($server->{name}, $server->{port});
+ $oConnection[$s]=create ZOOM::Connection($option1) || warn ("something went wrong: ".$oConnection[$s]->errmsg());
+ $oConnection[$s]->connect($server->{name}, $server->{port}) || warn ("something went wrong: ".$oConnection[$s]->errmsg());
$serverhost[$s]=$server->{host};
$encoding[$s]=$server->{syntax};
$s++;
}## while fetch
-
}# foreach
-my $nremaining = $s;
-my $firstresult=1;
+ my $nremaining = $s;
+ my $firstresult=1;
+
for (my $z=0 ;$z<$s;$z++){
-$oResult[$z] = $oConnection[$z]->search_pqf($query);
+ warn "doing the search";
+ $oResult[$z] = $oConnection[$z]->search_pqf($query) || warn ("somthing went wrong: " . $oConnection[$s]->errmsg());
+#$oResult[$z] = $oConnection[$z]->search_pqf($query);
+ }
-}
AGAIN:
my $k;
-my $event;
+ my $event;
while (($k = ZOOM::event(\@oConnection)) != 0) {
$event = $oConnection[$k-1]->last_event();
-# warn ("connection ", $k-1, ": event $event (", ZOOM::event_str($event), ")\n");
+ warn ("connection ", $k-1, ": event $event (", ZOOM::event_str($event), ")\n");
last if $event == ZOOM::Event::ZEND;
}
-if ($k != 0) {
+
+ if ($k != 0) {
$k--;
-#warn $serverhost[$k];
+ warn $serverhost[$k];
my($error, $errmsg, $addinfo, $diagset) = $oConnection[$k]->error_x();
if ($error) {
-
-# warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n";
+ warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n";
goto MAYBE_AGAIN;
}
-
my $numresults=$oResult[$k]->size() ;
-
my $i;
my $result='';
@breeding_loop = ();
-
if ($numresults>0){
for ($i=0; $i<(($numresults<5) ? ($numresults) : (5)) ; $i++) {
my $rec=$oResult[$k]->record($i);
@@ -179,12 +171,11 @@
## In HEAD i change everything to UTF-8
# In rel2_2 i am not sure what encoding is so no character conversion is done here
##Add necessary encoding changes to here -TG
-
my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,"");
$oldbiblio->{isbn} =~ s/ |-|\.//g,
$oldbiblio->{issn} =~ s/ |-|\.//g,
+ my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$bid)=ImportBreeding($marcdata,1,$serverhost[$k],$encoding[$k],$random);
-my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$bid)=ImportBreeding($marcdata,1,$serverhost[$k],$encoding[$k],$random);
my %row_data;
if ($i % 2) {
$toggle="#ffffcc";
@@ -194,30 +185,27 @@
$row_data{toggle} = $toggle;
$row_data{server} = $serverhost[$k];
$row_data{isbn} = $oldbiblio->{isbn};
-
$row_data{title} =$oldbiblio->{title};
$row_data{author} = $oldbiblio->{author};
$row_data{id} = $bid;
$row_data{oldbiblionumber}=$oldbiblionumber;
push (@breeding_loop, \%row_data);
-
}# upto 5 results
- }#$numresults
-}# if $k !=0
-
-$numberpending=$nremaining-1;
+ }#$numresults
+ }# if $k !=0
+ $numberpending=$nremaining-1;
$template->param(breeding_loop => \@breeding_loop,server=>$serverhost[$k],
numberpending => $numberpending,
);
-output_html_with_http_headers $input, "", $template->output if $firstresult==1;
+ output_html_with_http_headers $input, "", $template->output if $firstresult==1;
-print $template->output if $firstresult !=1;
-$firstresult++;
+ print $template->output if $firstresult !=1;
+ $firstresult++;
-MAYBE_AGAIN:
-if (--$nremaining > 0) {
+ MAYBE_AGAIN:
+ if (--$nremaining > 0) {
goto AGAIN;
-}
+ }
} ## if op=search
More information about the Koha-cvs
mailing list