=head1 NAME
-etail.pl : script to show an authority in MARC format
+detail.pl : script to show an authority in MARC format
=head1 SYNOPSIS
use C4::Auth;
use C4::Context;
use C4::Output;
-use C4::Interface::CGI::Output;
use CGI;
-use C4::Search;
use MARC::Record;
use C4::Koha;
# use C4::Biblio;
# use C4::Catalogue;
-use HTML::Template;
+
my $query=new CGI;
my $dbh=C4::Context->dbh;
+# open template
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "authorities/detail.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {catalogue => 1},
+ debug => 1,
+ });
+
my $authid = $query->param('authid');
-my $authtypecode = &AUTHfind_authtypecode($dbh,$authid);
-my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode);
-my $record =AUTHgetauthority($dbh,$authid);
-my $count = AUTHcount_usage($authid);
+
+
+my $authtypecode = &GetAuthTypeCode($authid);
+my $tagslib = &GetTagsLabels(1,$authtypecode);
+
+my $record;
+if (C4::Context->preference("AuthDisplayHierarchy")){
+ my $trees=BuildUnimarcHierarchies($authid);
+ my @trees = split /;/,$trees ;
+ push @trees,$trees unless (@trees);
+ my @loophierarchies;
+ foreach my $tree (@trees){
+ my @tree=split /,/,$tree;
+ push @tree,$tree unless (@tree);
+ my $cnt=0;
+ my @loophierarchy;
+ foreach my $element (@tree){
+ my $cell;
+ my $elementdata = GetAuthority($element);
+ $record= $elementdata if ($authid==$element);
+ push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid);
+ $cnt++;
+ }
+ push @loophierarchies, { 'loopelement' =>\@loophierarchy};
+ }
+ $template->param(
+ 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"),
+ 'loophierarchies' =>\@loophierarchies,
+ );
+} else {
+ $record=GetAuthority($authid);
+}
+my $count = CountUsage($authid);
# find the marc field/subfield used in biblio by this authority
my $sth = $dbh->prepare("select distinct tagfield from marc_subfield_structure where authtypecode=?");
}
chop $biblio_fields;
-# open template
-my ($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "authorities/detail.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {catalogue => 1},
- debug => 1,
- });
# fill arrays
my @loop_data =();
} else {
$subfield_data{marc_value}=$subf[$i][1];
}
+ $subfield_data{short_desc} = substr(
+ $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib},
+ 0, 20
+ );
+ $subfield_data{long_desc} =
+ $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
$subfield_data{marc_subfield}=$subf[$i][0];
$subfield_data{marc_tag}=$field->tag();
push(@subfields_data, \%subfield_data);