3aaaf2f2e4
The HTML for authority search results was previously generated in C4::AuthoritiesMarc::BuildSummary, which meant that it couldn't be translated. This patch moves the HTML generation into the templates by introducing a new authorities-search-results.inc include file for both the OPAC and the Intranet which contains a Template::Toolkit BLOCK for rendering the authority results. Fixes the authority autocomplete by removing the untranslatable strings, and returning only data from the database. To test: 1. Apply patch. 2. Test authority searching in the authority module in the staff client 3. Test authority searching in the authority control plugin in the cataloguing module (and the plugin for UNIMARC field 210$c, if you can figure out how) 4. Test authority searching in the OPAC Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Tested with MARC21 data. 1) Applies cleanly on current HEAD. 2) Authority search in staff Patch works wonderfully, only some small notes found while testing that have not been changed by this patch: ENH note: Search terms show up nowhere. So if I want to change the sorting, I have to repeat typing in my search term. Even if the form does not keep the term, it should be visible somewhere on the screen what I searched for. ENH note: The pagination on top and at the bottom of the result list are formatted differently. Maybe some missing CSS? ENH note: Also the authority type is not shown at all in the result list. 3) Cataloguing and authority plugins The autocomplete function works nicely. ENH note: There is only one small enhancement I could imagine. If I start my search from 100 it will limit the search to 'persons' but the autocomplete will also suggest other authorities. It would be a bit cleaner, if the autocomplete could limit by the appropriate authority type too. Very nice feature. Plugins overall work nicely. Created links include the authority numbers and work correctly. 4) Authority search in OPAC Works nicely. Display is consistent, but translatability greatly improved. ENH note: In staff we use 'Details' in OPAC we use 'View full heading' - I wonder if maybe 'details' would be better understandable for users? Note: Code reveals a system preference 'AuthDisplayHierarchy' that is not available in the system preference editor. I talked to Jared and he will work on this feature later on. For now it's no regression, as the preference has never been visible.
80 lines
2.6 KiB
Perl
Executable file
80 lines
2.6 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
# Copyright 2011 BibLibre
|
|
# Parts copyright 2012 Athens County Public Libraries
|
|
#
|
|
# 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 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.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
=head1 ysearch.pl
|
|
|
|
This script allows ajax call for dynamic authorities search
|
|
(used in auth_finder.pl)
|
|
|
|
=cut
|
|
|
|
use CGI;
|
|
use Modern::Perl;
|
|
use C4::Context;
|
|
use C4::Charset;
|
|
use C4::AuthoritiesMarc;
|
|
use C4::Auth qw/check_cookie_auth/;
|
|
|
|
my $query = new CGI;
|
|
|
|
binmode STDOUT, ':encoding(UTF-8)';
|
|
print $query->header( -type => 'text/plain', -charset => 'UTF-8' );
|
|
|
|
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } );
|
|
if ( $auth_status ne "ok" ) {
|
|
exit 0;
|
|
}
|
|
|
|
my $searchstr = $query->param('term');
|
|
my $searchtype = $query->param('querytype');
|
|
my @value;
|
|
given ($searchtype) {
|
|
when (/^marclist$/) { @value = (undef, undef, $searchstr); }
|
|
when (/^mainentry$/) { @value = (undef, $searchstr, undef); }
|
|
when (/^mainmainentry$/) { @value = ($searchstr, undef, undef); }
|
|
}
|
|
my @marclist = ($searchtype);
|
|
my $authtypecode = $query->param('authtypecode');
|
|
my @and_or = $query->param('and_or');
|
|
my @excluding = $query->param('excluding');
|
|
my @operator = $query->param('operator');
|
|
my $orderby = $query->param('orderby');
|
|
|
|
my $resultsperpage = 50;
|
|
my $startfrom = 0;
|
|
|
|
my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
|
|
|
|
print "[";
|
|
my $i = 0;
|
|
foreach my $result (@$results) {
|
|
if($i > 0){ print ","; }
|
|
my $value = '';
|
|
my $authorized = $result->{'summary'}->{authorized};
|
|
foreach my $heading (@$authorized) {
|
|
$value .= $heading . ' ';
|
|
}
|
|
$value = "{\"summary\":\"" . $value . "\"" . "}";
|
|
print nsb_clean($value) . "\n";
|
|
$i++;
|
|
}
|
|
print "]";
|