@@ -, +, @@ AdvancedSearchLanguagesSort is set to priority. -1. Set some languages into AdvancedSearchLanguages system preference --- C4/Languages.pm | 5 +++-- .../Bug_14912-Sort_Advanced_Search_Languages_by_priority.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/searching.pref | 8 ++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/Bug_14912-Sort_Advanced_Search_Languages_by_priority.sql --- a/C4/Languages.pm +++ a/C4/Languages.pm @@ -206,6 +206,7 @@ sub getLanguages { my @languages_loop; my $languages_hash; + my $priority_sorting = C4::Context->preference("AdvancedSearchLanguagesSort"); my $dbh=C4::Context->dbh; my $default_language = 'en'; my $current_language = $default_language; @@ -253,10 +254,10 @@ sub getLanguages { # Do not push unless valid iso639-2 code if ( $language_subtag_registry->{ iso639_2_code } and ( !$language_list || index ( $language_list, $language_subtag_registry->{ iso639_2_code } ) >= 0) ) { $languages_hash->{$language_subtag_registry->{ iso639_2_code }} = $language_subtag_registry; - push @languages_loop, $language_subtag_registry if not $language_list; + push @languages_loop, $language_subtag_registry if not $language_list or not $priority_sorting; } } - if ($language_list) { + if ($language_list and $priority_sorting) { # sort @languages_loop into order defined in AdvancedSearchLanguages preference my @adv_search_languages = split /[,|]+/, $language_list; foreach my $adv_search_lang (@adv_search_languages){ --- a/installer/data/mysql/atomicupdate/Bug_14912-Sort_Advanced_Search_Languages_by_priority.sql +++ a/installer/data/mysql/atomicupdate/Bug_14912-Sort_Advanced_Search_Languages_by_priority.sql @@ -0,0 +1, @@ +INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('AdvancedSearchLanguagesSort', '0', NULL, 'Use AdvancedSearchLanguages to sort the drop-down list. The leftmost language has the highest priority and appears on top of the drop-down.', 'YesNo'); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -9,6 +9,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AddressFormat','us','','Choose format to display postal addresses', 'Choice'), ('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'), ('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option. Example: eng|fre|ita','Textarea'), +('AdvancedSearchLanguagesSort','0',NULL,'Use AdvancedSearchLanguages to sort the drop-down list. The leftmost language has the highest priority and appears on top of the drop-down.','YesNo'), ('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'), ('AgeRestrictionMarker','',NULL,'Markers for age restriction indication, e.g. FSK|PEGI|Age|','free'), ('AgeRestrictionOverride','0',NULL,'Allow staff to check out an item with age restriction.','YesNo'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref @@ -92,6 +92,14 @@ Searching: - "ISO 639-2 language codes (separate values with | or ,)." - "For example, to limit listing to French and Italian, enter ita|fre." - + - By default, sort advanced search languages + - pref: AdvancedSearchLanguagesSort + type: boolean + choices: + yes: by priority + no: alphabetically + - '. The leftmost language in the AdvancedSearchLanguages preference has the highest priority and appears on top of the drop-down list.' + - - By default, - pref: expandedSearchOption type: boolean --