@@ -, +, @@ appropriate location with the appropriate alignment and wrapping the display more attractive would be gratefully received. --- C4/AuthoritiesMarc.pm | 58 ++++++--- .../opac-tmpl/prog/en/modules/opac-auth-detail.tt | 153 ++++++++++++++++++++ opac/opac-authoritiesdetail.pl | 152 ++++++++++---------- 3 files changed, 270 insertions(+), 93 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt --- a/C4/AuthoritiesMarc.pm +++ a/C4/AuthoritiesMarc.pm @@ -1037,12 +1037,13 @@ sub BuildSummary { # // form foreach my $field ($record->field('7..')) { my $lang = substr($field->subfield('8'),3,3); - push @otherscript, { lang => $lang, term => $field->subfield('a') }; + push @otherscript, { lang => $lang, term => $field->subfield('a'), direction => 'ltr' }; } } else { # construct MARC21 summary # FIXME - looping over 1XX is questionable # since MARC21 authority should have only one 1XX + my $subfields_to_report; foreach my $field ($record->field('1..')) { my $tag = $field->tag(); next if "152" eq $tag; @@ -1050,34 +1051,37 @@ sub BuildSummary { # in MARC21 -- purely local tags really ought to be # 9XX if ($tag eq '100') { - push @authorized, $field->as_string('abcdefghjklmnopqrstvxyz68'); + $subfields_to_report = 'abcdefghjklmnopqrstvxyz'; } elsif ($tag eq '110') { - push @authorized, $field->as_string('abcdefghklmnoprstvxyz68'); + $subfields_to_report = 'abcdefghklmnoprstvxyz'; } elsif ($tag eq '111') { - push @authorized, $field->as_string('acdefghklnpqstvxyz68'); + $subfields_to_report = 'acdefghklnpqstvxyz'; } elsif ($tag eq '130') { - push @authorized, $field->as_string('adfghklmnoprstvxyz68'); + $subfields_to_report = 'adfghklmnoprstvxyz'; } elsif ($tag eq '148') { - push @authorized, $field->as_string('abvxyz68'); + $subfields_to_report = 'abvxyz'; } elsif ($tag eq '150') { - push @authorized, $field->as_string('abvxyz68'); + $subfields_to_report = 'abvxyz'; } elsif ($tag eq '151') { - push @authorized, $field->as_string('avxyz68'); + $subfields_to_report = 'avxyz'; } elsif ($tag eq '155') { - push @authorized, $field->as_string('abvxyz68'); + $subfields_to_report = 'abvxyz'; } elsif ($tag eq '180') { - push @authorized, $field->as_string('vxyz68'); + $subfields_to_report = 'vxyz'; } elsif ($tag eq '181') { - push @authorized, $field->as_string('vxyz68'); + $subfields_to_report = 'vxyz'; } elsif ($tag eq '182') { - push @authorized, $field->as_string('vxyz68'); + $subfields_to_report = 'vxyz'; } elsif ($tag eq '185') { - push @authorized, $field->as_string('vxyz68'); + $subfields_to_report = 'vxyz'; + } + if ($subfields_to_report) { + push @authorized, $field->as_string($subfields_to_report); } else { push @authorized, $field->as_string(); } - } #See From - foreach my $field ($record->field('4..')) { + } + foreach my $field ($record->field('4..')) { #See From my $type = 'seefrom'; $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w')); if ($type eq 'subfi') { @@ -1085,8 +1089,8 @@ sub BuildSummary { } else { push @seefrom, { heading => $field->as_string($marc21subfields), type => $type }; } - } #See Also - foreach my $field ($record->field('5..')) { + } + foreach my $field ($record->field('5..')) { #See Also my $type = 'seealso'; $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w')); if ($type eq 'subfi') { @@ -1098,7 +1102,27 @@ sub BuildSummary { foreach my $field ($record->field('6..')) { push @notes, $field->as_string(); } + foreach my $field ($record->field('880')) { + my $linkage = $field->subfield('6'); + my $category = substr $linkage, 0, 1; + if ($category eq '1') { + $category = 'preferred'; + } elsif ($category eq '4') { + $category = 'seefrom'; + } elsif ($category eq '5') { + $category = 'seealso'; + } + my $type; + if ($field->subfield('w')) { + $type = $marc21controlrefs{substr $field->subfield('w'), '0'}; + } else { + $type = $category; + } + my $direction = $linkage =~ m#/r$# ? 'rtl' : 'ltr'; + push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction }; + } } + $summary{mainentry} = $authorized[0]; $summary{authorized} = \@authorized; $summary{notes} = \@notes; $summary{seefrom} = \@seefrom; --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-auth-detail.tt @@ -0,0 +1,153 @@ +[% BLOCK authtypelabel %] + [% UNLESS ( type=='seefrom' || type=='seealso' || type=='' ) %] +  [% FILTER trim %][% SWITCH type %] + [% CASE 'earlier' %]earlier heading + [% CASE 'later' %]later heading + [% CASE 'acronym' %]acronym + [% CASE 'musical' %]musical composition + [% CASE 'broader' %]broader heading + [% CASE 'narrower' %]narrower heading + [% CASE %][% type %] + [% END %][% END %] + [% END %] +[% END %] +[% BLOCK otherscript %] + [% FOREACH heading IN headings %] + [% IF heading.category == wantcategory %] + [% IF heading.direction == 'ltr' %] +
+ [% heading.term %] +
+ [% ELSIF heading.direction == 'rtl' %] +
+ [% heading.term %] +
+ [% END %] + [% END %] + [% END %] +[% END %] +[% BLOCK authheadingdisplay %] + [% IF authid %][% heading %] + [% ELSIF search %][% heading %] + [% ELSE %][% heading %] + [% END %] +[% END %] +[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Entry +[% INCLUDE 'doc-head-close.inc' %] +[% IF ( displayhierarchy ) %] + +[% END %] + + + + +
+
+[% INCLUDE 'masthead.inc' %] +
+
+
+ +[% IF ( displayhierarchy ) %] + +
+[% FOREACH loophierarchie IN loophierarchies %] +
+ [% FOREACH loopelemen IN loophierarchie.loopelement %] +
+ [% IF ( loopelemen.current_value ) %] + [% loopelemen.value %] + [% ELSE %] + [% loopelemen.value %] + [% END %] + [% IF ( loopelemen.ifchildren ) %] + +
+ [% FOREACH loopchildre IN loopelemen.loopchildren %] + + [% END %] + [% END %] +
+ [% END %] + +
+[% END %] +
+[% END %] +

[% summary.mainentry %] ([% authtypetext %])

+[% FOREACH authorize IN summary.authorized %] +
Preferred form: [% authorize %]
+[% END %] +[% PROCESS otherscript headings=summary.otherscript wantcategory='preferred' %] +[% FOREACH seefro IN summary.seefrom %] +
Used for/see from[% PROCESS authtypelabel type=seefro.type | trim %]: + [% PROCESS authheadingdisplay heading=seefro.heading search=seefrosearch authid=seefro.authid %] +
+[% END %] +[% PROCESS otherscript headings=summary.otherscript wantcategory='seefrom' %] +[% FOREACH seeals IN summary.seealso %] +
See also[% PROCESS authtypelabel type=seeals.type | trim %]: + [% PROCESS authheadingdisplay heading=seeals.heading search=seeals.search authid=seeals.authid %] +
+[% END %] +[% PROCESS otherscript headings=summary.otherscript wantcategory='seealso' %] +[% IF marcflavour == 'UNIMARC' %] + [% FOREACH otherscrip IN summary.otherscript %] +
See also[% PROCESS language lang=otherscript.lang | trim %] term: + [% otherscrip.term %] +
+ [% END %] +[% END %] +

Used in [% count %] records

+
+ +
+
+[% FOREACH note IN summary.notes %] +

[% note %]

+[% END %] +
+
+
+
+
+ +
+
+
+[% IF ( OpacNav ) %] +
+
+[% INCLUDE 'navigation.inc' %] +
+
[% END %] +
+[% INCLUDE 'opac-bottom.inc' %] --- a/opac/opac-authoritiesdetail.pl +++ a/opac/opac-authoritiesdetail.pl @@ -53,7 +53,7 @@ my $query = new CGI; my $dbh = C4::Context->dbh; my $display_hierarchy = C4::Context->preference("AuthDisplayHierarchy"); -my $show_marc = $query->param('marc') || 1; # Currently only MARC view is available +my $show_marc = $query->param('marc'); # open template my ( $template, $loggedinuser, $cookie ) = get_template_and_user( @@ -68,8 +68,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $authid = $query->param('authid'); my $authtypecode = &GetAuthTypeCode( $authid ); -my $tagslib = &GetTagsLabels( 0, $authtypecode ); - my $record; if ($display_hierarchy){ @@ -101,90 +99,92 @@ else { } my $count = CountUsage($authid); -# find the marc field/subfield used in biblio by this authority -my $sth = - $dbh->prepare( - "select distinct tagfield from marc_subfield_structure where authtypecode=?" - ); -$sth->execute($authtypecode); -my $biblio_fields; -while ( my ($tagfield) = $sth->fetchrow ) { - $biblio_fields .= $tagfield . "9,"; + +my $authtypes = getauthtypes(); +my @authtypesloop = (); +foreach my $thisauthtype ( keys %{$authtypes} ) { + push @authtypesloop, + { value => $thisauthtype, + selected => $thisauthtype eq $authtypecode, + authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, + }; } -chop $biblio_fields; +$template->{VARS}->{'authtypesloop'} = \@authtypesloop; +$template->{VARS}->{'authtypetext'} = $authtypes->{$authtypecode}{'authtypetext'}; +$template->{VARS}->{'authid'} = $authid; +$template->{VARS}->{'count'} = $count; + +# find the marc field/subfield used in biblio by this authority +if ($show_marc) { + my $tagslib = &GetTagsLabels( 0, $authtypecode ); + my $sth = + $dbh->prepare( + "select distinct tagfield from marc_subfield_structure where authtypecode=?" + ); + $sth->execute($authtypecode); + my $biblio_fields; + while ( my ($tagfield) = $sth->fetchrow ) { + $biblio_fields .= $tagfield . "9,"; + } + chop $biblio_fields; # fill arrays -my @loop_data = (); -my $tag; + my @loop_data = (); + my $tag; -# loop through each tab 0 through 9 -# for (my $tabloop = 0; $tabloop<=10;$tabloop++) { # loop through each tag -my @fields = $record->fields(); -foreach my $field (@fields) { - my @subfields_data; - - # skip UNIMARC fields <200, they are useless for a patron - next if C4::Context->preference('MarcFlavour') eq 'UNIMARC' && $field->tag() <200; - - # if tag <10, there's no subfield, use the "@" trick - if ( $field->tag() < 10 ) { - next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} ); - my %subfield_data; - $subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib}; - $subfield_data{marc_value} = $field->data(); - $subfield_data{marc_subfield} = '@'; - $subfield_data{marc_tag} = $field->tag(); - push( @subfields_data, \%subfield_data ); - } - else { - my @subf = $field->subfields; - - # loop through each subfield - for my $i ( 0 .. $#subf ) { - $subf[$i][0] = "@" unless $subf[$i][0]; - next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} ); - # skip useless subfields (for patrons) - next if $subf[$i][0] =~ /7|8|9/; + my @fields = $record->fields(); + foreach my $field (@fields) { + my @subfields_data; + +# skip UNIMARC fields <200, they are useless for a patron + next if C4::Context->preference('MarcFlavour') eq 'UNIMARC' && $field->tag() <200; + +# if tag <10, there's no subfield, use the "@" trick + if ( $field->tag() < 10 ) { + next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} ); my %subfield_data; - $subfield_data{marc_lib} = - $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib}; - $subfield_data{marc_subfield} = $subf[$i][0]; + $subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib}; + $subfield_data{marc_value} = $field->data(); + $subfield_data{marc_subfield} = '@'; $subfield_data{marc_tag} = $field->tag(); - $subfield_data{isurl} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl}; - $subfield_data{marc_value} = $subf[$i][1]; push( @subfields_data, \%subfield_data ); } + else { + my @subf = $field->subfields; + +# loop through each subfield + for my $i ( 0 .. $#subf ) { + $subf[$i][0] = "@" unless $subf[$i][0]; + next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} ); +# skip useless subfields (for patrons) + next if $subf[$i][0] =~ /7|8|9/; + my %subfield_data; + $subfield_data{marc_lib} = + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib}; + $subfield_data{marc_subfield} = $subf[$i][0]; + $subfield_data{marc_tag} = $field->tag(); + $subfield_data{isurl} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl}; + $subfield_data{marc_value} = $subf[$i][1]; + push( @subfields_data, \%subfield_data ); + } + } + if ( $#subfields_data >= 0 ) { + my %tag_data; + $tag_data{tag} = + $field->tag() + . ' ' + . C4::Koha::display_marc_indicators($field) + . ' - ' . $tagslib->{ $field->tag() }->{lib}; + $tag_data{subfield} = \@subfields_data; + push( @loop_data, \%tag_data ); + } } - if ( $#subfields_data >= 0 ) { - my %tag_data; - $tag_data{tag} = - $field->tag() - . ' ' - . C4::Koha::display_marc_indicators($field) - . ' - ' . $tagslib->{ $field->tag() }->{lib}; - $tag_data{subfield} = \@subfields_data; - push( @loop_data, \%tag_data ); - } -} -$template->param( "Tab0XX" => \@loop_data ); - -my $authtypes = getauthtypes(); -my @authtypesloop = (); -foreach my $thisauthtype ( keys %{$authtypes} ) { - push @authtypesloop, - { value => $thisauthtype, - selected => $thisauthtype eq $authtypecode, - authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, - }; + $template->param( "Tab0XX" => \@loop_data ); +} else { + my $summary = BuildSummary($record, $authid, $authtypecode); + $template->{VARS}->{'summary'} = $summary; } -$template->param( - authid => $authid, - count => $count, - biblio_fields => $biblio_fields, - authtypetext => $authtypes->{$authtypecode}{'authtypetext'}, - authtypesloop => \@authtypesloop, -); output_html_with_http_headers $query, $cookie, $template->output; --