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

(-)a/C4/Languages.pm (-1 / +38 lines)
Lines 46-52 BEGIN { Link Here
46
        &getLanguages
46
        &getLanguages
47
        &getAllLanguages
47
        &getAllLanguages
48
    );
48
    );
49
    @EXPORT_OK = qw(getLanguages_iso getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language);
49
    @EXPORT_OK = qw(getSearchLanguages getLanguages_iso getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language);
50
    $DEBUG = 0;
50
    $DEBUG = 0;
51
}
51
}
52
52
Lines 103-108 sub getFrameworkLanguages { Link Here
103
    return \@languages;
103
    return \@languages;
104
}
104
}
105
105
106
=head2 getSearchLanguages
107
108
Get selection of languages codes and iso639_2.
109
Use sysprefs LimitAdvancedSearchLanguages and AdvancedSearchLanguages,
110
default to english.
111
112
Returns a reference to an array of hashes:
113
114
 my $languages = getSearchLanguages();
115
 for my $language( @$languages ) {
116
    print "$language->{rfc4646_subtag}\n"; # language code in rfc4646
117
    print "$language->{iso638_2_code}\n";  # language code in iso 639-2
118
 }
119
120
=cut
121
122
sub getSearchLanguages {
123
    my $isFiltered    = C4::Context->preference("LimitAdvancedSearchLanguages");;
124
    my $language_list = C4::Context->preference("AdvancedSearchLanguages");
125
    $language_list    = 'eng' unless $language_list;
126
    my @languages     = split ( /\,/, $language_list );
127
    my $langs         = getLangCodes();
128
    my @result;
129
    my %enabled;
130
    $enabled{$_}++ for ( @languages );
131
132
    for my $code ( keys %$langs ) {
133
        if (( $isFiltered and $enabled{ $langs->{ $code } } ) or ( not $isFiltered )) {
134
            push @result, {
135
                rfc4646_subtag => $code,
136
                iso639_2_code  => $langs->{$code},
137
            }
138
        }
139
    }
140
    return \@result;
141
}
142
106
=head2 getLanguages_iso
143
=head2 getLanguages_iso
107
144
108
Get all languages codes and iso639_2 selected by iso639_2
145
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 339-345 if ( $template_type eq 'advsearch' ) { Link Here
339
                      search_boxes_loop => \@search_boxes_array);
339
                      search_boxes_loop => \@search_boxes_array);
340
340
341
    # load the language limits (for search)
341
    # load the language limits (for search)
342
    my $languages_limit_loop = getLanguages($lang, 1);
342
    my $languages_limit_loop = getSearchLanguages();
343
    $template->param(search_languages_loop => $languages_limit_loop,);
343
    $template->param(search_languages_loop => $languages_limit_loop,);
344
344
345
    # Expanded search options in advanced search:
345
    # Expanded search options in advanced search:
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 6-12 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
6
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
6
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
7
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
7
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
8
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
8
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
9
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option.  Example: eng|fre|ita','Textarea'),
9
('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an advanced search option','Language'),
10
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
10
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
11
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
11
('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'),
12
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
12
('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'),
Lines 170-175 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
170
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
170
('LibraryThingForLibrariesEnabled','0','','Enable or Disable Library Thing for Libraries Features','YesNo'),
171
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
171
('LibraryThingForLibrariesID','','','See:http://librarything.com/forlibraries/','free'),
172
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
172
('LibraryThingForLibrariesTabbedView','0','','Put LibraryThingForLibraries Content in Tabs.','YesNo'),
173
('LimitAdvancedSearchLanguages','1','','If ON, limit language list on advanced search languages. To set language list configure AdvancedSearchLanguages local system preference.','YesNo'),
173
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
174
('LinkerKeepStale','0',NULL,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.','YesNo'),
174
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
175
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
175
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
176
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+17 lines)
Lines 8202-8207 if ( CheckVersion($DBversion) ) { Link Here
8202
    SetVersion($DBversion);
8202
    SetVersion($DBversion);
8203
}
8203
}
8204
8204
8205
$DBversion = "3.15.00.XXX";
8206
if ( CheckVersion($DBversion) ) {
8207
    $dbh->do(q{
8208
        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
8209
        VALUES('LimitAdvancedSearchLanguages',1,'If ON, limit language list on advanced search languages.','','YesNo')
8210
    });
8211
    $dbh->do(q{
8212
        UPDATE systempreferences SET type = 'Languages',
8213
        explanation = 'ISO 639-2 codes of languages you wish to see appear as an advanced search option'
8214
        WHERE variable = 'AdvancedSearchLanguages'
8215
    });
8216
8217
    print "Upgrade to $DBversion done (Bug 12017 - Add system preferecence LimitAdvancedSearchLanguages)\n";
8218
    SetVersion($DBversion);
8219
}
8220
8221
8205
=head1 FUNCTIONS
8222
=head1 FUNCTIONS
8206
8223
8207
=head2 TableExists($table)
8224
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (-5 / +5 lines)
Lines 79-89 Searching: Link Here
79
            - "fields (separate values with |). Tabs appear in the order listed.<br/>"
