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).
44 use C4::Interface::CGI::Output;
54 my $dbh=C4::Context->dbh;
56 my $biblionumber=$query->param('bib');
57 my $bibid = $query->param('bibid');
58 $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless $bibid;
59 $biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless $biblionumber;
60 my $itemtype = &MARCfind_frameworkcode($dbh,$bibid);
61 my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
63 my $record =MARCgetbiblio($dbh,$bibid);
65 my ($template, $loggedinuser, $cookie)
66 = get_template_and_user({template_name => "catalogue/ISBDdetail.tmpl",
73 my $ISBD = C4::Context->preference('ISBD');
74 # my @blocs = split /\@/,$ISBD;
75 # my @fields = $record->fields();
77 # foreach my $bloc (@blocs) {
81 foreach my $isbdfield (split /#/,$bloc) {
82 warn "ISBDFIELD : $isbdfield";
83 # $isbdfield= /(.?.?.?)/;
84 $isbdfield =~ /(\d\d\d)\|(.*)\|(.*)\|(.*)/;
89 # warn "==> $1 / $2 / $3 / $4";
90 # my $fieldvalue=substr($isbdfield,0,3);
92 # warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue;
93 # warn "FV : $fieldvalue";
94 my $hasputtextbefore=0;
95 foreach my $field ($record->field($fieldvalue)) {
96 my $calculated = $analysestring;
97 my $tag = $field->tag();
100 my @subf = $field->subfields;
101 for my $i (0..$#subf) {
102 my $subfieldcode = $subf[$i][0];
103 my $subfieldvalue = $subf[$i][1];
104 my $tagsubf = $tag.$subfieldcode;
105 $calculated =~ s/\{(.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue\{$1$tagsubf$2\}$2/g;
107 # field builded, store the result
108 if ($calculated && !$hasputtextbefore) { # put textbefore if not done
109 $blocres .=$textbefore;
112 # remove punctuation at start
113 $calculated =~ s/^( |;|:|\.|-)*//g;
114 $blocres.=$calculated;
117 $blocres .=$textafter if $hasputtextbefore;
119 $blocres.=$isbdfield;
124 $res =~ s/\{(.*?)\}//g;
126 $res =~ s/\n/<br\/>/g;
129 $template->param(ISBD => $res,
130 biblionumber => $biblionumber);
132 output_html_with_http_headers $query, $cookie, $template->output;