[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] koha/catalogue MARCdetail.pl detail.pl
From: |
Tumer Garip |
Subject: |
[Koha-cvs] koha/catalogue MARCdetail.pl detail.pl |
Date: |
Fri, 01 Sep 2006 15:36:42 +0000 |
CVSROOT: /sources/koha
Module name: koha
Changes by: Tumer Garip <tgarip1957> 06/09/01 15:36:42
Modified files:
catalogue : MARCdetail.pl detail.pl
Log message:
Read XML. Sytem preference retrive_from to wheter read from SQL DB or
ZEBRA DB
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/MARCdetail.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/detail.pl?cvsroot=koha&r1=1.6&r2=1.7
Patches:
Index: MARCdetail.pl
===================================================================
RCS file: /sources/koha/koha/catalogue/MARCdetail.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- MARCdetail.pl 10 Aug 2006 13:23:09 -0000 1.5
+++ MARCdetail.pl 1 Sep 2006 15:36:42 -0000 1.6
@@ -46,43 +46,44 @@
use strict;
-require Exporter;
use C4::Auth;
use C4::Context;
use C4::Output;
use C4::Interface::CGI::Output;
use CGI;
-use C4::Koha;
-use MARC::Record;
+use C4::Search;
use C4::Biblio;
use C4::Acquisition;
use C4::Serials; #uses getsubscriptionsfrombiblionumber
-use HTML::Template;
-use C4::Search;
+use C4::Koha;
my $query=new CGI;
my $dbh=C4::Context->dbh;
-
+my $retrieve_from=C4::Context->preference('retrieve_from');
my $biblionumber=$query->param('biblionumber');
-if (!$biblionumber){
- $biblionumber = $query->param('bib');
-}
-# my $bibid = $query->param('bibid');
-my $itemtype = $query->param('frameworkcode');
+my $frameworkcode = $query->param('frameworkcode');
my $popup = $query->param('popup'); # if set to 1, then don't insert links,
it's just to show the biblio
+my $record;
+my @itemrecords;
+my $xmlhash;
+$frameworkcode=MARCfind_frameworkcode($dbh,$biblionumber);
+my $tagslib = &MARCgettagslib($dbh,1,$frameworkcode);
+my $itemstagslib = &MARCitemsgettagslib($dbh,1,$frameworkcode);
+
+if ($retrieve_from eq "zebra"){
+($xmlhash,@itemrecords)=ZEBRAgetrecord($biblionumber);
+
+}else{
+ $record =XMLgetbiblio($dbh,$biblionumber);
+$xmlhash=XML_xml2hash_onerecord($record);
+my @itemxmls=XMLgetallitems($dbh,$biblionumber);
+ foreach my $itemrecord(@itemxmls){
+ my $itemhash=XML_xml2hash($itemrecord);
+ push @itemrecords, $itemhash;
+ }
+}
-# $bibid = &MARCfind_MARCbibid_from_oldbiblionumber($dbh,$biblionumber) unless
$bibid;
-# $biblionumber = &MARCfind_oldbiblionumber_from_MARCbibid($dbh,$bibid) unless
$biblionumber;
-# $itemtype = &MARCfind_frameworkcode($dbh,$biblionumber) if not ($itemtype);
-# $itemtype = '' if ($itemtype eq 'Default');
-# warn "itemtype :".$itemtype;
-
-my $tagslib = &MARCgettagslib($dbh,1,$itemtype);
-#my $record = C4::Search::get_record($biblionumber);
-
-my $record =MARCgetbiblio($dbh,$biblionumber);
-# open template
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name =>
"catalogue/MARCdetail.tmpl",
query => $query,
@@ -93,7 +94,7 @@
});
#Getting the list of all frameworks
-my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from
biblio_framework");
+my $queryfwk =$dbh->prepare("select frameworktext, frameworkcode from
biblios_framework");
$queryfwk->execute;
my %select_fwk;
my @select_fwk;
@@ -104,7 +105,7 @@
push @select_fwk, $fwk;
$select_fwk{$fwk} = $description;
}
-$curfwk=$itemtype;
+$curfwk=$frameworkcode;
my $framework=CGI::scrolling_list( -name => 'Frameworks',
-id => 'Frameworks',
-default => $curfwk,
@@ -119,18 +120,22 @@
my @loop_data =();
my $tag;
# loop through each tab 0 through 9
-for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
+##Only attempt to fill the template if we actually received a MARC record
+if ($xmlhash){
+my ($isbntag,$isbnsub)=MARCfind_marc_from_kohafield("isbn","biblios");
+my $biblio=$xmlhash->{'datafield'};
+my $controlfields=$xmlhash->{'controlfield'};
+my $leader=$xmlhash->{'leader'};
+for (my $tabloop = 0; $tabloop<10;$tabloop++) {
# loop through each tag
- my @fields = $record->fields();
my @loop_data =();
my @subfields_data;
+
# deal with leader
- unless ($tagslib->{'000'}->{'@'}->{tab} ne $tabloop) { # or
($tagslib->{'000'}->{'@'}->{hidden}==(-7|-4|-3|-2|2|3|5|8))) {
+ unless (($tagslib->{'000'}->{'@'}->{tab} ne $tabloop) ||
(substr($tagslib->{'000'}->{'@'}->{hidden},1,1)>0)) {
+
my %subfield_data;
- $subfield_data{marc_lib}=$tagslib->{'000'}->{'@'}->{lib};
- $subfield_data{marc_value}=$record->leader();
- $subfield_data{marc_subfield}='@';
- $subfield_data{marc_tag}='000';
+ $subfield_data{marc_value}=$leader->[0] ;
push(@subfields_data, \%subfield_data);
my %tag_data;
$tag_data{tag}='000 -'. $tagslib->{'000'}->{lib};
@@ -139,58 +144,68 @@
push (@loop_data, \%tag_data);
undef @subfields_data;
}
- my @fields = $record->fields();
- for (my $x_i=0;$x_i<=$#fields;$x_i++) {
- # if tag <10, there's no subfield, use the "@" trick
- if ($fields[$x_i]->tag()<10) {
- next if ($tagslib->{$fields[$x_i]->tag()}->{'@'}->{tab}
ne $tabloop);
- next if
($tagslib->{$fields[$x_i]->tag()}->{'@'}->{hidden});
+ ##Controlfields
+
+ foreach my $control (@$controlfields){
my %subfield_data;
-
$subfield_data{marc_lib}=$tagslib->{$fields[$x_i]->tag()}->{'@'}->{lib};
- $subfield_data{marc_value}=$fields[$x_i]->data();
- $subfield_data{marc_subfield}='@';
- $subfield_data{marc_tag}=$fields[$x_i]->tag();
+ my %tag_data;
+ next if ($tagslib->{$control->{'tag'}}->{'@'}->{tab}
ne $tabloop);
+ next if
(substr($tagslib->{$control->{'tag'}}->{'@'}->{hidden},1,1)>0);
+ $subfield_data{marc_value}=$control->{'content'} ;
push(@subfields_data, \%subfield_data);
+ if (C4::Context->preference('hide_marc')) {
+
$tag_data{tag}=$tagslib->{$control->{'tag'}}->{lib};
} else {
- my @subf=$fields[$x_i]->subfields;
- # loop through each subfield
- for my $i (0..$#subf) {
- $subf[$i][0] = "@" unless $subf[$i][0];
- next if
($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{tab} ne $tabloop);
- next if
($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{hidden});
+ $tag_data{tag}=$control->{'tag'}.' -'.
$tagslib->{$control->{'tag'}}->{lib};
+ }
+ my @tmp = @subfields_data;
+ $tag_data{subfield} = address@hidden;
+ push (@loop_data, \%tag_data);
+ undef @subfields_data;
+ }
+ my $previoustag;
+ my %datatags;
+ my $i=0;
+ foreach my $data (@$biblio){
+ $datatags{$i++}=$data->{'tag'};
+ foreach my $subfield ( $data->{'subfield'}){
+ foreach my $code ( @$subfield){
+ next if
($tagslib->{$data->{'tag'}}->{$code->{'code'}}->{tab} ne $tabloop);
+ next if
(substr($tagslib->{$data->{'tag'}}->{$code->{'code'}}->{hidden},1,1)>0);
my %subfield_data;
-
$subfield_data{marc_lib}=$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{lib};
-
$subfield_data{link}=$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{link};
-# warn "tag :
".$tagslib->{$fields[$x_i]->tag()}." subfield
:".$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}."lien koha? :
"$subfield_data{link};
- if
($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{isurl}) {
- $subfield_data{marc_value}="<a
href=\"$subf[$i][1]\">$subf[$i][1]</a>";
- } elsif
($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{kohafield} eq
"biblioitems.isbn") {
-# warn " tag :
".$tagslib->{$fields[$x_i]->tag()}." subfield
:".$tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}. "ISBN :
".$subf[$i][1]."PosttraitementISBN :".DisplayISBN($subf[$i][1]);
-
$subfield_data{marc_value}=DisplayISBN($subf[$i][1]);
+ my $value=$code->{'content'};
+
$subfield_data{marc_lib}=$tagslib->{$data->{'tag'}}->{$code->{'code'}}->{lib};
+
$subfield_data{link}=$tagslib->{$data->{'tag'}}->{$code->{'code'}}->{link};
+ if
($tagslib->{$data->{'tag'}}->{$code->{'code'}}->{isurl}) {
+ $subfield_data{marc_value}="<a
href=\"$value]\">$value</a>";
+ } elsif ($data->{'tag'} eq $isbntag && $code->{'code'}
eq $isbnsub) {
+ $subfield_data{marc_value}=DisplayISBN($value);
} else {
- if
($tagslib->{$fields[$x_i]->tag()}->{$subf[$i][0]}->{authtypecode}) {
-
$subfield_data{authority}=$fields[$x_i]->subfield(9);
+ if
($tagslib->{$data->{'tag'}}->{$code->{'code'}}->{authtypecode}) {
+ my
($authtag,$authtagsub)=MARCfind_marc_from_kohafield("auth_authid","biblios");
+
$subfield_data{authority}=XML_readline_onerecord($xmlhash,"","",$data->{'tag'},$authtagsub);
}
-
$subfield_data{marc_value}=get_authorised_value_desc($fields[$x_i]->tag(),
$subf[$i][0], $subf[$i][1], '', $dbh);
+
$subfield_data{marc_value}=get_authorised_value_desc($data->{'tag'},
$code->{'code'}, $value, '', $dbh);
}
- $subfield_data{marc_subfield}=$subf[$i][0];
- $subfield_data{marc_tag}=$fields[$x_i]->tag();
+ $subfield_data{marc_subfield}=$code->{'code'};
+ $subfield_data{marc_tag}=$data->{'tag'};
push(@subfields_data, \%subfield_data);
- }
- }
+ }### $code
+
+
if ($#subfields_data==0) {
- $subfields_data[0]->{marc_lib}='';
- $subfields_data[0]->{marc_subfield}='';
+ # $subfields_data[0]->{marc_lib}='';
+ # $subfields_data[0]->{marc_subfield}='';
}
if ($#subfields_data>=0) {
my %tag_data;
- if ($fields[$x_i]->tag() eq $fields[$x_i-1]->tag()) {
+ if (($datatags{$i} eq $datatags{$i-1}) &&
(C4::Context->preference('LabelMARCView') eq 'economical')) {
$tag_data{tag}="";
} else {
if (C4::Context->preference('hide_marc')) {
-
$tag_data{tag}=$tagslib->{$fields[$x_i]->tag()}->{lib};
+
$tag_data{tag}=$tagslib->{$data->{'tag'}}->{lib};
} else {
- $tag_data{tag}=$fields[$x_i]->tag().' -'.
$tagslib->{$fields[$x_i]->tag()}->{lib};
+ $tag_data{tag}=$data->{'tag'}.' -'.
$tagslib->{$data->{'tag'}}->{lib};
}
}
my @tmp = @subfields_data;
@@ -198,7 +213,9 @@
push (@loop_data, \%tag_data);
undef @subfields_data;
}
+ }### each $subfield
}
+
$template->param($tabloop."XX" =>address@hidden);
}
# now, build item tab !
@@ -206,25 +223,43 @@
# loop through each tag
# warning : we may have differents number of columns in each row. Thus, we
first build a hash, complete it if necessary
# then construct template.
-my @fields = $record->fields();
+my @fields;
my %witness; #---- stores the list of subfields used at least once, with the
"meaning" of the code
my @big_array;
-foreach my $field (@fields) {
- next if ($field->tag()<10);
- my @subf=$field->subfields;
- my %this_row;
-# loop through each subfield
- for my $i (0..$#subf) {
- next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{tab} ne
10);
- next if ($tagslib->{$field->tag()}->{$subf[$i][0]}->{hidden});
- $witness{$subf[$i][0]} =
$tagslib->{$field->tag()}->{$subf[$i][0]}->{lib};
- $this_row{$subf[$i][0]} =$subf[$i][1];
+foreach my $itemrecord (@itemrecords){
+my $item=$itemrecord->{'datafield'};
+my $controlfields=$itemrecord->{'controlfield'};
+my $leader=$itemrecord->{'leader'};
+my %this_row;
+ ### The leader
+ unless (substr($itemstagslib->{'000'}->{'@'}->{hidden},1,1)>0){
+ my @datasub='000@';
+ $witness{$datasub[0]} =
$itemstagslib->{'000'}->{'@'}->{lib};
+ $this_row{$datasub[0]} =$leader->[0];
+ }
+ foreach my $control (@$controlfields){
+ next if ($itemstagslib->{$control->{'tag'}}->{'@'}->{tab} ne
10);
+ next if
(substr($itemstagslib->{$control->{'tag'}}->{'@'}->{hidden},1,1)>0);
+ my @datasub=$control->{'tag'}.'@';
+ $witness{$datasub[0]} =
$itemstagslib->{$control->{'tag'}}->{'@'}->{lib};
+ $this_row{$datasub[0]} =$control->{'content'};
+ }
+
+ foreach my $data (@$item){
+ foreach my $subfield ( $data->{'subfield'}){
+ foreach my $code ( @$subfield){
+ next if
($itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{tab} ne 10);
+ next if
(substr($itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{hidden},1,1)>0);
+ $witness{$data->{'tag'}.$code->{'code'}} =
$itemstagslib->{$data->{'tag'}}->{$code->{'code'}}->{lib};
+ $this_row{$data->{'tag'}.$code->{'code'}}
=$code->{'content'};
}
+ }# subfield
+ }## each field
if (%this_row) {
push(@big_array, \%this_row);
}
-}
-my ($holdingbrtagf,$holdingbrtagsubf) =
&MARCfind_marc_from_kohafield($dbh,"items.holdingbranch",$itemtype);
+}## each record
+my ($holdingbrtagf,$holdingbrtagsubf) =
&MARCfind_marc_from_kohafield("holdingbranch","holdings");
@big_array = sort {$a->{$holdingbrtagsubf} cmp $b->{$holdingbrtagsubf}}
@big_array;
#fill big_row with missing datas
@@ -251,7 +286,7 @@
push(@header_value_loop, \%header_value);
}
-my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
+my $subscriptionsnumber = GetSubscriptionsFromBiblionumber($biblionumber);
$template->param(item_loop => address@hidden,
item_header_loop =>
address@hidden,
biblionumber => $biblionumber,
@@ -262,6 +297,7 @@
intranetstylesheet =>
C4::Context->preference("intranetstylesheet"),
IntranetNav => C4::Context->preference("IntranetNav"),
);
+}
output_html_with_http_headers $query, $cookie, $template->output;
sub get_authorised_value_desc ($$$$$) {
@@ -269,13 +305,12 @@
#---- branch
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "branches" ) {
-# return getbranchdetail($value)->{branchname};
+ return getbranchname($value);
}
#---- itemtypes
if ($tagslib->{$tag}->{$subfield}->{'authorised_value'} eq "itemtypes" ) {
- # my $itemtypedef = getitemtypeinfo($itemtype);
- # return $itemtypedef->{description};
+ return ItemType($value);
}
#---- "true" authorized value
Index: detail.pl
===================================================================
RCS file: /sources/koha/koha/catalogue/detail.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- detail.pl 10 Aug 2006 13:31:22 -0000 1.6
+++ detail.pl 1 Sep 2006 15:36:42 -0000 1.7
@@ -1,14 +1,17 @@
#!/usr/bin/perl
use strict;
require Exporter;
-use CGI;
+use C4::Search;
use C4::Auth;
use C4::Serials; #uses getsubscriptionfrom biblionumber
use C4::Interface::CGI::Output;
-use HTML::Template;
+use CGI;
use C4::Biblio;
-use C4::Search;
+use C4::Context;
+
+use Encode;
+my $dbh=C4::Context->dbh;
my $query=new CGI;
my ($template, $borrowernumber, $cookie)
= get_template_and_user({template_name => "catalogue/detail.tmpl",
@@ -19,58 +22,60 @@
});
my $biblionumber=$query->param('biblionumber');
-if (!$biblionumber){
- $biblionumber=$query->param('bib');
- }
$template->param(biblionumber => $biblionumber);
+my $retrieve_from=C4::Context->preference('retrieve_from');
+my ($record,$frameworkcode);
+my @itemrecords;
+my @items;
+if ($retrieve_from eq "zebra"){
+($record,@itemrecords)=ZEBRAgetrecord($biblionumber);
+}else{
+ $record =XMLgetbiblio($dbh,$biblionumber);
+$record=XML_xml2hash_onerecord($record);
+my @itemxmls=XMLgetallitems($dbh,$biblionumber);
+ foreach my $itemrecord(@itemxmls){
+ my $itemhash=XML_xml2hash_onerecord($itemrecord);
+ push @itemrecords, $itemhash;
+ }
+}
-
-# change back when ive fixed request.pl
-my @items = &ItemInfo(undef, $biblionumber,
'intra');
-my $dat = &bibdata($biblionumber);
-my ($authorcount, $addauthor) = &addauthor($biblionumber);
-my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
-my ($websitecount, @websites) = &getwebsites($biblionumber);
-my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber);
-
-$dat->{'count'address@hidden;
-
-$dat->{'additional'}=$addauthor->[0]->{'author'};
-for (my $i = 1; $i < $authorcount; $i++) {
- $dat->{'additional'} .= " ; " . $addauthor->[$i]->{'author'};
-} # for
-
+my $dat = XMLmarc2koha_onerecord($dbh,$record,"biblios");
my $norequests = 1;
-foreach my $itm (@items) {
- $norequests = 0 unless $itm->{'notforloan'};
- $itm->{$itm->{'publictype'}} = 1;
+foreach my $itemrecord (@itemrecords){
+
+my $item= XMLmarc2koha_onerecord($dbh,$itemrecord,"holdings");
+$item=ItemInfo($dbh,$item);
+$item->{itemtype}=$dat->{itemtype};
+ $norequests = 0 unless $item->{'notforloan'};
+ $item->{$item->{'publictype'}} = 1; ## NOT sure what this is kept from old
db probably useless now
+push @items,$item;
}
+my $subscriptionsnumber = GetSubscriptionsFromBiblionumber($biblionumber);
+
+$dat->{'count'address@hidden;
+$template->param(count =>$dat->{'count'});
$template->param(norequests => $norequests);
- ## get notes and subjects from MARC record
-my $marc = C4::Context->preference("marc");
-if ($marc eq "yes") {
- my $dbh = C4::Context->dbh;
- my $marcflavour = C4::Context->preference("marcflavour");
- my $marcnotesarray = &getMARCnotes($dbh,$biblionumber,$marcflavour);
- my $marcsubjctsarray =
&getMARCsubjects($dbh,$biblionumber,$marcflavour);
+ ## get notes subjects and URLS from MARC record
+ my $marcflavour = C4::Context->preference("marcflavour");
+ my $marcnotesarray = &getMARCnotes($dbh,$record,$marcflavour);
+ my $marcsubjctsarray = &getMARCsubjects($dbh,$record,$marcflavour);
+ my $marcurlssarray = &getMARCurls($dbh,$record,$marcflavour);
+ $template->param(MARCURLS => $marcurlssarray);
$template->param(MARCNOTES => $marcnotesarray);
$template->param(MARCSUBJCTS => $marcsubjctsarray);
-}
+
my @results = ($dat,);
my address@hidden;
my address@hidden;
-my address@hidden;
-my address@hidden;
+
$template->param(BIBLIO_RESULTS => $resultsarray,
ITEM_RESULTS => $itemsarray,
- WEB_RESULTS => $webarray,
- SITE_RESULTS => $sitearray,
subscriptionsnumber => $subscriptionsnumber,
);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] koha/catalogue MARCdetail.pl detail.pl,
Tumer Garip <=