From 59ae3d902f082239f053686fd2a32aec832b9981 Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 28 May 2004 08:24:14 +0000 Subject: [PATCH] hidding hidden & isurl constraints into MARC subfield structure --- C4/Biblio.pm | 11 +++++- C4/SearchMarc.pm | 64 ++++++++++++++++--------------- admin/marc_subfields_structure.pl | 28 +++++++++++--- 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 41bbc18edd..be06332de2 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -239,7 +239,7 @@ sub MARCgettagslib { $res->{$tag}->{mandatory}=$mandatory; } - $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso from marc_subfield_structure where itemtype=? order by tagfield,tagsubfield"); + $sth=$dbh->prepare("select tagfield,tagsubfield,$libfield as lib,tab, mandatory, repeatable,authorised_value,thesaurus_category,value_builder,kohafield,seealso,hidden,isurl from marc_subfield_structure where itemtype=? order by tagfield,tagsubfield"); $sth->execute($itemtype); my $subfield; @@ -248,7 +248,9 @@ sub MARCgettagslib { my $value_builder; my $kohafield; my $seealso; - while ( ($tag, $subfield, $lib, $tab, $mandatory, $repeatable,$authorised_value,$thesaurus_category,$value_builder,$kohafield,$seealso) = $sth->fetchrow) { + my $hidden; + my $isurl; + while ( ($tag, $subfield, $lib, $tab, $mandatory, $repeatable,$authorised_value,$thesaurus_category,$value_builder,$kohafield,$seealso,$hidden,$isurl) = $sth->fetchrow) { $res->{$tag}->{$subfield}->{lib}=$lib; $res->{$tag}->{$subfield}->{tab}=$tab; $res->{$tag}->{$subfield}->{mandatory}=$mandatory; @@ -258,6 +260,8 @@ sub MARCgettagslib { $res->{$tag}->{$subfield}->{value_builder}=$value_builder; $res->{$tag}->{$subfield}->{kohafield}=$kohafield; $res->{$tag}->{$subfield}->{seealso}=$seealso; + $res->{$tag}->{$subfield}->{hidden}=$hidden; + $res->{$tag}->{$subfield}->{isurl}=$isurl; } return $res; } @@ -2199,6 +2203,9 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.90 2004/05/28 08:25:53 tipaul +# hidding hidden & isurl constraints into MARC subfield structure +# # Revision 1.89 2004/05/27 21:47:21 rangi # Fix for bug 787 # diff --git a/C4/SearchMarc.pm b/C4/SearchMarc.pm index 4721601d3c..9200a1fe06 100644 --- a/C4/SearchMarc.pm +++ b/C4/SearchMarc.pm @@ -219,58 +219,62 @@ sub catalogsearch { # we have bibid list. Now, loads title and author from [offset] to [offset]+[length] my $counter = $offset; - $sth = $dbh->prepare("SELECT biblio.biblionumber,author, title, items.holdingbranch, items.itemcallnumber, bibid - FROM biblio, marc_biblio left join items on items.biblionumber = biblio.biblionumber + $sth = $dbh->prepare("SELECT biblio.*, biblioitems.*, items.* + FROM biblio, marc_biblio + LEFT JOIN items on items.biblionumber = biblio.biblionumber + LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber WHERE biblio.biblionumber = marc_biblio.biblionumber AND bibid = ? GROUP BY items.biblionumber, items.holdingbranch, items.itemcallnumber"); my @finalresult = (); my @CNresults=(); my $oldbiblionumber=0; my $totalitems=0; - my ($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid); + my $oldline; +# my ($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid); my ($oldbibid, $oldauthor, $oldtitle,$oldbiblionumber); while (($counter <= $#result) && ($counter <= ($offset + $length))) { $sth->execute($result[$counter]); - while (($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid) = $sth->fetchrow) { -# warn "bibid : $oldbiblionumber ($biblionumber,$author,$title,$holdingbranch, $itemcallnumber, $bibid)"; + while (my $line = $sth->fetchrow_hashref) { # parse the result, putting holdingbranch & itemcallnumber in separate array - # then author, title & 1st array in main array - if ($oldbiblionumber && ($oldbiblionumber ne $biblionumber)) { - my %line; - $line{bibid}=$oldbibid; - $line{author}=$oldauthor; - $line{title}=$oldtitle; - $line{totitem} = $totalitems; - $line{biblionumber} = $oldbiblionumber; + # then all other fields in the main array + if ($oldbiblionumber && ($oldbiblionumber ne $line->{biblionumber})) { + my %newline; + %newline = %$oldline; + $newline{totitem} = $totalitems; + $newline{biblionumber} = $oldbiblionumber; my @CNresults2= @CNresults; - $line{CN} = \@CNresults2; + $newline{CN} = \@CNresults2; + $newline{'even'} = 1 if $counter % 2 == 0; + $newline{'odd'} = 1 if $counter % 2 == 1; @CNresults = (); - push @finalresult, \%line; + push @finalresult, \%newline; $totalitems=0; } - $oldbibid = $bibid; - $oldauthor = $author; - $oldtitle = $title; - $oldbiblionumber = $biblionumber; - $totalitems++ if ($holdingbranch); + $oldbiblionumber = $line->{biblionumber}; + $totalitems++ if ($line->{holdingbranch}); + $oldline = $line; + # item callnumber & branch my %lineCN; - $lineCN{holdingbranch} = $holdingbranch; - $lineCN{itemcallnumber} = $itemcallnumber; + $lineCN{holdingbranch} = $line->{holdingbranch}; + $lineCN{itemcallnumber} = $line->{itemcallnumber}; push @CNresults,\%lineCN; } $counter++; } # add the last line, that is not reached byt the loop / if ($oldbiblionumber...) - my %line; - $line{bibid}=$oldbibid; - $line{author}=$oldauthor; - $line{title}=$oldtitle; - $line{totitem} = $totalitems; - $line{biblionumber} = $oldbiblionumber; + my %newline; + %newline = %$oldline; + $newline{totitem} = $totalitems; + $newline{biblionumber} = $oldbiblionumber; my @CNresults2= @CNresults; - $line{CN} = \@CNresults2; + $newline{CN} = \@CNresults2; + $newline{'even'} = 1 if $counter % 2 == 0; + $newline{'odd'} = 1 if $counter % 2 == 1; @CNresults = (); - push @finalresult, \%line; + my @CNresults2= @CNresults; + $newline{CN} = \@CNresults2; + @CNresults = (); + push @finalresult, \%newline; my $nbresults = $#result + 1; return (\@finalresult, $nbresults); } diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index bc1b728482..9688ab7557 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -33,7 +33,7 @@ sub StringSearch { $searchstring=~ s/\'/\\\'/g; my @data=split(' ',$searchstring); my $count=@data; - my $sth=$dbh->prepare("Select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where (tagfield like ? and itemtype=?) order by tagfield"); + my $sth=$dbh->prepare("Select * from marc_subfield_structure where (tagfield like ? and itemtype=?) order by tagfield"); $sth->execute("$searchstring%",$itemtype); my @results; my $cnt=0; @@ -139,7 +139,7 @@ if ($op eq 'add_form') { closedir DIR; # build values list - my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where tagfield=? and itemtype=?"); # and tagsubfield='$tagsubfield'"); + my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and itemtype=?"); # and tagsubfield='$tagsubfield'"); $sth->execute($tagfield,$itemtype); my @loop_data = (); my $toggle="white"; @@ -192,6 +192,8 @@ if ($op eq 'add_form') { ); $row_data{repeatable} = CGI::checkbox("repeatable$i",$data->{'repeatable'}?'checked':'',1,''); $row_data{mandatory} = CGI::checkbox("mandatory$i",$data->{'mandatory'}?'checked':'',1,''); + $row_data{hidden} = CGI::checkbox("hidden$i",$data->{'hidden'}?'checked':'',1,''); + $row_data{isurl} = CGI::checkbox("isurl$i",$data->{'isurl'}?'checked':'',1,''); $row_data{bgcolor} = $toggle; push(@loop_data, \%row_data); $i++; @@ -216,6 +218,8 @@ if ($op eq 'add_form') { $row_data{seealso} = ""; $row_data{repeatable} = CGI::checkbox('repeatable','',1,''); $row_data{mandatory} = CGI::checkbox('mandatory','',1,''); + $row_data{hidden} = CGI::checkbox('hidden','',1,''); + $row_data{isurl} = CGI::checkbox('isurl','',1,''); $row_data{kohafield}= CGI::scrolling_list( -name=>'kohafield', -values=> \@kohafields, -default=> "", @@ -249,8 +253,8 @@ if ($op eq 'add_form') { } elsif ($op eq 'add_validate') { my $dbh = C4::Context->dbh; $template->param(tagfield => "$input->param('tagfield')"); - my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,thesaurus_category,value_builder,itemtype) - values (?,?,?,?,?,?,?,?,?,?,?,?,?)"); + my $sth=$dbh->prepare("replace marc_subfield_structure (tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,thesaurus_category,value_builder,hidden,isurl,itemtype) + values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); my @tagsubfield = $input->param('tagsubfield'); my @liblibrarian = $input->param('liblibrarian'); my @libopac = $input->param('libopac'); @@ -274,6 +278,8 @@ if ($op eq 'add_form') { my $authorised_value =$authorised_values[$i]; my $thesaurus_category =$thesaurus_category[$i]; my $value_builder=$value_builder[$i]; + my $hidden = $input->param("hidden$i")?1:0; + my $isurl = $input->param("isurl$i")?1:0; if ($liblibrarian) { unless (C4::Context->config('demo') eq 1) { $sth->execute ($tagfield, @@ -287,7 +293,11 @@ if ($op eq 'add_form') { $seealso, $authorised_value, $thesaurus_category, - $value_builder,$itemtype); + $value_builder, + $hidden, + $isurl, + $itemtype, + ); } } } @@ -300,7 +310,7 @@ if ($op eq 'add_form') { # called by default form, used to confirm deletion of data in DB } elsif ($op eq 'delete_confirm') { my $dbh = C4::Context->dbh; - my $sth=$dbh->prepare("select tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,thesaurus_category,value_builder from marc_subfield_structure where tagfield=? and tagsubfield=? and itemtype=?"); + my $sth=$dbh->prepare("select * from marc_subfield_structure where tagfield=? and tagsubfield=? and itemtype=?"); $sth->execute($tagfield,$tagsubfield); my $data=$sth->fetchrow_hashref; $sth->finish; @@ -349,8 +359,14 @@ if ($op eq 'add_form') { $row_data{authorised_value} = $results->[$i]{'authorised_value'}; $row_data{thesaurus_category} = $results->[$i]{'thesaurus_category'}; $row_data{value_builder} = $results->[$i]{'value_builder'}; + $row_data{hidden} = $results->[$i]{'hidden'}; + $row_data{isurl} = $results->[$i]{'isurl'}; $row_data{delete} = "$script_name?op=delete_confirm&tagfield=$tagfield&tagsubfield=".$results->[$i]{'tagsubfield'}."&itemtype=$itemtype"; $row_data{bgcolor} = $toggle; + if ($row_data{tab} eq -1) { + $row_data{subfield_ignored} = 1; + } + push(@loop_data, \%row_data); } $template->param(loop => \@loop_data); -- 2.39.5