use OpenSRF::Utils::Logger qw/$logger/;
use OpenILS::Utils::CStoreEditor qw/:funcs/;
use OpenILS::Utils::Fieldmapper;
+use OpenILS::Utils::Normalize qw/search_normalize/;
use OpenILS::Application::AppUtils;
use OpenSRF::Utils::JSON;
use OpenSRF::Utils::Cache;
);
}
-sub find_authority_headings {
+# Break out any Public General Notes (field 680) for display and
+# hyperlinking. These are sometimes (erroneously?) called "scope notes."
+# I say erroneously, tentatively, because LoC doesn't seem to document
+# a "scope notes" field for authority records, while it does so for
+# classification records, which are something else. But I am not a
+# librarian.
+sub extract_public_general_notes {
+ my ($self, $record, $row) = @_;
+
+ my @notes;
+ foreach my $note ($record->field('680')) {
+ my @note;
+ my $last_heading;
+
+ foreach my $subfield ($note->subfields) {
+ my ($code, $value) = @$subfield;
+
+ if ($code eq 'i') {
+ push @note, $value;
+ } elsif ($code eq '5') {
+ if ($last_heading) {
+ my $org = $self->ctx->{get_aou_by_shortname}->($value);
+ $last_heading->{org_id} = $org->id if $org;
+ }
+ push @note, { institution => $value };
+ } elsif ($code eq 'a') {
+ $last_heading = {
+ heading => $value, bterm => search_normalize($value)
+ };
+ push @note, $last_heading;
+ }
+ }
+
+ push @notes, \@note if @note;
+ }
+
+ $row->{notes} = \@notes;
+}
+
+sub find_authority_headings_and_notes {
my ($self, $row) = @_;
my $acsaf_table =
# a fuss.
}
- foreach my $acsaf (values(%$acsaf_table)) {
+ $self->extract_public_general_notes($record, $row);
+
+ # By applying grep in this way, we get acsaf objects that *have* and
+ # therefore *aren't* main entries, which is what we want.
+ foreach my $acsaf (grep { $_->main_entry } values(%$acsaf_table)) {
my @fields = $record->field($acsaf->tag);
my @headings;
push @headings, $h;
}
- # Remember: main_entry is a link field, so for it to evaluate
- # to true means that we *have* (and therefore *aren't*) a main
- # entry. The rest of the time when main_entry is undef we
- # *are* a main entry.
- #
- # For this, we only want non-main entries.
- push @{$row->{headings}}, {$acsaf->id => \@headings}
- if @headings and $acsaf->main_entry;
+ push @{$row->{headings}}, {$acsaf->id => \@headings} if @headings;
}
return $row;
# out non-main-entry headings. Build the headings and make a
# combined data structure for the template's use.
my %linked_headings_by_auth_id = map {
- $_->{id} => $self->find_authority_headings($_)
+ $_->{id} => $self->find_authority_headings_and_notes($_)
} @$linked;
# Graft this authority heading data onto our main result set at the
[% IF result.authorities %]
<ul class="browse-result-authority-headings">
[% FOR a IN result.authorities;
- NEXT UNLESS a.control_set; # Can't deal.
+ PROCESS authority_notes authority=a;
+
+ # Other than displaying public general
+ # notes, we can go no further sans
+ # control_set.
+ NEXT UNLESS a.control_set;
# get_authority_fields is fast and cache-y.
acs = ctx.get_authority_fields(a.control_set);
<div class="common-full-pad"></div>
</div>
</div>
+
+ [% BLOCK authority_notes;
+ # Displays public general notes (sometimes called "scope notes" ?)
+ FOR note IN authority.notes %]
+ <div class="browse-public-general-note">
+ <span class="browse-public-general-note-label">
+ [% l("Note:") %]
+ </span>
+ <span class="browse-public-general-note-body">
+ [% FOR piece IN note;
+ IF piece.heading;
+ mkurl_args = {bterm => piece.bterm};
+ IF piece.org_id;
+ mkurl_args.locg = piece.org_id;
+ END;
+ %]
+ <a href="[% mkurl('', mkurl_args, ['boffset','bpivot','bback']) %]">[% piece.heading | html %]</a>
+ [% ELSIF piece.institution %]
+ <span class="browse-public-general-note-institution">
+ [% piece.institution | html %]
+ </span>
+ [% ELSE %]
+ [% piece | html %]
+ [% END;
+ END %]
+ </span>
+ </div>
+ [% END;
+ END; # end of BLOCK authority_notes %]
+
[% END %]