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 with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
22 etail.pl : script to show an authority in MARC format
29 This script needs an authid
31 It shows the authority in a (nice) MARC format depending on authority MARC
43 use C4::AuthoritiesMarc;
47 use C4::Interface::CGI::Output;
58 my $dbh=C4::Context->dbh;
60 my $authid = $query->param('authid');
61 my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
62 my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
64 my $record =AUTHgetauthority($dbh,$authid);
65 my $count = AUTHcount_usage($authid);
67 # find the marc field/subfield used in biblio by this authority
68 my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
69 $sth->execute($authtypecode);
71 while (my ($tagfield) = $sth->fetchrow) {
72 $biblio_fields.= $tagfield."9,";
77 my ($template, $loggedinuser, $cookie)
78 = get_template_and_user({template_name => "authorities/detail.tmpl",
82 flagsrequired => {catalogue => 1},
89 # loop through each tab 0 through 9
90 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
91 # loop through each tag
92 my @fields = $record->fields();
94 foreach my $field (@fields) {
96 # if tag <10, there's no subfield, use the "@" trick
97 if ($field->tag()<10) {
98 next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
100 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
101 $subfield_data{marc_value}=$field->data();
102 $subfield_data{marc_subfield}='@';
103 $subfield_data{marc_tag}=$field->tag();
104 push(@subfields_data, \%subfield_data);
106 my @subf=$field->subfields;
107 # loop through each subfield
108 for my $i (0..$#subf) {
109 $subf[$i][0] = "@" unless $subf[$i][0];
110 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
112 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
113 if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
114 $subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
116 $subfield_data{marc_value}=$subf[$i][1];
118 $subfield_data{marc_subfield}=$subf[$i][0];
119 $subfield_data{marc_tag}=$field->tag();
120 push(@subfields_data, \%subfield_data);
123 if ($#subfields_data>=0) {
125 $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
126 $tag_data{subfield} = \@subfields_data;
127 push (@loop_data, \%tag_data);
130 $template->param("0XX" =>\@loop_data);
132 my $authtypes = getauthtypes;
134 foreach my $thisauthtype (keys %$authtypes) {
135 my $selected = 1 if $thisauthtype eq $authtypecode;
136 my %row =(value => $thisauthtype,
137 selected => $selected,
138 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
140 push @authtypesloop, \%row;
143 $template->param(authid => $authid,
145 biblio_fields => $biblio_fields,
146 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
147 authtypesloop => \@authtypesloop);
148 output_html_with_http_headers $query, $cookie, $template->output;