View | Details | Raw Unified | Return to bug 38460
Collapse All | Expand All

(-)a/C4/Biblio.pm (-14 / +11 lines)
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
    }
(-)a/Koha/AuthorisedValue.pm (+12 lines)
Lines 102-107 sub opac_description { Link Here
102
    return $self->lib_opac() || $self->lib();
102
    return $self->lib_opac() || $self->lib();
103
}
103
}
104
104
105
=head3 opac_translated_description
106
107
my $description = $av->opac_translated_description($lang);
108
109
=cut
110
111
sub opac_translated_description {
112
    my ($self, $lang) = @_;
113
114
    return $self->localization('lib_opac', $lang) || $self->localization('lib', $lang);
115
}
116
105
=head3 to_api_mapping
117
=head3 to_api_mapping
106
118
107
This method returns the mapping for representing a Koha::AuthorisedValue object
119
This method returns the mapping for representing a Koha::AuthorisedValue object
(-)a/Koha/Schema/Result/AuthorisedValue.pm (+2 lines)
Lines 176-181 __PACKAGE__->has_many( Link Here
176
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
176
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-01-21 13:39:29
177
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LH9dpEEzlVVsjNVv/jnONg
177
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LH9dpEEzlVVsjNVv/jnONg
178
178
179
__PACKAGE__->load_components('+Koha::Schema::Component::Localization');
180
__PACKAGE__->localization_add_relationships('id', 'lib', 'lib_opac');
179
181
180
# You can replace this text with custom code or comments, and it will be preserved on regeneration
182
# You can replace this text with custom code or comments, and it will be preserved on regeneration
181
1;
183
1;
(-)a/Koha/Template/Plugin/AuthorisedValues.pm (-3 / +5 lines)
Lines 22-37 use Template::Plugin; Link Here
22
use base qw( Template::Plugin );
22
use base qw( Template::Plugin );
23
23
24
use C4::Koha qw( GetAuthorisedValues );
24
use C4::Koha qw( GetAuthorisedValues );
25
use C4::Languages;
25
use Koha::AuthorisedValues;
26
use Koha::AuthorisedValues;
26
27
27
sub GetByCode {
28
sub GetByCode {
28
    my ( $self, $category, $code, $opac ) = @_;
29
    my ( $self, $category, $code, $opac ) = @_;
29
    my $av = Koha::AuthorisedValues->search( { category => $category, authorised_value => $code } );
30
    my $av   = Koha::AuthorisedValues->search( { category => $category, authorised_value => $code } );
31
    my $lang = C4::Languages::getlanguage();
30
    return
32
    return
31
          $av->count
33
          $av->count
32
        ? $opac
34
        ? $opac
33
            ? $av->next->opac_description
35
            ? $av->next->opac_translated_description($lang)
34
            : $av->next->lib
36
            : $av->next->localization( 'lib', $lang )
35
        : $code;
37
        : $code;
36
}
38
}
37
39
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (-1 / +3 lines)
Lines 190-199 Link Here
190
                        <li>
190
                        <li>
191
                            <label for="lib">Description: </label>
191
                            <label for="lib">Description: </label>
192
                            <input type="text" name="lib" id="lib" value="[% av.lib | html %]" maxlength="200" />
192
                            <input type="text" name="lib" id="lib" value="[% av.lib | html %]" maxlength="200" />
193
                            [% INCLUDE 'localization-link.inc' source='AuthorisedValue' object_id=av.id property='lib' %]
193
                        </li>
194
                        </li>
194
                        <li>
195
                        <li>
195
                            <label for="lib_opac">Description (OPAC): </label>
196
                            <label for="lib_opac">Description (OPAC): </label>
196
                            <input type="text" name="lib_opac" id="lib_opac" value="[% av.lib_opac | html %]" maxlength="200" />
197
                            <input type="text" name="lib_opac" id="lib_opac" value="[% av.lib_opac | html %]" maxlength="200" />
198
                            [% INCLUDE 'localization-link.inc' source='AuthorisedValue' object_id=av.id property='lib_opac' %]
197
                        </li>
199
                        </li>
198
                        <li
200
                        <li
199
                            ><label for="branches">Library limitations: </label>
201
                            ><label for="branches">Library limitations: </label>
Lines 403-408 Link Here
403
[% MACRO jsinclude BLOCK %]
405
[% MACRO jsinclude BLOCK %]
404
    [% Asset.js("js/admin-menu.js") | $raw %]
406
    [% Asset.js("js/admin-menu.js") | $raw %]
405
    [% INCLUDE 'datatables.inc' %]
407
    [% INCLUDE 'datatables.inc' %]
408
    [% INCLUDE 'greybox.inc' %]
406
    <script>
409
    <script>
407
        $(document).ready(function () {
410
        $(document).ready(function () {
408
            $("#categoriest").kohaTable({
411
            $("#categoriest").kohaTable({
409
- 

Return to bug 38460