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 (-16 / +41 lines)
Lines 24-29 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
use C4::Branch qw(GetBranchesCount);
27
28
28
use Memoize;
29
use Memoize;
29
use DateTime;
30
use DateTime;
Lines 713-726 sub getFacets { Link Here
713
                tags  => [ qw/ 225a / ],
714
                tags  => [ qw/ 225a / ],
714
                sep   => ', ',
715
                sep   => ', ',
715
            },
716
            },
716
        ];
717
            ];
717
        my $library_facet = {
718
718
            idx   => 'branch',
719
            my $library_facet;
719
            label => 'Libraries',
720
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
720
            tags  => [ qw/ 995b / ],
721
                $library_facet = {
721
            expanded => '1',
722
                    link_value  => 'branch',
722
        };
723
                    label_value => 'Libraries',
723
        push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
724
                    tags        => [ '995', ],
725
                    subfield    => 'b',
726
                    expanded    => '1',
727
                };
728
            } else {
729
                $library_facet = {
730
                    link_value  => 'location',
731
                    label_value => 'Location',
732
                    tags        => [ '995' ],
733
                    subfield    => 'c',
734
                    expanded    => '1',
735
                };
736
            }
737
            push( @$facets, $library_facet );
724
    }
738
    }
725
    else {
739
    else {
726
        $facets = [
740
        $facets = [
Lines 767-781 sub getFacets { Link Here
767
                sep   => ', ',
781
                sep   => ', ',
768
            },
782
            },
769
            ];
783
            ];
784
770
            my $library_facet;
785
            my $library_facet;
771
            $library_facet = {
786
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
772
                idx   => 'branch',
787
                $library_facet = {
773
                label => 'Libraries',
788
                    link_value  => 'branch',
774
                tags  => [ qw/ 952b / ],
789
                    label_value => 'Libraries',
775
                sep   => ', ',
790
                    tags        => [ '952', ],
776
                expanded    => '1',
791
                    subfield    => 'b',
777
            };
792
                    expanded    => '1',
778
            push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
793
                };
794
            } else {
795
                $library_facet = {
796
                    link_value => 'location',
797
                    label_value => 'Location',
798
                    tags => [ '952' ],
799
                    subfield => 'c',
800
                    expanded => '1',
801
                };
802
            }
803
            push( @$facets, $library_facet );
779
    }
804
    }
780
    return $facets;
805
    return $facets;
781
}
806
}
(-)a/C4/Search.pm (-2 / +7 lines)
Lines 301-308 See verbse embedded documentation. Link Here
301
sub getRecords {
301
sub getRecords {
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,$itemtypes,
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 567-572 sub getRecords { Link Here
567
                                }
567
                                }
568
                            }
568
                            }
569
569
570
                            # also, if it's a location code, use the name instead of the code
571
                            if ( $link_value =~ /location/ ) {
572
                                $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac) || '*';
573
                            }
574
570
                            # but we're down with the whole label being in the link's title.
575
                            # but we're down with the whole label being in the link's title.
571
                            push @this_facets_array, {
576
                            push @this_facets_array, {
572
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
577
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (+1 lines)
Lines 17-22 Link Here
17
[% IF ( facets_loo.type_label_Series ) %]Series[% END %]
17
[% IF ( facets_loo.type_label_Series ) %]Series[% END %]
18
[% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %]
18
[% IF ( facets_loo.type_label_ItemTypes ) %]Item types[% END %]
19
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
19
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% 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/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 ) %]
22
        [% 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 ) %]
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>
23
        <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 18-23 Link Here
18
[% UNLESS ( singleBranchMode ) %]
18
[% UNLESS ( singleBranchMode ) %]
19
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
19
[% IF ( facets_loo.type_label_Libraries ) %]Libraries[% END %]
20
[% END %]
20
[% END %]
21
[% IF ( facets_loo.type_label_Location ) %]Locations[% END %]
21
<ul>
22
<ul>
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 ) %]
23
        [% 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 ) %]
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>
24
        <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 487-493 elsif (C4::Context->preference('NoZebra')) { Link Here
487
    $pasarParams .= '&amp;simple_query=' . $simple_query;
487
    $pasarParams .= '&amp;simple_query=' . $simple_query;
488
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
488
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
489
    eval {
489
    eval {
490
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
490
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan,1);
491
    };
491
    };
492
}
492
}
493
# This sorts the facets into alphabetical order
493
# This sorts the facets into alphabetical order
494
- 

Return to bug 7401