2004-07-05 13:29:35 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
# Copyright 2000-2002 Katipo Communications
|
|
|
|
#
|
|
|
|
# This file is part of Koha.
|
|
|
|
#
|
2015-04-08 15:09:04 +00:00
|
|
|
# Koha is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
2004-07-05 13:29:35 +00:00
|
|
|
#
|
2015-04-08 15:09:04 +00:00
|
|
|
# Koha is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2004-07-05 13:29:35 +00:00
|
|
|
#
|
2015-04-08 15:09:04 +00:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
2004-07-05 13:29:35 +00:00
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
2010-11-11 13:18:47 +00:00
|
|
|
detail-biblio-search.pl - script to show an authority in MARC format
|
2004-07-05 13:29:35 +00:00
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
2010-11-11 13:18:47 +00:00
|
|
|
=cut
|
2004-07-05 13:29:35 +00:00
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
This script needs an authid
|
|
|
|
|
|
|
|
It shows the authority in a (nice) MARC format depending on authority MARC
|
|
|
|
parameters tables.
|
|
|
|
|
|
|
|
=head1 FUNCTIONS
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
2019-01-17 00:51:11 +00:00
|
|
|
use Modern::Perl;
|
2008-09-17 12:07:51 +00:00
|
|
|
|
2016-11-09 12:06:44 +00:00
|
|
|
use C4::Auth qw( get_template_and_user );
|
2021-08-03 12:35:18 +00:00
|
|
|
use C4::AuthoritiesMarc qw( GetAuthority GetTagsLabels );
|
2004-07-05 13:29:35 +00:00
|
|
|
use C4::Context;
|
2016-11-09 12:06:44 +00:00
|
|
|
use C4::Output qw( output_html_with_http_headers );
|
2014-03-14 14:26:16 +00:00
|
|
|
use CGI qw ( -utf8 );
|
2007-03-09 14:28:54 +00:00
|
|
|
# use C4::Biblio;
|
|
|
|
# use C4::Catalogue;
|
|
|
|
|
2015-12-15 13:43:47 +00:00
|
|
|
use Koha::Authorities;
|
2015-12-15 13:19:53 +00:00
|
|
|
use Koha::Authority::Types;
|
2004-07-05 13:29:35 +00:00
|
|
|
|
2020-06-29 17:07:54 +00:00
|
|
|
my $query=CGI->new;
|
2004-07-05 13:29:35 +00:00
|
|
|
|
|
|
|
my $dbh=C4::Context->dbh;
|
|
|
|
|
|
|
|
my $authid = $query->param('authid');
|
|
|
|
my $index = $query->param('index');
|
2015-12-15 13:43:47 +00:00
|
|
|
my $authtypecode = Koha::Authorities->find($authid)->authtypecode;
|
2021-08-03 12:35:18 +00:00
|
|
|
my $tagslib = GetTagsLabels(1,$authtypecode);
|
2004-07-05 13:29:35 +00:00
|
|
|
|
2007-04-06 14:48:45 +00:00
|
|
|
my $record =GetAuthority($authid);
|
2004-07-05 13:29:35 +00:00
|
|
|
# open template
|
2014-07-09 13:36:39 +00:00
|
|
|
my ($template, $loggedinuser, $cookie) = get_template_and_user(
|
|
|
|
{
|
|
|
|
template_name => "authorities/detail-biblio-search.tt",
|
|
|
|
query => $query,
|
|
|
|
type => "intranet",
|
|
|
|
flagsrequired => { catalogue => 1 },
|
|
|
|
}
|
|
|
|
);
|
2004-07-05 13:29:35 +00:00
|
|
|
|
|
|
|
# fill arrays
|
|
|
|
my @loop_data =();
|
|
|
|
# loop through each tab 0 through 9
|
2007-03-09 14:28:54 +00:00
|
|
|
# for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
|
2004-07-05 13:29:35 +00:00
|
|
|
# loop through each tag
|
2007-12-04 23:40:52 +00:00
|
|
|
my @fields = $record->fields();
|
2007-03-09 14:28:54 +00:00
|
|
|
foreach my $field (@fields) {
|
|
|
|
my @subfields_data;
|
|
|
|
# if tag <10, there's no subfield, use the "@" trick
|
|
|
|
if ($field->tag()<10) {
|
|
|
|
# next if ($tagslib->{$field->tag()}->{'@'}->{tab} ne $tabloop);
|
|
|
|
next if ($tagslib->{$field->tag()}->{'@'}->{hidden});
|
2004-07-05 13:29:35 +00:00
|
|
|
my %subfield_data;
|
2007-03-09 14:28:54 +00:00
|
|
|
$subfield_data{marc_lib}=$tagslib->{$field->tag()}->{'@'}->{lib};
|
|
|
|
$subfield_data{marc_value}=$field->data();
|
|
|
|
$subfield_data{marc_subfield}='@';
|
|
|
|
$subfield_data{marc_tag}=$field->tag();
|
2004-07-05 13:29:35 +00:00
|
|
|
push(@subfields_data, \%subfield_data);
|
2007-03-09 14:28:54 +00:00
|
|
|
} else {
|
|
|
|
my @subf=$field->subfields;
|
|
|
|
# loop through each subfield
|
|
|
|
for my $i (0..$#subf) {
|
2012-08-31 14:02:27 +00:00
|
|
|
$subf[$i][0] = "@" unless defined $subf[$i][0];
|
2007-03-09 14:28:54 +00:00
|
|
|
# next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
|
|
|
|
next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
|
|
|
|
my %subfield_data;
|
|
|
|
$subfield_data{marc_lib}=$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
|
|
|
|
if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{isurl}) {
|
|
|
|
$subfield_data{marc_value}="<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
|
2004-07-05 13:29:35 +00:00
|
|
|
} else {
|
2007-03-09 14:28:54 +00:00
|
|
|
$subfield_data{marc_value}=$subf[$i][1];
|
|
|
|
}
|
|
|
|
$subfield_data{marc_subfield}=$subf[$i][0];
|
|
|
|
$subfield_data{marc_tag}=$field->tag();
|
|
|
|
push(@subfields_data, \%subfield_data);
|
2006-09-06 16:21:03 +00:00
|
|
|
}
|
2007-03-09 14:28:54 +00:00
|
|
|
}
|
2004-07-05 13:29:35 +00:00
|
|
|
if ($#subfields_data>=0) {
|
|
|
|
my %tag_data;
|
2007-03-09 14:28:54 +00:00
|
|
|
$tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
|
|
|
|
$tag_data{subfield} = \@subfields_data;
|
2004-07-05 13:29:35 +00:00
|
|
|
push (@loop_data, \%tag_data);
|
|
|
|
}
|
|
|
|
}
|
2007-03-09 14:28:54 +00:00
|
|
|
$template->param("0XX" =>\@loop_data);
|
2004-07-05 13:29:35 +00:00
|
|
|
|
2015-12-15 13:19:53 +00:00
|
|
|
my $authority_types = Koha::Authority::Types->search( {}, { order_by => ['authtypetext'] } );
|
|
|
|
|
|
|
|
$template->param(
|
|
|
|
authid => $authid,
|
|
|
|
authority_types => $authority_types,
|
|
|
|
index => $index,
|
|
|
|
);
|
2004-07-05 13:29:35 +00:00
|
|
|
output_html_with_http_headers $query, $cookie, $template->output;
|
|
|
|
|