Lines 1205-1211
sub to_api_mapping {
Link Here
|
1205 |
|
1205 |
|
1206 |
$host = $biblio->get_marc_host; |
1206 |
$host = $biblio->get_marc_host; |
1207 |
# OR: |
1207 |
# OR: |
1208 |
( $host, $relatedparts ) = $biblio->get_marc_host; |
1208 |
( $host, $relatedparts, $hostinfo ) = $biblio->get_marc_host; |
1209 |
|
1209 |
|
1210 |
Returns host biblio record from MARC21 773 (undef if no 773 present). |
1210 |
Returns host biblio record from MARC21 773 (undef if no 773 present). |
1211 |
It looks at the first 773 field with MARCorgCode or only a control |
1211 |
It looks at the first 773 field with MARCorgCode or only a control |
Lines 1214-1219
sub to_api_mapping {
Link Here
|
1214 |
If there are, the sub returns undef. |
1214 |
If there are, the sub returns undef. |
1215 |
Called in list context, it also returns 773$g (related parts). |
1215 |
Called in list context, it also returns 773$g (related parts). |
1216 |
|
1216 |
|
|
|
1217 |
If there is no $w, we use $0 (host biblionumber) or $9 (host itemnumber) |
1218 |
to search for the host record. If there is also no $0 and no $9, we search |
1219 |
using author and title. Failing all of that, we return an undef host and |
1220 |
form a concatenation of strings with 773$agt for host information, |
1221 |
returned when called in list context. |
1222 |
|
1217 |
=cut |
1223 |
=cut |
1218 |
|
1224 |
|
1219 |
sub get_marc_host { |
1225 |
sub get_marc_host { |
Lines 1237-1254
sub get_marc_host {
Link Here
|
1237 |
last; |
1243 |
last; |
1238 |
} |
1244 |
} |
1239 |
} |
1245 |
} |
|
|
1246 |
|
1247 |
my $engine = Koha::SearchEngine::Search->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
1248 |
my $bibno; |
1240 |
if ( !$hostfld and $record->subfield('773','t') ) { |
1249 |
if ( !$hostfld and $record->subfield('773','t') ) { |
1241 |
# not linked using $w so just return plaintext |
1250 |
# not linked using $w |
1242 |
my $unlinkedf = $record->field('773'); |
1251 |
my $unlinkedf = $record->field('773'); |
1243 |
my $host = join( ", ", $unlinkedf->subfield('a'), $unlinkedf->subfield('t'), $unlinkedf->subfield('g') ); |
1252 |
my $host; |
1244 |
return wantarray ? ( $host, $unlinkedf->subfield('g') ) : $host; |
1253 |
if ( C4::Context->preference("EasyAnalyticalRecords") ) { |
|
|
1254 |
if ( $unlinkedf->subfield('0') ) { |
1255 |
# use 773$0 host biblionumber |
1256 |
$bibno = $unlinkedf->subfield('0'); |
1257 |
} elsif ( $unlinkedf->subfield('9') ) { |
1258 |
# use 773$9 host itemnumber |
1259 |
my $linkeditemnumber = $unlinkedf->subfield('9'); |
1260 |
$bibno = Koha::Items->find( $linkeditemnumber )->biblionumber; |
1261 |
} |
1262 |
} |
1263 |
if ( $bibno ) { |
1264 |
my $host = Koha::Biblios->find($bibno) or return; |
1265 |
return wantarray ? ( $host, $unlinkedf->subfield('g') ) : $host; |
1266 |
} |
1267 |
# just return plaintext and no host record |
1268 |
my $hostinfo = join( ", ", $unlinkedf->subfield('a'), $unlinkedf->subfield('t'), $unlinkedf->subfield('g') ); |
1269 |
return wantarray ? ( undef, $unlinkedf->subfield('g'), $hostinfo ) : undef; |
1245 |
} |
1270 |
} |
1246 |
return if !$hostfld; |
1271 |
return if !$hostfld; |
1247 |
my $rcn = $hostfld->subfield('w'); |
1272 |
my $rcn = $hostfld->subfield('w'); |
1248 |
|
1273 |
|
1249 |
# Look for control number with/without orgcode |
1274 |
# Look for control number with/without orgcode |
1250 |
my $engine = Koha::SearchEngine::Search->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
|
|
1251 |
my $bibno; |
1252 |
for my $try (1..2) { |
1275 |
for my $try (1..2) { |
1253 |
my ( $error, $results, $total_hits ) = $engine->simple_search_compat( 'Control-number='.$rcn, 0,1 ); |
1276 |
my ( $error, $results, $total_hits ) = $engine->simple_search_compat( 'Control-number='.$rcn, 0,1 ); |
1254 |
if( !$error and $total_hits == 1 ) { |
1277 |
if( !$error and $total_hits == 1 ) { |