3 # Copyright 2000-2002 Katipo Communications
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 opac-authoritiesdetail.pl : script to show an authority in MARC format
30 This script needs an authid
32 It shows the authority in a (nice) MARC format depending on authority MARC
41 use C4
::AuthoritiesMarc
;
43 use C4
::Biblio
qw(GetMarcUrls);
50 use Koha
::Authorities
;
51 use Koha
::Authority
::Types
;
55 my $dbh = C4
::Context
->dbh;
57 my $display_hierarchy = C4
::Context
->preference("AuthDisplayHierarchy");
58 my $marcflavour = C4
::Context
->preference("marcflavour");
59 my $show_marc = $query->param('marc');
62 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
64 template_name
=> $show_marc ?
"opac-auth-MARCdetail.tt" : "opac-auth-detail.tt",
67 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
72 my $authid = $query->param('authid');
73 $authid = int($authid);
74 my $record = GetAuthority
( $authid );
76 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
80 my $authority = Koha
::Authorities
->find( $authid );
81 my $authtypecode = $authority ?
$authority->authtypecode : q{};
83 if ($display_hierarchy){
84 $template->{VARS
}->{'displayhierarchy'} = $display_hierarchy;
85 $template->{VARS
}->{'loophierarchies'} = GenerateHierarchy
($authid);
88 my $count = $authority ?
$authority->get_usage_count : 0;
90 my $authority_types = Koha
::Authority
::Types
->search( {}, { order_by
=> ['authtypecode'] } );
91 my $marcurlsarray = GetMarcUrls
( $record, $marcflavour );
94 authority_types
=> $authority_types,
95 authtypetext
=> $authority_types->find($authtypecode)->authtypetext,
98 MARCURLS
=> $marcurlsarray,
101 # find the marc field/subfield used in biblio by this authority
103 my $tagslib = &GetTagsLabels
( 0, $authtypecode );
106 "select distinct tagfield from marc_subfield_structure where authtypecode=?"
108 $sth->execute($authtypecode);
110 while ( my ($tagfield) = $sth->fetchrow ) {
111 $biblio_fields .= $tagfield . "9,";
118 # loop through each tag
119 my @fields = $record->fields();
120 foreach my $field (@fields) {
123 # skip UNIMARC fields <200, they are useless for a patron
124 next if $marcflavour eq 'UNIMARC' && $field->tag() <200;
126 # if tag <10, there's no subfield, use the "@" trick
127 if ( $field->tag() < 10 ) {
128 next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden
} );
130 $subfield_data{marc_lib
} = $tagslib->{ $field->tag() }->{'@'}->{lib
};
131 $subfield_data{marc_value
} = $field->data();
132 $subfield_data{marc_subfield
} = '@';
133 $subfield_data{marc_tag
} = $field->tag();
134 push( @subfields_data, \
%subfield_data );
136 elsif ( $marcflavour eq 'MARC21' && $field->tag() eq 667 ) {
137 # tagfield 667 is a nonpublic general note in MARC21, which shouldn't be shown in the OPAC
140 my @subf = $field->subfields;
142 # loop through each subfield
143 for my $i ( 0 .. $#subf ) {
144 $subf[$i][0] = "@" unless defined $subf[$i][0];
145 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden
} );
146 # skip useless subfields (for patrons)
147 next if $subf[$i][0] =~ /7|8|9/;
149 $subfield_data{marc_lib
} =
150 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib
};
151 $subfield_data{marc_subfield
} = $subf[$i][0];
152 $subfield_data{marc_tag
} = $field->tag();
153 $subfield_data{isurl
} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl
};
154 $subfield_data{marc_value
} = $subf[$i][1];
155 push( @subfields_data, \
%subfield_data );
158 if ( $#subfields_data >= 0 ) {
163 . C4
::Koha
::display_marc_indicators
($field)
164 . ' - ' . $tagslib->{ $field->tag() }->{lib
};
165 $tag_data{subfield
} = \
@subfields_data;
166 push( @loop_data, \
%tag_data );
169 $template->param( "Tab0XX" => \
@loop_data );
171 my $summary = BuildSummary
($record, $authid, $authtypecode);
172 $template->{VARS
}->{'summary'} = $summary;
175 output_html_with_http_headers
$query, $cookie, $template->output;