|
Lines 31-36
use C4::Context;
Link Here
|
| 31 |
use Module::Load qw( load ); |
31 |
use Module::Load qw( load ); |
| 32 |
use List::Util qw( none first ); |
32 |
use List::Util qw( none first ); |
| 33 |
|
33 |
|
|
|
34 |
# Package-level cache for authority types from frameworks |
| 35 |
my %authority_type_cache; |
| 36 |
|
| 34 |
=head1 NAME |
37 |
=head1 NAME |
| 35 |
|
38 |
|
| 36 |
C4::Heading |
39 |
C4::Heading |
|
Lines 71-77
sub new_from_field {
Link Here
|
| 71 |
my $frameworkcode = shift; #FIXME this is not used? |
74 |
my $frameworkcode = shift; #FIXME this is not used? |
| 72 |
my $auth = shift; |
75 |
my $auth = shift; |
| 73 |
my $marcflavour = C4::Context->preference('marcflavour'); |
76 |
my $marcflavour = C4::Context->preference('marcflavour'); |
| 74 |
my $marc_handler = _marc_format_handler($marcflavour); |
77 |
|
|
|
78 |
# Enable framework lookup for MARC21 if LinkerUseFrameworkAuthTypes is enabled |
| 79 |
my $use_frameworks = $marcflavour eq 'MARC21' |
| 80 |
&& C4::Context->preference('LinkerUseFrameworkAuthTypes'); |
| 81 |
my $marc_handler = _marc_format_handler( $marcflavour, { use_frameworks => $use_frameworks } ); |
| 75 |
|
82 |
|
| 76 |
return unless $field; |
83 |
return unless $field; |
| 77 |
my $tag = $field->tag(); |
84 |
my $tag = $field->tag(); |
|
Lines 304-309
sub _filter_diacritics {
Link Here
|
| 304 |
|
311 |
|
| 305 |
=head1 INTERNAL FUNCTIONS |
312 |
=head1 INTERNAL FUNCTIONS |
| 306 |
|
313 |
|
|
|
314 |
=head2 _load_authority_types_from_frameworks |
| 315 |
|
| 316 |
Load authority type mappings from marc_subfield_structure. |
| 317 |
Shared by both MARC21 and UNIMARC implementations. |
| 318 |
Results are cached at package level. |
| 319 |
|
| 320 |
=cut |
| 321 |
|
| 322 |
sub _load_authority_types_from_frameworks { |
| 323 |
my $cache_key = shift // 'default'; |
| 324 |
|
| 325 |
unless ( exists $authority_type_cache{$cache_key} ) { |
| 326 |
my $dbh = C4::Context->dbh; |
| 327 |
my $sth = $dbh->prepare( |
| 328 |
"SELECT DISTINCT tagfield, authtypecode |
| 329 |
FROM marc_subfield_structure |
| 330 |
WHERE frameworkcode = '' AND authtypecode <> ''" |
| 331 |
); |
| 332 |
$sth->execute(); |
| 333 |
|
| 334 |
$authority_type_cache{$cache_key} = {}; |
| 335 |
while ( my ( $tag, $auth_type ) = $sth->fetchrow ) { |
| 336 |
$authority_type_cache{$cache_key}->{$tag} = $auth_type; |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
return $authority_type_cache{$cache_key}; |
| 341 |
} |
| 342 |
|
| 307 |
=head2 _marc_format_handler |
343 |
=head2 _marc_format_handler |
| 308 |
|
344 |
|
| 309 |
Returns a C4::Heading::MARC21 or C4::Heading::UNIMARC object |
345 |
Returns a C4::Heading::MARC21 or C4::Heading::UNIMARC object |
|
Lines 313-321
depending on the selected MARC flavour.
Link Here
|
| 313 |
|
349 |
|
| 314 |
sub _marc_format_handler { |
350 |
sub _marc_format_handler { |
| 315 |
my $marcflavour = uc shift; |
351 |
my $marcflavour = uc shift; |
|
|
352 |
my $params = shift // {}; |
| 316 |
my $pname = "C4::Heading::$marcflavour"; |
353 |
my $pname = "C4::Heading::$marcflavour"; |
| 317 |
load $pname; |
354 |
load $pname; |
| 318 |
return $pname->new(); |
355 |
return $pname->new($params); |
| 319 |
} |
356 |
} |
| 320 |
|
357 |
|
| 321 |
=head1 AUTHOR |
358 |
=head1 AUTHOR |