Lines 390-402
sub _convert_facets {
Link Here
|
390 |
|
390 |
|
391 |
# These should correspond to the ES field names, as opposed to the CCL |
391 |
# These should correspond to the ES field names, as opposed to the CCL |
392 |
# things that zebra uses. |
392 |
# things that zebra uses. |
|
|
393 |
# TODO let the library define the order using the interface. |
393 |
my %type_to_label = ( |
394 |
my %type_to_label = ( |
394 |
author => 'Authors', |
395 |
author => { order => 1, label => 'Authors', }, |
395 |
location => 'Location', |
396 |
itype => { order => 2, label => 'ItemTypes', }, |
396 |
itype => 'ItemTypes', |
397 |
location => { order => 3, label => 'Location', }, |
397 |
se => 'Series', |
398 |
'su-geo' => { order => 4, label => 'Places', }, |
398 |
subject => 'Topics', |
399 |
se => { order => 5, label => 'Series', }, |
399 |
'su-geo' => 'Places', |
400 |
subject => { order => 6, label => 'Topics', }, |
400 |
); |
401 |
); |
401 |
|
402 |
|
402 |
# We also have some special cases, e.g. itypes that need to show the |
403 |
# We also have some special cases, e.g. itypes that need to show the |
Lines 408-427
sub _convert_facets {
Link Here
|
408 |
itype => { map { $_->itemtype => $_->description } @itypes }, |
409 |
itype => { map { $_->itemtype => $_->description } @itypes }, |
409 |
location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations }, |
410 |
location => { map { $_->authorised_value => ( $opac ? ( $_->lib_opac || $_->lib ) : $_->lib ) } @locations }, |
410 |
); |
411 |
); |
411 |
my @res; |
412 |
my @facets; |
412 |
$exp_facet //= ''; |
413 |
$exp_facet //= ''; |
413 |
while ( ( $type, $data ) = each %$es ) { |
414 |
while ( ( $type, $data ) = each %$es ) { |
414 |
next if !exists( $type_to_label{$type} ); |
415 |
next if !exists( $type_to_label{$type} ); |
415 |
|
416 |
|
416 |
# We restrict to the most popular $limit results |
417 |
# We restrict to the most popular $limit !results |
417 |
my $limit = ( $type eq $exp_facet ) ? 10 : 5; |
418 |
my $limit = ( $type eq $exp_facet ) ? 10 : 5; |
418 |
my $facet = { |
419 |
my $facet = { |
419 |
type_id => $type . '_id', |
420 |
type_id => $type . '_id', |
420 |
expand => $type, |
421 |
expand => $type, |
421 |
expandable => ( $type ne $exp_facet ) |
422 |
expandable => ( $type ne $exp_facet ) |
422 |
&& ( @{ $data->{terms} } > $limit ), |
423 |
&& ( @{ $data->{terms} } > $limit ), |
423 |
"type_label_$type_to_label{$type}" => 1, |
424 |
"type_label_$type_to_label{$type}{label}" => 1, |
424 |
type_link_value => $type, |
425 |
type_link_value => $type, |
|
|
426 |
order => $type_to_label{$type}{order}, |
425 |
}; |
427 |
}; |
426 |
$limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } ); |
428 |
$limit = @{ $data->{terms} } if ( $limit > @{ $data->{terms} } ); |
427 |
foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) { |
429 |
foreach my $term ( @{ $data->{terms} }[ 0 .. $limit - 1 ] ) { |
Lines 442-450
sub _convert_facets {
Link Here
|
442 |
type_link_value => $type, |
444 |
type_link_value => $type, |
443 |
}; |
445 |
}; |
444 |
} |
446 |
} |
445 |
push @res, $facet if exists $facet->{facets}; |
447 |
push @facets, $facet if exists $facet->{facets}; |
446 |
} |
448 |
} |
447 |
return \@res; |
449 |
|
|
|
450 |
@facets = sort { $a->{order} cmp $b->{order} } @facets; |
451 |
return \@facets; |
448 |
} |
452 |
} |
449 |
|
453 |
|
450 |
|
454 |
|