[Koha-cvs] CVS: koha/z3950 search.pl,NONE,1.1

Paul POULAIN tipaul at users.sourceforge.net
Tue Apr 29 18:50:51 CEST 2003


Update of /cvsroot/koha/koha/z3950
In directory sc8-pr-cvs1:/tmp/cvs-serv5011/z3950

Added Files:
	search.pl 
Log Message:
really proud of this commit :-)
z3950 search and import seems to works fine.
Let me explain how :
* a "search z3950" button is added in the addbiblio template.
* when clicked, a popup appears and z3950/search.pl is called
* z3950/search.pl calls addz3950search in the DB
* the z3950 daemon retrieve the records and stores them in z3950results AND in marc_breeding table.
* as long as there as searches pending, the popup auto refresh every 2 seconds, and says how many searches are pending.
* when the user clicks on a z3950 result => the parent popup is called with the requested biblio, and auto-filled

Note :
* character encoding support : (It's a nightmare...) In the z3950servers table, a "encoding" column has been added. You can put "UNIMARC" or "USMARC" in this column. Depending on this, the char_decode in C4::Biblio.pm replaces marc-char-encode by an iso 8859-1 encoding. Note that in the breeding import this value has been added too, for a better support.
* the marc_breeding and z3950* tables have been modified : they have an encoding column and the random z3950 number is stored too for convenience => it's the key I use to list only requested biblios in the popup.


--- NEW FILE ---
#!/usr/bin/perl

# 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;
use CGI;
use C4::Auth;
use C4::Output;
use C4::Interface::CGI::Output;
use C4::Biblio;
use C4::Context;
use C4::Koha; # XXX subfield_is_koha_internal_p
use C4::Z3950;
use C4::Search;
use HTML::Template;
use MARC::File::USMARC;

use vars qw( $tagslib );
use vars qw( $is_a_modif );


my $input = new CGI;
my $dbh = C4::Context->dbh;
my $error = $input->param('error');
my $bibid=$input->param('bibid');
my $title = $input->param('title');
my $isbn = $input->param('isbn');
my $issn = $input->param('issn');
my $random = $input->param('random');
my @results;
my $count;
my $toggle;

my $record;
my $oldbiblio;
if ($bibid) {
	$record = MARCgetbiblio($dbh,$bibid);
	$oldbiblio = MARCmarc2koha($dbh,$record);
}
$isbn = $oldbiblio->{'isbn'};
$issn = $oldbiblio->{'issn'};
$title = $oldbiblio->{'title'};
my $errmsg;
unless ($random) { # if random is a parameter => we're just waiting for the search to end, it's a refresh.
	if ($isbn) {
		$random =rand(1000000000);
		$errmsg = addz3950queue($isbn, "isbn", $random, 'CHECKED');
	}
}
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "z3950/searchresult.tmpl",
				query => $input,
				type => "intranet",
				authnotrequired => 0,
				flagsrequired => {catalogue => 1},
				debug => 1,
				});

# fill with books in breeding farm
($count, @results) = breedingsearch($title,$isbn,$random);
my $numberpending= &checkz3950searchdone($random);
my @breeding_loop = ();
for (my $i=0; $i <= $#results; $i++) {
	my %row_data;
	if ($i % 2) {
		$toggle="#ffffcc";
	} else {
		$toggle="white";
	}
	$row_data{toggle} = $toggle;
	$row_data{id} = $results[$i]->{'id'};
	$row_data{isbn} = $results[$i]->{'isbn'};
	$row_data{file} = $results[$i]->{'file'};
	$row_data{title} = $results[$i]->{'title'};
	$row_data{author} = $results[$i]->{'author'};
	push (@breeding_loop, \%row_data);
}

$template->param(isbn => $isbn,
						title => $title,
						breeding_loop => \@breeding_loop,
						refresh => ($numberpending eq 0 ? 0 : "search.pl?bibid=$bibid&random=$random"),
						numberpending => $numberpending,
						oldbiblionumber => $oldbiblio->{'biblionumber'},
						);

print $input->header(
-type => guesstype($template->output),
-cookie => $cookie
),$template->output;





More information about the Koha-cvs mailing list