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

(-)a/Koha/Template/Plugin/HtmlId.pm (+28 lines)
Line 0 Link Here
1
package Koha::Template::Plugin::HtmlId;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use parent qw( Template::Plugin::Filter );
21
22
sub filter {
23
    my ( $self, $text ) = @_;
24
25
    return $text =~ s/[^a-zA-Z0-9-]+/_/gr
26
}
27
28
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-menu.inc (-1 / +2 lines)
Lines 1-3 Link Here
1
[% USE HtmlId %]
1
<div id="menu">
2
<div id="menu">
2
    <ul>
3
    <ul>
3
        [% IF ( accounting ) %]
4
        [% IF ( accounting ) %]
Lines 176-182 Link Here
176
            <ul>
177
            <ul>
177
                [% FOREACH LINE IN TAB.LINES %]
178
                [% FOREACH LINE IN TAB.LINES %]
178
                    [% IF ( LINE.is_group_title ) %]
179
                    [% IF ( LINE.is_group_title ) %]
179
                        <li><a class="pref_sublink" href="#[% LINE.title | replace('\s+', '_') | uri %]">[% LINE.title | html %]</a></li>
180
                        <li><a class="pref_sublink" href="#[% LINE.title | $HtmlId %]">[% LINE.title | html %]</a></li>
180
                    [% END %]
181
                    [% END %]
181
                [% END %]
182
                [% END %]
182
            </ul>
183
            </ul>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt (-3 / +4 lines)
Lines 2-7 Link Here
2
[% USE To %]
2
[% USE To %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE Koha %]
4
[% USE Koha %]
5
[% USE HtmlId %]
5
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
<title>Koha &rsaquo; Administration &rsaquo; System preferences</title>
8
<title>Koha &rsaquo; Administration &rsaquo; System preferences</title>
Lines 49-64 Link Here
49
            [% UNLESS ( loop.first ) %]</tbody></table>[% END %]
50
            [% UNLESS ( loop.first ) %]</tbody></table>[% END %]
50
            <div class="row">
51
            <div class="row">
51
                <div class="col-sm-6">
52
                <div class="col-sm-6">
52
                    <h3 id="[% LINE.title | replace('\s+', '_') | html %]"><i class="fa fa-caret-down"></i> [% LINE.title | html %]</h3>
53
                    <h3 id="[% LINE.title | $HtmlId %]"><i class="fa fa-caret-down"></i> [% LINE.title | html %]</h3>
53
                </div>
54
                </div>
54
                <div class="col-sm-6">
55
                <div class="col-sm-6">
55
                    [% IF ( searchfield ) %]
56
                    [% IF ( searchfield ) %]
56
                        <div class="pull-right"><a class="btn btn-link" href="/cgi-bin/koha/admin/preferences.pl?tab=[% TAB.tab_id | html %]#[% LINE.title | replace('\s+', '_') | html %]"><i class="fa fa-list-ul"></i> View all [% LINE.title | html %] preferences</a></div>
57
                        <div class="pull-right"><a class="btn btn-link" href="/cgi-bin/koha/admin/preferences.pl?tab=[% TAB.tab_id | html %]#[% LINE.title | $HtmlId %]"><i class="fa fa-list-ul"></i> View all [% LINE.title | html %] preferences</a></div>
57
                    [% END %]
58
                    [% END %]
58
                </div>
59
                </div>
59
            </div>
60
            </div>
60
61
61
            <table class="preferences" id="collapse_[% LINE.title | replace('\s+', '_') | html %]">
62
            <table class="preferences" id="collapse_[% LINE.title | $HtmlId %]">
62
            <thead><tr><th>Preference</th><th>Value</th></tr></thead>
63
            <thead><tr><th>Preference</th><th>Value</th></tr></thead>
63
            [% UNLESS ( loop.last ) %]<tbody>[% END %]
64
            [% UNLESS ( loop.last ) %]<tbody>[% END %]
64
            [% ELSE %]
65
            [% ELSE %]
(-)a/t/Koha_Template_Plugin_HtmlId.t (-1 / +25 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
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 2;
21
22
use_ok( 'Koha::Template::Plugin::HtmlId' );
23
24
my $filter = Koha::Template::Plugin::HtmlId->new();
25
is('Some_not-allowed_characters', $filter->filter('Some/;:not-allowed*$^characters'), 'Forbidden characters are replaced by _');

Return to bug 27336