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 $index = $query->param('index');
62 my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
63 my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
65 my $record =AUTHgetauthority($dbh,$authid);
67 my ($template, $loggedinuser, $cookie)
68 = get_template_and_user({template_name => "authorities/detail-biblio-search.tmpl",
72 flagsrequired => {catalogue => 1},
79 # loop through each tab 0 through 9
80 # for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
81 # loop through each tag
82 my @fields = $record->fields();
84 foreach my $field (@fields) {
86 # if tag <10, there's no subfield, use the "@" trick
87 if ($field->tag()<10) {
88 # next if ($tagslib->{$field->tag()}->{'@'}->{tab} ne $tabloop);
89 next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
91 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
92 $subfield_data{marc_value}=$field->data();
93 $subfield_data{marc_subfield}='@';
94 $subfield_data{marc_tag}=$field->tag();
95 push(@subfields_data, \%subfield_data);
97 my @subf=$field->subfields;
98 # loop through each subfield
99 for my $i (0..$#subf) {
100 $subf[$i][0] = "@" unless $subf[$i][0];
101 # next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
102 next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
104 $subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
105 if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
106 $subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
108 $subfield_data{marc_value}=$subf[$i][1];
110 $subfield_data{marc_subfield}=$subf[$i][0];
111 $subfield_data{marc_tag}=$field->tag();
112 push(@subfields_data, \%subfield_data);
115 if ($#subfields_data>=0) {
117 $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
118 $tag_data{subfield} = \@subfields_data;
119 push (@loop_data, \%tag_data);
122 $template->param("0XX" =>\@loop_data);
124 # now, build item tab !
125 # the main difference is that datas are in lines and not in columns : thus, we build the <th> first, then the values...
126 # loop through each tag
127 # warning : we may have differents number of columns in each row. Thus, we first build a hash, complete it if necessary
128 # then construct template.
129 # my @fields = $record->fields();
130 # my %witness; #---- stores the list of subfields used at least once, with the "meaning" of the code
132 # foreach my $field (@fields) {
133 # next if ($field->tag()<10);
134 # my @subf=$field->subfields;
136 # # loop through each subfield
137 # for my $i (0..$#subf) {
138 # next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne 10);
139 # $witness{$subf[$i][0]} = $tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
140 # $this_row{$subf[$i][0]} =$subf[$i][1];
143 # push(@big_array, \%this_row);
146 # #fill big_row with missing datas
147 # foreach my $subfield_code (keys(%witness)) {
148 # for (my $i=0;$i<=$#big_array;$i++) {
149 # $big_array[$i]{$subfield_code}=" " unless ($big_array[$i]{$subfield_code});
152 # # now, construct template !
153 # my @item_value_loop;
154 # my @header_value_loop;
155 # for (my $i=0;$i<=$#big_array; $i++) {
157 # foreach my $subfield_code (keys(%witness)) {
158 # $items_data .="<td>".$big_array[$i]{$subfield_code}."</td>";
161 # $row_data{item_value} = $items_data;
162 # push(@item_value_loop,\%row_data);
164 # foreach my $subfield_code (keys(%witness)) {
166 # $header_value{header_value} = $witness{$subfield_code};
167 # push(@header_value_loop, \%header_value);
170 my $authtypes = getauthtypes;
172 foreach my $thisauthtype (keys %$authtypes) {
173 my $selected = 1 if $thisauthtype eq $authtypecode;
174 my %row =(value => $thisauthtype,
175 selected => $selected,
176 authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
178 push @authtypesloop, \%row;
181 $template->param(authid => $authid,
182 authtypesloop => \@authtypesloop, index => $index,
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;