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
42 use C4::AuthoritiesMarc;
46 use C4::Interface::CGI::Output;
54 my $dbh = C4::Context->dbh;
56 my $authid = $query->param('authid');
57 my $authtypecode = &AUTHfind_authtypecode( $dbh, $authid );
58 my $tagslib = &AUTHgettagslib( $dbh, 1, $authtypecode );
61 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63 template_name => "opac-authoritiesdetail.tmpl",
72 if ( C4::Context->preference("AuthDisplayHierarchy") ) {
73 my $trees = BuildUnimarcHierarchies($authid);
75 # warn "trees :$trees";
76 my @trees = split /;/, $trees;
77 push @trees, $trees unless (@trees);
79 foreach my $tree (@trees) {
83 my @tree = split /,/, $tree;
84 push @tree, $tree unless (@tree);
87 foreach my $element (@tree) {
89 # warn "tree :$element";
91 my $elementdata = AUTHgetauthority( $dbh, $element );
92 $record = $elementdata if ( $authid == $element );
94 BuildUnimarcHierarchy( $elementdata, "child" . $cnt, $authid );
97 push @loophierarchies, { 'loopelement' => \@loophierarchy };
100 C4::Context->preference("AuthDisplayHierarchy"),
101 'loophierarchies' => \@loophierarchies,
106 $record = AUTHgetauthority( $dbh, $authid );
108 my $count = AUTHcount_usage($authid);
110 # find the marc field/subfield used in biblio by this authority
113 "select distinct tagfield from marc_subfield_structure where authtypecode=?"
115 $sth->execute($authtypecode);
117 while ( my ($tagfield) = $sth->fetchrow ) {
118 $biblio_fields .= $tagfield . "9,";
126 # loop through each tab 0 through 9
127 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
128 # loop through each tag
129 my @fields = $record->fields();
130 foreach my $field (@fields) {
133 # if tag <10, there's no subfield, use the "@" trick
134 if ( $field->tag() < 10 ) {
135 next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} );
137 $subfield_data{marc_lib} = $tagslib->{ $field->tag() }->{'@'}->{lib};
138 $subfield_data{marc_value} = $field->data();
139 $subfield_data{marc_subfield} = '@';
140 $subfield_data{marc_tag} = $field->tag();
141 push( @subfields_data, \%subfield_data );
144 my @subf = $field->subfields;
146 # loop through each subfield
147 for my $i ( 0 .. $#subf ) {
148 $subf[$i][0] = "@" unless $subf[$i][0];
149 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} );
151 $subfield_data{marc_lib} =
152 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
153 if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl} ) {
154 $subfield_data{marc_value} =
155 "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
158 $subfield_data{marc_value} = $subf[$i][1];
160 $subfield_data{marc_subfield} = $subf[$i][0];
161 $subfield_data{marc_tag} = $field->tag();
162 push( @subfields_data, \%subfield_data );
165 if ( $#subfields_data >= 0 ) {
168 $field->tag() . ' -' . $tagslib->{ $field->tag() }->{lib};
169 $tag_data{subfield} = \@subfields_data;
170 push( @loop_data, \%tag_data );
173 $template->param( "0XX" => \@loop_data );
175 my $authtypes = getauthtypes;
177 foreach my $thisauthtype ( keys %$authtypes ) {
178 my $selected = 1 if $thisauthtype eq $authtypecode;
180 value => $thisauthtype,
181 selected => $selected,
182 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
184 push @authtypesloop, \%row;
190 biblio_fields => $biblio_fields,
191 authtypetext => $authtypes->{$authtypecode}{'authtypetext'},
192 authtypesloop => \@authtypesloop,
193 LibraryName => C4::Context->preference("LibraryName"),
194 OpacNav => C4::Context->preference("OpacNav"),
195 opaccredits => C4::Context->preference("opaccredits"),
196 opacsmallimage => C4::Context->preference("opacsmallimage"),
197 opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
198 opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
200 output_html_with_http_headers $query, $cookie, $template->output;