# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
#use warnings; FIXME - Bug 2505
use Business::ISBN;
use MARC::Record;
use MARC::Field;
-use utf8;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG);
# set the version for version checking
&buildQuery
&GetDistinctValues
&enabled_staff_search_views
- &PurgeSearchHistory
);
# make all your functions, whether exported or not;
* $query can be a simple keyword or a complete CCL query
* @servers is optional. Defaults to biblioserver as found in koha-conf.xml
- * $offset - If present, represents the number of records at the beggining to omit. Defaults to 0
+ * $offset - If present, represents the number of records at the beginning to omit. Defaults to 0
* $max_results - if present, determines the maximum number of records to fetch. undef is All. defaults to undef.
{
$facet_label_value =
$itemtypes->{$one_facet}
- ->{'description'};
+ ->{translated_description};
}
}
# remove stopwords from operand : parse all stopwords & remove them (case insensitive)
# we use IsAlpha unicode definition, to deal correctly with diacritics.
-# otherwise, a French word like "leçon" woudl be split into "le" "çon", "le"
+# otherwise, a French word like "leçon" would be split into "le" "çon", "le"
# is a stopword, we'd get "çon" and wouldn't find anything...
#
foreach ( keys %{ C4::Context->stopwords } ) {
'Date-of-publication',
'Dewey-classification',
'Dissertation-information',
+ 'diss',
'EAN',
'extent',
'fic',
'popularity',
'pubdate',
'Publisher',
+ 'Provider',
+ 'pv',
'Record-control-number',
'rcn',
'Record-type',
if ( @limits ) {
$q .= ' and '.join(' and ', @limits);
}
- return ( undef, $q, $q, "q=ccl=".uri_escape($q), $q, '', '', '', '', 'ccl' );
+ return ( undef, $q, $q, "q=ccl=".uri_escape_utf8($q), $q, '', '', '', '', 'ccl' );
}
if ( $query =~ /^cql=/ ) {
- return ( undef, $', $', "q=cql=".uri_escape($'), $', '', '', '', '', 'cql' );
+ return ( undef, $', $', "q=cql=".uri_escape_utf8($'), $', '', '', '', '', 'cql' );
}
if ( $query =~ /^pqf=/ ) {
if ($query_desc) {
- $query_cgi = "q=".uri_escape($query_desc);
+ $query_cgi = "q=".uri_escape_utf8($query_desc);
} else {
$query_desc = $';
- $query_cgi = "q=pqf=".uri_escape($');
+ $query_cgi = "q=pqf=".uri_escape_utf8($');
}
return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' );
}
$remove_stopwords
) = ( 0, 0, 0, 0, 0 );
+ if ( $index eq 'nb' ) {
+ if ( C4::Context->preference("SearchWithISBNVariations") ) {
+ my @isbns = C4::Koha::GetVariationsOfISBN( $operand );
+ $operands[$i] = $operand = '(nb=' . join(' OR nb=', @isbns) . ')';
+ $indexes[$i] = $index = '';
+ }
+ }
}
if(not $index){
if ( $k !~ /mc-i(tem)?type/ ) {
# in case the mc-ccode value has complicating chars like ()'s inside it we wrap in quotes
$this_limit =~ tr/"//d;
- $this_limit = $k.":\"".$v."\"";
+ $this_limit = $k.":'".$v."'";
}
$group_OR_limits{$k} .= " or " if $group_OR_limits{$k};
$limit_desc .= " or " if $group_OR_limits{$k};
$group_OR_limits{$k} .= "$this_limit";
- $limit_cgi .= "&limit=" . uri_escape($this_limit);
+ $limit_cgi .= "&limit=" . uri_escape_utf8($this_limit);
$limit_desc .= " $this_limit";
}
else {
$limit .= " and " if $limit || $query;
$limit .= "$this_limit";
- $limit_cgi .= "&limit=" . uri_escape($this_limit);
+ $limit_cgi .= "&limit=" . uri_escape_utf8($this_limit);
if ($this_limit =~ /^branch:(.+)/) {
my $branchcode = $1;
my $branchname = GetBranchName($branchcode);
#e.g. " and kw,wrdl:test"
$params->{query} .= $operator . $operand;
- $params->{query_cgi} .= "&op=".uri_escape($operator) if $operator;
- $params->{query_cgi} .= "&idx=".uri_escape($params->{index}) if $params->{index};
- $params->{query_cgi} .= "&q=".uri_escape($params->{original_operand}) if $params->{original_operand};
+ $params->{query_cgi} .= "&op=".uri_escape_utf8($operator) if $operator;
+ $params->{query_cgi} .= "&idx=".uri_escape_utf8($params->{index}) if $params->{index};
+ $params->{query_cgi} .= "&q=".uri_escape_utf8($params->{original_operand}) if $params->{original_operand};
#e.g. " and kw,wrdl: test"
$params->{query_desc} .= $operator . $params->{index_plus} . " " . $params->{original_operand};
# get notforloan authorised value list (see $shelflocations FIXME)
my $notforloan_authorised_value = GetAuthValCode('items.notforloan','');
- #Build itemtype hash
- #find itemtype & itemtype image
- my %itemtypes;
- $bsth =
- $dbh->prepare(
- "SELECT itemtype,description,imageurl,summary,notforloan FROM itemtypes"
- );
- $bsth->execute();
- while ( my $bdata = $bsth->fetchrow_hashref ) {
- foreach (qw(description imageurl summary notforloan)) {
- $itemtypes{ $bdata->{'itemtype'} }->{$_} = $bdata->{$_};
- }
- }
+ #Get itemtype hash
+ my %itemtypes = %{ GetItemTypes() };
#search item field code
my ($itemtag, undef) = &GetMarcFromKohaField( "items.itemnumber", "" );
## find column names of items related to MARC
- my $sth2 = $dbh->prepare("SHOW COLUMNS FROM items");
- $sth2->execute;
my %subfieldstosearch;
- while ( ( my $column ) = $sth2->fetchrow ) {
+ my @columns = Koha::Database->new()->schema()->resultset('Item')->result_source->columns;
+ for my $column ( @columns ) {
my ( $tagfield, $tagsubfield ) =
&GetMarcFromKohaField( "items." . $column, "" );
if ( defined $tagsubfield ) {
: $bibliotag < 10
? GetFrameworkCode($marcrecord->field($bibliotag)->data)
: GetFrameworkCode($marcrecord->subfield($bibliotag,$bibliosubf));
+
+ SetUTF8Flag($marcrecord);
my $oldbiblio = TransformMarcToKoha( $dbh, $marcrecord, $fw );
$oldbiblio->{subtitle} = GetRecordValue('subtitle', $marcrecord, $fw);
$oldbiblio->{result_number} = $i + 1;
# edition information, if any
$oldbiblio->{edition} = $oldbiblio->{editionstatement};
- $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description};
+ $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{translated_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
if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
if($marcrecord->field($1)){
my @repl = $marcrecord->field($1)->subfield($2);
my $subfieldvalue = $repl[$i];
-
- if (! utf8::is_utf8($subfieldvalue)) {
- utf8::decode($subfieldvalue);
- }
-
- $newline =~ s/\[$tag\]/$subfieldvalue/g;
+ $newline =~ s/\[$tag\]/$subfieldvalue/g;
}
}
$newsummary .= "$newline\n";
foreach my $code ( keys %subfieldstosearch ) {
$item->{$code} = $field->subfield( $subfieldstosearch{$code} );
}
- $item->{description} = $itemtypes{ $item->{itype} }{description};
+ $item->{description} = $itemtypes{ $item->{itype} }{translated_description};
# OPAC hidden items
if ($is_opac) {
my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
my $userenv = C4::Context->userenv;
- if ( $item->{onloan} && !(C4::Members::GetHideLostItemsPreference($userenv->{'number'}) && $item->{itemlost}) ) {
+ if ( $item->{onloan}
+ && !( C4::Members::GetHideLostItemsPreference( $userenv->{'number'} ) && $item->{itemlost} ) )
+ {
$onloan_count++;
- my $key = $prefix . $item->{onloan} . $item->{barcode};
- $onloan_items->{$key}->{due_date} = format_date($item->{onloan});
- $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}->{description} = $item->{description};
- $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
+ my $key = $prefix . $item->{onloan} . $item->{barcode};
+ $onloan_items->{$key}->{due_date} = format_date( $item->{onloan} );
+ $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}->{description} = $item->{description};
+ $onloan_items->{$key}->{imageurl} =
+ getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} );
+
# if something's checked out and lost, mark it as 'long overdue'
if ( $item->{itemlost} ) {
- $onloan_items->{$prefix}->{longoverdue}++;
+ $onloan_items->{$key}->{longoverdue}++;
$longoverdue_count++;
- } else { # can place holds as long as item isn't lost
+ }
+ else { # can place holds as long as item isn't lost
$can_place_holds = 1;
}
}
# items not on loan, but still unavailable ( lost, withdrawn, damaged )
else {
+ $item->{notforloan}=1 if !$item->{notforloan} && $itemtypes{ C4::Context->preference("item-level_itypes")? $item->{itype}: $oldbiblio->{itemtype} }->{notforloan};
+
# item is on order
if ( $item->{notforloan} < 0 ) {
$ordered_count++;
# should map transit status to record indexed in Zebra.
#
($transfertwhen, $transfertfrom, $transfertto) = C4::Circulation::GetTransfers($item->{itemnumber});
- $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber}, $oldbiblio->{biblionumber} );
+ $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} );
}
# item is withdrawn, lost, damaged, not for loan, reserved or in transit
}
# XSLT processing of some stuff
- SetUTF8Flag($marcrecord);
- 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, $interface."XSLTResultsDisplay", 1, \@hiddenitems);
);
}
-sub PurgeSearchHistory{
- my ($pSearchhistory)=@_;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("DELETE FROM search_history WHERE time < DATE_SUB( NOW(), INTERVAL ? DAY )");
- $sth->execute($pSearchhistory) or die $dbh->errstr;
-}
-
=head2 z3950_search_args
$arrayref = z3950_search_args($matchpoints)
my $raw_data = shift;
# Set the default indexing modes
my $index_mode = ( $server eq 'biblioserver' )
- ? C4::Context->config('zebra_bib_index_mode') // 'grs1'
+ ? C4::Context->config('zebra_bib_index_mode') // 'dom'
: C4::Context->config('zebra_auth_index_mode') // 'dom';
my $marc_record = eval {