From 796b9e8d5dd374a306d4b2d9ca853644c6a34dcc Mon Sep 17 00:00:00 2001 From: hdl Date: Mon, 15 Jan 2007 17:56:43 +0000 Subject: [PATCH] Bug Fixing authtrees --- C4/AuthoritiesMarc.pm | 38 ++++++++++++++++++++++++++++---------- authorities/authorities.pl | 20 ++++++++++---------- authorities/detail.pl | 16 +++++++++------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index a6e0a24773..135f538dcd 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -195,6 +195,7 @@ sub authoritysearch { chop $tags_using_authtype; my $reported_tag; # if the library has a summary defined, use it. Otherwise, build a standard one + $summary=BuildSummary($record,$summary); if ($summary) { my @fields = $record->fields(); $reported_tag = '$9'.$result[$counter]; @@ -532,7 +533,7 @@ sub AUTHaddauthority { # existing authids in the records. I've adjusted below to account for this instance --JF. if ($authid) { $dbh->do("lock tables auth_header WRITE,auth_subfield_table WRITE, auth_word WRITE, stopwords READ"); - my $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode) values (?,now(),?)"); + my $sth=$dbh->prepare("insert ignore into auth_header (authid,datecreated,authtypecode) values (?,now(),?)"); $sth->execute($authid,$authtypecode); $sth->finish; # if authid empty => true add, find a new authid number @@ -1132,8 +1133,6 @@ sub FindDuplicate { sub BuildSummary{ my $record = shift @_; my $summary = shift @_; - ##TODO : use langages from authorised_values - ## AND Thesaurii from auth_types my %language; $language{'fre'}="Français"; $language{'eng'}="Anglais"; @@ -1187,33 +1186,49 @@ sub BuildSummary{ } # rejected form(s) foreach my $field ($record->field('3..')) { - $notes.= ''.$field->subfield('a')."\n"; + $notes.= ''.$field->subfield('a').""; } foreach my $field ($record->field('4..')) { my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : " if ($field->subfield('2')); - $see.= ''.$thesaurus.$field->subfield('a')." -- \n"; + $see.= ''.$thesaurus.$field->subfield('a')." -- "; } # see : foreach my $field ($record->field('5..')) { if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { - $broaderterms.= ' '.$field->subfield('a')." -- \n"; + $broaderterms.= ''; +# $broaderterms.=''; + $broaderterms.=$field->subfield('a'); +# $broaderterms.=""; + $broaderterms.=" -- "; } elsif (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'h')){ - $narrowerterms.= ''.$field->subfield('a')." -- \n"; + $narrowerterms.= ''; +# $narrowerterms.=''; + $narrowerterms.=$field->subfield('a'); +# $narrowerterms.=""; + $narrowerterms.=" -- "; } elsif ($field->subfield('a')) { - $seealso.= ''.$field->subfield('a')." -- \n"; + $seealso.= ''; +# $seealso.= ''; + $seealso.= $field->subfield('a'); +# $seealso.= ""; + $seealso.= " -- "; } } # // form foreach my $field ($record->field('7..')) { my $lang = substr($field->subfield('8'),3,3); - $seeheading.= ' En '.$language{$lang}.' : '.$field->subfield('a')."
\n"; + $seeheading.= ' En '.$language{$lang}.' : '.$field->subfield('a')."\n"; } $broaderterms =~s/-- \n$//; $narrowerterms =~s/-- \n$//; $seealso =~s/-- \n$//; $see =~s/-- \n$//; - $summary = "".$heading."
".($notes?"$notes
":""); + $summary = ""; +# $summary.= ""; + $summary.=$heading; +# $summary.=""; + $summary.="
".($notes?"$notes
":""); $summary.= '

TG : '.$broaderterms.'

' if ($broaderterms); $summary.= '

TS : '.$narrowerterms.'

' if ($narrowerterms); $summary.= '

TA : '.$seealso.'

' if ($seealso); @@ -1335,6 +1350,9 @@ Paul POULAIN paul.poulain@free.fr # $Id$ # $Log$ +# Revision 1.9.2.25 2007/01/15 17:56:43 hdl +# Bug Fixing authtrees +# # Revision 1.9.2.24 2006/08/10 12:42:33 tipaul # warn commenting + some bugfixes I forgot to commit (for authorities editing) # diff --git a/authorities/authorities.pl b/authorities/authorities.pl index 99b42d31e6..19438b343a 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -330,16 +330,16 @@ if ($op eq "add") { my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); my $record; - if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") { + if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1"||C4::Context->preference('marcflavour') eq "UNIMARC") { my %indicators; for (my $i=0;$i<=$#ind_tag;$i++) { $indicators{$ind_tag[$i]} = $indicator[$i]; } $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - } else { - my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour')); - } + } else { + my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); + $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour')); + } warn "REC : ".$record->as_formatted; # # MARC::Record built => now, record in DB @@ -376,16 +376,16 @@ if ($op eq "add") { my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); my $record; - if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1") { + if (C4::Context->preference('TemplateEncoding') eq "iso-8859-1" ||C4::Context->preference('marcflavour') eq "UNIMARC") { my %indicators; for (my $i=0;$i<=$#ind_tag;$i++) { $indicators{$ind_tag[$i]} = $indicator[$i]; } $record = AUTHhtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - } else { - my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour')); - } + } else { + my $xml = AUTHhtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); + $record=MARC::Record->new_from_xml($xml,C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour')); + } warn "REC : ".$record->as_formatted; my $field = MARC::Field->new("$addedfield",'','','a'=> ""); $record->append_fields($field); diff --git a/authorities/detail.pl b/authorities/detail.pl index ca651aaa76..75002d6534 100755 --- a/authorities/detail.pl +++ b/authorities/detail.pl @@ -72,32 +72,34 @@ my $tagslib = &AUTHgettagslib($dbh,1,$authtypecode); my $record; if (C4::Context->preference("AuthDisplayHierarchy")){ +# warn "displayhiereachy"; my $trees=BuildUnimarcHierarchies($authid); -# warn "trees :$trees"; +# warn "trees :$trees"; my @trees = split /;/,$trees ; push @trees,$trees unless (@trees); my @loophierarchies; foreach my $tree (@trees){ -# warn "tree :$tree"; +# warn "tree :$tree"; my @tree=split /,/,$tree; push @tree,$tree unless (@tree); my $cnt=0; my @loophierarchy; foreach my $element (@tree){ -# warn "tree :$element"; +# warn "tree :$element"; my %cell; my $elementdata = AUTHgetauthority($dbh,$element); $record= $elementdata if ($authid==$element); push @loophierarchy, BuildUnimarcHierarchy($elementdata,"child".$cnt, $authid); $cnt++; } +# use Data::Dumper;warn Dumper(@loophierarchy); push @loophierarchies, { 'loopelement' =>\@loophierarchy}; - $template->param( - 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"), - 'loophierarchies' =>\@loophierarchies, - ); } + $template->param( + 'displayhierarchy' =>C4::Context->preference("AuthDisplayHierarchy"), + 'loophierarchies' =>\@loophierarchies, + ); } else { $record=AUTHgetauthority($dbh,$authid); } -- 2.39.5