[Koha-cvs] koha/C4 Search.pm [dev_week]

Joshua Ferraro jmf at kados.org
Mon Dec 4 06:41:04 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Joshua Ferraro <kados>	06/12/04 05:41:03

Modified files:
	C4             : Search.pm 

Log message:
	Fix for bug 1227: Series information not displaying reliably
	
	Owen, you'll need to commit the template changes for this and possibly remove the old series display from the detail page
	and just use the getMARCseries one now.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.99.2.11.2.34&r2=1.99.2.11.2.35

Patches:
Index: Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.99.2.11.2.34
retrieving revision 1.99.2.11.2.35
diff -u -b -r1.99.2.11.2.34 -r1.99.2.11.2.35
--- Search.pm	4 Dec 2006 04:58:05 -0000	1.99.2.11.2.34
+++ Search.pm	4 Dec 2006 05:41:02 -0000	1.99.2.11.2.35
@@ -40,7 +40,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.99.2.11.2.34 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.99.2.11.2.35 $' =~ /\d+/g;
           shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -84,7 +84,7 @@
 
 &searchZOOM &searchResults &getRecords &buildQuery
 
-&getMARCnotes &getMARCsubjects &getMARCurls);
+&getMARCnotes &getMARCsubjects &getMARCurls &getMARCseries);
 # make all your functions, whether exported or not;
 
 =head1 findseealso($dbh,$fields);
@@ -2673,6 +2673,51 @@
 	return $marcsubjctsarray;
 }  #end getMARCsubjects
 
+sub getMARCseries {
+    my ($dbh, $bibid, $marcflavour) = @_;
+    my ($mintag, $maxtag);
+    if ($marcflavour eq "MARC21") {
+        $mintag = "440";
+        $maxtag = "490";
+    } else {           # assume unimarc if not marc21
+        $mintag = "600";
+        $maxtag = "619";
+    }
+    my $record=MARCgetbiblio($dbh,$bibid);
+    my @marcseries;
+    my $subjct = "";
+    my $subfield = "";
+    my $marcsubjct;
+
+    foreach my $field ($record->field('440'), $record->field('490')) {
+        my @subfields_loop;
+        #my $value = $field->subfield('a');
+        #$marcsubjct = {MARCSUBJCT => $value,};
+        my @subfields = $field->subfields();
+        #warn "subfields:".join " ", @$subfields;
+        my $counter = 0;
+        my @link_loop;
+        for my $series_subfield (@subfields ) {
+            my $code = $series_subfield->[0];
+            my $value = $series_subfield->[1];
+            my $linkvalue = $value;
+            $linkvalue =~ s/(\(|\))//g;
+            my $operator = " and " unless $counter==0;
+            push @link_loop, {link => $linkvalue, operator => $operator };
+            my $separator = C4::Context->preference("authoritysep") unless $counter==0;
+            push @subfields_loop, {code => $code, value => $value, link_loop => \@link_loop, separator => $separator};
+            $counter++;
+        }
+        push @marcseries, { MARCSERIES_SUBFIELDS_LOOP => \@subfields_loop };
+        #$marcsubjct = {MARCSUBJCT => $field->as_string(),};
+        #push @marcsubjcts, $marcsubjct;
+        #$subjct = $value;
+
+    }
+    my $marcseriessarray=\@marcseries;
+    return $marcseriessarray;
+}  #end getMARCseriess
+
 
 sub getMARCurls {
     my ($dbh, $bibid, $marcflavour) = @_;





More information about the Koha-cvs mailing list