Lines 50-56
BEGIN {
Link Here
|
50 |
&GetRecordValue |
50 |
&GetRecordValue |
51 |
); |
51 |
); |
52 |
|
52 |
|
53 |
push @EXPORT, qw( |
53 |
push @EXPORT, qw( |
54 |
&AddBiblio |
54 |
&AddBiblio |
55 |
); |
55 |
); |
56 |
|
56 |
|
Lines 63-74
BEGIN {
Link Here
|
63 |
&GetBiblioItemByBiblioNumber |
63 |
&GetBiblioItemByBiblioNumber |
64 |
&GetBiblioFromItemNumber |
64 |
&GetBiblioFromItemNumber |
65 |
&GetBiblioSummary |
65 |
&GetBiblioSummary |
66 |
|
66 |
|
67 |
&GetRecordValue |
67 |
&GetRecordValue |
68 |
&GetFieldMapping |
68 |
&GetFieldMapping |
69 |
&SetFieldMapping |
69 |
&SetFieldMapping |
70 |
&DeleteFieldMapping |
70 |
&DeleteFieldMapping |
71 |
|
71 |
|
72 |
&GetISBDView |
72 |
&GetISBDView |
73 |
|
73 |
|
74 |
&GetMarcNotes |
74 |
&GetMarcNotes |
Lines 87-93
BEGIN {
Link Here
|
87 |
&GetFrameworkCode |
87 |
&GetFrameworkCode |
88 |
&GetPublisherNameFromIsbn |
88 |
&GetPublisherNameFromIsbn |
89 |
&TransformKohaToMarc |
89 |
&TransformKohaToMarc |
90 |
|
90 |
|
91 |
&CountItemsIssued |
91 |
&CountItemsIssued |
92 |
); |
92 |
); |
93 |
|
93 |
|
Lines 240-249
sub AddBiblio {
Link Here
|
240 |
|
240 |
|
241 |
# update MARC subfield that stores biblioitems.cn_sort |
241 |
# update MARC subfield that stores biblioitems.cn_sort |
242 |
_koha_marc_update_biblioitem_cn_sort($record, $olddata, $frameworkcode); |
242 |
_koha_marc_update_biblioitem_cn_sort($record, $olddata, $frameworkcode); |
243 |
|
243 |
|
244 |
# now add the record |
244 |
# now add the record |
245 |
ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $$options{defer_marc_save} ||= 0; |
245 |
ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $$options{defer_marc_save} ||= 0; |
246 |
|
246 |
|
247 |
logaction("CATALOGUING", "ADD", $biblionumber, "biblio") if C4::Context->preference("CataloguingLog"); |
247 |
logaction("CATALOGUING", "ADD", $biblionumber, "biblio") if C4::Context->preference("CataloguingLog"); |
248 |
return ( $biblionumber, $biblioitemnumber ); |
248 |
return ( $biblionumber, $biblioitemnumber ); |
249 |
} |
249 |
} |
Lines 278-286
sub ModBiblio {
Link Here
|
278 |
my $newrecord = GetMarcBiblio($biblionumber); |
278 |
my $newrecord = GetMarcBiblio($biblionumber); |
279 |
logaction("CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>".$newrecord->as_formatted); |
279 |
logaction("CATALOGUING", "MODIFY", $biblionumber, "BEFORE=>".$newrecord->as_formatted); |
280 |
} |
280 |
} |
281 |
|
281 |
|
282 |
my $dbh = C4::Context->dbh; |
282 |
my $dbh = C4::Context->dbh; |
283 |
|
283 |
|
284 |
$frameworkcode = "" unless $frameworkcode; |
284 |
$frameworkcode = "" unless $frameworkcode; |
285 |
|
285 |
|
286 |
# get the items before and append them to the biblio before updating the record, atm we just have the biblio |
286 |
# get the items before and append them to the biblio before updating the record, atm we just have the biblio |
Lines 293-302
sub ModBiblio {
Link Here
|
293 |
foreach my $field ($record->field($itemtag)) { |
293 |
foreach my $field ($record->field($itemtag)) { |
294 |
$record->delete_field($field); |
294 |
$record->delete_field($field); |
295 |
} |
295 |
} |
296 |
|
296 |
|
297 |
# once all the items fields are removed, copy the old ones, in order to keep synchronize |
297 |
# once all the items fields are removed, copy the old ones, in order to keep synchronize |
298 |
$record->append_fields($oldRecord->field( $itemtag )); |
298 |
$record->append_fields($oldRecord->field( $itemtag )); |
299 |
|
299 |
|
300 |
# update biblionumber and biblioitemnumber in MARC |
300 |
# update biblionumber and biblioitemnumber in MARC |
301 |
# FIXME - this is assuming a 1 to 1 relationship between |
301 |
# FIXME - this is assuming a 1 to 1 relationship between |
302 |
# biblios and biblioitems |
302 |
# biblios and biblioitems |
Lines 314-320
sub ModBiblio {
Link Here
|
314 |
|
314 |
|
315 |
# update the MARC record (that now contains biblio and items) with the new record data |
315 |
# update the MARC record (that now contains biblio and items) with the new record data |
316 |
&ModBiblioMarc( $record, $biblionumber, $frameworkcode ); |
316 |
&ModBiblioMarc( $record, $biblionumber, $frameworkcode ); |
317 |
|
317 |
|
318 |
# modify the other koha tables |
318 |
# modify the other koha tables |
319 |
_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); |
319 |
_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); |
320 |
_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio ); |
320 |
_koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio ); |
Lines 358-364
sub DelBiblio {
Link Here
|
358 |
my ( $biblionumber ) = @_; |
358 |
my ( $biblionumber ) = @_; |
359 |
my $dbh = C4::Context->dbh; |
359 |
my $dbh = C4::Context->dbh; |
360 |
my $error; # for error handling |
360 |
my $error; # for error handling |
361 |
|
361 |
|
362 |
# First make sure this biblio has no items attached |
362 |
# First make sure this biblio has no items attached |
363 |
my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?"); |
363 |
my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?"); |
364 |
$sth->execute($biblionumber); |
364 |
$sth->execute($biblionumber); |
Lines 374-380
sub DelBiblio {
Link Here
|
374 |
foreach my $subscription (@$subscriptions){ |
374 |
foreach my $subscription (@$subscriptions){ |
375 |
&C4::Serials::DelSubscription($subscription->{subscriptionid}); |
375 |
&C4::Serials::DelSubscription($subscription->{subscriptionid}); |
376 |
} |
376 |
} |
377 |
|
377 |
|
378 |
# Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio |
378 |
# Delete in Zebra. Be careful NOT to move this line after _koha_delete_biblio |
379 |
# for at least 2 reasons : |
379 |
# for at least 2 reasons : |
380 |
# - we need to read the biblio if NoZebra is set (to remove it from the indexes |
380 |
# - we need to read the biblio if NoZebra is set (to remove it from the indexes |
Lines 423-432
Links bib headings to authority records by checking
Link Here
|
423 |
each authority-controlled field in the C<MARC::Record> |
423 |
each authority-controlled field in the C<MARC::Record> |
424 |
object C<$marc>, looking for a matching authority record, |
424 |
object C<$marc>, looking for a matching authority record, |
425 |
and setting the linking subfield $9 to the ID of that |
425 |
and setting the linking subfield $9 to the ID of that |
426 |
authority record. |
426 |
authority record. |
427 |
|
427 |
|
428 |
If no matching authority exists, or if multiple |
428 |
If no matching authority exists, or if multiple |
429 |
authorities match, no $9 will be added, and any |
429 |
authorities match, no $9 will be added, and any |
430 |
existing one inthe field will be deleted. |
430 |
existing one inthe field will be deleted. |
431 |
|
431 |
|
432 |
Returns the number of heading links changed in the |
432 |
Returns the number of heading links changed in the |
Lines 439-445
sub LinkBibHeadingsToAuthorities {
Link Here
|
439 |
|
439 |
|
440 |
my $num_headings_changed = 0; |
440 |
my $num_headings_changed = 0; |
441 |
foreach my $field ($bib->fields()) { |
441 |
foreach my $field ($bib->fields()) { |
442 |
my $heading = C4::Heading->new_from_bib_field($field); |
442 |
my $heading = C4::Heading->new_from_bib_field($field); |
443 |
next unless defined $heading; |
443 |
next unless defined $heading; |
444 |
|
444 |
|
445 |
# check existing $9 |
445 |
# check existing $9 |
Lines 483-507
Get MARC fields from a keyword defined in fieldmapping table.
Link Here
|
483 |
sub GetRecordValue { |
483 |
sub GetRecordValue { |
484 |
my ($field, $record, $frameworkcode) = @_; |
484 |
my ($field, $record, $frameworkcode) = @_; |
485 |
my $dbh = C4::Context->dbh; |
485 |
my $dbh = C4::Context->dbh; |
486 |
|
486 |
|
487 |
my $sth = $dbh->prepare('SELECT fieldcode, subfieldcode FROM fieldmapping WHERE frameworkcode = ? AND field = ?'); |
487 |
my $sth = $dbh->prepare('SELECT fieldcode, subfieldcode FROM fieldmapping WHERE frameworkcode = ? AND field = ?'); |
488 |
$sth->execute($frameworkcode, $field); |
488 |
$sth->execute($frameworkcode, $field); |
489 |
|
489 |
|
490 |
my @result = (); |
490 |
my @result = (); |
491 |
|
491 |
|
492 |
while(my $row = $sth->fetchrow_hashref){ |
492 |
while(my $row = $sth->fetchrow_hashref){ |
493 |
foreach my $field ($record->field($row->{fieldcode})){ |
493 |
foreach my $field ($record->field($row->{fieldcode})){ |
494 |
if( ($row->{subfieldcode} ne "" && $field->subfield($row->{subfieldcode}))){ |
494 |
if( ($row->{subfieldcode} ne "" && $field->subfield($row->{subfieldcode}))){ |
495 |
foreach my $subfield ($field->subfield($row->{subfieldcode})){ |
495 |
foreach my $subfield ($field->subfield($row->{subfieldcode})){ |
496 |
push @result, { 'subfield' => $subfield }; |
496 |
push @result, { 'subfield' => $subfield }; |
497 |
} |
497 |
} |
498 |
|
498 |
|
499 |
}elsif($row->{subfieldcode} eq "") { |
499 |
}elsif($row->{subfieldcode} eq "") { |
500 |
push @result, {'subfield' => $field->as_string()}; |
500 |
push @result, {'subfield' => $field->as_string()}; |
501 |
} |
501 |
} |
502 |
} |
502 |
} |
503 |
} |
503 |
} |
504 |
|
504 |
|
505 |
return \@result; |
505 |
return \@result; |
506 |
} |
506 |
} |
507 |
|
507 |
|
Lines 520-532
Set a Field to MARC mapping value, if it already exists we don't add a new one.
Link Here
|
520 |
sub SetFieldMapping { |
520 |
sub SetFieldMapping { |
521 |
my ($framework, $field, $fieldcode, $subfieldcode) = @_; |
521 |
my ($framework, $field, $fieldcode, $subfieldcode) = @_; |
522 |
my $dbh = C4::Context->dbh; |
522 |
my $dbh = C4::Context->dbh; |
523 |
|
523 |
|
524 |
my $sth = $dbh->prepare('SELECT * FROM fieldmapping WHERE fieldcode = ? AND subfieldcode = ? AND frameworkcode = ? AND field = ?'); |
524 |
my $sth = $dbh->prepare('SELECT * FROM fieldmapping WHERE fieldcode = ? AND subfieldcode = ? AND frameworkcode = ? AND field = ?'); |
525 |
$sth->execute($fieldcode, $subfieldcode, $framework, $field); |
525 |
$sth->execute($fieldcode, $subfieldcode, $framework, $field); |
526 |
if(not $sth->fetchrow_hashref){ |
526 |
if(not $sth->fetchrow_hashref){ |
527 |
my @args; |
527 |
my @args; |
528 |
$sth = $dbh->prepare('INSERT INTO fieldmapping (fieldcode, subfieldcode, frameworkcode, field) VALUES(?,?,?,?)'); |
528 |
$sth = $dbh->prepare('INSERT INTO fieldmapping (fieldcode, subfieldcode, frameworkcode, field) VALUES(?,?,?,?)'); |
529 |
|
529 |
|
530 |
$sth->execute($fieldcode, $subfieldcode, $framework, $field); |
530 |
$sth->execute($fieldcode, $subfieldcode, $framework, $field); |
531 |
} |
531 |
} |
532 |
} |
532 |
} |
Lines 546-552
Delete a field mapping from an $id.
Link Here
|
546 |
sub DeleteFieldMapping{ |
546 |
sub DeleteFieldMapping{ |
547 |
my ($id) = @_; |
547 |
my ($id) = @_; |
548 |
my $dbh = C4::Context->dbh; |
548 |
my $dbh = C4::Context->dbh; |
549 |
|
549 |
|
550 |
my $sth = $dbh->prepare('DELETE FROM fieldmapping WHERE id = ?'); |
550 |
my $sth = $dbh->prepare('DELETE FROM fieldmapping WHERE id = ?'); |
551 |
$sth->execute($id); |
551 |
$sth->execute($id); |
552 |
} |
552 |
} |
Lines 566-575
Get all field mappings for a specified frameworkcode
Link Here
|
566 |
sub GetFieldMapping { |
566 |
sub GetFieldMapping { |
567 |
my ($framework) = @_; |
567 |
my ($framework) = @_; |
568 |
my $dbh = C4::Context->dbh; |
568 |
my $dbh = C4::Context->dbh; |
569 |
|
569 |
|
570 |
my $sth = $dbh->prepare('SELECT * FROM fieldmapping where frameworkcode = ?'); |
570 |
my $sth = $dbh->prepare('SELECT * FROM fieldmapping where frameworkcode = ?'); |
571 |
$sth->execute($framework); |
571 |
$sth->execute($framework); |
572 |
|
572 |
|
573 |
my @return; |
573 |
my @return; |
574 |
while(my $row = $sth->fetchrow_hashref){ |
574 |
while(my $row = $sth->fetchrow_hashref){ |
575 |
push @return, $row; |
575 |
push @return, $row; |
Lines 599-619
sub GetBiblioData {
Link Here
|
599 |
my ( $bibnum ) = @_; |
599 |
my ( $bibnum ) = @_; |
600 |
my $dbh = C4::Context->dbh; |
600 |
my $dbh = C4::Context->dbh; |
601 |
|
601 |
|
602 |
# my $query = C4::Context->preference('item-level_itypes') ? |
602 |
# my $query = C4::Context->preference('item-level_itypes') ? |
603 |
# " SELECT * , biblioitems.notes AS bnotes, biblio.notes |
603 |
# " SELECT * , biblioitems.notes AS bnotes, biblio.notes |
604 |
# FROM biblio |
604 |
# FROM biblio |
605 |
# LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber |
605 |
# LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber |
606 |
# WHERE biblio.biblionumber = ? |
606 |
# WHERE biblio.biblionumber = ? |
607 |
# AND biblioitems.biblionumber = biblio.biblionumber |
607 |
# AND biblioitems.biblionumber = biblio.biblionumber |
608 |
#"; |
608 |
#"; |
609 |
|
609 |
|
610 |
my $query = " SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes |
610 |
my $query = " SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes |
611 |
FROM biblio |
611 |
FROM biblio |
612 |
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber |
612 |
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber |
613 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
613 |
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype |
614 |
WHERE biblio.biblionumber = ? |
614 |
WHERE biblio.biblionumber = ? |
615 |
AND biblioitems.biblionumber = biblio.biblionumber "; |
615 |
AND biblioitems.biblionumber = biblio.biblionumber "; |
616 |
|
616 |
|
617 |
my $sth = $dbh->prepare($query); |
617 |
my $sth = $dbh->prepare($query); |
618 |
$sth->execute($bibnum); |
618 |
$sth->execute($bibnum); |
619 |
my $data; |
619 |
my $data; |
Lines 644-652
sub GetBiblioItemData {
Link Here
|
644 |
my $dbh = C4::Context->dbh; |
644 |
my $dbh = C4::Context->dbh; |
645 |
my $query = "SELECT *,biblioitems.notes AS bnotes |
645 |
my $query = "SELECT *,biblioitems.notes AS bnotes |
646 |
FROM biblio LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber "; |
646 |
FROM biblio LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber "; |
647 |
unless(C4::Context->preference('item-level_itypes')) { |
647 |
unless(C4::Context->preference('item-level_itypes')) { |
648 |
$query .= "LEFT JOIN itemtypes on biblioitems.itemtype=itemtypes.itemtype "; |
648 |
$query .= "LEFT JOIN itemtypes on biblioitems.itemtype=itemtypes.itemtype "; |
649 |
} |
649 |
} |
650 |
$query .= " WHERE biblioitemnumber = ? "; |
650 |
$query .= " WHERE biblioitemnumber = ? "; |
651 |
my $sth = $dbh->prepare($query); |
651 |
my $sth = $dbh->prepare($query); |
652 |
my $data; |
652 |
my $data; |
Lines 705-720
sub GetBiblioFromItemNumber {
Link Here
|
705 |
my $dbh = C4::Context->dbh; |
705 |
my $dbh = C4::Context->dbh; |
706 |
my $sth; |
706 |
my $sth; |
707 |
if($itemnumber) { |
707 |
if($itemnumber) { |
708 |
$sth=$dbh->prepare( "SELECT * FROM items |
708 |
$sth=$dbh->prepare( "SELECT * FROM items |
709 |
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber |
709 |
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber |
710 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
710 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
711 |
WHERE items.itemnumber = ?") ; |
711 |
WHERE items.itemnumber = ?") ; |
712 |
$sth->execute($itemnumber); |
712 |
$sth->execute($itemnumber); |
713 |
} else { |
713 |
} else { |
714 |
$sth=$dbh->prepare( "SELECT * FROM items |
714 |
$sth=$dbh->prepare( "SELECT * FROM items |
715 |
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber |
715 |
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber |
716 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
716 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
717 |
WHERE items.barcode = ?") ; |
717 |
WHERE items.barcode = ?") ; |
718 |
$sth->execute($barcode); |
718 |
$sth->execute($barcode); |
719 |
} |
719 |
} |
720 |
my $data = $sth->fetchrow_hashref; |
720 |
my $data = $sth->fetchrow_hashref; |
Lines 722-728
sub GetBiblioFromItemNumber {
Link Here
|
722 |
return ($data); |
722 |
return ($data); |
723 |
} |
723 |
} |
724 |
|
724 |
|
725 |
=head2 GetISBDView |
725 |
=head2 GetISBDView |
726 |
|
726 |
|
727 |
=over 4 |
727 |
=over 4 |
728 |
|
728 |
|
Lines 740-755
sub GetISBDView {
Link Here
|
740 |
my $itemtype = &GetFrameworkCode($biblionumber); |
740 |
my $itemtype = &GetFrameworkCode($biblionumber); |
741 |
my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype); |
741 |
my ($holdingbrtagf,$holdingbrtagsubf) = &GetMarcFromKohaField("items.holdingbranch",$itemtype); |
742 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
742 |
my $tagslib = &GetMarcStructure( 1, $itemtype ); |
743 |
|
743 |
|
744 |
my $ISBD = C4::Context->preference('ISBD'); |
744 |
my $ISBD = C4::Context->preference('ISBD'); |
745 |
if($template eq "opac"){ |
745 |
if($template eq "opac"){ |
746 |
$ISBD = C4::Context->preference('OPACISBD'); |
746 |
$ISBD = C4::Context->preference('OPACISBD'); |
747 |
} |
747 |
} |
748 |
|
748 |
|
749 |
my $bloc = $ISBD; |
749 |
my $bloc = $ISBD; |
750 |
my $res; |
750 |
my $res; |
751 |
my $blocres; |
751 |
my $blocres; |
752 |
|
752 |
|
753 |
foreach my $isbdfield ( split (/#/, $bloc) ) { |
753 |
foreach my $isbdfield ( split (/#/, $bloc) ) { |
754 |
|
754 |
|
755 |
# $isbdfield= /(.?.?.?)/; |
755 |
# $isbdfield= /(.?.?.?)/; |
Lines 759-777
sub GetISBDView {
Link Here
|
759 |
my $textbefore = $3; |
759 |
my $textbefore = $3; |
760 |
my $analysestring = $4; |
760 |
my $analysestring = $4; |
761 |
my $textafter = $5; |
761 |
my $textafter = $5; |
762 |
|
762 |
|
763 |
# warn "==> $1 / $2 / $3 / $4"; |
763 |
# warn "==> $1 / $2 / $3 / $4"; |
764 |
# my $fieldvalue=substr($isbdfield,0,3); |
764 |
# my $fieldvalue=substr($isbdfield,0,3); |
765 |
if ( $fieldvalue > 0 ) { |
765 |
if ( $fieldvalue > 0 ) { |
766 |
my $hasputtextbefore = 0; |
766 |
my $hasputtextbefore = 0; |
767 |
my @fieldslist = $record->field($fieldvalue); |
767 |
my @fieldslist = $record->field($fieldvalue); |
768 |
@fieldslist = sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf); |
768 |
@fieldslist = sort {$a->subfield($holdingbrtagsubf) cmp $b->subfield($holdingbrtagsubf)} @fieldslist if ($fieldvalue eq $holdingbrtagf); |
769 |
|
769 |
|
770 |
# warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue; |
770 |
# warn "ERROR IN ISBD DEFINITION at : $isbdfield" unless $fieldvalue; |
771 |
# warn "FV : $fieldvalue"; |
771 |
# warn "FV : $fieldvalue"; |
772 |
if ($subfvalue ne ""){ |
772 |
if ($subfvalue ne ""){ |
773 |
foreach my $field ( @fieldslist ) { |
773 |
foreach my $field ( @fieldslist ) { |
774 |
foreach my $subfield ($field->subfield($subfvalue)){ |
774 |
foreach my $subfield ($field->subfield($subfvalue)){ |
775 |
my $calculated = $analysestring; |
775 |
my $calculated = $analysestring; |
776 |
my $tag = $field->tag(); |
776 |
my $tag = $field->tag(); |
777 |
if ( $tag < 10 ) { |
777 |
if ( $tag < 10 ) { |
Lines 783-805
sub GetISBDView {
Link Here
|
783 |
my $tagsubf = $tag . $subfvalue; |
783 |
my $tagsubf = $tag . $subfvalue; |
784 |
$calculated =~ |
784 |
$calculated =~ |
785 |
s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; |
785 |
s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; |
786 |
|
786 |
|
787 |
# field builded, store the result |
787 |
# field builded, store the result |
788 |
if ( $calculated && !$hasputtextbefore ) |
788 |
if ( $calculated && !$hasputtextbefore ) |
789 |
{ # put textbefore if not done |
789 |
{ # put textbefore if not done |
790 |
$blocres .= $textbefore; |
790 |
$blocres .= $textbefore; |
791 |
$hasputtextbefore = 1; |
791 |
$hasputtextbefore = 1; |
792 |
} |
792 |
} |
793 |
|
793 |
|
794 |
# remove punctuation at start |
794 |
# remove punctuation at start |
795 |
$calculated =~ s/^( |;|:|\.|-)*//g; |
795 |
$calculated =~ s/^( |;|:|\.|-)*//g; |
796 |
$blocres .= $calculated; |
796 |
$blocres .= $calculated; |
797 |
|
797 |
|
798 |
} |
798 |
} |
799 |
} |
799 |
} |
800 |
} |
800 |
} |
801 |
$blocres .= $textafter if $hasputtextbefore; |
801 |
$blocres .= $textafter if $hasputtextbefore; |
802 |
} else { |
802 |
} else { |
803 |
foreach my $field ( @fieldslist ) { |
803 |
foreach my $field ( @fieldslist ) { |
804 |
my $calculated = $analysestring; |
804 |
my $calculated = $analysestring; |
805 |
my $tag = $field->tag(); |
805 |
my $tag = $field->tag(); |
Lines 814-853
sub GetISBDView {
Link Here
|
814 |
GetAuthorisedValueDesc( $tag, $subf[$i][0], |
814 |
GetAuthorisedValueDesc( $tag, $subf[$i][0], |
815 |
$subf[$i][1], '', $tagslib ); |
815 |
$subf[$i][1], '', $tagslib ); |
816 |
my $tagsubf = $tag . $subfieldcode; |
816 |
my $tagsubf = $tag . $subfieldcode; |
817 |
|
817 |
|
818 |
$calculated =~ s/\{\{$tagsubf\}\}/$valuecode/gx; |
818 |
$calculated =~ s/\{\{$tagsubf\}\}/$valuecode/gx; |
819 |
$calculated =~ |
819 |
$calculated =~ |
820 |
s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; |
820 |
s/\{(.?.?.?.?)$tagsubf(.*?)\}/$1$subfieldvalue$2\{$1$tagsubf$2\}/g; |
821 |
} |
821 |
} |
822 |
|
822 |
|
823 |
# field builded, store the result |
823 |
# field builded, store the result |
824 |
if ( $calculated && !$hasputtextbefore ) |
824 |
if ( $calculated && !$hasputtextbefore ) |
825 |
{ # put textbefore if not done |
825 |
{ # put textbefore if not done |
826 |
$blocres .= $textbefore; |
826 |
$blocres .= $textbefore; |
827 |
$hasputtextbefore = 1; |
827 |
$hasputtextbefore = 1; |
828 |
} |
828 |
} |
829 |
|
829 |
|
830 |
# remove punctuation at start |
830 |
# remove punctuation at start |
831 |
$calculated =~ s/^( |;|:|\.|-)*//g; |
831 |
$calculated =~ s/^( |;|:|\.|-)*//g; |
832 |
$blocres .= $calculated; |
832 |
$blocres .= $calculated; |
833 |
} |
833 |
} |
834 |
} |
834 |
} |
835 |
$blocres .= $textafter if $hasputtextbefore; |
835 |
$blocres .= $textafter if $hasputtextbefore; |
836 |
} |
836 |
} |
837 |
} |
837 |
} |
838 |
else { |
838 |
else { |
839 |
$blocres .= $isbdfield; |
839 |
$blocres .= $isbdfield; |
840 |
} |
840 |
} |
841 |
} |
841 |
} |
842 |
$res .= $blocres; |
842 |
$res .= $blocres; |
843 |
|
843 |
|
844 |
$res =~ s/\{(.*?)\}//g; |
844 |
$res =~ s/\{(.*?)\}//g; |
845 |
$res =~ s/\\n/\n/g; |
845 |
$res =~ s/\\n/\n/g; |
846 |
$res =~ s/\n/<br\/>/g; |
846 |
$res =~ s/\n/<br\/>/g; |
847 |
|
847 |
|
848 |
# remove empty () |
848 |
# remove empty () |
849 |
$res =~ s/\(\)//g; |
849 |
$res =~ s/\(\)//g; |
850 |
|
850 |
|
851 |
return $res; |
851 |
return $res; |
852 |
} |
852 |
} |
853 |
|
853 |
|
Lines 934-942
sub GetMarcStructure {
Link Here
|
934 |
my ($total) = $sth->fetchrow; |
934 |
my ($total) = $sth->fetchrow; |
935 |
$frameworkcode = "" unless ( $total > 0 ); |
935 |
$frameworkcode = "" unless ( $total > 0 ); |
936 |
$sth = $dbh->prepare( |
936 |
$sth = $dbh->prepare( |
937 |
"SELECT tagfield,liblibrarian,libopac,mandatory,repeatable |
937 |
"SELECT tagfield,liblibrarian,libopac,mandatory,repeatable |
938 |
FROM marc_tag_structure |
938 |
FROM marc_tag_structure |
939 |
WHERE frameworkcode=? |
939 |
WHERE frameworkcode=? |
940 |
ORDER BY tagfield" |
940 |
ORDER BY tagfield" |
941 |
); |
941 |
); |
942 |
$sth->execute($frameworkcode); |
942 |
$sth->execute($frameworkcode); |
Lines 953-965
sub GetMarcStructure {
Link Here
|
953 |
} |
953 |
} |
954 |
|
954 |
|
955 |
$sth = $dbh->prepare( |
955 |
$sth = $dbh->prepare( |
956 |
"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue |
956 |
"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab,mandatory,repeatable,authorised_value,authtypecode,value_builder,kohafield,seealso,hidden,isurl,link,defaultvalue |
957 |
FROM marc_subfield_structure |
957 |
FROM marc_subfield_structure |
958 |
WHERE frameworkcode=? |
958 |
WHERE frameworkcode=? |
959 |
ORDER BY tagfield,tagsubfield |
959 |
ORDER BY tagfield,tagsubfield |
960 |
" |
960 |
" |
961 |
); |
961 |
); |
962 |
|
962 |
|
963 |
$sth->execute($frameworkcode); |
963 |
$sth->execute($frameworkcode); |
964 |
|
964 |
|
965 |
my $subfield; |
965 |
my $subfield; |
Lines 1010-1023
sub GetMarcStructure {
Link Here
|
1010 |
|
1010 |
|
1011 |
the same function as GetMarcStructure except it just takes field |
1011 |
the same function as GetMarcStructure except it just takes field |
1012 |
in tab 0-9. (used field) |
1012 |
in tab 0-9. (used field) |
1013 |
|
1013 |
|
1014 |
my $results = GetUsedMarcStructure($frameworkcode); |
1014 |
my $results = GetUsedMarcStructure($frameworkcode); |
1015 |
|
1015 |
|
1016 |
L<$results> is a ref to an array which each case containts a ref |
1016 |
L<$results> is a ref to an array which each case containts a ref |
1017 |
to a hash which each keys is the columns from marc_subfield_structure |
1017 |
to a hash which each keys is the columns from marc_subfield_structure |
1018 |
|
1018 |
|
1019 |
L<$frameworkcode> is the framework code. |
1019 |
L<$frameworkcode> is the framework code. |
1020 |
|
1020 |
|
1021 |
=cut |
1021 |
=cut |
1022 |
|
1022 |
|
1023 |
sub GetUsedMarcStructure($){ |
1023 |
sub GetUsedMarcStructure($){ |
Lines 1025-1031
sub GetUsedMarcStructure($){
Link Here
|
1025 |
my $query = qq/ |
1025 |
my $query = qq/ |
1026 |
SELECT * |
1026 |
SELECT * |
1027 |
FROM marc_subfield_structure |
1027 |
FROM marc_subfield_structure |
1028 |
WHERE tab > -1 |
1028 |
WHERE tab > -1 |
1029 |
AND frameworkcode = ? |
1029 |
AND frameworkcode = ? |
1030 |
ORDER BY tagfield, tagsubfield |
1030 |
ORDER BY tagfield, tagsubfield |
1031 |
/; |
1031 |
/; |
Lines 1039-1045
sub GetUsedMarcStructure($){
Link Here
|
1039 |
=over 4 |
1039 |
=over 4 |
1040 |
|
1040 |
|
1041 |
($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode); |
1041 |
($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode); |
1042 |
Returns the MARC fields & subfields mapped to the koha field |
1042 |
Returns the MARC fields & subfields mapped to the koha field |
1043 |
for the given frameworkcode |
1043 |
for the given frameworkcode |
1044 |
|
1044 |
|
1045 |
=back |
1045 |
=back |
Lines 1250-1275
Return the summary of a record.
Link Here
|
1250 |
|
1250 |
|
1251 |
sub GetBiblioSummary { |
1251 |
sub GetBiblioSummary { |
1252 |
my $recorddata =shift @_; |
1252 |
my $recorddata =shift @_; |
1253 |
|
1253 |
|
1254 |
return unless $recorddata; |
1254 |
return unless $recorddata; |
1255 |
my $marcflavour = C4::Context->preference("marcflavour"); |
1255 |
my $marcflavour = C4::Context->preference("marcflavour"); |
1256 |
my $marc=MARC::Record::new_from_xml($recorddata,"utf-8",$marcflavour); |
1256 |
my $marc=MARC::Record::new_from_xml($recorddata,"utf-8",$marcflavour); |
1257 |
return unless $marc; |
1257 |
return unless $marc; |
1258 |
|
1258 |
|
1259 |
my $str; |
1259 |
my $str; |
1260 |
|
1260 |
|
1261 |
if($marcflavour eq "MARC21"){ |
1261 |
if($marcflavour eq "MARC21"){ |
1262 |
$str="<b>".$marc->subfield('245',"a")."</b>" if $marc->subfield('245','a'); |
1262 |
$str="<b>".$marc->subfield('245',"a")."</b>" if $marc->subfield('245','a'); |
1263 |
$str.= " <i>".$marc->subfield('245',"b")."</i> " if $marc->subfield('245','b'); |
1263 |
$str.= " <i>".$marc->subfield('245',"b")."</i> " if $marc->subfield('245','b'); |
1264 |
|
1264 |
|
1265 |
if ($marc->field('245')){ |
1265 |
if ($marc->field('245')){ |
1266 |
$str.=" / "; |
1266 |
$str.=" / "; |
1267 |
foreach ($marc->field('100')->subfield("a")) { |
1267 |
foreach ($marc->field('100')->subfield("a")) { |
1268 |
$str.=$_." ; "; |
1268 |
$str.=$_." ; "; |
1269 |
} |
1269 |
} |
1270 |
$str=~s/ ; $/. /; |
1270 |
$str=~s/ ; $/. /; |
1271 |
} |
1271 |
} |
1272 |
|
1272 |
|
1273 |
if ($marc->field('260')){ |
1273 |
if ($marc->field('260')){ |
1274 |
$str.=" - "; |
1274 |
$str.=" - "; |
1275 |
$str.=$marc->subfield('260',"a")." " if $marc->subfield('260','a'); |
1275 |
$str.=$marc->subfield('260',"a")." " if $marc->subfield('260','a'); |
Lines 1287-1298
sub GetBiblioSummary {
Link Here
|
1287 |
$str.= " - "; |
1287 |
$str.= " - "; |
1288 |
foreach ($_->subfield("a")){ |
1288 |
foreach ($_->subfield("a")){ |
1289 |
$str.=$_."; " |
1289 |
$str.=$_."; " |
1290 |
} |
1290 |
} |
1291 |
} |
1291 |
} |
1292 |
my $itemtypes=GetItemTypes(); |
1292 |
my $itemtypes=GetItemTypes(); |
1293 |
$str.=" - <u>".$itemtypes->{$marc->subfield('942','c')}->{'description'}."</u> "; |
1293 |
$str.=" - <u>".$itemtypes->{$marc->subfield('942','c')}->{'description'}."</u> "; |
1294 |
$str.="<br />\n"; |
1294 |
$str.="<br />\n"; |
1295 |
|
1295 |
|
1296 |
}else{ |
1296 |
}else{ |
1297 |
$str = "<b>".$marc->subfield('200','a')."</b>" if $marc->subfield('200','a'); |
1297 |
$str = "<b>".$marc->subfield('200','a')."</b>" if $marc->subfield('200','a'); |
1298 |
$str.= " <i>".$marc->subfield('200','e')."</i> " if $marc->subfield('200','e'); |
1298 |
$str.= " <i>".$marc->subfield('200','e')."</i> " if $marc->subfield('200','e'); |
Lines 1301-1317
sub GetBiblioSummary {
Link Here
|
1301 |
foreach ($marc->field('200')->subfield("f")) { |
1301 |
foreach ($marc->field('200')->subfield("f")) { |
1302 |
$str.=$_." ; "; |
1302 |
$str.=$_." ; "; |
1303 |
} |
1303 |
} |
1304 |
$str=~s/ ; $/. /; |
1304 |
$str=~s/ ; $/. /; |
1305 |
} |
1305 |
} |
1306 |
|
1306 |
|
1307 |
if ($marc->subfield('200','g')){ |
1307 |
if ($marc->subfield('200','g')){ |
1308 |
$str.=" ; "; |
1308 |
$str.=" ; "; |
1309 |
foreach ($marc->field('200')->subfield("g")){ |
1309 |
foreach ($marc->field('200')->subfield("g")){ |
1310 |
$str.=$_." ; "; |
1310 |
$str.=$_." ; "; |
1311 |
} |
1311 |
} |
1312 |
$str=~s/ ; $/. /; |
1312 |
$str=~s/ ; $/. /; |
1313 |
} |
1313 |
} |
1314 |
|
1314 |
|
1315 |
if ($marc->field('461')){ |
1315 |
if ($marc->field('461')){ |
1316 |
$str.="- In :"; |
1316 |
$str.="- In :"; |
1317 |
$str.= $marc->subfield('461','t') if $marc->subfield('461','t'); |
1317 |
$str.= $marc->subfield('461','t') if $marc->subfield('461','t'); |
Lines 1320-1333
sub GetBiblioSummary {
Link Here
|
1320 |
$str.=", ".$marc->subfield('461','h') if $marc->subfield('461','h'); |
1320 |
$str.=", ".$marc->subfield('461','h') if $marc->subfield('461','h'); |
1321 |
$str.=" ; ".$marc->subfield('461','x') if $marc->subfield('461','x'); |
1321 |
$str.=" ; ".$marc->subfield('461','x') if $marc->subfield('461','x'); |
1322 |
} |
1322 |
} |
1323 |
|
1323 |
|
1324 |
if ($marc->field('210')){ |
1324 |
if ($marc->field('210')){ |
1325 |
$str.=" - "; |
1325 |
$str.=" - "; |
1326 |
$str.=$marc->subfield('210',"a")." " if $marc->subfield('210','a'); |
1326 |
$str.=$marc->subfield('210',"a")." " if $marc->subfield('210','a'); |
1327 |
$str.=" : ".$marc->subfield('210',"c")." " if $marc->subfield('210','c'); |
1327 |
$str.=" : ".$marc->subfield('210',"c")." " if $marc->subfield('210','c'); |
1328 |
$str.=", ".$marc->subfield('210',"d")." " if $marc->subfield('210','d'); |
1328 |
$str.=", ".$marc->subfield('210',"d")." " if $marc->subfield('210','d'); |
1329 |
} |
1329 |
} |
1330 |
|
1330 |
|
1331 |
if ($marc->field('215')){ |
1331 |
if ($marc->field('215')){ |
1332 |
$str.=" - "; |
1332 |
$str.=" - "; |
1333 |
$str.=$marc->subfield('215','a') if ($marc->subfield(215,'a')); |
1333 |
$str.=$marc->subfield('215','a') if ($marc->subfield(215,'a')); |
Lines 1339-1353
sub GetBiblioSummary {
Link Here
|
1339 |
$str.=" - "; |
1339 |
$str.=" - "; |
1340 |
foreach ($_->subfield("a")){ |
1340 |
foreach ($_->subfield("a")){ |
1341 |
$str.=$_."; " |
1341 |
$str.=$_."; " |
1342 |
} |
1342 |
} |
1343 |
} |
1343 |
} |
1344 |
|
1344 |
|
1345 |
my $itemtypes=GetItemTypes; |
1345 |
my $itemtypes=GetItemTypes; |
1346 |
if($itemtypes->{$marc->subfield('200','b')}){ |
1346 |
if($itemtypes->{$marc->subfield('200','b')}){ |
1347 |
$str.=" - <u>".$itemtypes->{$marc->subfield('200','b')}->{'description'}."</u> "; |
1347 |
$str.=" - <u>".$itemtypes->{$marc->subfield('200','b')}->{'description'}."</u> "; |
1348 |
} |
1348 |
} |
1349 |
$str.="<br />\n"; |
1349 |
$str.="<br />\n"; |
1350 |
} |
1350 |
} |
1351 |
return $str; |
1351 |
return $str; |
1352 |
} |
1352 |
} |
1353 |
|
1353 |
|
Lines 1472-1478
sub GetMarcSubjects {
Link Here
|
1472 |
$mintag = "600"; |
1472 |
$mintag = "600"; |
1473 |
$maxtag = "611"; |
1473 |
$maxtag = "611"; |
1474 |
} |
1474 |
} |
1475 |
|
1475 |
|
1476 |
my @marcsubjects; |
1476 |
my @marcsubjects; |
1477 |
my $subject = ""; |
1477 |
my $subject = ""; |
1478 |
my $subfield = ""; |
1478 |
my $subfield = ""; |
Lines 1485-1490
sub GetMarcSubjects {
Link Here
|
1485 |
my $counter = 0; |
1485 |
my $counter = 0; |
1486 |
my @link_loop; |
1486 |
my @link_loop; |
1487 |
# if there is an authority link, build the link with an= subfield9 |
1487 |
# if there is an authority link, build the link with an= subfield9 |
|
|
1488 |
my $found9 = 0; |
1488 |
my $subfield9 = $field->subfield('9'); |
1489 |
my $subfield9 = $field->subfield('9'); |
1489 |
for my $subject_subfield (@subfields ) { |
1490 |
for my $subject_subfield (@subfields ) { |
1490 |
# don't load unimarc subfields 3,4,5 |
1491 |
# don't load unimarc subfields 3,4,5 |
Lines 1494-1515
sub GetMarcSubjects {
Link Here
|
1494 |
my $code = $subject_subfield->[0]; |
1495 |
my $code = $subject_subfield->[0]; |
1495 |
my $value = $subject_subfield->[1]; |
1496 |
my $value = $subject_subfield->[1]; |
1496 |
my $linkvalue = $value; |
1497 |
my $linkvalue = $value; |
|
|
1498 |
my $limit = ''; |
1497 |
$linkvalue =~ s/(\(|\))//g; |
1499 |
$linkvalue =~ s/(\(|\))//g; |
1498 |
my $operator = " and " unless $counter==0; |
1500 |
my $operator = " and " unless $counter == 0; |
1499 |
if ($subfield9) { |
1501 |
if ( $code eq 9 ) { |
1500 |
@link_loop = ({'limit' => 'an' ,link => "$subfield9" }); |
1502 |
$found9 = 1; |
1501 |
} else { |
1503 |
$limit = 'an'; |
1502 |
push @link_loop, {'limit' => 'su', link => $linkvalue, operator => $operator }; |
1504 |
@link_loop = ( {link => "$linkvalue" } ); |
|
|
1505 |
} |
1506 |
if ( not $found9 ) { |
1507 |
$limit = 'su'; |
1508 |
push @link_loop, {link => $linkvalue, operator => $operator }; |
1503 |
} |
1509 |
} |
1504 |
my $separator = C4::Context->preference("authoritysep") unless $counter==0; |
1510 |
my $separator = C4::Context->preference("authoritysep") unless $counter==0; |
1505 |
# ignore $9 |
1511 |
# ignore $9 |
1506 |
my @this_link_loop = @link_loop; |
1512 |
my @this_link_loop = @link_loop; |
1507 |
push @subfields_loop, {code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator} unless ($subject_subfield->[0] eq 9 ); |
1513 |
push @subfields_loop, { code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator, limit => $limit} unless ( $subject_subfield->[0] eq 9 ); |
1508 |
$counter++; |
1514 |
$counter++; |
1509 |
} |
1515 |
} |
1510 |
|
|
|
1511 |
push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; |
1516 |
push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; |
1512 |
|
1517 |
|
1513 |
} |
1518 |
} |
1514 |
return \@marcsubjects; |
1519 |
return \@marcsubjects; |
1515 |
} #end getMARCsubjects |
1520 |
} #end getMARCsubjects |
Lines 1533-1539
sub GetMarcAuthors {
Link Here
|
1533 |
my $tagslib = &GetMarcStructure( 1, '' ); # FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct. |
1538 |
my $tagslib = &GetMarcStructure( 1, '' ); # FIXME : we don't have the framework available, we take the default framework. May be buggy on some setups, will be usually correct. |
1534 |
if ( $marcflavour eq "MARC21" ) { |
1539 |
if ( $marcflavour eq "MARC21" ) { |
1535 |
$mintag = "700"; |
1540 |
$mintag = "700"; |
1536 |
$maxtag = "720"; |
1541 |
$maxtag = "720"; |
1537 |
} |
1542 |
} |
1538 |
elsif ( $marcflavour eq "UNIMARC" ) { # assume unimarc if not marc21 |
1543 |
elsif ( $marcflavour eq "UNIMARC" ) { # assume unimarc if not marc21 |
1539 |
$mintag = "700"; |
1544 |
$mintag = "700"; |
Lines 1588-1594
sub GetMarcAuthors {
Link Here
|
1588 |
|
1593 |
|
1589 |
$marcurls = GetMarcUrls($record,$marcflavour); |
1594 |
$marcurls = GetMarcUrls($record,$marcflavour); |
1590 |
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop. |
1595 |
Returns arrayref of URLs from MARC data, suitable to pass to tmpl loop. |
1591 |
Assumes web resources (not uncommon in MARC21 to omit resource type ind) |
1596 |
Assumes web resources (not uncommon in MARC21 to omit resource type ind) |
1592 |
|
1597 |
|
1593 |
=back |
1598 |
=back |
1594 |
|
1599 |
|
Lines 1841-1847
sub TransformHtmlToXml {
Link Here
|
1841 |
$auth_type = C4::Context->preference('marcflavour') unless $auth_type; |
1846 |
$auth_type = C4::Context->preference('marcflavour') unless $auth_type; |
1842 |
MARC::File::XML->default_record_format($auth_type); |
1847 |
MARC::File::XML->default_record_format($auth_type); |
1843 |
# in UNIMARC, field 100 contains the encoding |
1848 |
# in UNIMARC, field 100 contains the encoding |
1844 |
# check that there is one, otherwise the |
1849 |
# check that there is one, otherwise the |
1845 |
# MARC::Record->new_from_xml will fail (and Koha will die) |
1850 |
# MARC::Record->new_from_xml will fail (and Koha will die) |
1846 |
my $unimarc_and_100_exist=0; |
1851 |
my $unimarc_and_100_exist=0; |
1847 |
$unimarc_and_100_exist=1 if $auth_type eq 'ITEM'; # if we rebuild an item, no need of a 100 field |
1852 |
$unimarc_and_100_exist=1 if $auth_type eq 'ITEM'; # if we rebuild an item, no need of a 100 field |
Lines 2011-2021
sub TransformHtmlToMarc {
Link Here
|
2011 |
my $param_value = $cgi_params->{$param_name}; |
2016 |
my $param_value = $cgi_params->{$param_name}; |
2012 |
if (utf8::decode($param_value)) { |
2017 |
if (utf8::decode($param_value)) { |
2013 |
$cgi_params->{$param_name} = $param_value; |
2018 |
$cgi_params->{$param_name} = $param_value; |
2014 |
} |
2019 |
} |
2015 |
# FIXME - need to do something if string is not valid UTF-8 |
2020 |
# FIXME - need to do something if string is not valid UTF-8 |
2016 |
} |
2021 |
} |
2017 |
} |
2022 |
} |
2018 |
|
2023 |
|
2019 |
# creating a new record |
2024 |
# creating a new record |
2020 |
my $record = MARC::Record->new(); |
2025 |
my $record = MARC::Record->new(); |
2021 |
my $i=0; |
2026 |
my $i=0; |
Lines 2041-2055
sub TransformHtmlToMarc {
Link Here
|
2041 |
); |
2046 |
); |
2042 |
} |
2047 |
} |
2043 |
push @fields,$newfield if($newfield); |
2048 |
push @fields,$newfield if($newfield); |
2044 |
} |
2049 |
} |
2045 |
elsif ($param =~ /^tag_(\d*)_indicator1_/){ # new field start when having 'input name="..._indicator1_..." |
2050 |
elsif ($param =~ /^tag_(\d*)_indicator1_/){ # new field start when having 'input name="..._indicator1_..." |
2046 |
my $tag = $1; |
2051 |
my $tag = $1; |
2047 |
|
2052 |
|
2048 |
my $ind1 = _default_ind_to_space(substr($cgi->param($param), 0, 1)); |
2053 |
my $ind1 = _default_ind_to_space(substr($cgi->param($param), 0, 1)); |
2049 |
my $ind2 = _default_ind_to_space(substr($cgi->param($params->[$i+1]), 0, 1)); |
2054 |
my $ind2 = _default_ind_to_space(substr($cgi->param($params->[$i+1]), 0, 1)); |
2050 |
$newfield=0; |
2055 |
$newfield=0; |
2051 |
my $j=$i+2; |
2056 |
my $j=$i+2; |
2052 |
|
2057 |
|
2053 |
if($tag < 10){ # no code for theses fields |
2058 |
if($tag < 10){ # no code for theses fields |
2054 |
# in MARC editor, 000 contains the leader. |
2059 |
# in MARC editor, 000 contains the leader. |
2055 |
if ($tag eq '000' ) { |
2060 |
if ($tag eq '000' ) { |
Lines 2088-2094
sub TransformHtmlToMarc {
Link Here
|
2088 |
} |
2093 |
} |
2089 |
$i++; |
2094 |
$i++; |
2090 |
} |
2095 |
} |
2091 |
|
2096 |
|
2092 |
$record->append_fields(@fields); |
2097 |
$record->append_fields(@fields); |
2093 |
return $record; |
2098 |
return $record; |
2094 |
} |
2099 |
} |
Lines 2105-2111
our $inverted_field_map;
Link Here
|
2105 |
=back |
2110 |
=back |
2106 |
|
2111 |
|
2107 |
Extract data from a MARC bib record into a hashref representing |
2112 |
Extract data from a MARC bib record into a hashref representing |
2108 |
Koha biblio, biblioitems, and items fields. |
2113 |
Koha biblio, biblioitems, and items fields. |
2109 |
|
2114 |
|
2110 |
=cut |
2115 |
=cut |
2111 |
sub TransformMarcToKoha { |
2116 |
sub TransformMarcToKoha { |
Lines 2114-2120
sub TransformMarcToKoha {
Link Here
|
2114 |
my $result; |
2119 |
my $result; |
2115 |
$limit_table=$limit_table||0; |
2120 |
$limit_table=$limit_table||0; |
2116 |
$frameworkcode = '' unless defined $frameworkcode; |
2121 |
$frameworkcode = '' unless defined $frameworkcode; |
2117 |
|
2122 |
|
2118 |
unless (defined $inverted_field_map) { |
2123 |
unless (defined $inverted_field_map) { |
2119 |
$inverted_field_map = _get_inverted_marc_field_map(); |
2124 |
$inverted_field_map = _get_inverted_marc_field_map(); |
2120 |
} |
2125 |
} |
Lines 2238-2244
name with the table name would require changing lots
Link Here
|
2238 |
of code and templates, and exposing more of the DB |
2243 |
of code and templates, and exposing more of the DB |
2239 |
structure than is good to the UI templates, particularly |
2244 |
structure than is good to the UI templates, particularly |
2240 |
since biblio and bibloitems may well merge in a future |
2245 |
since biblio and bibloitems may well merge in a future |
2241 |
version. In the future, it would also be good to |
2246 |
version. In the future, it would also be good to |
2242 |
separate DB access and UI presentation field names |
2247 |
separate DB access and UI presentation field names |
2243 |
more. |
2248 |
more. |
2244 |
|
2249 |
|
Lines 2280-2286
FIXME: this is meant to replace TransformMarcToKohaOneField after more testing.
Link Here
|
2280 |
|
2285 |
|
2281 |
sub get_koha_field_from_marc { |
2286 |
sub get_koha_field_from_marc { |
2282 |
my ($koha_table,$koha_column,$record,$frameworkcode) = @_; |
2287 |
my ($koha_table,$koha_column,$record,$frameworkcode) = @_; |
2283 |
my ( $tagfield, $subfield ) = GetMarcFromKohaField( $koha_table.'.'.$koha_column, $frameworkcode ); |
2288 |
my ( $tagfield, $subfield ) = GetMarcFromKohaField( $koha_table.'.'.$koha_column, $frameworkcode ); |
2284 |
my $kohafield; |
2289 |
my $kohafield; |
2285 |
foreach my $field ( $record->field($tagfield) ) { |
2290 |
foreach my $field ( $record->field($tagfield) ) { |
2286 |
if ( $field->tag() < 10 ) { |
2291 |
if ( $field->tag() < 10 ) { |
Lines 2310-2316
sub get_koha_field_from_marc {
Link Here
|
2310 |
} |
2315 |
} |
2311 |
} |
2316 |
} |
2312 |
return $kohafield; |
2317 |
return $kohafield; |
2313 |
} |
2318 |
} |
2314 |
|
2319 |
|
2315 |
|
2320 |
|
2316 |
=head2 TransformMarcToKohaOneField |
2321 |
=head2 TransformMarcToKohaOneField |
Lines 2460-2466
sub PrepareItemrecordDisplay {
Link Here
|
2460 |
if ( ($tagslib->{$tag}->{$subfield}->{kohafield} eq |
2465 |
if ( ($tagslib->{$tag}->{$subfield}->{kohafield} eq |
2461 |
'items.holdingbranch' || |
2466 |
'items.holdingbranch' || |
2462 |
$tagslib->{$tag}->{$subfield}->{kohafield} eq |
2467 |
$tagslib->{$tag}->{$subfield}->{kohafield} eq |
2463 |
'items.homebranch') |
2468 |
'items.homebranch') |
2464 |
&& $defaultvalues->{'branchcode'} ) |
2469 |
&& $defaultvalues->{'branchcode'} ) |
2465 |
{ |
2470 |
{ |
2466 |
my $temp = $itemrecord->field($subfield) if ($itemrecord); |
2471 |
my $temp = $itemrecord->field($subfield) if ($itemrecord); |
Lines 2580-2594
sub PrepareItemrecordDisplay {
Link Here
|
2580 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2585 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2581 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
2586 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
2582 |
# =head2 ModZebrafiles |
2587 |
# =head2 ModZebrafiles |
2583 |
# |
2588 |
# |
2584 |
# &ModZebrafiles( $dbh, $biblionumber, $record, $folder, $server ); |
2589 |
# &ModZebrafiles( $dbh, $biblionumber, $record, $folder, $server ); |
2585 |
# |
2590 |
# |
2586 |
# =cut |
2591 |
# =cut |
2587 |
# |
2592 |
# |
2588 |
# sub ModZebrafiles { |
2593 |
# sub ModZebrafiles { |
2589 |
# |
2594 |
# |
2590 |
# my ( $dbh, $biblionumber, $record, $folder, $server ) = @_; |
2595 |
# my ( $dbh, $biblionumber, $record, $folder, $server ) = @_; |
2591 |
# |
2596 |
# |
2592 |
# my $op; |
2597 |
# my $op; |
2593 |
# my $zebradir = |
2598 |
# my $zebradir = |
2594 |
# C4::Context->zebraconfig($server)->{directory} . "/" . $folder . "/"; |
2599 |
# C4::Context->zebraconfig($server)->{directory} . "/" . $folder . "/"; |
Lines 2598-2604
sub PrepareItemrecordDisplay {
Link Here
|
2598 |
# } |
2603 |
# } |
2599 |
# closedir DIR; |
2604 |
# closedir DIR; |
2600 |
# my $filename = $zebradir . $biblionumber; |
2605 |
# my $filename = $zebradir . $biblionumber; |
2601 |
# |
2606 |
# |
2602 |
# if ($record) { |
2607 |
# if ($record) { |
2603 |
# open( OUTPUT, ">", $filename . ".xml" ); |
2608 |
# open( OUTPUT, ">", $filename . ".xml" ); |
2604 |
# print OUTPUT $record; |
2609 |
# print OUTPUT $record; |
Lines 2615-2625
ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord );
Link Here
|
2615 |
$biblionumber is the biblionumber we want to index |
2620 |
$biblionumber is the biblionumber we want to index |
2616 |
$op is specialUpdate or delete, and is used to know what we want to do |
2621 |
$op is specialUpdate or delete, and is used to know what we want to do |
2617 |
$server is the server that we want to update |
2622 |
$server is the server that we want to update |
2618 |
$oldRecord is the MARC::Record containing the previous version of the record. This is used only when |
2623 |
$oldRecord is the MARC::Record containing the previous version of the record. This is used only when |
2619 |
NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to |
2624 |
NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to |
2620 |
do an update. |
2625 |
do an update. |
2621 |
$newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one. |
2626 |
$newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one. |
2622 |
|
2627 |
|
2623 |
=back |
2628 |
=back |
2624 |
|
2629 |
|
2625 |
=cut |
2630 |
=cut |
Lines 2643-2649
sub ModZebra {
Link Here
|
2643 |
if ($op eq 'specialUpdate') { |
2648 |
if ($op eq 'specialUpdate') { |
2644 |
# OK, we have to add or update the record |
2649 |
# OK, we have to add or update the record |
2645 |
# 1st delete (virtually, in indexes), if record actually exists |
2650 |
# 1st delete (virtually, in indexes), if record actually exists |
2646 |
if ($oldRecord) { |
2651 |
if ($oldRecord) { |
2647 |
%result = _DelBiblioNoZebra($biblionumber,$oldRecord,$server); |
2652 |
%result = _DelBiblioNoZebra($biblionumber,$oldRecord,$server); |
2648 |
} |
2653 |
} |
2649 |
# ... add the record |
2654 |
# ... add the record |
Lines 2665-2671
sub ModZebra {
Link Here
|
2665 |
# |
2670 |
# |
2666 |
# we use zebra, just fill zebraqueue table |
2671 |
# we use zebra, just fill zebraqueue table |
2667 |
# |
2672 |
# |
2668 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2673 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2669 |
WHERE server = ? |
2674 |
WHERE server = ? |
2670 |
AND biblio_auth_number = ? |
2675 |
AND biblio_auth_number = ? |
2671 |
AND operation = ? |
2676 |
AND operation = ? |
Lines 2685-2691
sub ModZebra {
Link Here
|
2685 |
=head2 GetNoZebraIndexes |
2690 |
=head2 GetNoZebraIndexes |
2686 |
|
2691 |
|
2687 |
%indexes = GetNoZebraIndexes; |
2692 |
%indexes = GetNoZebraIndexes; |
2688 |
|
2693 |
|
2689 |
return the data from NoZebraIndexes syspref. |
2694 |
return the data from NoZebraIndexes syspref. |
2690 |
|
2695 |
|
2691 |
=cut |
2696 |
=cut |
Lines 2721-2727
sub GetNoZebraIndexes {
Link Here
|
2721 |
|
2726 |
|
2722 |
sub _DelBiblioNoZebra { |
2727 |
sub _DelBiblioNoZebra { |
2723 |
my ($biblionumber, $record, $server)=@_; |
2728 |
my ($biblionumber, $record, $server)=@_; |
2724 |
|
2729 |
|
2725 |
# Get the indexes |
2730 |
# Get the indexes |
2726 |
my $dbh = C4::Context->dbh; |
2731 |
my $dbh = C4::Context->dbh; |
2727 |
# Get the indexes |
2732 |
# Get the indexes |
Lines 2742-2748
sub _DelBiblioNoZebra {
Link Here
|
2742 |
$index{'mainentry'} = $authref->{'auth_tag_to_report'}.'*'; |
2747 |
$index{'mainentry'} = $authref->{'auth_tag_to_report'}.'*'; |
2743 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
2748 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
2744 |
} |
2749 |
} |
2745 |
|
2750 |
|
2746 |
my %result; |
2751 |
my %result; |
2747 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
2752 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
2748 |
$title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g; |
2753 |
$title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g; |
Lines 3101-3107
sub _koha_add_biblio {
Link Here
|
3101 |
my $serial = 0; |
3106 |
my $serial = 0; |
3102 |
if ( $biblio->{'seriestitle'} ) { $serial = 1 }; |
3107 |
if ( $biblio->{'seriestitle'} ) { $serial = 1 }; |
3103 |
|
3108 |
|
3104 |
my $query = |
3109 |
my $query = |
3105 |
"INSERT INTO biblio |
3110 |
"INSERT INTO biblio |
3106 |
SET frameworkcode = ?, |
3111 |
SET frameworkcode = ?, |
3107 |
author = ?, |
3112 |
author = ?, |
Lines 3169-3175
sub _koha_modify_biblio {
Link Here
|
3169 |
" |
3174 |
" |
3170 |
; |
3175 |
; |
3171 |
my $sth = $dbh->prepare($query); |
3176 |
my $sth = $dbh->prepare($query); |
3172 |
|
3177 |
|
3173 |
$sth->execute( |
3178 |
$sth->execute( |
3174 |
$frameworkcode, |
3179 |
$frameworkcode, |
3175 |
$biblio->{'author'}, |
3180 |
$biblio->{'author'}, |
Lines 3210-3217
sub _koha_modify_biblioitem_nonmarc {
Link Here
|
3210 |
# re-calculate the cn_sort, it may have changed |
3215 |
# re-calculate the cn_sort, it may have changed |
3211 |
my ($cn_sort) = GetClassSort($biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'} ); |
3216 |
my ($cn_sort) = GetClassSort($biblioitem->{'biblioitems.cn_source'}, $biblioitem->{'cn_class'}, $biblioitem->{'cn_item'} ); |
3212 |
|
3217 |
|
3213 |
my $query = |
3218 |
my $query = |
3214 |
"UPDATE biblioitems |
3219 |
"UPDATE biblioitems |
3215 |
SET biblionumber = ?, |
3220 |
SET biblionumber = ?, |
3216 |
volume = ?, |
3221 |
volume = ?, |
3217 |
number = ?, |
3222 |
number = ?, |
Lines 3306-3317
sub _koha_add_biblioitem {
Link Here
|
3306 |
volume volumedate volumedesc |
3311 |
volume volumedate volumedesc |
3307 |
/; |
3312 |
/; |
3308 |
|
3313 |
|
3309 |
($$biblioitem{cn_sort}) = GetClassSort( @$biblioitem{qw/ biblioitems.cn_source cn_class cn_item /} ); |
3314 |
($$biblioitem{cn_sort}) = GetClassSort( @$biblioitem{qw/ biblioitems.cn_source cn_class cn_item /} ); |
3310 |
|
3315 |
|
3311 |
my $query = 'INSERT INTO biblioitems SET ' |
3316 |
my $query = 'INSERT INTO biblioitems SET ' |
3312 |
. join ( ',', map { "$_ =?" } @fields ) |
3317 |
. join ( ',', map { "$_ =?" } @fields ) |
3313 |
. ';' |
3318 |
. ';' |
3314 |
; |
3319 |
; |
3315 |
|
3320 |
|
3316 |
my $sth = $dbh->prepare($query); |
3321 |
my $sth = $dbh->prepare($query); |
3317 |
$sth->execute( @$biblioitem{@fields} ); |
3322 |
$sth->execute( @$biblioitem{@fields} ); |
Lines 3433-3447
sub _koha_delete_biblioitems {
Link Here
|
3433 |
=head2 ModBiblioMarc |
3438 |
=head2 ModBiblioMarc |
3434 |
|
3439 |
|
3435 |
&ModBiblioMarc($newrec,$biblionumber,$frameworkcode); |
3440 |
&ModBiblioMarc($newrec,$biblionumber,$frameworkcode); |
3436 |
|
3441 |
|
3437 |
Add MARC data for a biblio to koha |
3442 |
Add MARC data for a biblio to koha |
3438 |
|
3443 |
|
3439 |
Function exported, but should NOT be used, unless you really know what you're doing |
3444 |
Function exported, but should NOT be used, unless you really know what you're doing |
3440 |
|
3445 |
|
3441 |
=cut |
3446 |
=cut |
3442 |
|
3447 |
|
3443 |
sub ModBiblioMarc { |
3448 |
sub ModBiblioMarc { |
3444 |
|
3449 |
|
3445 |
# pass the MARC::Record to this function, and it will create the records in the marc field |
3450 |
# pass the MARC::Record to this function, and it will create the records in the marc field |
3446 |
my ( $record, $biblionumber, $frameworkcode ) = @_; |
3451 |
my ( $record, $biblionumber, $frameworkcode ) = @_; |
3447 |
my $dbh = C4::Context->dbh; |
3452 |
my $dbh = C4::Context->dbh; |
Lines 3621-3627
sub set_service_options {
Link Here
|
3621 |
sub get_biblio_authorised_values { |
3626 |
sub get_biblio_authorised_values { |
3622 |
my $biblionumber = shift; |
3627 |
my $biblionumber = shift; |
3623 |
my $record = shift; |
3628 |
my $record = shift; |
3624 |
|
3629 |
|
3625 |
my $forlibrarian = 1; # are we in staff or opac? |
3630 |
my $forlibrarian = 1; # are we in staff or opac? |
3626 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
3631 |
my $frameworkcode = GetFrameworkCode( $biblionumber ); |
3627 |
|
3632 |
|
Lines 3638-3644
sub get_biblio_authorised_values {
Link Here
|
3638 |
AND (kohafield like 'biblio%' |
3643 |
AND (kohafield like 'biblio%' |
3639 |
OR kohafield like '') ); |
3644 |
OR kohafield like '') ); |
3640 |
my $bibliolevel_authorised_values = C4::Context->dbh->selectall_hashref( $query, 'authorised_value' ); |
3645 |
my $bibliolevel_authorised_values = C4::Context->dbh->selectall_hashref( $query, 'authorised_value' ); |
3641 |
|
3646 |
|
3642 |
foreach my $tag ( keys( %$tagslib ) ) { |
3647 |
foreach my $tag ( keys( %$tagslib ) ) { |
3643 |
foreach my $subfield ( keys( %{$tagslib->{ $tag }} ) ) { |
3648 |
foreach my $subfield ( keys( %{$tagslib->{ $tag }} ) ) { |
3644 |
# warn "checking $subfield. type is: " . ref $tagslib->{ $tag }{ $subfield }; |
3649 |
# warn "checking $subfield. type is: " . ref $tagslib->{ $tag }{ $subfield }; |