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

(-)a/C4/Languages.pm (-1 / +38 lines)
Lines 49-55 BEGIN { Link Here
49
        &getLanguages
49
        &getLanguages
50
        &getAllLanguages
50
        &getAllLanguages
51
    );
51
    );
52
    @EXPORT_OK = qw(getLanguagesIso getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language getlanguage);
52
    @EXPORT_OK = qw(getSearchLanguages getLanguagesIso getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language getlanguage);
53
    $DEBUG = 0;
53
    $DEBUG = 0;
54
}
54
}
55
55
Lines 106-111 sub getFrameworkLanguages { Link Here
106
    return \@languages;
106
    return \@languages;
107
}
107
}
108
108
109
=head2 getSearchLanguages
110
111
Get selection of languages codes and iso639_2.
112
Use sysprefs LimitAdvancedSearchLanguages and AdvancedSearchLanguages,
113
default to english.
114
115
Returns a reference to an array of hashes:
116
117
 my $languages = getSearchLanguages();
118
 for my $language( @$languages ) {
119
    print "$language->{rfc4646_subtag}\n"; # language code in rfc4646
120
    print "$language->{iso638_2_code}\n";  # language code in iso 639-2
121
 }
122
123
=cut
124
125
sub getSearchLanguages {
126
    my $isFiltered    = C4::Context->preference("LimitAdvancedSearchLanguages");;
127
    my $language_list = C4::Context->preference("AdvancedSearchLanguages");
128
    $language_list    = 'eng' unless $language_list;
129
    my @languages     = split ( /\,/, $language_list );
130
    my $langs         = getLangCodes();
131
    my @result;
132
    my %enabled;
133
    $enabled{$_}++ for ( @languages );
134
135
    for my $code ( keys %$langs ) {
136
        if (( $isFiltered and $enabled{ $langs->{ $code } } ) or ( not $isFiltered )) {
137
            push @result, {
138
                rfc4646_subtag => $code,
139
                iso639_2_code  => $langs->{$code},
140
            }
141
        }
142
    }
143
    return \@result;
144
}
145
109
=head2 getLanguagesIso
146
=head2 getLanguagesIso
110
147
111
Get all languages codes and iso639_2 selected by iso639_2
148
Get all languages codes and iso639_2 selected by iso639_2
(-)a/catalogue/search.pl (-2 / +2 lines)
Lines 144-150 use C4::Context; Link Here
144
use C4::Output;
144
use C4::Output;
145
use C4::Auth qw(:DEFAULT get_session);
145
use C4::Auth qw(:DEFAULT get_session);
146
use C4::Search;
146
use C4::Search;
147
use C4::Languages qw(getLanguages);
147
use C4::Languages qw(getSearchLanguages);
148
use C4::Koha;
148
use C4::Koha;
149
use C4::Members qw(GetMember);
149
use C4::Members qw(GetMember);
150
use C4::VirtualShelves;
150
use C4::VirtualShelves;
Lines 346-352 if ( $template_type eq 'advsearch' ) { Link Here
346
                      search_boxes_loop => \@search_boxes_array);
346
                      search_boxes_loop => \@search_boxes_array);
347
347
348
    # load the language limits (for search)
348
    # load the language limits (for search)
349
    my $languages_limit_loop = getLanguages($lang, 1);
349
    my $languages_limit_loop = getSearchLanguages();
350
    $template->param(search_languages_loop => $languages_limit_loop,);
350
    $template->param(search_languages_loop => $languages_limit_loop,);
351
351
352
    # Expanded search options in advanced search:
352
    # Expanded search options in advanced search:
(-)a/installer/data/mysql/atomicupdate/bug-12017-add-syspres-LimitAdvancedSearchLanguage.sql (+24 lines)
Line 0 Link Here
1
2
INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
3
VALUES('LimitAdvancedSearchLanguages',1,'If ON, limit language list on advanced search languages.','','YesNo');
4
5
UPDATE systempreferences SET
6
type = 'Languages',
7
explanation = 'ISO 639-2 codes of languages you wish to see appear as an advanced search option'
8
WHERE variable = 'AdvancedSearchLanguages';
9
10
-- $DBversion = "3.21.00.XXX";
11
-- if ( CheckVersion($DBversion) ) {
12
--     $dbh->do(q{
13
--         INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
14
--         VALUES('LimitAdvancedSearchLanguages',1,'If ON, limit language list on advanced search languages.','','YesNo')
15
--     });
16
--     $dbh->do(q{
17
--         UPDATE systempreferences SET type = 'Languages',
18
--         explanation = 'ISO 639-2 codes of languages you wish to see appear as an advanced search option'
19
--         WHERE variable = 'AdvancedSearchLanguages'
20
--     });
21
--
22
--     print "Upgrade to $DBversion done (Bug 12017 - Add system preferecence LimitAdvancedSearchLanguages)\n";
23
--     SetVersion($DBversion);
24
-- }
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 8-14 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
9
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
9
('AddressFormat','us','','Choose format to display postal addresses', 'Choice'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
10
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
11
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an advanced search option','Language'),
12
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
12
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
13
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
13
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
14
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
14
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
Lines 189-194 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
189
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
189
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
190
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
190
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
191
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
191
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
192
('LimitAdvancedSearchLanguages','1','','If ON, limit language list on advanced search languages. To set language list configure AdvancedSearchLanguages local system preference.','YesNo'),
192
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
193
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
193
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
194
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
194
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
195
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-5 / +5 lines)
Lines 86-96 Searching: Link Here
86
            - "fields (separate values with |). Tabs appear in the order listed.<br/>"
