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(getLanguages_iso getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language getlanguage);
52
    @EXPORT_OK = qw(getSearchLanguages getLanguages_iso 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 getLanguages_iso
146
=head2 getLanguages_iso
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/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
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
9
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','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 180-185 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
180
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
180
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
181
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
181
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
182
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
182
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
183
('LimitAdvancedSearchLanguages','1','','If ON, limit language list on advanced search languages. To set language list configure AdvancedSearchLanguages local system preference.','YesNo'),
183
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
184
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
184
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
185
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
185
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
186
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 9005-9010 if ( CheckVersion($DBversion) ) { Link Here
9005
    SetVersion($DBversion);
9005
    SetVersion($DBversion);
9006
}
9006
}
9007
9007
9008
$DBversion = "3.17.00.XXX";
9009
if ( CheckVersion($DBversion) ) {
9010
    $dbh->do(q{
9011
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
9012
        VALUES('LimitAdvancedSearchLanguages',1,'If ON, limit language list on advanced search languages.','','YesNo')
9013
    });
9014
    $dbh->do(q{
9015
        UPDATE systempreferences SET type = 'Languages',
9016
        explanation = 'ISO 639-2 codes of languages you wish to see appear as an advanced search option'
9017
        WHERE variable = 'AdvancedSearchLanguages'
9018
    });
9019
9020
    print "Upgrade to $DBversion done (Bug 12017 - Add system preferecence LimitAdvancedSearchLanguages)\n";
9021
    SetVersion($DBversion);
9022
}
9023
9008
=head1 FUNCTIONS
9024
=head1 FUNCTIONS
9009
9025
9010
=head2 TableExists($table)
9026
=head2 TableExists($table)
(-)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 (-3 / +3 lines)
Lines 140-150 Link Here
140
		<p><label for="language-limit">Language: </label>                                        
140
		<p><label for="language-limit">Language: </label>                                        
141
		<select name="limit" id="language-limit">
141
		<select name="limit" id="language-limit">
142
        <option value="">No limit</option>
142
        <option value="">No limit</option>
143
		[% FOREACH search_languages_loo IN search_languages_loop %]
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 165-175 Link Here
165
                                    <label for="language-limit">Language: </label>
165
                                    <label for="language-limit">Language: </label>
166
                                    <select id="language-limit" name="limit">
166
                                    <select id="language-limit" name="limit">
167
                                        <option value="">No limit</option>
167
                                        <option value="">No limit</option>
168
                                            [% FOREACH search_languages_loo IN search_languages_loop %]
168
                                            [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
169
                                                [% IF ( search_languages_loo.selected ) %]
169
                                                [% IF ( search_languages_loo.selected ) %]
170
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
170
                                                    <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>
171
                                                [% ELSE %]
171
                                                [% ELSE %]
172
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
172
                                                    <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>
173
                                                [% END %]
173
                                                [% END %]
174
                                            [% END %]
174
                                            [% END %]
175
                                    </select>
175
                                    </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 190-196 $template->param( Link Here
190
);
190
);
191
191
192
# load the language limits (for search)
192
# load the language limits (for search)
193
my $languages_limit_loop = getLanguages($lang, 1);
193
my $languages_limit_loop = getSearchLanguages();
194
$template->param(search_languages_loop => $languages_limit_loop,);
194
$template->param(search_languages_loop => $languages_limit_loop,);
195
195
196
# load the Type stuff
196
# load the Type stuff
197
- 

Return to bug 12017