From 8e01ae8e18654d39846cc9c3e1cb2caae6d47e1d Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Tue, 6 Nov 2007 16:30:51 -0600 Subject: [PATCH] fixing subject link on detail pages and searching API Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 73 +++++++++---------- C4/Search.pm | 4 +- .../prog/en/modules/catalogue/detail.tmpl | 5 +- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index d5a01a1917..451e0728f7 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1790,48 +1790,43 @@ sub GetMarcSubjects { $mintag = "600"; $maxtag = "611"; } + + my @marcsubjects; + my $subject = ""; + my $subfield = ""; + my $marcsubject; - my @marcsubjcts; - - foreach my $field ( $record->fields ) { + foreach my $field ( $record->field('6..' )) { next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; + my @subfields_loop; my @subfields = $field->subfields(); - my $link = "su:"; - my $label; - my $flag = 0; - my $authoritysep=C4::Context->preference("authoritysep"); - for my $subject_subfield ( @subfields ) { - if ( - $marcflavour ne 'MARC21' - and ( - ($subject_subfield->[0] eq '3') or - ($subject_subfield->[0] eq '4') or - ($subject_subfield->[0] eq '5') - ) - ) - { - next; - } - my $code = $subject_subfield->[0]; - $label .= $subject_subfield->[1].$authoritysep unless ( $code == 9 ); - $link .= " and su-to:".$subject_subfield->[1] unless ( $code == 9 ); - if ( $code == 9 ) { - $link = "an:".$subject_subfield->[1]; - $flag = 1; - } - elsif ( ! $flag ) { - $link =~ s/ and\ssu-to:$//; - } - } - $label =~ s/$authoritysep$//; - push @marcsubjcts, - { - label => $label, - link => $link - } - } - return \@marcsubjcts; -} #end GetMarcSubjects + my $counter = 0; + my @link_loop; + for my $subject_subfield (@subfields ) { + # don't load unimarc subfields 3,4,5 + next if (($marcflavour eq "UNIMARC") and ($subject_subfield->[0] =~ (3|4|5) ) ); + my $code = $subject_subfield->[0]; + my $value = $subject_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; + # ignore $9 + push @subfields_loop, {code => $code, value => $value, link_loop => \@link_loop, separator => $separator} unless ($subject_subfield->[0] == 9 ); + # this needs to be added back in in a way that the template can expose it properly + #if ( $code == 9 ) { + # $link = "an:".$subject_subfield->[1]; + # $flag = 1; + #} + $counter++; + } + + push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; + + } + return \@marcsubjects; +} #end getMARCsubjects =head2 GetMarcAuthors diff --git a/C4/Search.pm b/C4/Search.pm index 70ed90d685..729529dcb0 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -565,6 +565,7 @@ sub _remove_stopwords { # otherwise, a french word like "leçon" is splitted in "le" "çon", le is an empty word, we get "çon" # and don't find anything... foreach (keys %{C4::Context->stopwords}) { + next if ($_ =~/(and|or|not)/); # don't remove operators $operand=~ s/\P{IsAlpha}$_\P{IsAlpha}/ /i; $operand=~ s/^$_\P{IsAlpha}/ /i; $operand=~ s/\P{IsAlpha}$_$/ /i; @@ -747,6 +748,7 @@ sub buildQuery { # COMBINE OPERANDS, INDEXES AND OPERATORS if ( $operands[$i] ) { + warn "OP: $operands[$i]"; my $operand = $operands[$i]; my $index = $indexes[$i]; # if there's no index, don't use one, it will throw a CCL error @@ -755,7 +757,7 @@ sub buildQuery { # Remove Stopwords $operand = _remove_stopwords($operand,$index); - + warn "OP_SW: $operand"; # Handle Truncation my ($nontruncated,$righttruncated,$lefttruncated,$rightlefttruncated,$regexpr); ($nontruncated,$righttruncated,$lefttruncated,$rightlefttruncated,$regexpr) = _add_truncation($operand,$index); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl index 4ee7757654..0893cb6281 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tmpl @@ -92,8 +92,9 @@
  • Subjects:
  • -- 2.39.5