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 $authid = $query->param('authid');
56 my $authtypecode = &GetAuthTypeCode
( $authid );
57 my $tagslib = &GetTagsLabels
( 1, $authtypecode );
60 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
62 template_name
=> "opac-authoritiesdetail.tmpl",
65 authnotrequired
=> ( C4
::Context
->preference("OpacPublic") ?
1 : 0 ),
71 if (C4
::Context
->preference("AuthDisplayHierarchy")){
72 my $trees=BuildUnimarcHierarchies
($authid);
73 my @trees = split /;/,$trees ;
74 push @trees,$trees unless (@trees);
76 foreach my $tree (@trees){
77 my @tree=split /,/,$tree;
78 push @tree,$tree unless (@tree);
81 foreach my $element (@tree){
83 my $elementdata = GetAuthority
($element);
84 $record= $elementdata if ($authid==$element);
85 push @loophierarchy, BuildUnimarcHierarchy
($elementdata,"child".$cnt, $authid);
88 push @loophierarchies, { 'loopelement' =>\
@loophierarchy};
91 'displayhierarchy' =>C4
::Context
->preference("AuthDisplayHierarchy"),
92 'loophierarchies' =>\
@loophierarchies,
96 $record = GetAuthority
( $authid );
98 my $count = CountUsage
($authid);
100 # find the marc field/subfield used in biblio by this authority
103 "select distinct tagfield from marc_subfield_structure where authtypecode=?"
105 $sth->execute($authtypecode);
107 while ( my ($tagfield) = $sth->fetchrow ) {
108 $biblio_fields .= $tagfield . "9,";
116 # loop through each tab 0 through 9
117 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
118 # loop through each tag
119 my @fields = $record->fields();
120 foreach my $field (@fields) {
123 # skip UNIMARC fields <200, they are useless for a patron
124 next if C4
::Context
->preference('MarcFlavour') eq 'UNIMARC' && $field->tag() <200;
126 # if tag <10, there's no subfield, use the "@" trick
127 if ( $field->tag() < 10 ) {
128 next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden
} );
130 $subfield_data{marc_lib
} = $tagslib->{ $field->tag() }->{'@'}->{lib
};
131 $subfield_data{marc_value
} = $field->data();
132 $subfield_data{marc_subfield
} = '@';
133 $subfield_data{marc_tag
} = $field->tag();
134 push( @subfields_data, \
%subfield_data );
137 my @subf = $field->subfields;
139 # loop through each subfield
140 for my $i ( 0 .. $#subf ) {
141 $subf[$i][0] = "@" unless $subf[$i][0];
142 next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden
} );
143 # skip useless subfields (for patrons)
144 next if $subf[$i][0] =~ /7|8|9/;
146 $subfield_data{marc_lib
} =
147 $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib
};
148 if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl
} ) {
149 $subfield_data{marc_value
} =
150 "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
153 $subfield_data{marc_value
} = $subf[$i][1];
155 $subfield_data{marc_subfield
} = $subf[$i][0];
156 $subfield_data{marc_tag
} = $field->tag();
157 push( @subfields_data, \
%subfield_data );
160 if ( $#subfields_data >= 0 ) {
165 . C4
::Koha
::display_marc_indicators
($field)
166 . ' - ' . $tagslib->{ $field->tag() }->{lib
};
167 $tag_data{subfield
} = \
@subfields_data;
168 push( @loop_data, \
%tag_data );
171 $template->param( "Tab0XX" => \
@loop_data );
173 my $authtypes = getauthtypes
();
174 my @authtypesloop = ();
175 foreach my $thisauthtype ( keys %{$authtypes} ) {
177 { value
=> $thisauthtype,
178 selected
=> $thisauthtype eq $authtypecode,
179 authtypetext
=> $authtypes->{$thisauthtype}{'authtypetext'},
186 biblio_fields
=> $biblio_fields,
187 authtypetext
=> $authtypes->{$authtypecode}{'authtypetext'},
188 authtypesloop
=> \
@authtypesloop,
189 LibraryName
=> C4
::Context
->preference("LibraryName"),
190 OpacNav
=> C4
::Context
->preference("OpacNav"),
191 opaccredits
=> C4
::Context
->preference("opaccredits"),
192 opacsmallimage
=> C4
::Context
->preference("opacsmallimage"),
193 opaclayoutstylesheet
=> C4
::Context
->preference("opaclayoutstylesheet"),
194 opaccolorstylesheet
=> C4
::Context
->preference("opaccolorstylesheet"),
196 output_html_with_http_headers
$query, $cookie, $template->output;