Lines 93-98
BEGIN {
Link Here
|
93 |
&ModBiblio |
93 |
&ModBiblio |
94 |
&ModBiblioframework |
94 |
&ModBiblioframework |
95 |
&ModZebra |
95 |
&ModZebra |
|
|
96 |
|
97 |
&BatchModField |
96 |
); |
98 |
); |
97 |
|
99 |
|
98 |
# To delete something |
100 |
# To delete something |
Lines 376-382
sub ModBiblioframework {
Link Here
|
376 |
|
378 |
|
377 |
=head2 DelBiblio |
379 |
=head2 DelBiblio |
378 |
|
380 |
|
379 |
my $error = &DelBiblio($dbh,$biblionumber); |
381 |
my $error = &DelBiblio($biblionumber); |
380 |
|
382 |
|
381 |
Exported function (core API) for deleting a biblio in koha. |
383 |
Exported function (core API) for deleting a biblio in koha. |
382 |
Deletes biblio record from Zebra and Koha tables (biblio,biblioitems,items) |
384 |
Deletes biblio record from Zebra and Koha tables (biblio,biblioitems,items) |
Lines 1046-1054
The MARC record contains both biblio & item data.
Link Here
|
1046 |
|
1048 |
|
1047 |
sub GetMarcBiblio { |
1049 |
sub GetMarcBiblio { |
1048 |
my $biblionumber = shift; |
1050 |
my $biblionumber = shift; |
|
|
1051 |
my $deletedtable = shift; |
1049 |
my $dbh = C4::Context->dbh; |
1052 |
my $dbh = C4::Context->dbh; |
1050 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1053 |
my $strsth = qq{SELECT marcxml FROM biblioitems WHERE biblionumber=?}; |
1051 |
$sth->execute($biblionumber); |
1054 |
$strsth .= qq{UNION SELECT marcxml FROM deletedbiblioitems WHERE biblionumber=?} if $deletedtable; |
|
|
1055 |
my $sth = $dbh->prepare($strsth); |
1056 |
my @params=($biblionumber); |
1057 |
push @params, $biblionumber if ($deletedtable); |
1058 |
$sth->execute(@params); |
1052 |
my $row = $sth->fetchrow_hashref; |
1059 |
my $row = $sth->fetchrow_hashref; |
1053 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1060 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1054 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1061 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
Lines 1113-1118
sub GetCOinSBiblio {
Link Here
|
1113 |
my $isbn = ''; |
1120 |
my $isbn = ''; |
1114 |
my $issn = ''; |
1121 |
my $issn = ''; |
1115 |
my $publisher = ''; |
1122 |
my $publisher = ''; |
|
|
1123 |
my $place = ''; |
1124 |
my $tpages = ''; |
1116 |
|
1125 |
|
1117 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1126 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1118 |
my $fmts6; |
1127 |
my $fmts6; |
Lines 1159-1182
sub GetCOinSBiblio {
Link Here
|
1159 |
$genre = ( $mtx eq 'dc' ) ? "&rft.type=$genre" : "&rft.genre=$genre"; |
1168 |
$genre = ( $mtx eq 'dc' ) ? "&rft.type=$genre" : "&rft.genre=$genre"; |
1160 |
|
1169 |
|
1161 |
# Setting datas |
1170 |
# Setting datas |
1162 |
$aulast = $record->subfield( '700', 'a' ); |
1171 |
|
1163 |
$aufirst = $record->subfield( '700', 'b' ); |
1172 |
# authors |
1164 |
$oauthors = "&rft.au=$aufirst $aulast"; |
1173 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
|
|
1174 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1175 |
|
1176 |
foreach my $field (qw/700 701/) { |
1177 |
my $author = ''; |
1178 |
$author = $record->subfield($field, 'a') || ''; |
1179 |
$author .= ", " . $record->subfield($field, 'b') if ($author and $record->subfield($field, 'b')); |
1180 |
$author .= " - " . join(' - ', $record->subfield($field, '4')) if ($record->subfield($field, '4')); |
1181 |
$author .= " (" . $record->subfield($field, 'f') . ")" if ($record->subfield($field, 'f')); |
1182 |
|
1183 |
$oauthors .= "&rft.au=$author" if ($author); |
1184 |
} |
1185 |
|
1186 |
foreach my $field (qw/710 711/) { |
1187 |
my $author = ''; |
1188 |
$author = $record->subfield($field, 'a') || ''; |
1189 |
$author .= ", " . $record->subfield($field, 'b') if ($author and $record->subfield($field, 'b')); |
1190 |
$author .= " - " . join(' - ', $record->subfield($field, '4')) if ($record->subfield($field, '4')); |
1191 |
$author .= " (" . $record->subfield($field, 'c') . ")" if ($record->subfield($field, 'c')); |
1192 |
|
1193 |
$oauthors .= "&rft.au=$author" if ($author); |
1194 |
} |
1195 |
|
1165 |
|
1196 |
|
1166 |
# others authors |
1197 |
# others authors |
1167 |
if ( $record->field('200') ) { |
1198 |
if ( $record->field('200') ) { |
|
|
1199 |
for my $au ( $record->field('200')->subfield('f') ) { |
1200 |
$oauthors .= "&rft.au=$au"; |
1201 |
} |
1168 |
for my $au ( $record->field('200')->subfield('g') ) { |
1202 |
for my $au ( $record->field('200')->subfield('g') ) { |
1169 |
$oauthors .= "&rft.au=$au"; |
1203 |
$oauthors .= "&rft.au=$au"; |
1170 |
} |
1204 |
} |
|
|
1205 |
|
1171 |
} |
1206 |
} |
|
|
1207 |
|
1208 |
# place |
1209 |
$place = join(" - ", $record->subfield('210', 'a')); |
1210 |
$place = "&rtf.place=$place" if ($place); |
1211 |
|
1212 |
# tpages |
1213 |
my $i = 0; |
1214 |
foreach my $field ($record->field('215')) { |
1215 |
$tpages .= " | " if ($i > 0); |
1216 |
$tpages .= join(" - ", $field->subfield('a')); |
1217 |
$tpages .= join(" ; ", $field->subfield('d')); |
1218 |
$tpages .= join(" + ", $field->subfield('e')); |
1219 |
$i++; |
1220 |
} |
1221 |
$tpages = "&rtf.tpages=$tpages" if ($tpages); |
1222 |
|
1223 |
# title |
1224 |
my $btitle = join(' ; ', $record->subfield('200', 'a')); |
1225 |
$btitle .= " : " . join(' : ', $record->subfield('200', 'e')) if ($record->subfield('200', 'e')); |
1226 |
|
1172 |
$title = |
1227 |
$title = |
1173 |
( $mtx eq 'dc' ) |
1228 |
( $mtx eq 'dc' ) |
1174 |
? "&rft.title=" . $record->subfield( '200', 'a' ) |
1229 |
? "&rft.title=" . $record->subfield( '200', 'a' ) |
1175 |
: "&rft.title=" . $record->subfield( '200', 'a' ) . "&rft.btitle=" . $record->subfield( '200', 'a' ); |
1230 |
: "&rft.title=" . $record->subfield( '200', 'a' ) . "&rft.btitle=" . $btitle; |
1176 |
$pubyear = $record->subfield( '210', 'd' ); |
1231 |
$pubyear = $record->subfield( '210', 'd' ) || ''; |
1177 |
$publisher = $record->subfield( '210', 'c' ); |
1232 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1178 |
$isbn = $record->subfield( '010', 'a' ); |
1233 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1179 |
$issn = $record->subfield( '011', 'a' ); |
1234 |
$issn = $record->subfield( '011', 'a' ) || ''; |
1180 |
} else { |
1235 |
} else { |
1181 |
|
1236 |
|
1182 |
# MARC21 need some improve |
1237 |
# MARC21 need some improve |
Lines 1205-1211
sub GetCOinSBiblio {
Link Here
|
1205 |
|
1260 |
|
1206 |
} |
1261 |
} |
1207 |
my $coins_value = |
1262 |
my $coins_value = |
1208 |
"ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A$mtx$genre$title&rft.isbn=$isbn&rft.issn=$issn&rft.aulast=$aulast&rft.aufirst=$aufirst$oauthors&rft.pub=$publisher&rft.date=$pubyear"; |
1263 |
"ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A$mtx$genre$title&rft.isbn=$isbn&rft.issn=$issn&rft.aulast=$aulast&rft.aufirst=$aufirst$oauthors&rft.pub=$publisher&rft.date=$pubyear$place$tpages"; |
1209 |
$coins_value =~ s/(\ |&[^a])/\+/g; |
1264 |
$coins_value =~ s/(\ |&[^a])/\+/g; |
1210 |
$coins_value =~ s/\"/\"\;/g; |
1265 |
$coins_value =~ s/\"/\"\;/g; |
1211 |
|
1266 |
|
Lines 1750-1755
sub TransformHtmlToXml {
Link Here
|
1750 |
@$values[$i] =~ s/>/>/g; |
1805 |
@$values[$i] =~ s/>/>/g; |
1751 |
@$values[$i] =~ s/"/"/g; |
1806 |
@$values[$i] =~ s/"/"/g; |
1752 |
@$values[$i] =~ s/'/'/g; |
1807 |
@$values[$i] =~ s/'/'/g; |
|
|
1808 |
@$values[$i] = NormalizeString(@$values[$i]); |
1753 |
|
1809 |
|
1754 |
# if ( !utf8::is_utf8( @$values[$i] ) ) { |
1810 |
# if ( !utf8::is_utf8( @$values[$i] ) ) { |
1755 |
# utf8::decode( @$values[$i] ); |
1811 |
# utf8::decode( @$values[$i] ); |
Lines 2313-2319
sub PrepareItemrecordDisplay {
Link Here
|
2313 |
push @authorised_values, $branchcode; |
2369 |
push @authorised_values, $branchcode; |
2314 |
$authorised_lib{$branchcode} = $branchname; |
2370 |
$authorised_lib{$branchcode} = $branchname; |
2315 |
} |
2371 |
} |
|
|
2372 |
$defaultvalue = C4::Context->userenv->{branch}; |
2316 |
} |
2373 |
} |
|
|
2374 |
$defaultvalue = C4::Context->userenv->{branch}; |
2317 |
|
2375 |
|
2318 |
#----- itemtypes |
2376 |
#----- itemtypes |
2319 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { |
2377 |
} elsif ( $tagslib->{$tag}->{$subfield}->{authorised_value} eq "itemtypes" ) { |
Lines 3461-3466
sub get_biblio_authorised_values {
Link Here
|
3461 |
return $authorised_values; |
3519 |
return $authorised_values; |
3462 |
} |
3520 |
} |
3463 |
|
3521 |
|
|
|
3522 |
=head3 BatchModField |
3523 |
|
3524 |
Mod subfields in field record |
3525 |
|
3526 |
returns 1,$record if succeed |
3527 |
returns 0,$record if Action was not processed |
3528 |
returns -1 if no record |
3529 |
returns -2 if no action done on record |
3530 |
|
3531 |
=cut |
3532 |
|
3533 |
sub BatchModField { |
3534 |
my ( $record, $field, $subfield, $action, $condval, $nocond, $repval ) = @_; |
3535 |
|
3536 |
return -1 unless $record; |
3537 |
$condval=NormalizeString($condval); |
3538 |
my $condition=qr/$condval/; |
3539 |
|
3540 |
if($action eq "add"){ |
3541 |
for my $rfield ($record->field($field)){ |
3542 |
$rfield->add_subfields( $subfield => $repval ); |
3543 |
} |
3544 |
return 1; |
3545 |
}elsif($action eq "addfield"){ |
3546 |
my $new_field = MARC::Field->new($field,'','', |
3547 |
$subfield => $repval); |
3548 |
$record->insert_fields_ordered($new_field); |
3549 |
return 1; |
3550 |
} else { |
3551 |
my $done=0; |
3552 |
for my $rfield ($record->field($field)) { |
3553 |
if ($subfield && $subfield ne "@"){ |
3554 |
my @subfields = $rfield->subfields(); |
3555 |
my @subfields_to_add; |
3556 |
foreach my $subf (@subfields) { |
3557 |
if ($subf->[0] eq $subfield){ |
3558 |
$subf->[1]=NormalizeString($subf->[1]); |
3559 |
if ( $action eq "mod" ) { |
3560 |
if ( $nocond ne "true" && $subf->[1] =~ s/$condition/$repval/) { |
3561 |
$done=1; |
3562 |
} |
3563 |
if ($nocond eq "true"){ |
3564 |
$subf->[1] = $repval; |
3565 |
$done=1; |
3566 |
} |
3567 |
} elsif ( $action eq "del" ) { |
3568 |
if ( $subf->[1] =~ m/$condition/ || $nocond eq "true" ) { |
3569 |
$done=1; |
3570 |
next; |
3571 |
} |
3572 |
} |
3573 |
} |
3574 |
push @subfields_to_add,@$subf; |
3575 |
} |
3576 |
if ($done){ |
3577 |
if (@subfields_to_add){ |
3578 |
$rfield->replace_with(MARC::Field->new($rfield->tag,$rfield->indicator(1),$rfield->indicator(2),@subfields_to_add)); |
3579 |
} |
3580 |
else { |
3581 |
my $count= $record->delete_field($rfield); |
3582 |
} |
3583 |
} |
3584 |
} |
3585 |
else { |
3586 |
if ($action eq "del"){ |
3587 |
my $count=$record->delete_field($rfield); |
3588 |
$done=1; |
3589 |
} |
3590 |
else { |
3591 |
if ($field < 10){ |
3592 |
my $value=$record->field($field)->data(); |
3593 |
if ($value=~ s/$condition/$repval/){ |
3594 |
$record->field($field)->update($value); |
3595 |
$done=1; |
3596 |
|
3597 |
} |
3598 |
if ( $nocond eq 'true'){ |
3599 |
$record->field($field)->update($repval); |
3600 |
$done=1; |
3601 |
} |
3602 |
} |
3603 |
} |
3604 |
} |
3605 |
} |
3606 |
return ($done,$record); |
3607 |
} |
3608 |
return -2; |
3609 |
} |
3610 |
|
3464 |
1; |
3611 |
1; |
3465 |
|
3612 |
|
3466 |
__END__ |
3613 |
__END__ |