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 ISBDdetail.pl : script to show a biblio in ISBD format
29 This script needs a biblionumber in bib parameter (bibnumber
30 from koha style DB. Automaticaly maps to marc biblionumber).
43 use C4::AuthoritiesMarc;
44 use C4::Interface::CGI::Output;
53 my $dbh=C4::Context->dbh;
55 my $biblionumber=$query->param('biblionumber');
57 my $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber);
58 my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
60 my $record =XMLgetbibliohash($dbh,$biblionumber);
62 my ($template, $loggedinuser, $cookie)
63 = get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",
70 my $ISBD = C4::Context->preference('ISBD');
74 foreach my $isbdfield (split /#/,$bloc) {
75 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
81 my $hasputtextbefore=0;
83 my $calculated = $analysestring;
84 my $tag = $fieldvalue;
86 my $value=XML_readline_onerecord($record,"","",$tag);
87 my $subfieldcode = "@";
88 my $subfieldvalue = get_authorised_value_desc($tag, $subf[$i][0], $value, '', $dbh);;
89 my $tagsubf = $tag.$subfieldcode;
90 $calculated =~ s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
93 my @subf = XML_readline_withtags($record,"","",$tag);
94 for my $i (0..$#subf) {
95 my $subfieldcode = $subf[$i][0];
96 my $subfieldvalue = get_authorised_value_desc($tag, $subf[$i][0], $subf[$i][1], '', $dbh);;
97 my $tagsubf = $tag.$subfieldcode;
98 $calculated =~ s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
100 # field builded, store the result
101 if ($calculated && !$hasputtextbefore) { # put textbefore if not done
102 $blocres .=$textbefore;
105 # remove punctuation at start
106 $calculated =~ s/^( |;|:|\.|-)*//g;
107 $blocres.=$calculated;
110 $blocres .=$textafter if $hasputtextbefore;
112 $blocres.=$isbdfield;
117 $res =~ s/\{(.*?)\}//g;
119 $res =~ s/\n/<br\/>/g;
122 $template->param(ISBD => $res,
123 biblionumber => $biblionumber);
125 output_html_with_http_headers $query, $cookie, $template->output;
127 sub get_authorised_value_desc ($$$$$) {
128 my($tag, $subfield, $value, $framework, $dbh) = @_;
131 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
132 return getbranchname($value);
136 if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
137 return ItemType($value);
140 #---- "true" authorized value
141 my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
143 if ($category ne "") {
144 my $sth = $dbh->prepare("select lib from authorised_values where category = ? and authorised_value = ?");
145 $sth->execute($category, $value);
146 my $data = $sth->fetchrow_hashref;
147 return $data->{'lib'};
149 return $value; # if nothing is found return the original value