From 8a3295821b80f1f2ff9fe43cb3d842e14e205a89 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 23 Sep 2004 16:33:13 +0000 Subject: [PATCH] value builder for 210c (editor) and 225a (collection) * create a authority category called "EDITORS" * set : 200$a => ISBN 200$b => editor 200$c => (repeatable) collection. Then enter, for example : $a 23 $b Hachette Litterature $c collection1|collection2|collection3 map your "editor" field to plugin 210c, your "collection" field to plugin 225a Once you arrive on the editor field, if the beginning of the ISBN exists, the editor is automatically found. Once you arrive on collection field, click on ... you can choose in the collection list. The 210c / 225a comes from the UNIMARC editor/collection field, but should work as well with MARC21. --- value_builder/unimarc_field_210c.pl | 18 ++++++++++++------ value_builder/unimarc_field_225a.pl | 11 ++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/value_builder/unimarc_field_210c.pl b/value_builder/unimarc_field_210c.pl index 99a7d87c60..3fbd075290 100644 --- a/value_builder/unimarc_field_210c.pl +++ b/value_builder/unimarc_field_210c.pl @@ -57,14 +57,20 @@ my $function_name= "210c".(int(rand(100000))+1); #---- build editors list. #---- the editor list is built from the "EDITORS" thesaurus #---- this thesaurus category must be filled as follow : -#---- isbn_identifier authorityseparator editor authorityseparator collection -#---- sample : 2224 -- Cerf -- Sources chrétiennes -my $sth = $dbh->prepare("select father,stdlib from bibliothesaurus where category='EDITORS' and level=2"); +#---- 200$a for isbn +#---- 200$b for editor +#---- 200$c (repeated) for collections +my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table + left join auth_header on auth_subfield_table.authid=auth_header.authid + where authtypecode='EDITORS' and tag='200' and subfieldcode='a'"); +my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='b' and authid=?"); $sth->execute; my @editors; my $authoritysep = C4::Context->preference("authoritysep"); -while (my ($father,$stdlib) = $sth->fetchrow) { - push(@editors,"$father $stdlib"); +while (my ($authid,$isbn) = $sth->fetchrow) { + $sth2->execute($authid); + my ($editor) = $sth2->fetchrow; + push(@editors,"$isbn $authoritysep $editor"); } my $res = " diff --git a/value_builder/unimarc_field_225a.pl b/value_builder/unimarc_field_225a.pl index 3e7f4cab57..c61d88eca9 100644 --- a/value_builder/unimarc_field_225a.pl +++ b/value_builder/unimarc_field_225a.pl @@ -119,13 +119,18 @@ my ($input) = @_; # if there is an isbn, complete search my @collections; if ($isbn_found) { - my $sth = $dbh->prepare("select stdlib from bibliothesaurus where father=? and category='EDITORS' order by stdlib"); + my $sth = $dbh->prepare("select auth_subfield_table.authid,subfieldvalue from auth_subfield_table + left join auth_header on auth_subfield_table.authid=auth_header.authid + where authtypecode='EDITORS' and tag='200' and subfieldcode='a' and subfieldvalue=?"); + my $sth2 = $dbh->prepare("select subfieldvalue from auth_subfield_table where tag='200' and subfieldcode='c' and authid=?"); my @splited = split //, $isbn_found; my $isbn_rebuild=''; foreach my $x (@splited) { $isbn_rebuild.=$x; - $sth->execute("$isbn_rebuild $authoritysep $editor_found $authoritysep"); - while (my ($line)= $sth->fetchrow) { + $sth->execute($isbn_rebuild); + my ($authid) = $sth->fetchrow; + $sth2->execute($authid); + while (my ($line)= $sth2->fetchrow) { push @collections,$line; } } -- 2.39.2