[Koha-cvs] koha/C4 Search.pm

Chris Cormack chris at katipo.co.nz
Tue Feb 14 05:00:23 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch: 	
Changes by:	Chris Cormack <rangi at savannah.gnu.org>	06/02/14 04:00:23

Modified files:
	C4             : Search.pm 

Log message:
	Work in progress still, committing for testing

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/koha/C4/Search.pm.diff?tr1=1.110&tr2=1.111&r1=text&r2=text

Patches:
Index: koha/C4/Search.pm
diff -u koha/C4/Search.pm:1.110 koha/C4/Search.pm:1.111
--- koha/C4/Search.pm:1.110	Mon Feb 13 21:03:21 2006
+++ koha/C4/Search.pm	Tue Feb 14 04:00:23 2006
@@ -21,13 +21,16 @@
 use ZOOM;
 use Smart::Comments;
 use C4::Context;
+use MARC::Record;
+use MARC::File::XML;
+use C4::Biblio;
 
 require Exporter;
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.110 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.111 $' =~ /\d+/g;
           shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -55,13 +58,16 @@
 
 sub search {
     my ($search,$type)=@_;
+    my $dbh=C4::Context->dbh();
     my $q;
     my $host=C4::Context->config("zebraserver");
     my $port=C4::Context->config("zebraport");
     my $intranetdir=C4::Context->config("intranetdir");
+    my $database="koha3";
     my $Zconn;
+    my $raw;
     eval {
-	$Zconn = new ZOOM::Connection($host,$port);
+	$Zconn = new ZOOM::Connection("$host:$port/$database");
     };
     if ($@) {
 	warn "Error ", $@->code(), ": ", $@->message(), "\n";                  
@@ -73,17 +79,33 @@
 	    $string.="$var=\"$search->{$var}\" ";
 	}	    
 	$Zconn->option(cqlfile => "$intranetdir/zebra/pqf.properties");
-	$Zconn->option(preferredRecordSyntax => "xml");
+	$Zconn->option(preferredRecordSyntax => "usmarc");
 	$q = new ZOOM::Query::CQL2RPN( $string, $Zconn);	
 	}
     eval {
 	my $rs = $Zconn->search($q);
 	my $n = $rs->size();
-	###$rs->record(0)->render();
+	if ($n >0){
+	    $raw=$rs->record(0)->raw();
+	}
+#	print "here is $n";
+#	$raw=$rs->record(0)->raw();
+	print $raw;
+
+
     };
     if ($@) {
 	print "Error ", $@->code(), ": ", $@->message(), "\n";
     }   
+    my $record = MARC::Record->new_from_usmarc($raw);
+    ### $record                                                                                                    
+    # transform it into a meaningul hash                                                                       
+    my $line = MARCmarc2koha($dbh,$record);                                                                    
+    ### $line                                                                                                      
+    my $biblionumber=$line->{biblionumber};                                                                    
+    my $title=$line->{title};                                                                                  
+
+
 }
 1;
 __END__





More information about the Koha-cvs mailing list