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

(-)a/C4/Languages.pm (+14 lines)
Lines 612-617 sub getlanguage { Link Here
612
    return $language;
612
    return $language;
613
}
613
}
614
614
615
=head2 get_rfc4646_from_iso639
616
617
    Select a language rfc4646 code given an iso639 code
618
619
=cut
620
621
sub get_rfc4646_from_iso639 {
622
623
    my $iso_code = shift;
624
    my $rfc_subtag = Koha::Database->new()->schema->resultset('LanguageRfc4646ToIso639')->find({iso639_2_code=>$iso_code})->rfc4646_subtag;
625
    return $rfc_subtag;
626
627
}
628
615
1;
629
1;
616
630
617
__END__
631
__END__
(-)a/Koha/SearchEngine/Elasticsearch.pm (+16 lines)
Lines 479-484 sub process_error { Link Here
479
    return "Unable to perform your search. Please try again.\n";
479
    return "Unable to perform your search. Please try again.\n";
480
}
480
}
481
481
482
sub get_facetable_fields {
483
    my ($self) = @_;
484
485
    # These should correspond to the ES field names, as opposed to the CCL
486
    # things that zebra uses.
487
    my @search_field_names = qw( author itype location su-geo se subject ccode holdingbranch homebranch ln);
488
    my @faceted_fields = Koha::SearchFields->search(
489
        { name => { -in => \@search_field_names }, facet_order => { '!=' => undef } }, { order_by => ['facet_order'] }
490
    );
491
    my @not_faceted_fields = Koha::SearchFields->search(
492
        { name => { -in => \@search_field_names }, facet_order => undef }, { order_by => ['facet_order'] }
493
    );
494
    # This could certainly be improved
495
    return ( @faceted_fields, @not_faceted_fields );
496
}
497
482
1;
498
1;
483
499
484
__END__
500
__END__
(-)a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm (+1 lines)
Lines 119-124 sub build_query { Link Here
119
        'su-geo' => { terms => { field => "su-geo__facet" } },
119
        'su-geo' => { terms => { field => "su-geo__facet" } },
120
        se       => { terms => { field => "se__facet" } },
120
        se       => { terms => { field => "se__facet" } },
121
        ccode    => { terms => { field => "ccode__facet" } },
121
        ccode    => { terms => { field => "ccode__facet" } },
122
        ln       => { terms => { field => "ln__facet" } },
122
    };
123
    };
