Lines 16-21
package C4::Search;
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
|
|
19 |
use feature qw(fc); |
19 |
use C4::Context; |
20 |
use C4::Context; |
20 |
use C4::Biblio qw( TransformMarcToKoha GetMarcFromKohaField GetFrameworkCode GetAuthorisedValueDesc GetBiblioData ); |
21 |
use C4::Biblio qw( TransformMarcToKoha GetMarcFromKohaField GetFrameworkCode GetAuthorisedValueDesc GetBiblioData ); |
21 |
use C4::Koha |
22 |
use C4::Koha |
Lines 40-47
use URI::Escape;
Link Here
|
40 |
use Business::ISBN; |
41 |
use Business::ISBN; |
41 |
use MARC::Record; |
42 |
use MARC::Record; |
42 |
use MARC::Field; |
43 |
use MARC::Field; |
43 |
use POSIX qw(setlocale LC_COLLATE); |
44 |
use Sort::Naturally qw(ncmp); |
44 |
use Unicode::Collate::Locale; |
|
|
45 |
|
45 |
|
46 |
our ( @ISA, @EXPORT_OK ); |
46 |
our ( @ISA, @EXPORT_OK ); |
47 |
|
47 |
|
Lines 304-323
Sorts facets using a configurable locale for Zebra search engine.
Link Here
|
304 |
sub _sort_facets_zebra { |
304 |
sub _sort_facets_zebra { |
305 |
my ( $facets, $locale ) = @_; |
305 |
my ( $facets, $locale ) = @_; |
306 |
|
306 |
|
307 |
if ( !$locale ) { |
307 |
if ($facets) { |
308 |
|
308 |
my @sorted_facets = sort { ncmp( $a->{facet_label_value}, $b->{facet_label_value} ) } @$facets; |
309 |
# Get locale from system preference, falling back to system LC_COLLATE |
|
|
310 |
$locale = C4::Context->preference('FacetSortingLocale') || 'default'; |
311 |
if ( $locale eq 'default' || !$locale ) { |
312 |
|
313 |
#NOTE: When setlocale is run with only the 1st parameter, it is a "get" not a "set" function. |
314 |
$locale = setlocale(LC_COLLATE) || 'default'; |
315 |
} |
316 |
} |
317 |
|
318 |
my $collator = Unicode::Collate::Locale->new( locale => $locale ); |
319 |
if ( $collator && $facets ) { |
320 |
my @sorted_facets = sort { $collator->cmp( $a->{facet_label_value}, $b->{facet_label_value} ) } @{$facets}; |
321 |
if (@sorted_facets) { |
309 |
if (@sorted_facets) { |
322 |
return \@sorted_facets; |
310 |
return \@sorted_facets; |
323 |
} |
311 |
} |