X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=cataloguing%2Faddbooks.pl;h=1d52bb800794260e64588ce870d31cb409df0fa4;hb=4927671b15d6d1f95a84257ef293872e1c0c9665;hp=b08f1e5dce4ccb942d894480e4ffdae4a88325dc;hpb=59f31b98361046af37646485f652f70e16a2e206;p=koha.git diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl index b08f1e5dce..1d52bb8007 100755 --- a/cataloguing/addbooks.pl +++ b/cataloguing/addbooks.pl @@ -5,18 +5,18 @@ # # 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 . =head1 cataloguing:addbooks.pl @@ -26,7 +26,7 @@ use strict; use warnings; -use CGI; +use CGI qw ( -utf8 ); use C4::Auth; use C4::Biblio; use C4::Breeding; @@ -34,47 +34,50 @@ use C4::Output; use C4::Koha; use C4::Search; +use Koha::BiblioFrameworks; +use Koha::SearchEngine::Search; +use Koha::SearchEngine::QueryBuilder; + my $input = new CGI; my $success = $input->param('biblioitem'); my $query = $input->param('q'); -my @value = $input->param('value'); +my @value = $input->multi_param('value'); my $page = $input->param('page') || 1; my $results_per_page = 20; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => "cataloguing/addbooks.tmpl", + template_name => "cataloguing/addbooks.tt", query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => { editcatalogue => 'edit_catalogue' }, + flagsrequired => { editcatalogue => '*' }, debug => 1, } ); -# get framework list -my $frameworks = getframeworks; -my @frameworkcodeloop; -foreach my $thisframeworkcode ( sort {$frameworks->{$a} cmp $frameworks->{$b}}keys %{$frameworks} ) { - push @frameworkcodeloop, { - value => $thisframeworkcode, - frameworktext => $frameworks->{$thisframeworkcode}->{'frameworktext'}, - }; -} - - # Searching the catalog. if ($query) { # build query my @operands = $query; - my (@operators, @indexes, @sort_by, @limits) = (); - my ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,@limits,\@sort_by,undef,undef); + my $QParser; + $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser')); + my $builtquery; + my $builder = Koha::SearchEngine::QueryBuilder->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + my $searcher = Koha::SearchEngine::Search->new( + { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); + if ($QParser) { + $builtquery = $query; + } else { + ( undef,$builtquery,undef,undef,undef,undef,undef,undef,undef,undef) = $builder->build_query_compat(undef,\@operands); + } # find results - my ( $error, $marcresults, $total_hits ) = SimpleSearch($builtquery, $results_per_page * ($page - 1), $results_per_page); + my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page); if ( defined $error ) { $template->param( error => $error ); @@ -85,8 +88,8 @@ if ($query) { # format output # SimpleSearch() give the results per page we want, so 0 offet here - my $total = scalar @$marcresults; - my @newresults = searchResults( $query, $total, $results_per_page, 0, 0, @$marcresults ); + my $total = @{$marcresults}; + my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults ); $template->param( total => $total_hits, query => $query, @@ -105,7 +108,9 @@ if ($query) { #check is on isbn legnth 13 for new isbn and 10 for old isbn my ( $title, $isbn ); if ($query=~/\d/) { - my $querylength = length $query; + my $clean_query = $query; + $clean_query =~ s/-//g; # remove hyphens + my $querylength = length $clean_query; if ( $querylength == 13 || $querylength == 10 ) { $isbn = $query; } @@ -128,8 +133,9 @@ for my $resultsbr (@resultsbr) { }; } +my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); $template->param( - frameworkcodeloop => \@frameworkcodeloop, + frameworks => $frameworks, breeding_count => $countbr, breeding_loop => $breeding_loop, z3950_search_params => C4::Search::z3950_search_args($query),