From 3126f2996b418ef0282a0860fe940b545ad79900 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 20 Aug 2009 17:18:24 +0200 Subject: [PATCH] Bug Fixing 3542 : searching for authority in cataloguing There was a problem in the query building and PERL is quite picky with empty data in arrays so setting empty elements to undef --- C4/AuthoritiesMarc.pm | 30 ++++++++++++-------- authorities/auth_finder.pl | 2 +- .../prog/en/includes/auth-finder-search.inc | 20 ++++++------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 7c2e531..836ac09 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -101,8 +101,10 @@ returns ref to array result and count of results returned sub SearchAuthorities { my ($tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby) = @_; - #use Data::Dumper; map {warn "CALL : ".Data::Dumper::Dumper($_);} @_; +# warn "CALL : $tags, $and_or, $excluding, $operator, $value, $offset,$length,$authtypecode,$sortby"; my $dbh=C4::Context->dbh; + use YAML; + warn "tags : ",Dump($tags),"\noperators:",Dump($operator),"\nvalues:",Dump($value); if (C4::Context->preference('NoZebra')) { # @@ -213,14 +215,19 @@ sub SearchAuthorities { while ($n>1){$query= "\@or ".$query;$n--;} } + my $dosearch; my $and=" \@and " ; - my $q2=""; + my $q2; for(my $i = 0 ; $i <= $#{$value} ; $i++) { if (@$value[$i]){ ##If mainentry search $a tag if (@$tags[$i] eq "mainmainentry") { - $attr =" \@attr 1=Heading-Main "; + +# FIXME: 'Heading-Main' index not yet defined in zebra + $attr =" \@attr 1=Heading-Main "; +# $attr =" \@attr 1=Heading "; + }elsif (@$tags[$i] eq "mainentry") { $attr =" \@attr 1=Heading "; }else{ @@ -236,16 +243,16 @@ sub SearchAuthorities { $attr .=" \@attr 5=1 \@attr 4=6 ";## Word list, right truncated, anywhere } $attr =$attr."\"".@$value[$i]."\""; - $q2 =($q2 ne "" ?$and.$q2.$attr:$attr); + $q2 =($q2?"$and $q2 $attr":"$attr"); + $dosearch=1; }#if value } ##Add how many queries generated - if ($query=~/\S+/ && $q2 ne ""){ - $query= $and.$query.$q2; - } - elsif ($q2 ne "") { - $query=$q2; - } + if ($query=~/\S+/){ + $query= $and.$query.$q2 + } else { + $query=$q2; + } ## Adding order #$query=' @or @attr 7=2 @attr 1=Heading 0 @or @attr 7=1 @attr 1=Heading 1'.$query if ($sortby eq "HeadingDsc"); my $orderstring= ($sortby eq "HeadingAsc"? @@ -255,8 +262,7 @@ sub SearchAuthorities { '@attr 7=2 @attr 1=Heading 0' :'' ); - my $allrecords=" \@attr 1=_ALLRECORDS \@attr 2=103 '' "; - $query=($q2?"\@or $orderstring $query":"\@or $orderstring ".($query?"\@and $allrecords $query":$allrecords) ); + $query=($query?"\@or $orderstring $query":"\@or \@attr 1=_ALLRECORDS \@attr 2=103 '' $orderstring "); $offset=0 unless $offset; my $counter = $offset; diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 717771c..18d84b6 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -59,7 +59,7 @@ if ( $op eq "do_search" ) { my @and_or = $query->param('and_or'); my @excluding = $query->param('excluding'); my @operator = $query->param('operator'); - my @value = ($query->param('value_mainstr'), $query->param('value_main'), $query->param('value_any')); + my @value = ($query->param('value_mainstr')||undef, $query->param('value_main')||undef, $query->param('value_any')||undef); my $orderby = $query->param('orderby'); $resultsperpage = $query->param('resultsperpage'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc index 17366e9..1c7120f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc @@ -33,24 +33,24 @@ " />
  • - + - " />
  • -
  • - - -
  • +
  • + + +
  • Cancel
    -- 1.6.0.4