# Suite 330, Boston, MA 02111-1307 USA
use strict;
+# use warnings; # FIXME
require Exporter;
use C4::Context;
use C4::Biblio; # GetMarcFromKohaField
use XML::Simple;
use C4::Dates qw(format_date);
use C4::XSLT;
+use C4::Branch;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
expandable => $expandable,
expand => $link_value,
}
- );
+ ) unless ( ($facets_info->{$link_value}->{'label_value'} =~ /Libraries/) and (C4::Context->preference('singleBranchMode')) );
}
}
}
foreach ( keys %{ C4::Context->stopwords } ) {
next if ( $_ =~ /(and|or|not)/ ); # don't remove operators
if ( $operand =~
- /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$)/ )
+ /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$|^$_$)/ )
{
$operand =~ s/\P{IsAlpha}$_\P{IsAlpha}/ /gi;
$operand =~ s/^$_\P{IsAlpha}/ /gi;
$operand =~ s/\P{IsAlpha}$_$/ /gi;
+ $operand =~ s/$1//gi;
push @stopwords_removed, $_;
}
}
}
# Detect Truncation
- my ( $nontruncated, $righttruncated, $lefttruncated,
- $rightlefttruncated, $regexpr );
my $truncated_operand;
- (
- $nontruncated, $righttruncated, $lefttruncated,
+ my( $nontruncated, $righttruncated, $lefttruncated,
$rightlefttruncated, $regexpr
) = _detect_truncation( $operand, $index );
warn
$limit .= " and " if $limit || $query;
$limit .= "$this_limit";
$limit_cgi .= "&limit=$this_limit";
- $limit_desc .= " $this_limit";
+ if ($this_limit =~ /^branch:(.+)/) {
+ my $branchcode = $1;
+ my $branchname = GetBranchName($branchcode);
+ if (defined $branchname) {
+ $limit_desc .= " branch:$branchname";
+ } else {
+ $limit_desc .= " $this_limit";
+ }
+ } else {
+ $limit_desc .= " $this_limit";
+ }
}
}
if ($group_OR_limits) {
$times = $hits; # FIXME: if $hits is undefined, why do we want to equal it?
}
+ my $marcflavour = C4::Context->preference("marcflavour");
# loop through all of the records we've retrieved
for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
my $marcrecord = MARC::File::USMARC::decode( $marcresults[$i] );
$oldbiblio->{result_number} = $i + 1;
# add imageurl to itemtype if there is one
- if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} =~ /^http:/ ) {
- $oldbiblio->{imageurl} =
- $itemtypes{ $oldbiblio->{itemtype} }->{imageurl};
- } else {
- $oldbiblio->{imageurl} =
- getitemtypeimagesrc() . "/"
- . $itemtypes{ $oldbiblio->{itemtype} }->{imageurl}
- if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
- }
- my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{biblionumber} ) );
- $oldbiblio->{authorised_value_images} = $biblio_authorised_value_images;
- my $aisbn = $oldbiblio->{'isbn'};
- $aisbn =~ /(\d*[X]*)/;
- $oldbiblio->{amazonisbn} = $1;
+ $oldbiblio->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
+
+ $oldbiblio->{'authorised_value_images'} = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{'biblionumber'}, $marcrecord ) );
+ $oldbiblio->{normalized_upc} = GetNormalizedUPC($marcrecord,$marcflavour);
+ $oldbiblio->{normalized_ean} = GetNormalizedEAN($marcrecord,$marcflavour);
+ $oldbiblio->{normalized_oclc} = GetNormalizedOCLCNumber($marcrecord,$marcflavour);
+ $oldbiblio->{normalized_isbn} = GetNormalizedISBN(undef,$marcrecord,$marcflavour);
+ $oldbiblio->{content_identifier_exists} = 1 if ($oldbiblio->{normalized_isbn} or $oldbiblio->{normalized_oclc} or $oldbiblio->{normalized_ean} or $oldbiblio->{normalized_upc});
$oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description};
# Build summary if there is one (the summary is defined in the itemtypes table)
# FIXME: is this used anywhere, I think it can be commented out? -- JF
# save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link
$oldbiblio->{'author_nospan'} = $oldbiblio->{'author'};
$oldbiblio->{'title_nospan'} = $oldbiblio->{'title'};
+ $oldbiblio->{'subtitle_nospan'} = $oldbiblio->{'subtitle'};
# Add search-term highlighting to the whole record where they match using <span>s
if (C4::Context->preference("OpacHighlightedWords")){
my $searchhighlightblob;
my $item_in_transit_count = 0;
my $can_place_holds = 0;
my $items_count = scalar(@fields);
- my $items_counter;
my $maxitems =
( C4::Context->preference('maxItemsinSearchResults') )
? C4::Context->preference('maxItemsinSearchResults') - 1
# loop through every item
foreach my $field (@fields) {
my $item;
- $items_counter++;
# populate the items hash
foreach my $code ( keys %subfieldstosearch ) {
$onloan_count++;
my $key = $prefix . $item->{due_date};
$onloan_items->{$key}->{due_date} = format_date($item->{onloan});
- $onloan_items->{$key}->{count}++ if $item->{homebranch};
+ $onloan_items->{$key}->{count}++ if $item->{$hbranch};
$onloan_items->{$key}->{branchname} = $item->{branchname};
$onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
- $onloan_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
# if something's checked out and lost, mark it as 'long overdue'
if ( $item->{itemlost} ) {
$onloan_items->{$prefix}->{longoverdue}++;
}
$other_items->{$key}->{intransit} = ($transfertwhen ne '') ? 1 : 0;
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
- $other_items->{$key}->{count}++ if $item->{homebranch};
+ $other_items->{$key}->{count}++ if $item->{$hbranch};
$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
- $other_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
}
# item is available
else {
$can_place_holds = 1;
$available_count++;
- $available_items->{$prefix}->{count}++ if $item->{homebranch};
+ $available_items->{$prefix}->{count}++ if $item->{$hbranch};
foreach (qw(branchname itemcallnumber)) {
$available_items->{$prefix}->{$_} = $item->{$_};
}
$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
- $available_items->{$prefix}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl};
+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
}
}
} # notforloan, item level and biblioitem level
# XSLT processing of some stuff
if (C4::Context->preference("XSLTResultsDisplay") && !$scan) {
- my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
+ my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
$oldbiblio->{XSLTResultsRecord} = $newxmlrecord;
}
$oldbiblio->{damagedcount} = $itemdamaged_count;
$oldbiblio->{intransitcount} = $item_in_transit_count;
$oldbiblio->{orderedcount} = $ordered_count;
- $oldbiblio->{isbn} =~
- s/-//g; # deleting - in isbn to enable amazon content
- $oldbiblio->{'authorised_value_images'} = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{'biblionumber'} ) );
push( @newresults, $oldbiblio );
}
return @newresults;
my ( $biblionumber, $title ) = split /,/, $_;
my $record = GetMarcBiblio($biblionumber);
my $callnumber;
- my ( $callnumber_tag, $callnumber_subfield ) =
- GetMarcFromKohaField( $dbh, 'items.itemcallnumber' );
- ( $callnumber_tag, $callnumber_subfield ) =
- GetMarcFromKohaField('biblioitems.callnumber')
- unless $callnumber_tag;
+ my $frameworkcode = GetFrameworkCode($biblionumber);
+ my ( $callnumber_tag, $callnumber_subfield ) = GetMarcFromKohaField( 'items.itemcallnumber', $frameworkcode);
+ ( $callnumber_tag, $callnumber_subfield ) = GetMarcFromKohaField('biblioitems.callnumber', $frameworkcode)
+ unless $callnumber_tag;
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' ) {
$callnumber = $record->subfield( '200', 'f' );
- }
- else {
+ } else {
$callnumber = $record->subfield( '100', 'a' );
}
$tag = $tag . $subfield;
undef $subfield;
}
- my ( $bntag, $bnsubf ) = GetMarcFromKohaField('biblio.biblionumber');
- my ( $itemtag, $itemsubf ) = GetMarcFromKohaField('items.itemnumber');
+ my ( $bntag, $bnsubf ) = GetMarcFromKohaField('biblio.biblionumber', '');
+ my ( $itemtag, $itemsubf ) = GetMarcFromKohaField('items.itemnumber', '');
if ($tag eq $itemtag) {
# do not allow the embedded item tag to be
# edited from here