[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/C4 Search.pm [rel_3_0]
From: |
Antoine Farnault |
Subject: |
[Koha-cvs] koha/C4 Search.pm [rel_3_0] |
Date: |
Fri, 20 Oct 2006 15:29:17 +0000 |
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: Antoine Farnault <toins> 06/10/20 15:29:17
Modified files:
C4 : Search.pm
Log message:
sync with dev_week.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Search.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.120.2.10&r2=1.120.2.11
Patches:
Index: Search.pm
===================================================================
RCS file: /sources/koha/koha/C4/Search.pm,v
retrieving revision 1.120.2.10
retrieving revision 1.120.2.11
diff -u -b -r1.120.2.10 -r1.120.2.11
--- Search.pm 20 Oct 2006 10:35:05 -0000 1.120.2.10
+++ Search.pm 20 Oct 2006 15:29:17 -0000 1.120.2.11
@@ -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.120.2.10 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.120.2.11 $' =~ /\d+/g;
shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
=head1 NAME
@@ -2503,6 +2503,7 @@
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;
@@ -3004,13 +3005,13 @@
$weighted_query .= "
$operand";
}
else {
- $weighted_query .= "
Title-cover,ext,r1=$operand"; # index label as exact
+ $weighted_query .= "
Title-cover,ext,r1=\"$operand\""; # index label as exact
$weighted_query .= " or ti,ext,r2=$operand";
# index as exact
#$weighted_query .= " or ti,phr,r3=$operand";
# index as phrase
#$weighted_query .= " or any,ext,r4=$operand";
# index as exact
$weighted_query .= " or kw,wrdl,r5=$operand";
# index as exact
$weighted_query .= " or
wrd,fuzzy,r9=$operand";
- $weighted_query .= " or
wrd=$stemmed_operand" if $stemming;
+ #$weighted_query .= "
or wrd=$stemmed_operand" if $stemming;
}
}
elsif ($index =~ /au/) {
@@ -3023,8 +3024,11 @@
elsif ($index =~ /ti/) {
$weighted_query .= " Title-cover,ext,r1=$operand";
# index label as exact
$weighted_query .= " or
Title-series,ext,r2=$operand";
+ #$weighted_query .= " or
ti,ext,r2=$operand";
+ #$weighted_query .= " or
ti,phr,r3=$operand";
+ #$weighted_query .= " or
ti,wrd,r3=$operand";
$weighted_query .= " or
(title-sort-az=0 or Title-cover,startswithnt,st-word,r3=$operand #)";
- #$weighted_query .= " or
(title-sort-az=0 or Title-cover,phr,r4=$operand)";
+ $weighted_query .= " or
(title-sort-az=0 or Title-cover,phr,r6=$operand)";
#$weighted_query .= " or
Title-cover,wrd,r5=$operand";
#$weighted_query .= " or
ti,ext,r6=$operand";
#$weighted_query .= " or
ti,startswith,phr,r7=$operand";
@@ -3081,25 +3085,35 @@
# add limits
my $limit_query;
my $limit_search_desc;
+ # FIXME: should write up some documentation about the design goals here
foreach my $limit (@limits) {
# FIXME: not quite right yet ... will work on this soon -- JF
if ($limit =~ /available/) {
- $limit_query.=" and (($query and datedue=0000-00-00) or
($query and datedue=0000-00-00 not lost=1) or ($query and datedue=0000-00-00
not lost=2))";
+ $limit_query.=" (($query and datedue=0000-00-00) or
($query and datedue=0000-00-00 not lost=1) or ($query and datedue=0000-00-00
not lost=2))";
#$limit_search_desc.=" and available";
}
+ # these queries are treated as OR
elsif (($limit_query) && ($limit =~/mc/)) {
$limit_query.=" or $limit" if $limit;
$limit_search_desc.=" or $limit" if $limit;
}
- elsif (($limit_query) || ($query)) {
+ # these are treated as AND
+ elsif ($limit_query) {
$limit_query.=" and $limit" if $limit;
$limit_search_desc.=" and $limit" if $limit;
}
+ # otherwise, there is nothing but the limit
else {
$limit_query.="$limit" if $limit;
$limit_search_desc.="$limit" if $limit;
}
}
+ # if there's also a query, we need to AND the limits to it
+ if (($limit_query) && ($query)) {
+ $limit_query=" and (".$limit_query.")";
+ $limit_search_desc=" and ($limit_search_desc)" if
$limit_search_desc;
+
+ }
$query .= $limit_query;
$human_search_desc .= $limit_search_desc;
# now normalize the strings
@@ -3131,7 +3145,11 @@
my $toggle;
my $even=1;
my @newresults;
- my @span_terms = split (/ /, $searchdesc);
+ my $span_terms_hashref;
+ for my $span_term (split (/ /, $searchdesc)) {
+ $span_term =~s/(.*=|\)|\(|\+|\.)//g;
+ $span_terms_hashref->{$span_term}++;
+ }
#Build brancnames hash
#find branchname
#get branch information.....
@@ -3172,10 +3190,11 @@
my $oldbiblio = MARCmarc2koha($dbh,$marcrecord,'');
# add spans to search term in results
- foreach my $term (@span_terms) {
+ foreach my $term (keys %$span_terms_hashref) {
+ #warn "term: $term";
my $old_term = $term;
if (length($term) > 3) {
- $term =~ s/(.*=|\)|\(|\+)//g;
+ $term =~ s/(.*=|\)|\(|\+|\.)//g;
#FIXME: is there a better way to do this?
$oldbiblio->{'title'} =~ s/$term/<span
class=term>$&<\/span>/gi;
$oldbiblio->{'subtitle'} =~ s/$term/<span
class=term>$&<\/span>/gi;
@@ -3197,9 +3216,11 @@
my @fields = $marcrecord->field($itemtag);
my @items_loop;
my $items;
+ my $ordered_count = 0;
my $onloan_count = 0;
my $wthdrawn_count = 0;
my $itemlost_count = 0;
+ my $itembinding_count = 0;
my $norequests = 1;
foreach my $field (@fields) {
my $item;
@@ -3209,19 +3230,27 @@
if ($item->{wthdrawn}) {
$wthdrawn_count++;
}
+ elsif ($item->{notforloan} == -1) {
+ $ordered_count++;
+ $norequests = 0;
+ }
elsif ($item->{itemlost}) {
$itemlost_count++;
}
+ elsif ($item->{binding}) {
+ $itembinding_count++;
+ }
elsif (($item->{onloan}) && ($item->{onloan} !=
'0000-00-00')) {
$onloan_count++;
$norequests = 0;
}
else {
$norequests = 0;
- if ($item->{'holdingbranch'}) {
-
$items->{$item->{'holdingbranch'}}->{count}++;
+ if ($item->{'homebranch'}) {
+
$items->{$item->{'homebranch'}}->{count}++;
}
- elsif ($item->{'homebranch'}) {
+ # Last resort
+ elsif ($item->{'holdingbranch'}) {
$items->{$item->{'homebranch'}}->{count}++;
}
}
@@ -3237,6 +3266,8 @@
$oldbiblio->{onloancount} = $onloan_count;
$oldbiblio->{wthdrawncount} = $wthdrawn_count;
$oldbiblio->{itemlostcount} = $itemlost_count;
+ $oldbiblio->{bindingcount} = $itembinding_count;
+ $oldbiblio->{orderedcount} = $ordered_count;
=head1 FIXME
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/16
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/16
- [Koha-cvs] koha/C4 Search.pm [rel_3_0],
Antoine Farnault <=
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/23
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/23
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/23
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], paul poulain, 2006/10/30
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/30
- [Koha-cvs] koha/C4 Search.pm [rel_3_0], Antoine Farnault, 2006/10/31