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;
47 use C4::Interface::CGI::Output;
57 my $dbh=C4::Context->dbh;
60 my ($template, $loggedinuser, $cookie)
61 = get_template_and_user({template_name => "authorities/detail.tmpl",
65 flagsrequired => {catalogue => 1},
69 my $authid = $query->param('authid');
73 my $authtypecode = &GetAuthTypeCode($authid);
74 my $tagslib = &GetTagsLabels(1,$authtypecode);
77 if (C4::Context->preference("AuthDisplayHierarchy")){
78 my $trees=BuildUnimarcHierarchies($authid);
79 my @trees = split /;/,$trees ;
80 push @trees,$trees unless (@trees);
82 foreach my $tree (@trees){
83 my @tree=split /,/,$tree;
84 push @tree,$tree unless (@tree);
87 foreach my $element (@tree){
89 my $elementdata = GetAuthority($element);
90 $record= $elementdata if ($authid==$element);
91 push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
94 push @loophierarchies, { 'loopelement' =>\@loophierarchy};
97 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"),
98 'loophierarchies' =>\@loophierarchies,
101 $record=GetAuthority($authid);
103 my $count = CountUsage($authid);
105 # find the marc field/subfield used in biblio by this authority
106 my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
107 $sth->execute($authtypecode);
109 while (my ($tagfield) = $sth->fetchrow) {
110 $biblio_fields.= $tagfield."9,";
118 # loop through each tab 0 through 9
119 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
120 # loop through each tag
121 my @fields = $record->fields();
123 foreach my $field (@fields) {
125 # if tag <10, there's no subfield, use the "@" trick
126 if ($field->tag()<10) {
127 next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
129 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
130 $subfield_data{marc_value}=$field->data();
131 $subfield_data{marc_subfield}='@';
132 $subfield_data{marc_tag}=$field->tag();
133 push(@subfields_data, \%subfield_data);
135 my @subf=$field->subfields;
136 # loop through each subfield
137 for my $i (0..$#subf) {
138 $subf[$i][0] = "@" unless $subf[$i][0];
139 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
141 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
142 if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
143 $subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
145 $subfield_data{marc_value}=$subf[$i][1];
147 $subfield_data{short_desc} = substr(
148 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib},
151 $subfield_data{long_desc} =
152 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
153 $subfield_data{marc_subfield}=$subf[$i][0];
154 $subfield_data{marc_tag}=$field->tag();
155 push(@subfields_data, \%subfield_data);
158 if ($#subfields_data>=0) {
160 $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
161 $tag_data{subfield} = \@subfields_data;
162 push (@loop_data, \%tag_data);
165 $template->param("0XX" =>\@loop_data);
167 my $authtypes = getauthtypes;
169 foreach my $thisauthtype (keys %$authtypes) {
170 my $selected = 1 if $thisauthtype eq $authtypecode;
171 my %row =(value => $thisauthtype,
172 selected => $selected,
173 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
175 push @authtypesloop, \%row;
178 $template->param(authid => $authid,
180 biblio_fields => $biblio_fields,
181 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
182 authtypesloop => \@authtypesloop,
183 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
184 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
185 IntranetNav => C4::Context->preference("IntranetNav"),
187 output_html_with_http_headers $query, $cookie, $template->output;