123
124
124
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
125
    my $display_library_facets = C4::Context->preference('DisplayLibraryFacets');
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-8 / +9 lines)
Lines 425-439 sub _convert_facets { Link Here
425
    # things that zebra uses.
425
    # things that zebra uses.
426
    # TODO let the library define the order using the interface.
426
    # TODO let the library define the order using the interface.
427
    my %type_to_label = (
427
    my %type_to_label = (
428
        author   => { order => 1, label => 'Authors', },
428
        author        => { order => 1, label => 'Authors', },
429
        itype    => { order => 2, label => 'ItemTypes', },
429
        itype         => { order => 2, label => 'ItemTypes', },
430
        location => { order => 3, label => 'Location', },
430
        location      => { order => 3, label => 'Location', },
431
        'su-geo' => { order => 4, label => 'Places', },
431
        'su-geo'      => { order => 4, label => 'Places', },
432
        se       => { order => 5, label => 'Series', },
432
        se            => { order => 5, label => 'Series', },
433
        subject  => { order => 6, label => 'Topics', },
433
        subject       => { order => 6, label => 'Topics', },
434
        ccode    => { order => 7, label => 'CollectionCodes',},
434
        ccode         => { order => 7, label => 'CollectionCodes',},
435
        holdingbranch => { order => 8, label => 'HoldingLibrary' },
435
        holdingbranch => { order => 8, label => 'HoldingLibrary' },
436
        homebranch => { order => 9, label => 'HomeLibrary' }
436
        homebranch    => { order => 9, label => 'HomeLibrary' },
437
        ln            => { order => 10, label =>  'Language' }
437
    );
438
    );
438
439
439
    # We also have some special cases, e.g. itypes that need to show the
440
    # We also have some special cases, e.g. itypes that need to show the
(-)a/admin/searchengine/elasticsearch/mappings.yaml (-3 / +4 lines)
Lines 1715-1736 biblios: Link Here
1715
  ln:
1715
  ln:
1716
    label: ln
1716
    label: ln
1717
    mappings:
1717
    mappings:
1718
      - facet: ''
1718
      - facet: '1'
1719
        marc_field: 008_/35-37
1719
        marc_field: 008_/35-37
1720
        marc_type: marc21
1720
        marc_type: marc21
1721
        sort: ~
1721
        sort: ~
1722
        suggestible: ''
1722
        suggestible: ''
1723
      - facet: ''
1723
      - facet: '1'
1724
        marc_field: 008_/35-37
1724
        marc_field: 008_/35-37
1725
        marc_type: normarc
1725
        marc_type: normarc
1726
        sort: ~
1726
        sort: ~
1727
        suggestible: ''
1727
        suggestible: ''
1728
      - facet: ''
1728
      - facet: '1'
1729
        marc_field: 101a
1729
        marc_field: 101a
1730
        marc_type: unimarc
1730
        marc_type: unimarc
1731
        sort: ~
1731
        sort: ~
1732
        suggestible: ''
1732
        suggestible: ''
1733
    type: ''
1733
    type: ''
1734
    facet_order: 10
1734
  local-classification:
1735
  local-classification:
1735
    label: local-classification
1736
    label: local-classification
1736
    mappings:
1737
    mappings:
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/facets.inc (-1 / +4 lines)
Lines 1-4 Link Here
1
[% USE AuthorisedValues %]
1
[% USE AuthorisedValues %]
2
[% USE Languages %]
2
[% IF ( opacfacets ) %]
3
[% IF ( opacfacets ) %]
3
[% IF ( facets_loop ) %]
4
[% IF ( facets_loop ) %]
4
<div id="search-facets">
5
<div id="search-facets">
Lines 21-27 Link Here
21
[% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
22
[% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
22
[% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]
23
[% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]
23
[% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
24
[% IF facets_loo.type_label_Location %]<span id="facet-locations">Locations</span>[% END %]
24
[% IF facets_loo.type_label_CollectionCodes %]<span id="facet-locations">Collections</span>[% END %]
25
[% IF facets_loo.type_label_CollectionCodes %]<span id="facet-collections">Collections</span>[% END %]
26
[% IF facets_loo.type_label_Language %]<span id="facet-languages">Languages</span>[% END %]
25
<ul>
27
<ul>
26
  [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
28
  [% SET url = "/cgi-bin/koha/catalogue/search.pl?" _ query_cgi _ limit_cgi %]
27
  [% IF ( sort_by ) %]
29
  [% IF ( sort_by ) %]
Lines 29-34 Link Here
29
  [% END %]
31
  [% END %]
30
  [% FOREACH facet IN facets_loo.facets %]
32
  [% FOREACH facet IN facets_loo.facets %]
31
  [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,0) || facet.facet_label_value %][% END %]
33
  [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,0) || facet.facet_label_value %][% END %]
34
  [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
32
    <li>
35
    <li>
33
      [% IF facet.active %]
36
      [% IF facet.active %]
34
        [% SET local_url = url _ "&amp;nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %]
37
        [% SET local_url = url _ "&amp;nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (+46 lines)
Lines 283-288 a.add, a.delete { Link Here
283
                        </tr>
283
                        </tr>
284
                      </tfoot>
284
                      </tfoot>
285
                    </table>
285
                    </table>
286
287
                    [% IF index.index_name == 'biblios' %]
288
                        <h3>Facet order</h3>
289
                        <div id="facet_[% index.index_name %]">
290
                            <table>
291
                                <thead>
292
                                    <tr>
293
                                        <th>Search field</th>
294
                                        <th>Label</th>
295
                                        <th>Display</th>
296
                                    </tr>
297
                                </thead>
298
                                <tbody>
299
                                    [% FOREACH f IN facetable_fields %]
300
                                        <tr>
301
                                            <td>
302
                                                [% f.name %]
303
                                            </td>
304
                                            <td>
305
                                                [% SWITCH f.name %]
306
                                                [% CASE 'author' %]Authors
307
                                                [% CASE 'itype' %]Item Types
308
                                                [% CASE 'location' %]Locations
309
                                                [% CASE 'su-geo' %]Places
310
                                                [% CASE 'se' %]Series
311
                                                [% CASE 'subject' %]Topics
312
                                                [% CASE 'ccode' %]Collections
313
                                                [% CASE 'holdingbranch' %]Holding libraries
314
                                                [% CASE 'homebranch' %]Home libraries
315
                                                [% CASE 'ln' %]Language
316
                                                [% CASE %][% f %]
317
                                                [% END %]
318
                                            </td>
319
                                            <td>
320
                                                [% IF f.facet_order %]
321
                                                    <input type="checkbox" name="display_facet" value="[% f.name %]" checked="checked" />
322
                                                [% ELSE %]
323
                                                    <input type="checkbox" name="display_facet" value="[% f.name %]" />
324
                                                [% END %]
325
                                            </td>
326
                                        </tr>
327
                                    [% END %]
328
                                </tbody>
329
                            </table>
330
                        </div>
331
                    [% END %]
286
                </div>
332
                </div>
287
            [% END %]
333
            [% END %]
288
        </div>
334
        </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-facets.inc (-1 / +4 lines)
Lines 1-4 Link Here
1
[% USE AuthorisedValues %]
1
[% USE AuthorisedValues %]
2
[% USE Languages %]
2
[% IF ( opacfacets && facets_loop && total ) %]
3
[% IF ( opacfacets && facets_loop && total ) %]
3
    <div id="search-facets">
4
    <div id="search-facets">
4
        <h4><a href="#" class="menu-collapse-toggle">Refine your search</a></h4>
5
        <h4><a href="#" class="menu-collapse-toggle">Refine your search</a></h4>
Lines 25-31 Link Here
25
                        [% IF facets_loo.type_label_Places %]<h5 id="facet-places">Places</h5>[% END %]
26
                        [% IF facets_loo.type_label_Places %]<h5 id="facet-places">Places</h5>[% END %]
26
                        [% IF facets_loo.type_label_Series %]<h5 id="facet-series">Series</h5>[% END %]
27
                        [% IF facets_loo.type_label_Series %]<h5 id="facet-series">Series</h5>[% END %]
27
                        [% IF facets_loo.type_label_ItemTypes %]<h5 id="facet-itemtypes">Item types</h5>[% END %]
28
                        [% IF facets_loo.type_label_ItemTypes %]<h5 id="facet-itemtypes">Item types</h5>[% END %]
28
                        [% IF facets_loo.type_label_CollectionCodes %]<h5 id="facet-itemtypes">Collections</h5>[% END %]
29
                        [% IF facets_loo.type_label_CollectionCodes %]<h5 id="facet-collections">Collections</h5>[% END %]
30
                        [% IF facets_loo.type_label_Language %]<h5 id="facet-languages">Languages</h5>[% END %]
29
                        [% UNLESS singleBranchMode %]
31
                        [% UNLESS singleBranchMode %]
30
                            [% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
32
                            [% IF ( facets_loo.type_label_HomeLibrary ) %]<span id="facet-home-libraries">Home libraries</span>[% END %]
31
                            [% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]
33
                            [% IF ( facets_loo.type_label_HoldingLibrary ) %]<span id="facet-holding-libraries">Holding libraries</span>[% END %]
Lines 38-43 Link Here
38
                            [% END %]
40
                            [% END %]
39
                            [% FOREACH facet IN facets_loo.facets %]
41
                            [% FOREACH facet IN facets_loo.facets %]
40
                            [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %]
42
                            [% IF facets_loo.type_label_CollectionCodes %][% SET facet.facet_label_value = AuthorisedValues.GetByCode('CCODE',facet.facet_label_value,1) || facet.facet_label_value %][% END %]
43
                            [% IF facets_loo.type_label_Language %][% SET facet.facet_label_value = Languages.GetByISOCode(lang,facet.facet_label_value) || facet.facet_label_value %][% END %]
41
                                <li>
44
                                <li>
42
                                  [% IF facet.active %]
45
                                  [% IF facet.active %]
43
                                    [% SET local_url = url _ "&amp;nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %]
46
                                    [% SET local_url = url _ "&amp;nolimit=" _ facet.type_link_value _ ":" _ facet.facet_link_value %]
(-)a/t/db_dependent/Languages.t (-2 / +7 lines)
Lines 6-12 Link Here
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 17;
9
use Test::More tests => 18;
10
use List::Util qw(first);
10
use List::Util qw(first);
11
use Data::Dumper;
11
use Data::Dumper;
12
use Test::Warn;
12
use Test::Warn;
Lines 95-98 my $LangRfc4646 = $sth->fetchall_arrayref({}); Link Here
95
95
96
is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates.");
96
is(scalar(@$LangRfc4646),scalar(@$DistinctLangRfc4646),"No unexpected language_rfc4646_to_iso639 duplicates.");
97
97
98
my $i = 0;
99
foreach my $pair (@$DistinctLangRfc4646){
100
    $i++ if $pair->{rfc4646_subtag} eq C4::Languages::get_rfc4646_from_iso639( $pair->{iso639_2_code} );
101
}
102
is($i,scalar(@$DistinctLangRfc4646),"get_rfc4646_from_iso639 returns correct rfc for all iso values.");
103
98
$dbh->rollback;
104
$dbh->rollback;
99
- 

Return to bug 18213