use C4::Branch;
use C4::Reserves; # CheckReserves
use C4::Debug;
-use C4::Items;
use C4::Charset;
use YAML;
use URI::Escape;
# set the version for version checking
BEGIN {
- $VERSION = 3.01;
+ $VERSION = 3.07.00.049;
$DEBUG = ($ENV{DEBUG}) ? 1 : 0;
}
&AddSearchHistory
&GetDistinctValues
&enabled_staff_search_views
+ &SimpleSearch
);
# make all your functions, whether exported or not;
( undef, $results_hashref, \@facets_loop ) = getRecords (
$koha_query, $simple_query, $sort_by_ref, $servers_ref,
- $results_per_page, $offset, $expanded_facet, $branches,
+ $results_per_page, $offset, $expanded_facet, $branches,$itemtypes,
$query_type, $scan
);
sub getRecords {
my (
$koha_query, $simple_query, $sort_by_ref, $servers_ref,
- $results_per_page, $offset, $expanded_facet, $branches,
+ $results_per_page, $offset, $expanded_facet, $branches,$itemtypes,
$query_type, $scan
) = @_;
# avoid first line
my $tag_num = substr($tag, 0, 3);
my $letters = substr($tag, 3);
- my $field_pattern = '\n' . $tag_num . ' ([^\n]+)';
+ my $field_pattern = '\n' . $tag_num . ' ([^z][^\n]+)';
+ $field_pattern = '\n' . $tag_num . ' ([^\n]+)' if (int($tag_num) < 10);
my @field_tokens = ( $render_record =~ /$field_pattern/g ) ;
foreach my $field_token (@field_tokens) {
my @subf = ( $field_token =~ /\$([a-zA-Z0-9]) ([^\$]+)/g );
$facet_label_value = "*";
}
}
+ # if it's a itemtype, label by the name, not the code,
+ if ( $link_value =~ /itype/ ) {
+ if (defined $itemtypes
+ && ref($itemtypes) eq "HASH"
+ && defined $itemtypes->{$one_facet}
+ && ref ($itemtypes->{$one_facet}) eq "HASH")
+ {
+ $facet_label_value =
+ $itemtypes->{$one_facet}->{'description'};
+ }
+ }
# but we're down with the whole label being in the link's title.
push @this_facets_array, {
sub _build_stemmed_operand {
my ($operand,$lang) = @_;
require Lingua::Stem::Snowball ;
- my $stemmed_operand;
+ my $stemmed_operand=q{};
# 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
# FIXME: the locale should be set based on the user's language and/or search choice
#warn "$lang";
+ # Make sure we only use the first two letters from the language code
+ $lang = lc(substr($lang, 0, 2));
+ # The language codes for the two variants of Norwegian will now be "nb" and "nn",
+ # none of which Lingua::Stem::Snowball can use, so we need to "translate" them
+ if ($lang eq 'nb' || $lang eq 'nn') {
+ $lang = 'no';
+ }
my $stemmer = Lingua::Stem::Snowball->new( lang => $lang,
encoding => "UTF-8" );
$weighted_query .=
"Title-cover,ext,r1=\"$operand\""; # exact title-cover
$weighted_query .= " or ti,ext,r2=\"$operand\""; # exact title
- $weighted_query .= " or ti,phr,r3=\"$operand\""; # phrase title
+ $weighted_query .= " or Title-cover,phr,r3=\"$operand\""; # phrase title
#$weighted_query .= " or any,ext,r4=$operand"; # exact any
#$weighted_query .=" or kw,wrdl,r5=\"$operand\""; # word list any
$weighted_query .= " or wrdl,fuzzy,r8=\"$operand\""
my @search_results = searchResults($search_context, $searchdesc, $hits,
$results_per_page, $offset, $scan,
- @marcresults, $hidelostitems);
+ @marcresults);
Format results in a form suitable for passing to the template
my $dbh = C4::Context->dbh;
my @newresults;
+ require C4::Items;
+
$search_context = 'opac' if !$search_context || $search_context ne 'intranet';
my ($is_opac, $hidelostitems);
if ($search_context eq 'opac') {
}
#search item field code
- my $sth =
- $dbh->prepare(
-"SELECT tagfield FROM marc_subfield_structure WHERE kohafield LIKE 'items.itemnumber'"
- );
- $sth->execute;
- my ($itemtag) = $sth->fetchrow;
+ my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" );
## find column names of items related to MARC
my $sth2 = $dbh->prepare("SHOW COLUMNS FROM items");
# Hidden items
if ($is_opac) {
- my @hi = GetHiddenItemnumbers($item);
- $item->{'hideatopac'} = @hi;
- push @hiddenitems, @hi;
+ my @hi = C4::Items::GetHiddenItemnumbers($item);
+ $item->{'hideatopac'} = @hi;
+ push @hiddenitems, @hi;
}
my $hbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch' : 'holdingbranch';
}
$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;
+ $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};
# XSLT processing of some stuff
use C4::Charset;
SetUTF8Flag($marcrecord);
- $debug && warn $marcrecord->as_formatted;
+ warn $marcrecord->as_formatted if $DEBUG;
my $interface = $search_context eq 'opac' ? 'OPAC' : '';
if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) {
- $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, 'Results',
- $search_context, 1, \@hiddenitems);
+ $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
# the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs
}
$oldbiblio->{intransitcount} = $item_in_transit_count;
$oldbiblio->{onholdcount} = $item_onhold_count;
$oldbiblio->{orderedcount} = $ordered_count;
- # deleting - in isbn to enable amazon content
- $oldbiblio->{isbn} =~ s/-//g;
if (C4::Context->preference("AlternateHoldingsField") && $items_count == 0) {
my $fieldspec = C4::Context->preference("AlternateHoldingsField");