Bugzilla – Attachment 19551 Details for
Bug 9282
authorities auto-completion in mainmainentry
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9282: authorities auto-completion in mainmainentry
Bug-9282-authorities-auto-completion-in-mainmainen.patch (text/plain), 8.31 KB, created by
Marcel de Rooy
on 2013-07-11 09:36:23 UTC
(
hide
)
Description:
Bug 9282: authorities auto-completion in mainmainentry
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-07-11 09:36:23 UTC
Size:
8.31 KB
patch
obsolete
>From 4fb2ff6abfb3684139cb5f2e6963df0e7f934c9f Mon Sep 17 00:00:00 2001 >From: Fridolyn SOMERS <fridolyn.somers@biblibre.com> >Date: Thu, 13 Dec 2012 14:38:11 +0100 >Subject: [PATCH] Bug 9282: authorities auto-completion in mainmainentry >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr> >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Works as advertised. >Tested with an authority where I added my search term in $b. >The modified authority came up in main entry, not in mainmainentry. >That was the desired result. >--- > C4/AuthoritiesMarc.pm | 59 ++++++++++++++++++++++++++++++++++++----------- > authorities/ysearch.pl | 39 +++++++++++++++++++++---------- > 2 files changed, 71 insertions(+), 27 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 9ea3b2d..3702356 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -953,7 +953,11 @@ sub BuildSummary { > # construct UNIMARC summary, that is quite different from MARC21 one > # accepted form > foreach my $field ($record->field('2..')) { >- push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() }; >+ push @authorized, { >+ heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), >+ hemain => $field->subfield('a'), >+ field => $field->tag(), >+ }; > } > # rejected form(s) > foreach my $field ($record->field('3..')) { >@@ -961,7 +965,12 @@ sub BuildSummary { > } > foreach my $field ($record->field('4..')) { > my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : ''; >- push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() }; >+ push @seefrom, { >+ heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), >+ hemain => $field->subfield('a'), >+ type => 'seefrom', >+ field => $field->tag(), >+ }; > } > > # see : >@@ -972,6 +981,7 @@ sub BuildSummary { > field => $_->tag, > type => $type, > heading => $heading, >+ hemain => $_->subfield('a'), > search => $heading, > authid => $_->subfield('9'), > } >@@ -1022,9 +1032,17 @@ sub BuildSummary { > $subfields_to_report = 'vxyz'; > } > if ($subfields_to_report) { >- push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag }; >+ push @authorized, { >+ heading => $field->as_string($subfields_to_report), >+ hemain => $field->subfield( substr($subfields_to_report, 0, 1) ), >+ field => $tag, >+ }; > } else { >- push @authorized, { heading => $field->as_string(), field => $tag }; >+ push @authorized, { >+ heading => $field->as_string(), >+ hemain => $field->subfield('a'), >+ field => $tag, >+ }; > } > } > foreach my $field ($record->field('4..')) { #See From >@@ -1035,9 +1053,19 @@ sub BuildSummary { > $type = 'earlier' if $type && $type ne 'n'; > } > if ($type eq 'subfi') { >- push @seefrom, { heading => $field->as_string($marc21subfields), type => ($field->subfield('i') || ''), field => $field->tag() }; >+ push @seefrom, { >+ heading => $field->as_string($marc21subfields), >+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ), >+ type => ($field->subfield('i') || ''), >+ field => $field->tag(), >+ }; > } else { >- push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; >+ push @seefrom, { >+ heading => $field->as_string($marc21subfields), >+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ), >+ type => $type, >+ field => $field->tag(), >+ }; > } > } > foreach my $field ($record->field('5..')) { #See Also >@@ -1050,18 +1078,20 @@ sub BuildSummary { > if ($type eq 'subfi') { > push @seealso, { > heading => $field->as_string($marc21subfields), >- type => $field->subfield('i'), >- field => $field->tag(), >- search => $field->as_string($marc21subfields) || '', >- authid => $field->subfield('9') || '' >+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ), >+ type => $field->subfield('i'), >+ field => $field->tag(), >+ search => $field->as_string($marc21subfields) || '', >+ authid => $field->subfield('9') || '' > }; > } else { > push @seealso, { > heading => $field->as_string($marc21subfields), >- type => $type, >- field => $field->tag(), >- search => $field->as_string($marc21subfields) || '', >- authid => $field->subfield('9') || '' >+ hemain => $field->subfield( substr($marc21subfields, 0, 1) ), >+ type => $type, >+ field => $field->tag(), >+ search => $field->as_string($marc21subfields) || '', >+ authid => $field->subfield('9') || '' > }; > } > } >@@ -1089,6 +1119,7 @@ sub BuildSummary { > } > } > $summary{mainentry} = $authorized[0]->{heading}; >+ $summary{mainmainentry} = $authorized[0]->{hemain}; > $summary{authorized} = \@authorized; > $summary{notes} = \@notes; > $summary{seefrom} = \@seefrom; >diff --git a/authorities/ysearch.pl b/authorities/ysearch.pl >index 6584123..7996c6d 100755 >--- a/authorities/ysearch.pl >+++ b/authorities/ysearch.pl >@@ -29,18 +29,22 @@ This script allows ajax call for dynamic authorities search > > use CGI; > use Modern::Perl; >+use JSON; >+ > use C4::Context; > use C4::Charset; > use C4::AuthoritiesMarc; > use C4::Auth qw/check_cookie_auth/; >+use C4::Output; > > 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'), { catalogue => 1 } ); > >-my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } ); > if ( $auth_status ne "ok" ) { >+ # send empty response >+ my $reply = CGI->new(""); >+ print $reply->header(-type => 'text/html'); > exit 0; > } > >@@ -64,17 +68,26 @@ if ( $auth_status ne "ok" ) { > > my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby ); > >-print "["; >-my $i = 0; >+ my %used_summaries; # hash to avoid duplicates >+ my @summaries; > foreach my $result (@$results) { >- if($i > 0){ print ","; } >- my $value = ''; > my $authorized = $result->{'summary'}->{'authorized'}; >- foreach my $heading (@$authorized) { >- $value .= $heading->{'heading'} . ' '; >+ my $summary = join( >+ ' ', >+ map { >+ ( $searchtype eq 'mainmainentry' ) >+ ? $_->{'hemain'} >+ : $_->{'heading'} >+ } @$authorized >+ ); >+ $summary =~ s/^\s+//; >+ $summary =~ s/\s+$//; >+ $summary = nsb_clean($summary); >+ # test if already added ignoring case >+ unless ( exists $used_summaries{ lc($summary) } ) { >+ push @summaries, { 'summary' => $summary }; >+ $used_summaries{ lc($summary) } = 1; > } >- $value = "{\"summary\":\"" . $value . "\"" . "}"; >- print nsb_clean($value) . "\n"; >- $i++; > } >-print "]"; >+ >+output_with_http_headers $query, undef, to_json(\@summaries, { utf8 => 1 }), 'json'; >-- >1.7.7.6
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9282
:
14073
|
14075
|
14734
|
14735
| 19551 |
19552