Lines 1502-1526
sub GetAuthorisedValueDesc {
Link Here
|
1502 |
|
1502 |
|
1503 |
my $dbh = C4::Context->dbh; |
1503 |
my $dbh = C4::Context->dbh; |
1504 |
if ( $category ne "" ) { |
1504 |
if ( $category ne "" ) { |
1505 |
$cache_key = "AV_descriptions:" . $category; |
1505 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
1506 |
my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); |
1506 |
my $cache_key = 'GetAuthorisedValueDesc:authorised_values'; |
1507 |
if ( !$av_descriptions ) { |
1507 |
my $authorised_values = $memory_cache->get_from_cache($cache_key); |
1508 |
$av_descriptions = { |
1508 |
unless ($authorised_values) { |
1509 |
map { |
1509 |
$authorised_values = { map { $_->authorised_value => $_ } Koha::AuthorisedValues->as_list }; |
1510 |
$_->authorised_value => |
1510 |
$memory_cache->set_in_cache($cache_key, $authorised_values); |
1511 |
{ lib => $_->lib, lib_opac => $_->lib_opac } |
|
|
1512 |
} Koha::AuthorisedValues->search( |
1513 |
{ category => $category }, |
1514 |
{ |
1515 |
columns => [ 'authorised_value', 'lib_opac', 'lib' ] |
1516 |
} |
1517 |
)->as_list |
1518 |
}; |
1519 |
$cache->set_in_cache($cache_key, $av_descriptions); |
1520 |
} |
1511 |
} |
1521 |
return ( $opac && $av_descriptions->{$value}->{'lib_opac'} ) |
1512 |
my $av = $authorised_values->{$value}; |
1522 |
? $av_descriptions->{$value}->{'lib_opac'} |
1513 |
return unless $av; |
1523 |
: $av_descriptions->{$value}->{'lib'}; |
1514 |
|
|
|
1515 |
my $lang = C4::Languages::getlanguage(); |
1516 |
return $opac ? $av->opac_translated_description : $av->localization('lib', $lang); |
1524 |
} else { |
1517 |
} else { |
1525 |
return $value; # if nothing is found return the original value |
1518 |
return $value; # if nothing is found return the original value |
1526 |
} |
1519 |
} |