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 detail.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;
56 my $dbh=C4::Context->dbh;
59 my ($template, $loggedinuser, $cookie)
60 = get_template_and_user({template_name => "authorities/detail.tmpl",
64 flagsrequired => {catalogue => 1},
68 my $authid = $query->param('authid');
72 my $authtypecode = &GetAuthTypeCode($authid);
73 my $tagslib = &GetTagsLabels(1,$authtypecode);
76 if (C4::Context->preference("AuthDisplayHierarchy")){
77 my $trees=BuildUnimarcHierarchies($authid);
78 my @trees = split /;/,$trees ;
79 push @trees,$trees unless (@trees);
81 foreach my $tree (@trees){
82 my @tree=split /,/,$tree;
83 push @tree,$tree unless (@tree);
86 foreach my $element (@tree){
88 my $elementdata = GetAuthority($element);
89 $record= $elementdata if ($authid==$element);
90 push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
93 push @loophierarchies, { 'loopelement' =>\@loophierarchy};
96 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"),
97 'loophierarchies' =>\@loophierarchies,
100 $record=GetAuthority($authid);
102 my $count = CountUsage($authid);
104 # find the marc field/subfield used in biblio by this authority
105 my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
106 $sth->execute($authtypecode);
108 while (my ($tagfield) = $sth->fetchrow) {
109 $biblio_fields.= $tagfield."9,";
117 # loop through each tab 0 through 9
118 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
119 # loop through each tag
120 my @fields = $record->fields();
122 foreach my $field (@fields) {
124 # if tag <10, there's no subfield, use the "@" trick
125 if ($field->tag()<10) {
126 next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
128 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
129 $subfield_data{marc_value}=$field->data();
130 $subfield_data{marc_subfield}='@';
131 $subfield_data{marc_tag}=$field->tag();
132 push(@subfields_data, \%subfield_data);
134 my @subf=$field->subfields;
135 # loop through each subfield
136 for my $i (0..$#subf) {
137 $subf[$i][0] = "@" unless $subf[$i][0];
138 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
140 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
141 if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
142 $subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
144 $subfield_data{marc_value}=$subf[$i][1];
146 $subfield_data{short_desc} = substr(
147 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib},
150 $subfield_data{long_desc} =
151 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
152 $subfield_data{marc_subfield}=$subf[$i][0];
153 $subfield_data{marc_tag}=$field->tag();
154 push(@subfields_data, \%subfield_data);
157 if ($#subfields_data>=0) {
159 $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
160 $tag_data{subfield} = \@subfields_data;
161 push (@loop_data, \%tag_data);
164 $template->param("0XX" =>\@loop_data);
166 my $authtypes = getauthtypes;
168 foreach my $thisauthtype (keys %$authtypes) {
169 my $selected = 1 if $thisauthtype eq $authtypecode;
170 my %row =(value => $thisauthtype,
171 selected => $selected,
172 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
174 push @authtypesloop, \%row;
177 $template->param(authid => $authid,
179 biblio_fields => $biblio_fields,
180 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
181 authtypesloop => \@authtypesloop,
182 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
183 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
184 IntranetNav => C4::Context->preference("IntranetNav"),
186 output_html_with_http_headers $query, $cookie, $template->output;