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

(-)a/C4/Branch.pm (+10 lines)
Lines 46-51 BEGIN { Link Here
46
		&DelBranchCategory
46
		&DelBranchCategory
47
	        &CheckCategoryUnique
47
	        &CheckCategoryUnique
48
		&mybranch
48
		&mybranch
49
		&GetBranchesCount
49
	);
50
	);
50
	@EXPORT_OK = qw( &onlymine &mybranch get_branch_code_from_name );
51
	@EXPORT_OK = qw( &onlymine &mybranch get_branch_code_from_name );
51
}
52
}
Lines 580-585 sub get_branch_code_from_name { Link Here
580
   return $sth->fetchrow_array;
581
   return $sth->fetchrow_array;
581
}
582
}
582
583
584
sub GetBranchesCount {
585
    my $dbh = C4::Context->dbh();
586
    my $query = "SELECT COUNT(*) AS branches_count FROM branches";
587
    my $sth = $dbh->prepare( $query );
588
    $sth->execute();
589
    my $row = $sth->fetchrow_hashref();
590
    return $row->{'branches_count'};
591
}
592
583
1;
593
1;
584
__END__
594
__END__
585
595
(-)a/C4/Koha.pm (-17 / +41 lines)
Lines 24-30 use strict; Link Here
24
#use warnings; FIXME - Bug 2505
24
#use warnings; FIXME - Bug 2505
25
25
26
use C4::Context;
26
use C4::Context;
27
27
use C4::Branch qw(GetBranchesCount);
28
use Memoize;
28
use Memoize;
29
use DateTime;
29
use DateTime;
30
use DateTime::Format::MySQL;
30
use DateTime::Format::MySQL;
Lines 713-726 sub getFacets { Link Here
713
                tags  => [ qw/ 225a / ],
713
                tags  => [ qw/ 225a / ],
714
                sep   => ', ',
714
                sep   => ', ',
715
            },
715
            },
716
        ];
716
            ];
717
        my $library_facet = {
717
718
            idx   => 'branch',
718
            my $library_facet;
719
            label => 'Libraries',
719
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
720
            tags  => [ qw/ 995b / ],
720
                $library_facet = {
721
            expanded => '1',
721
                    link_value  => 'branch',
722
        };
722
                    label_value => 'Libraries',
723
        push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
723
                    tags        => [ '995', ],
724
                    subfield    => 'b',
725
                    expanded    => '1',
726
                };
727
            } else {
728
                $library_facet = {
729
                    link_value  => 'location',
730
                    label_value => 'Location',
731
                    tags        => [ '995' ],
732
                    subfield    => 'c',
733
                    expanded    => '1',
734
                };
735
            }
736
            push( @$facets, $library_facet );
724
    }
737
    }
725
    else {
738
    else {
726
        $facets = [
739
        $facets = [
Lines 761-775 sub getFacets { Link Here
761
                sep   => ', ',
774
                sep   => ', ',
762
            },
775
            },
763
            ];
776
            ];
777
            
764
            my $library_facet;
778
            my $library_facet;
765
            $library_facet = {
779
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
766
                idx   => 'branch',
780
                $library_facet = {
767
                label => 'Libraries',
781
                    link_value  => 'branch',
768
                tags  => [ qw/ 952b / ],
782
                    label_value => 'Libraries',
769
                sep   => ', ',
783
                    tags        => [ '952', ],
770
                expanded    => '1',
784
                    subfield    => 'b',
771
            };
785
                    expanded    => '1',
772
            push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
786
                };
787
            } else {
788
                $library_facet = {
789
                    link_value => 'location',
790
                    label_value => 'Location',
791
                    tags => [ '952' ],
792
                    subfield => 'c',
793
                    expanded => '1',
794
                };
795
            }
796
            push( @$facets, $library_facet );
773
    }
797
    }
774
    return $facets;
798
    return $facets;
775
}
799
}
(-)a/C4/Search.pm (-1 / +6 lines)
Lines 302-308 sub getRecords { Link Here
302
    my (
302
    my (
303
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
303
        $koha_query,       $simple_query, $sort_by_ref,    $servers_ref,
304
        $results_per_page, $offset,       $expanded_facet, $branches,
304
        $results_per_page, $offset,       $expanded_facet, $branches,
305
        $query_type,       $scan
305
        $query_type,       $scan,         $opac
306
    ) = @_;
306
    ) = @_;
307
307
308
    my @servers = @$servers_ref;
308
    my @servers = @$servers_ref;
Lines 556-561 sub getRecords { Link Here
556
								}
556
								}
557
                            }
557
                            }
558
558
559
                            # also, if it's a location code, use the name instead of the code
560
                            if ( $link_value =~ /location/ ) {
561
                                $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac) || '*';
562
                            }
563
559
                            # but we're down with the whole label being in the link's title.
564
                            # but we're down with the whole label being in the link's title.
560
                            push @this_facets_array, {
565
                            push @this_facets_array, {
561
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
566
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (+1 lines)
Lines 16-21 Link Here
16
[% IF ( facets_loo.type_label_Places ) %]Places[% END %]
16
[% IF ( facets_loo.type_label_Places ) %]Places[% END %]
17
[% IF ( facets_loo.type_label_Series ) %]Series[% END %]
17
[% IF ( facets_loo.type_label_Series ) %]Series[% END %]
18
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
18
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
19
[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
19
<ul>
20
<ul>
20
        [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
21
        [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
21
        <li class="showmore"><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %][% IF ( offset ) %]&amp;offset=[% offset %][% END %]&amp;expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
22
        <li class="showmore"><a href="/cgi-bin/koha/catalogue/search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %][% IF ( offset ) %]&amp;offset=[% offset %][% END %]&amp;expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc (+1 lines)
Lines 17-22 Link Here
17
[% UNLESS ( singleBranchMode ) %]
17
[% UNLESS ( singleBranchMode ) %]
18
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
18
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
19
[% END %]
19
[% END %]
20
[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
20
<ul>
21
<ul>
21
        [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value |html %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
22
        [% FOREACH facet IN facets_loo.facets %]<li><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=[% facet.type_link_value %]:[% facet.facet_link_value %]" title="[% facet.facet_title_value |html %]">[% facet.facet_label_value %]</a> [% IF ( displayFacetCount ) %]([% facet.facet_count %])[% END %]</li>[% END %][% IF ( facets_loo.expandable ) %]
22
        <li class="showmore"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %][% IF ( offset ) %]&amp;offset=[% offset %][% END %]&amp;expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
23
        <li class="showmore"><a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&amp;sort_by=[% sort_by %][% END %][% IF ( offset ) %]&amp;offset=[% offset %][% END %]&amp;expand=[% facets_loo.expand %]#[% facets_loo.type_id %]">Show more</a></li>
(-)a/opac/opac-search.pl (-2 / +1 lines)
Lines 475-481 elsif (C4::Context->preference('NoZebra')) { Link Here
475
    $pasarParams .= '&amp;simple_query=' . $simple_query;
475
    $pasarParams .= '&amp;simple_query=' . $simple_query;
476
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
476
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
477
    eval {
477
    eval {
478
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
478
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan,1);
479
    };
479
    };
480
}
480
}
481
# This sorts the facets into alphabetical order
481
# This sorts the facets into alphabetical order
482
- 

Return to bug 7401