$facet_label_value = $av->count ? $av->next->opac_description : '';
}
+ # also, if it's a collection code, use the name instead of the code
+ if ( $link_value =~ /ccode/ ) {
+ # TODO Retrieve all authorised values at once, instead of 1 query per entry
+ my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $one_facet });
+ $facet_label_value = $av->count ? $av->next->opac_description : '';
+ }
+
# but we're down with the whole label being in the link's title.
push @this_facets_array,
{
my $rs = shift;
my $facets;
- my $indexing_mode = C4::Context->config('zebra_bib_index_mode') // 'dom';
my $use_zebra_facets = C4::Context->config('use_zebra_facets') // 0;
- if ( $indexing_mode eq 'dom' &&
- $use_zebra_facets ) {
+ if ( $use_zebra_facets ) {
$facets = _get_facets_from_zebra( $rs );
} else {
$facets = _get_facets_from_records( $rs );
require Lingua::Stem::Snowball ;
my $stemmed_operand=q{};
+ # Stemmer needs language
+ return $operand unless $lang;
+
# If operand contains a digit, it is almost certainly an identifier, and should
# not be stemmed. This is particularly relevant for ISBNs and ISSNs, which
# can contain the letter "X" - for example, _build_stemmend_operand would reduce
'an',
'Any',
'at',
+ 'arl',
+ 'arp',
'au',
'aub',
'aud',
for ( my $i = 0 ; $i <= @operands ; $i++ ) {
# COMBINE OPERANDS, INDEXES AND OPERATORS
- if ( $operands[$i] ) {
+ if ( ($operands[$i] // '') ne '' ) {
$operands[$i]=~s/^\s+//;
# A flag to determine whether or not to add the index to the query
$stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = 0;
}
# ISBN,ISSN,Standard Number, don't need special treatment
- elsif ( $index eq 'nb' || $index eq 'ns' ) {
+ elsif ( $index eq 'nb' || $index eq 'ns' || $index eq 'hi' ) {
(
$stemming, $auto_truncation,
$weight_fields, $fuzzy_enabled
query_desc => $query_desc,
operator => ($operators[ $i - 1 ]) ? $operators[ $i - 1 ] : '',
parsed_operand => $operand,
- original_operand => ($operands[$i]) ? $operands[$i] : '',
+ original_operand => $operands[$i] // '',
index => $index,
index_plus => $index_plus,
indexes_set => $indexes_set,
require C4::Items;
- $search_context = 'opac' if !$search_context || $search_context ne 'intranet';
+ $search_context->{'interface'} = 'opac' if !$search_context->{'interface'} || $search_context->{'interface'} ne 'intranet';
my ($is_opac, $hidelostitems);
- if ($search_context eq 'opac') {
+ if ($search_context->{'interface'} eq 'opac') {
$hidelostitems = C4::Context->preference('hidelostitems');
$is_opac = 1;
}
{ map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) };
# get notforloan authorised value list (see $shelflocations FIXME)
- my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => { not => undef } });
+ my $av = Koha::MarcSubfieldStructures->search({ frameworkcode => '', kohafield => 'items.notforloan', authorised_value => [ -and => {'!=' => undef }, {'!=' => ''}] });
my $notforloan_authorised_value = $av->count ? $av->next->authorised_value : undef;
#Get itemtype hash
my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
# set stuff for XSLT processing here once, not later again for every record we retrieved
- my $interface = $search_context eq 'opac' ? 'OPAC' : '';
+ my $interface = $is_opac ? 'OPAC' : '';
my $xslsyspref = $interface . "XSLTResultsDisplay";
my $xslfile = C4::Context->preference($xslsyspref);
my $lang = $xslfile ? C4::Languages::getlanguage() : undef;
# add imageurl to itemtype if there is one
$oldbiblio->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
+ $oldbiblio->{'authorised_value_images'} = ($search_context->{'interface'} eq 'opac' && C4::Context->preference('AuthorisedValueImages')) || ($search_context->{'interface'} eq 'intranet' && C4::Context->preference('StaffAuthorisedValueImages')) ? 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);
# Pull out the items fields
my @fields = $marcrecord->field($itemtag);
my $marcflavor = C4::Context->preference("marcflavour");
+
# adding linked items that belong to host records
- my $analyticsfield = '773';
- if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
- $analyticsfield = '773';
- } elsif ($marcflavor eq 'UNIMARC') {
- $analyticsfield = '461';
- }
- foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
- my $hostbiblionumber = $hostfield->subfield("0");
- my $linkeditemnumber = $hostfield->subfield("9");
- if(!$hostbiblionumber eq undef){
- my $hostbiblio = GetMarcBiblio({
- biblionumber => $hostbiblionumber,
- embed_items => 1 });
- my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
- if(!$hostbiblio eq undef){
- my @hostitems = $hostbiblio->field($itemfield);
- foreach my $hostitem (@hostitems){
- if ($hostitem->subfield("9") eq $linkeditemnumber){
- my $linkeditem =$hostitem;
- # append linked items if they exist
- if (!$linkeditem eq undef){
- push (@fields, $linkeditem);}
+ if ( C4::Context->preference('EasyAnalyticalRecords') ) {
+ my $analyticsfield = '773';
+ if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
+ $analyticsfield = '773';
+ } elsif ($marcflavor eq 'UNIMARC') {
+ $analyticsfield = '461';
+ }
+ foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
+ my $hostbiblionumber = $hostfield->subfield("0");
+ my $linkeditemnumber = $hostfield->subfield("9");
+ if( $hostbiblionumber ) {
+ my $hostbiblio = GetMarcBiblio({
+ biblionumber => $hostbiblionumber,
+ embed_items => 1 });
+ my ($itemfield, undef) = GetMarcFromKohaField( 'items.itemnumber', GetFrameworkCode($hostbiblionumber) );
+ if( $hostbiblio ) {
+ my @hostitems = $hostbiblio->field($itemfield);
+ foreach my $hostitem (@hostitems){
+ if ($hostitem->subfield("9") eq $linkeditemnumber){
+ my $linkeditem =$hostitem;
+ # append linked items if they exist
+ push @fields, $linkeditem if $linkeditem;
+ }
}
}
}
next;
}
# hidden based on OpacHiddenItems syspref
- my @hi = C4::Items::GetHiddenItemnumbers($item);
+ my @hi = C4::Items::GetHiddenItemnumbers({ items=> [ $item ], borcat => $search_context->{category} });
if (scalar @hi) {
push @hiddenitems, @hi;
$hideatopac_count++;
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
$onloan_items->{$key}->{description} = $item->{description};
$onloan_items->{$key}->{imageurl} =
- getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
+ getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
# if something's checked out and lost, mark it as 'long overdue'
if ( $item->{itemlost} ) {
$other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0;
$other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0;
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan};
- $other_items->{$key}->{count}++ if $item->{$hbranch};
- $other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
- $other_items->{$key}->{description} = $item->{description};
- $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
+ $other_items->{$key}->{count}++ if $item->{$hbranch};
+ $other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
+ $other_items->{$key}->{description} = $item->{description};
+ $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
}
# item is available
else {
$can_place_holds = 1;
$available_count++;
- $available_items->{$prefix}->{count}++ if $item->{$hbranch};
- foreach (qw(branchname itemcallnumber description)) {
- $available_items->{$prefix}->{$_} = $item->{$_};
- }
- $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
- $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
+ $available_items->{$prefix}->{count}++ if $item->{$hbranch};
+ foreach (qw(branchname itemcallnumber description)) {
+ $available_items->{$prefix}->{$_} = $item->{$_};
+ }
+ $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context->{'interface'}, $itemtypes{ $item->{itype} }->{imageurl} );
}
}
} # notforloan, item level and biblioitem level
# we fetched the sysprefs already before the loop through all retrieved record!
if (!$scan && $xslfile) {
$oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $xslsyspref, 1, \@hiddenitems, $sysxml, $xslfile, $lang);
- # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
}
# if biblio level itypes are used and itemtype is notforloan, it can't be reserved either
}
}
$oldbiblio->{norequests} = 1 unless $can_place_holds;
- $oldbiblio->{itemsplural} = 1 if $items_count > 1;
$oldbiblio->{items_count} = $items_count;
$oldbiblio->{available_items_loop} = \@available_items_loop;
$oldbiblio->{onloan_items_loop} = \@onloan_items_loop;
# Set the default indexing modes
my $search_engine = C4::Context->preference("SearchEngine");
if ($search_engine eq 'Elasticsearch') {
- return $raw_data;
+ return ref $raw_data eq 'MARC::Record' ? $raw_data : MARC::Record->new_from_xml( $raw_data, 'UTF-8' );
}
my $index_mode = ( $server eq 'biblioserver' )
? C4::Context->config('zebra_bib_index_mode') // 'dom'