79
            - "fields (separate values with |). Tabs appear in the order listed.<br/>"
80
            - "<em>Currently supported values</em>: Item types (<strong>itemtypes</strong>), Collection Codes (<strong>ccode</strong>) and Shelving Location (<strong>loc</strong>)."
80
            - "<em>Currently supported values</em>: Item types (<strong>itemtypes</strong>), Collection Codes (<strong>ccode</strong>) and Shelving Location (<strong>loc</strong>)."
81
        -
81
        -
82
            - Limit the languages listed in the advanced search drop-down to the
82
            - pref: LimitAdvancedSearchLanguages
83
            - pref: AdvancedSearchLanguages
83
              choices:
84
              class: long
84
                  yes: Limit
85
            - "ISO 639-2 language codes (separate values with | or ,)."
85
                  no: "Don't limit"
86
            - "For example, to limit listing to French and Italian, enter <em>ita|fre</em>."
86
            - the languages listed in the advanced search drop-down to the ISO 639-2 language codes managed on Local use system preference AdvancedSearchLanguages.
87
        -
87
        -
88
            - By default,
88
            - By default,
89
            - pref: expandedSearchOption
89
            - 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 (-4 / +4 lines)
Lines 175-185 Link Here
175
                                    <label for="language-limit">Language: </label>
175
                                    <label for="language-limit">Language: </label>
176
                                    <select id="language-limit" name="limit">
176
                                    <select id="language-limit" name="limit">
177
                                        <option value="">No limit</option>
177
                                        <option value="">No limit</option>
178
                                            [% FOREACH search_languages_loo IN search_languages_loop %]
178
                                            [% FOREACH search_languages_loo IN search_languages_loop.sort('iso639_2_code') %]
179
                                                [% IF ( search_languages_loo.selected ) %]
179
                                                [% IF ( search_languages_loo.selected ) %]
180
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
180
                                                    <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>
181
                                                [% ELSE %]
181
                                                [% ELSE %]
182
                                                    <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
182
                                                    <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>
183
                                                [% END %]
183
                                                [% END %]
184
                                            [% END %]
184
                                            [% END %]
185
                                    </select>
185
                                    </select>
Lines 392-395 Link Here
392
    });
392
    });
393
    //]]>
393
    //]]>
394
</script>
394
</script>
395
[% END %]
395
[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt (-2 / +2 lines)
Lines 205-213 Link Here
205
                <option value="">No limit</option>
205
                <option value="">No limit</option>
206
                [% FOREACH search_languages_loo IN search_languages_loop %]
206
                [% FOREACH search_languages_loo IN search_languages_loop %]
207
                    [% IF ( search_languages_loo.selected ) %]
207
                    [% IF ( search_languages_loo.selected ) %]
208
                        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]" selected="selected">[% search_languages_loo.language_description %]</option>
208
                        <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>
209
                    [% ELSE %]
209
                    [% ELSE %]
210
                        <option value="ln,rtrn:[% search_languages_loo.iso639_2_code %]">[% search_languages_loo.language_description %]</option>
210
                        <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>
211
                    [% END %]
211
                    [% END %]
212
                [% END %]
212
                [% END %]
213
                </select></p><!-- <a href="">Show all languages</a>-->
213
                </select></p><!-- <a href="">Show all languages</a>-->
(-)a/opac/opac-search.pl (-3 / +2 lines)
Lines 43-49 for ( $searchengine ) { Link Here
43
43
44
use C4::Output;
44
use C4::Output;
45
use C4::Auth qw(:DEFAULT get_session ParseSearchHistorySession SetSearchHistorySession);
45
use C4::Auth qw(:DEFAULT get_session ParseSearchHistorySession SetSearchHistorySession);
46
use C4::Languages qw(getLanguages);
46
use C4::Languages qw(getSearchLanguages);
47
use C4::Search;
47
use C4::Search;
48
use C4::Biblio;  # GetBiblioData
48
use C4::Biblio;  # GetBiblioData
49
use C4::Koha;
49
use C4::Koha;
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