|
Lines 340-345
sub getRecords {
Link Here
|
| 340 |
my $facets_counter = (); |
340 |
my $facets_counter = (); |
| 341 |
my $facets_info = (); |
341 |
my $facets_info = (); |
| 342 |
my $facets = getFacets(); |
342 |
my $facets = getFacets(); |
|
|
343 |
# result : reference to a hash with the following informations for each facet: |
| 344 |
# facet_n => {idx => index_n string |
| 345 |
# label => label_n string |
| 346 |
# tags => [ fieldandsubfields string : MARC tag code followed by MARC subtags codes |
| 347 |
# fieldandsubfields |
| 348 |
# fieldandsubfields ] |
| 349 |
# order => 0 digit : if 0 or void, don't show the facet |
| 350 |
# sort => type_of_string string : 4 values : alpha_asc, alpha_desc, occur_asc, occur_desc |
| 351 |
# sep => separator} string |
| 352 |
|
| 343 |
my $facets_maxrecs = C4::Context->preference('maxRecordsForFacets')||20; |
353 |
my $facets_maxrecs = C4::Context->preference('maxRecordsForFacets')||20; |
| 344 |
|
354 |
|
| 345 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
355 |
my @facets_loop; # stores the ref to array of hashes for template facets loop |
|
Lines 501-513
sub getRecords {
Link Here
|
| 501 |
|
511 |
|
| 502 |
my $jmax = |
512 |
my $jmax = |
| 503 |
$size > $facets_maxrecs ? $facets_maxrecs : $size; |
513 |
$size > $facets_maxrecs ? $facets_maxrecs : $size; |
| 504 |
for my $facet (@$facets) { |
514 |
# only display facets with {order} value undef |
|
|
515 |
my @active_facets = grep {defined $facets->{$_}->{order}} keys %{ $facets }; |
| 516 |
foreach my $facet_key (@active_facets) { |
| 505 |
for ( my $j = 0 ; $j < $jmax ; $j++ ) { |
517 |
for ( my $j = 0 ; $j < $jmax ; $j++ ) { |
| 506 |
my $render_record = |
518 |
my $render_record = |
| 507 |
$results[ $i - 1 ]->record($j)->render(); |
519 |
$results[ $i - 1 ]->record($j)->render(); |
| 508 |
my @used_datas = (); |
520 |
my @used_datas = (); |
| 509 |
foreach my $tag ( @{ $facet->{tags} } ) { |
521 |
foreach my $tag ( @{ $facets->{$facet_key}->{tags}} ) { |
| 510 |
|
|
|
| 511 |
# avoid first line |
522 |
# avoid first line |
| 512 |
my $tag_num = substr( $tag, 0, 3 ); |
523 |
my $tag_num = substr( $tag, 0, 3 ); |
| 513 |
my $letters = substr( $tag, 3 ); |
524 |
my $letters = substr( $tag, 3 ); |
|
Lines 529-547
sub getRecords {
Link Here
|
| 529 |
push @values, $value; |
540 |
push @values, $value; |
| 530 |
} |
541 |
} |
| 531 |
} |
542 |
} |
| 532 |
my $data = join( $facet->{sep}, @values ); |
543 |
my $data = join( $facets->{$facet_key}-> {sep}, @values ); |
| 533 |
unless ( $data ~~ @used_datas ) { |
544 |
unless ( $data ~~ @used_datas ) { |
| 534 |
$facets_counter->{ $facet->{idx} } |
545 |
$facets_counter->{ $facets->{$facet_key}-> {idx} } |
| 535 |
->{$data}++; |
546 |
->{$data}++; |
| 536 |
push @used_datas, $data; |
547 |
push @used_datas, $data; |
| 537 |
} |
548 |
} |
| 538 |
} # fields |
549 |
} # fields |
| 539 |
} # field codes |
550 |
} # field codes |
| 540 |
} # records |
551 |
} # records |
| 541 |
$facets_info->{ $facet->{idx} }->{label_value} = |
552 |
$facets_info->{ $facets->{$facet_key}-> {idx} }->{label_value} = |
| 542 |
$facet->{label}; |
553 |
$facets->{$facet_key}-> {label}; |
| 543 |
$facets_info->{ $facet->{idx} }->{expanded} = |
554 |
$facets_info->{ $facets->{$facet_key}-> {idx} }->{expanded} = |
| 544 |
$facet->{expanded}; |
555 |
$facets->{$facet_key}-> {expanded}; |
| 545 |
} # facets |
556 |
} # facets |
| 546 |
} |
557 |
} |
| 547 |
|
558 |
|
|
Lines 621-629
sub getRecords {
Link Here
|
| 621 |
|
632 |
|
| 622 |
# also, if it's a location code, use the name instead of the code |
633 |
# also, if it's a location code, use the name instead of the code |
| 623 |
if ( $link_value =~ /location/ ) { |
634 |
if ( $link_value =~ /location/ ) { |
|
|
635 |
warn $link_value ; |
| 636 |
warn $one_facet; |
| 637 |
warn $opac; |
| 638 |
warn $facet_label_value; |
| 624 |
$facet_label_value = |
639 |
$facet_label_value = |
| 625 |
GetKohaAuthorisedValueLib( 'LOC', |
640 |
GetKohaAuthorisedValueLib( 'LOC', |
| 626 |
$one_facet, $opac ); |
641 |
$one_facet, $opac ); |
|
|
642 |
warn $facet_label_value; |
| 627 |
} |
643 |
} |
| 628 |
|
644 |
|
| 629 |
# but we're down with the whole label being in the link's title. |
645 |
# but we're down with the whole label being in the link's title. |
| 630 |
- |
|
|