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 / +33 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 714-727 sub getFacets { Link Here
714
                tags  => [ qw/ 225a / ],
714
                tags  => [ qw/ 225a / ],
715
                sep   => ', ',
715
                sep   => ', ',
716
            },
716
            },
717
        ];
717
            ];
718
        my $library_facet = {
718
719
            idx   => 'branch',
719
            my $library_facet;
720
            label => 'Libraries',
720
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
721
            tags  => [ qw/ 995b / ],
721
                $library_facet = {
722
            expanded => '1',
722
                    idx  => 'branch',
723
        };
723
                    label => 'Libraries',
724
        push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
724
                    tags        => [ qw/ 995b / ],
725
                };
726
            } else {
727
                $library_facet = {
728
                    idx  => 'location',
729
                    label => 'Location',
730
                    tags        => [ qw/ 995c / ],
731
                };
732
            }
733
            push( @$facets, $library_facet );
725
    }
734
    }
726
    else {
735
    else {
727
        $facets = [
736
        $facets = [
Lines 768-782 sub getFacets { Link Here
768
                sep   => ', ',
777
                sep   => ', ',
769
            },
778
            },
770
            ];
779
            ];
780
771
            my $library_facet;
781
            my $library_facet;
772
            $library_facet = {
782
            unless ( C4::Context->preference("singleBranchMode") || GetBranchesCount() == 1 ) {
773
                idx   => 'branch',
783
                $library_facet = {
774
                label => 'Libraries',
784
                    idx  => 'branch',
775
                tags  => [ qw/ 952b / ],
785
                    label => 'Libraries',
776
                sep   => ', ',
786
                    tags        => [ qw / 952b / ],
777
                expanded    => '1',
787
                };
778
            };
788
            } else {
779
            push @$facets, $library_facet unless C4::Context->preference("singleBranchMode");
789
                $library_facet = {
790
                    idx => 'location',
791
                    label => 'Location',
792
                    tags => [ qw / 952c / ],
793
                };
794
            }
795
            push( @$facets, $library_facet );
780
    }
796
    }
781
    return $facets;
797
    return $facets;
782
}
798
}
(-)a/C4/Search.pm (-3 / +8 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
        $itemtypes,        $query_type,   $scan,           $opac
306
    ) = @_;
306
    ) = @_;
307
307
308
    my @servers = @$servers_ref;
308
    my @servers = @$servers_ref;
Lines 568-573 sub getRecords { Link Here
568
                                }
568
                                }
569
                            }
569
                            }
570
570
571
                            # also, if it's a location code, use the name instead of the code
572
                            if ( $link_value =~ /location/ ) {
573
                                $facet_label_value = GetKohaAuthorisedValueLib('LOC', $one_facet, $opac);
574
                            }
575
571
                            # but we're down with the whole label being in the link's title.
576
                            # but we're down with the whole label being in the link's title.
572
                            push @this_facets_array, {
577
                            push @this_facets_array, {
573
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
578
                                facet_count       => $facets_counter->{$link_value}->{$one_facet},
Lines 575-581 sub getRecords { Link Here
575
                                facet_title_value => $one_facet,
580
                                facet_title_value => $one_facet,
576
                                facet_link_value  => $facet_link_value,
581
                                facet_link_value  => $facet_link_value,
577
                                type_link_value   => $link_value,
582
                                type_link_value   => $link_value,
578
                            };
583
                            } if ( $facet_label_value );
579
                        }
584
                        }
580
                    }
585
                    }
581
586
(-)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 499-505 elsif (C4::Context->preference('NoZebra')) { Link Here
499
    $pasarParams .= '&amp;simple_query=' . $simple_query;
499
    $pasarParams .= '&amp;simple_query=' . $simple_query;
500
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
500
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
501
    eval {
501
    eval {
502
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
502
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan,1);
503
    };
503
    };
504
}
504
}
505
# This sorts the facets into alphabetical order
505
# This sorts the facets into alphabetical order
506
- 

Return to bug 7401