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

(-)a/Koha/Template/Plugin/Frameworks.pm (+58 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::Frameworks;
2
3
# Copyright ByWater Solutions 2023
4
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Template::Plugin;
23
use base qw( Template::Plugin );
24
25
use Koha::BiblioFrameworks;
26
27
=head1 NAME
28
29
Koha::Template::Plugin::Frameworks - A module for dealing with biblio frameworks in templates
30
31
=head1 DESCRIPTION
32
33
This plugin contains functions for getting frameowrk information in the template
34
35
=head2 Methods
36
37
=head3 GetName
38
39
[% Frameworks.GetName( frameworkcode ) %]
40
41
Return the display name (frameworktext field) for a framework, or the passed code if the framework
42
is not found
43
44
=cut
45
46
47
sub GetName {
48
    my ( $self, $frameworkcode ) = @_;
49
    return q{} unless defined $frameworkcode;
50
    return q{} if $frameworkcode eq q{};
51
52
    my $f = Koha::BiblioFrameworks->find($frameworkcode);
53
54
    my $frameworktext = $f ? $f->frameworktext : $frameworkcode;
55
    return $frameworktext;
56
}
57
58
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (+5 lines)
Lines 6-11 Link Here
6
[% USE AuthorisedValues %]
6
[% USE AuthorisedValues %]
7
[% USE Branches %]
7
[% USE Branches %]
8
[% USE Biblio %]
8
[% USE Biblio %]
9
[% USE Frameworks %]
9
[% USE Price %]
10
[% USE Price %]
10
[% USE TablesSettings %]
11
[% USE TablesSettings %]
11
[% PROCESS 'i18n.inc' %]
12
[% PROCESS 'i18n.inc' %]
Lines 135-140 Link Here
135
                    </span>
136
                    </span>
136
        [% END %]
137
        [% END %]
137
        <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
138
        <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber | uri %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
139
        <span id="catalogue_detail_framework" class="results_summary">
140
            <span class="label">MARC framework:</span>
141
            <span class="frameworkcode">[% Frameworks.GetName(biblio.frameworkcode) | html %]</span>
142
        </span>
138
        [% IF !item_level_itypes ||  Koha.Preference("BiblioItemtypeInfo") %]
143
        [% IF !item_level_itypes ||  Koha.Preference("BiblioItemtypeInfo") %]
139
           <span class="results_summary itemtype"><span class="label">Itemtype:</span>
144
           <span class="results_summary itemtype"><span class="label">Itemtype:</span>
140
          [% IF ( !noItemTypeImages && imageurl ) %]
145
          [% IF ( !noItemTypeImages && imageurl ) %]
(-)a/t/db_dependent/Template/Plugin/Frameworks.t (-1 / +52 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
17
use Modern::Perl;
18
19
use Test::More tests => 2;
20
use Test::MockModule;
21
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
24
25
BEGIN {
26
    use_ok('Koha::Template::Plugin::Frameworks');
27
}
28
29
my $schema  = Koha::Database->schema;
30
my $builder = t::lib::TestBuilder->new;
31
32
$schema->storage->txn_begin;
33
34
subtest 'GetName tests' => sub {
35
    plan tests => 3;
36
37
    my $framework = $builder->build_object({ class => 'Koha::BiblioFrameworks' })->store;
38
39
    my $plugin = Koha::Template::Plugin::Frameworks->new();
40
41
    my $name = $plugin->GetName( $framework->frameworkcode );
42
    is( $name, $framework->frameworktext, "Name correctly fetched" );
43
44
    $name = $plugin->GetName();
45
    is( $name, q{}, "Nothing returned if nothing passed" );
46
47
    $framework->delete;
48
    $name = $plugin->GetName( $framework->frameworkcode );
49
    is( $name, $framework->frameworkcode, "When framework not found, we get the code back" );
50
};
51
52
$schema->storage->txn_rollback;

Return to bug 33607