86
            - "fields (separate values with |). Tabs appear in the order listed.<br/>"
87
            - "<em>Currently supported values</em>: Item types (<strong>itemtypes</strong>), Collection Codes (<strong>ccode</strong>) and Shelving Location (<strong>loc</strong>)."
87
            - "<em>Currently supported values</em>: Item types (<strong>itemtypes</strong>), Collection Codes (<strong>ccode</strong>) and Shelving Location (<strong>loc</strong>)."
88
        -
88
        -
89
            - Limit the languages listed in the advanced search drop-down to the
89
            - pref: LimitAdvancedSearchLanguages
90
            - pref: AdvancedSearchLanguages
90
              choices:
91
              class: long
91
                  yes: Limit
92
            - "ISO 639-2 language codes (separate values with | or ,)."
92
                  no: "Don't limit"
93
            - "For example, to limit listing to French and Italian, enter <em>ita|fre</em>."
93
            - the languages listed in the advanced search drop-down to the ISO 639-2 language codes managed on Local use system preference AdvancedSearchLanguages.
94
        -
94
        -
95
            - By default,
95
            - By default,
96
            - pref: expandedSearchOption
96
            - pref: expandedSearchOption
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt (-2 / +2 lines)
Lines 142-150 Link Here
142
        <option value="">No limit</option>
142
        <option value="">No limit</option>
143
        [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
143
        [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
144
		[% IF ( search_languages_loo.selected ) %]
144
		[% IF ( search_languages_loo.selected ) %]
145
		<option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
145
        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag t=1 -%] ([%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag -%])</option>
146
		[% ELSE %]
146
		[% ELSE %]
147
		<option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
147
        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag t=1 -%] ([%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag -%])</option>
148
		[% END %]
148
		[% END %]
149
		
149
		
150
		[% END %]
150
		[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt (-3 / +3 lines)
Lines 173-183 Link Here
173
                                    <label for="language-limit">Language: </label>
173
                                    <label for="language-limit">Language: </label>
174
                                    <select id="language-limit" name="limit">
174
                                    <select id="language-limit" name="limit">
175
                                        <option value="">No limit</option>
175
                                        <option value="">No limit</option>
176
                                            [% FOREACH search_languages_loo IN search_languages_loop %]
176
                                            [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
177
                                                [% IF ( search_languages_loo.selected ) %]
177
                                                [% IF ( search_languages_loo.selected ) %]
178
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
178
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag t=1 -%] ([%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag -%])</option>
179
                                                [% ELSE %]
179
                                                [% ELSE %]
180
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
180
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag t=1 -%] ([%- INCLUDE language_descriptions code = search_languages_loo.rfc4646_subtag -%])</option>
181
                                                [% END %]
181
                                                [% END %]
182
                                            [% END %]
182
                                            [% END %]
183
                                    </select>
183
                                    </select>
(-)a/opac/opac-search.pl (-3 / +2 lines)
Lines 32-38 use List::MoreUtils q/any/; Link Here
32
32
33
use C4::Output;
33
use C4::Output;
34
use C4::Auth qw(:DEFAULT get_session);
34
use C4::Auth qw(:DEFAULT get_session);
35
use C4::Languages qw(getLanguages);
35
use C4::Languages qw(getSearchLanguages);
36
use C4::Search;
36
use C4::Search;
37
use C4::Search::History;
37
use C4::Search::History;
38
use C4::Biblio;  # GetBiblioData
38
use C4::Biblio;  # GetBiblioData
Lines 206-212 $template->param( Link Here
206
);
206
);
207
207
208
# load the language limits (for search)
208
# load the language limits (for search)
209
my $languages_limit_loop = getLanguages($lang, 1);
209
my $languages_limit_loop = getSearchLanguages();
210
$template->param(search_languages_loop => $languages_limit_loop,);
210
$template->param(search_languages_loop => $languages_limit_loop,);
211
211
212
# load the Type stuff
212
# load the Type stuff
213
- 

Return to bug 12017