# 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.
#
my $query = new CGI;
-binmode STDOUT, ":utf8";
+binmode STDOUT, ':encoding(UTF-8)';
print $query->header( -type => 'text/plain', -charset => 'UTF-8' );
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } );
exit 0;
}
- my $searchstr = $query->param('query');
+ my $searchstr = $query->param('term');
my $searchtype = $query->param('querytype');
my @value;
given ($searchtype) {
my $startfrom = 0;
my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
- foreach (@$results) {
- my ($value) = $_->{'summary'};
- # Removes new lines
- $value =~ s/<br \/>/ /g;
- $value =~ s/\n//g;
- print nsb_clean($value) . "\n";
+
+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->{'heading'} . ' ';
+ }
+ $value = "{\"summary\":\"" . $value . "\"" . "}";
+ print nsb_clean($value) . "\n";
+ $i++;
}
+print "]";