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 344-350 if ( $template_type eq 'advsearch' ) { Link Here
344
                      search_boxes_loop => \@search_boxes_array);
344
                      search_boxes_loop => \@search_boxes_array);
345
345
346
    # load the language limits (for search)
346
    # load the language limits (for search)
347
    my $languages_limit_loop = getLanguages($lang, 1);
347
    my $languages_limit_loop = getSearchLanguages();
348
    $template->param(search_languages_loop => $languages_limit_loop,);
348
    $template->param(search_languages_loop => $languages_limit_loop,);
349
349
350
    # Expanded search options in advanced search:
350
    # Expanded search options in advanced search:
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 7-13 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
7
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
7
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
8
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
8
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
9
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
9
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
10
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
10
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an advanced search option','Language'),
11
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
11
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
12
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
12
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
13
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
13
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
Lines 175-180 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
175
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
175
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
176
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
176
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
177
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
177
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
178
('LimitAdvancedSearchLanguages','1','','If ON, limit language list on advanced search languages. To set language list configure AdvancedSearchLanguages local system preference.','YesNo'),
178
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
179
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
179
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
180
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
180
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
181
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+16 lines)
Lines 8570-8575 if ( CheckVersion($DBversion) ) { Link Here
8570
    SetVersion($DBversion);
8570
    SetVersion($DBversion);
8571
}
8571
}
8572
8572
8573
$DBversion = "3.17.00.XXX";
8574
if ( CheckVersion($DBversion) ) {
8575
    $dbh->do(q{
8576
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
8577
        VALUES('LimitAdvancedSearchLanguages',1,'If ON, limit language list on advanced search languages.','','YesNo')
8578
    });
8579
    $dbh->do(q{
8580
        UPDATE systempreferences SET type = 'Languages',
8581
        explanation = 'ISO 639-2 codes of languages you wish to see appear as an advanced search option'
8582
        WHERE variable = 'AdvancedSearchLanguages'
8583
    });
8584
8585
    print "Upgrade to $DBversion done (Bug 12017 - Add system preferecence LimitAdvancedSearchLanguages)\n";
8586
    SetVersion($DBversion);
8587
}
8588
8573
=head1 FUNCTIONS
8589
=head1 FUNCTIONS
8574
8590
8575
=head2 TableExists($table)
8591
=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 139-149 Link Here
139
		<p><label for="language-limit">Language: </label>                                        
139
		<p><label for="language-limit">Language: </label>                                        
140
		<select name="limit" id="language-limit">
140
		<select name="limit" id="language-limit">
141
        <option value="">No limit</option>
141
        <option value="">No limit</option>
142
		[% FOREACH search_languages_loo IN search_languages_loop %]
142
        [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
143
		[% IF ( search_languages_loo.selected ) %]
143
		[% IF ( search_languages_loo.selected ) %]
144
		<option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
144
        <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>
145
		[% ELSE %]
145
		[% ELSE %]
146
		<option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
146
        <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>
147
		[% END %]
147
		[% END %]
148
		
148
		
149
		[% END %]
149
		[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt (-3 / +3 lines)
Lines 174-184 Link Here
174
                                    <label for="language-limit">Language: </label>
174
                                    <label for="language-limit">Language: </label>
175
                                    <select id="language-limit" name="limit">
175
                                    <select id="language-limit" name="limit">
176
                                        <option value="">No limit</option>
176
                                        <option value="">No limit</option>
177
                                            [% FOREACH search_languages_loo IN search_languages_loop %]
177
                                            [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
178
                                                [% IF ( search_languages_loo.selected ) %]
178
                                                [% IF ( search_languages_loo.selected ) %]
179
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
179
                                                    <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>
180
                                                [% ELSE %]
180
                                                [% ELSE %]
181
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
181
                                                    <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>
182
                                                [% END %]
182
                                                [% END %]
183
                                            [% END %]
183
                                            [% END %]
184
                                    </select>
184
                                    </select>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt (-2 / +2 lines)
Lines 204-212 Link Here
204
                <option value="">No limit</option>
204
                <option value="">No limit</option>
205
                [% FOREACH search_languages_loo IN search_languages_loop %]
205
                [% FOREACH search_languages_loo IN search_languages_loop %]
206
                    [% IF ( search_languages_loo.selected ) %]
206
                    [% IF ( search_languages_loo.selected ) %]
207
                        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
207
                        <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>
208
                    [% ELSE %]
208
                    [% ELSE %]
209
                        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
209
                        <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>
210
                    [% END %]
210
                    [% END %]
211
                [% END %]
211
                [% END %]
212
                </select></p><!-- <a href="">Show all languages</a>-->
212
                </select></p><!-- <a href="">Show all languages</a>-->
(-)a/opac/opac-search.pl (-3 / +2 lines)
Lines 40-46 if ( $searchengine =~ /^Solr$/ ) { Link Here
40
40
41
use C4::Output;
41
use C4::Output;
42
use C4::Auth qw(:DEFAULT get_session);
42
use C4::Auth qw(:DEFAULT get_session);
43
use C4::Languages qw(getLanguages);
43
use C4::Languages qw(getSearchLanguages);
44
use C4::Search;
44
use C4::Search;
45
use C4::Search::History;
45
use C4::Search::History;
46
use C4::Biblio;  # GetBiblioData
46
use C4::Biblio;  # GetBiblioData
Lines 198-204 $template->param( Link Here
198
);
198
);
199
199
200
# load the language limits (for search)
200
# load the language limits (for search)
201
my $languages_limit_loop = getLanguages($lang, 1);
201
my $languages_limit_loop = getSearchLanguages();
202
$template->param(search_languages_loop => $languages_limit_loop,);
202
$template->param(search_languages_loop => $languages_limit_loop,);
203
203
204
# load the Type stuff
204
# load the Type stuff
205
- 

Return to bug 12017