Lines 1559-1579
sub GetAuthorisedValueDesc {
Link Here
|
1559 |
|
1559 |
|
1560 |
my $dbh = C4::Context->dbh; |
1560 |
my $dbh = C4::Context->dbh; |
1561 |
if ( $category ne "" ) { |
1561 |
if ( $category ne "" ) { |
1562 |
$cache_key = "AV_descriptions:" . $category; |
1562 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance(); |
1563 |
my $av_descriptions = $cache->get_from_cache( $cache_key, { unsafe => 1 } ); |
1563 |
my $cache_key = 'GetAuthorisedValueDesc:authorised_values'; |
1564 |
if ( !$av_descriptions ) { |
1564 |
my $authorised_values = $memory_cache->get_from_cache($cache_key); |
1565 |
$av_descriptions = { |
1565 |
unless ($authorised_values) { |
1566 |
map { $_->authorised_value => { lib => $_->lib, lib_opac => $_->lib_opac } } |
1566 |
$authorised_values = { map { $_->authorised_value => $_ } Koha::AuthorisedValues->as_list }; |
1567 |
Koha::AuthorisedValues->search( |
1567 |
$memory_cache->set_in_cache( $cache_key, $authorised_values ); |
1568 |
{ category => $category }, |
|
|
1569 |
{ columns => [ 'authorised_value', 'lib_opac', 'lib' ] } |
1570 |
)->as_list |
1571 |
}; |
1572 |
$cache->set_in_cache( $cache_key, $av_descriptions ); |
1573 |
} |
1568 |
} |
1574 |
return ( $opac && $av_descriptions->{$value}->{'lib_opac'} ) |
1569 |
my $av = $authorised_values->{$value}; |
1575 |
? $av_descriptions->{$value}->{'lib_opac'} |
1570 |
return unless $av; |
1576 |
: $av_descriptions->{$value}->{'lib'}; |
1571 |
|
|
|
1572 |
my $lang = C4::Languages::getlanguage(); |
1573 |
return $opac ? $av->opac_translated_description($lang) : $av->localization( 'lib', $lang ); |
1577 |
} else { |
1574 |
} else { |
1578 |
return $value; # if nothing is found return the original value |
1575 |
return $value; # if nothing is found return the original value |
1579 |
} |
1576 |
} |