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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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
42 use C4
::AuthoritiesMarc
;
53 my $dbh = C4
::Context
->dbh;
55 my $display_hierarchy = C4
::Context
->preference("AuthDisplayHierarchy");
56 my $show_marc = $query->param('marc');
59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
61 template_name
=> $show_marc ?
"opac-auth-MARCdetail.tt" : "opac-auth-detail.tt",
64 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
69 my $authid = $query->param('authid');
70 $authid = int($authid);
71 my $record = GetAuthority
( $authid );
73 print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
77 my $authtypecode = &GetAuthTypeCode
( $authid );
79 if ($display_hierarchy){
80 $template->{VARS
}->{'displayhierarchy'} = $display_hierarchy;
81 $template->{VARS
}->{'loophierarchies'} = GenerateHierarchy
($authid);
84 my $count = CountUsage
($authid);
87 my $authtypes = getauthtypes
();
88 my @authtypesloop = ();
89 foreach my $thisauthtype ( keys %{$authtypes} ) {
91 { value
=> $thisauthtype,
92 selected
=> $thisauthtype eq $authtypecode,
93 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
96 $template->{VARS
}->{'authtypesloop'} = \
@authtypesloop;
97 $template->{VARS
}->{'authtypetext'} = $authtypes->{$authtypecode}{'authtypetext'};
98 $template->{VARS
}->{'authid'} = $authid;
99 $template->{VARS
}->{'count'} = $count;
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,";
119 # loop through each tag
120 my @fields = $record->fields();
121 foreach my $field (@fields) {
124 # skip UNIMARC fields <200, they are useless for a patron
125 next if C4
::Context
->preference('marcflavour') eq 'UNIMARC' && $field->tag() <200;
127 # if tag <10, there's no subfield, use the "@" trick
128 if ( $field->tag() < 10 ) {
129 next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden
} );
131 $subfield_data{marc_lib
} = $tagslib->{ $field->tag() }->{'@'}->{lib
};
132 $subfield_data{marc_value
} = $field->data();
133 $subfield_data{marc_subfield
} = '@';
134 $subfield_data{marc_tag
} = $field->tag();
135 push( @subfields_data, \
%subfield_data );
137 elsif ( C4
::Context
->preference('marcflavour') eq 'MARC21' && $field->tag() eq 667 ) {
138 # tagfield 667 is a nonpublic general note in MARC21, which shouldn't be shown in the OPAC
141 my @subf = $field->subfields;
143 # loop through each subfield
144 for my $i ( 0 .. $#subf ) {
145 $subf[$i][0] = "@" unless defined $subf[$i][0];
146 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden
} );
147 # skip useless subfields (for patrons)
148 next if $subf[$i][0] =~ /7|8|9/;
150 $subfield_data{marc_lib
} =
151 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib
};
152 $subfield_data{marc_subfield
} = $subf[$i][0];
153 $subfield_data{marc_tag
} = $field->tag();
154 $subfield_data{isurl
} = $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl
};
155 $subfield_data{marc_value
} = $subf[$i][1];
156 push( @subfields_data, \
%subfield_data );
159 if ( $#subfields_data >= 0 ) {
164 . C4
::Koha
::display_marc_indicators
($field)
165 . ' - ' . $tagslib->{ $field->tag() }->{lib
};
166 $tag_data{subfield
} = \
@subfields_data;
167 push( @loop_data, \
%tag_data );
170 $template->param( "Tab0XX" => \
@loop_data );
172 my $summary = BuildSummary
($record, $authid, $authtypecode);
173 $template->{VARS
}->{'summary'} = $summary;
176 output_html_with_http_headers
$query, $cookie, $template->output;