Bugzilla – Attachment 79687 Details for
Bug 11175
Show the parent record's component parts in the detailed views
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11175: Show record component parts in the detail view
0001-Bug-11175-Show-record-component-parts-in-the-detail-.patch (text/plain), 15.09 KB, created by
paxed
on 2018-10-01 05:28:06 UTC
(
hide
)
Description:
Bug 11175: Show record component parts in the detail view
Filename:
MIME Type:
Creator:
paxed
Created:
2018-10-01 05:28:06 UTC
Size:
15.09 KB
patch
obsolete
>From fc0eb0f35468056157e51517b27b97cdafb8ada4 Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@joensuu.fi> >Date: Mon, 20 Aug 2018 09:51:55 +0300 >Subject: [PATCH] Bug 11175: Show record component parts in the detail view > >Shows the component records of a host on the host intranet detail view, >with clickable links to the component records. >Host has no linking entries to the components, but the components link >to the host record via 773$w. > >Adds a new search index, Control-number-identifier (aka cni), which >indexes the 003 controlfield. > >When looking up the component part records, the code searches for >records with (773$w=Host001 and 003=Host003) or 773$w='Host003 Host001'. > >Does not use easyanalytics. > >Only for MARC21 biblios - MARC21 holdings and UNIMARC indexdefs >haven't been updated. > >Only for the intranet detail page. > >Staff-client.css has not been recreated, so you need to sass that > >Test plan: > >1) perl bulkmarcimport -file /tmp/easypiano.mrc -m MARCXML >2) rebuild the zebra biblio index >3) Search for "easy piano" in staff client, and go to > the biblio detail page. You should see a list of > component part records on the detail page. > >Signed-off-by: Pasi Kallinen <pasi.kallinen@joensuu.fi> >--- > C4/Search.pm | 2 + > C4/XSLT.pm | 19 ++++++- > Koha/Biblio.pm | 41 ++++++++++++++ > Koha/QueryParser/Driver/PQF.pm | 2 + > etc/searchengine/queryparser.yaml | 10 ++++ > etc/zebradb/biblios/etc/bib1.att | 1 + > etc/zebradb/ccl.properties | 3 + > .../marc21/biblios/biblio-koha-indexdefs.xml | 3 + > .../marc21/biblios/biblio-zebra-indexdefs.xsl | 5 ++ > .../intranet-tmpl/prog/css/src/staff-global.scss | 8 +++ > .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 2 + > .../intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl | 66 ++++++++++++++++++++++ > t/QueryParser.t | 2 +- > 13 files changed, 162 insertions(+), 2 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 06e837de03..5f6020cf8a 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1119,6 +1119,8 @@ sub getIndexes{ > 'Conference-name-seealso', > 'Content-type', > 'Control-number', >+ 'Control-number-identifier', >+ 'cni', > 'copydate', > 'Corporate-name', > 'Corporate-name-heading', >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index bf2647ab74..1029a45a47 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -243,7 +243,24 @@ sub XSLTParse4Display { > my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); > >- $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; >+ my $partsxml = ''; >+ # Add component part records only for Detail view >+ if ( $xslsyspref =~ m/Details/ ) { >+ my $biblio = Koha::Biblios->find( $biblionumber ); >+ if ( $biblio->components() ) { >+ my @componentPartRecordXML = ('<componentPartRecords>'); >+ for my $cb ( @{ $biblio->components() } ) { >+ # Remove the xml header >+ $cb =~ s/^<\?xml.*?\?>//; >+ push @componentPartRecordXML, decode('utf8', $cb); >+ } >+ push @componentPartRecordXML, '</componentPartRecords>'; >+ >+ $partsxml = join "\n", @componentPartRecordXML; >+ } >+ } >+ >+ $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$partsxml\<\/record\>/; > if ($fixamps) { # We need to correct the HTML entities that Zebra outputs > $xmlrecord =~ s/\&amp;/\&/g; > $xmlrecord =~ s/\&\;lt\;/\<\;/g; >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 1dca4d9cf6..1c54620354 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -36,6 +36,8 @@ use Koha::IssuingRules; > use Koha::Item::Transfer::Limits; > use Koha::Libraries; > use Koha::Subscriptions; >+use Koha::SearchEngine; >+use Koha::SearchEngine::Search; > > =head1 NAME > >@@ -386,6 +388,45 @@ sub biblioitem { > return $self->{_biblioitem}; > } > >+=head3 components >+ >+my $components = $self->components(); >+ >+Returns an array of MARCXML data, which are component parts of >+this object (MARC21 773$w points to this) >+ >+=cut >+ >+sub components { >+ my ($self) = @_; >+ >+ return undef if (C4::Context->preference('marcflavour') ne 'MARC21'); >+ >+ if (!defined($self->{_components})) { >+ my $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $self->id }); >+ my $pf001 = $marc->field('001') || undef; >+ my $pf003 = $marc->field('003') || undef; >+ >+ my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); >+ >+ if (defined($pf001)) { >+ # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001') >+ my $searchstr = "(rcn='".$pf001->data()."'"; >+ $searchstr .= " and cni='".$pf003->data()."'" if (defined($pf003)); >+ $searchstr .= ")"; >+ $searchstr .= " or rcn='".$pf003->data()." ".$pf001->data()."'" if (defined($pf003)); >+ >+ my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, undef ); >+ >+ $self->{_components} = $results if ( defined($results) && scalar(@$results) ); >+ } else { >+ warn "Record $self->id has no 001"; >+ } >+ } >+ >+ return $self->{_components}; >+} >+ > =head3 subscriptions > > my $subscriptions = $self->subscriptions >diff --git a/Koha/QueryParser/Driver/PQF.pm b/Koha/QueryParser/Driver/PQF.pm >index 8181cd3dd1..3cc277aa90 100644 >--- a/Koha/QueryParser/Driver/PQF.pm >+++ b/Koha/QueryParser/Driver/PQF.pm >@@ -727,6 +727,8 @@ sub TEST_SETUP { > $self->add_search_field_alias( 'keyword' => 'note' => 'nt' ); > $self->add_bib1_field_map('keyword' => 'record-control-number' => 'biblioserver' => { '1' => '1045' } ); > $self->add_search_field_alias( 'keyword' => 'record-control-number' => 'rcn' ); >+ $self->add_bib1_field_map('keyword' => 'control-number-identifier' => 'biblioserver' => { '1' => '9014' } ); >+ $self->add_search_field_alias( 'keyword' => 'control-number-identifier' => 'cni' ); > $self->add_bib1_field_map('subject' => '' => 'biblioserver' => { '1' => '21' } ); > $self->add_search_field_alias( 'subject' => '' => 'su' ); > $self->add_search_field_alias( 'subject' => '' => 'su-to' ); >diff --git a/etc/searchengine/queryparser.yaml b/etc/searchengine/queryparser.yaml >index d9f637bfd3..174c935571 100644 >--- a/etc/searchengine/queryparser.yaml >+++ b/etc/searchengine/queryparser.yaml >@@ -321,6 +321,16 @@ field_mappings: > aliases: > - control-number > label: Control-number >+ control-number-identifier: >+ bib1_mapping: >+ biblioserver: >+ 1: 9014 >+ enabled: 1 >+ index: control-number-identifier >+ aliases: >+ - control-number-identifier >+ - cni >+ label: Control-number-identifier > copynumber: > bib1_mapping: > biblioserver: >diff --git a/etc/zebradb/biblios/etc/bib1.att b/etc/zebradb/biblios/etc/bib1.att >index 7acdc1816b..dc64854226 100644 >--- a/etc/zebradb/biblios/etc/bib1.att >+++ b/etc/zebradb/biblios/etc/bib1.att >@@ -221,6 +221,7 @@ att 9010 cn-suffix > att 9011 Suppress > att 9012 Identifier-other > att 9013 not-onloan-count >+att 9014 Control-number-identifier > > # Items Index > att 8001 withdrawn >diff --git a/etc/zebradb/ccl.properties b/etc/zebradb/ccl.properties >index a1ea690c43..420294a8d8 100644 >--- a/etc/zebradb/ccl.properties >+++ b/etc/zebradb/ccl.properties >@@ -996,6 +996,9 @@ llength 1=llength > Summary 1=Summary > not-onloan-count 1=9013 4=109 > >+Control-number-identifier 1=9014 >+cni Control-number-identifier >+ > ### > # Items Index > withdrawn 1=8001 >diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >index b3b12a0e2b..24e2a1b193 100644 >--- a/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >+++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml >@@ -16,6 +16,9 @@ > <index_control_field tag="001"> > <target_index>Control-number:w</target_index> > </index_control_field> >+ <index_control_field tag="003"> >+ <target_index>Control-number-identifier:w</target_index> >+ </index_control_field> > <!--record.abs line 44: melm 005 Date/time-last-modified--> > <index_control_field tag="005"> > <target_index>Date/time-last-modified:w</target_index> >diff --git a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >index c5fed3e859..2db2c7737b 100644 >--- a/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >+++ b/etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl >@@ -62,6 +62,11 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml) > <xslo:value-of select="."/> > </z:index> > </xslo:template> >+ <xslo:template match="marc:controlfield[@tag='003']"> >+ <z:index name="Control-number-identifier:w"> >+ <xslo:value-of select="."/> >+ </z:index> >+ </xslo:template> > <xslo:template match="marc:controlfield[@tag='005']"> > <z:index name="Date/time-last-modified:w"> > <xslo:value-of select="."/> >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >index 8af60e2809..e72efc1ba0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -707,6 +707,14 @@ ol { > padding: 7px 0; > } > >+.componentPartRecordsContainer { >+ float: right; >+ overflow-y: auto; >+ overflow-x: hidden; >+ max-width: 50%; >+ max-height: 25em; >+} >+ > #editions { > table, > td { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index 9727767dbb..9bc08b9ac6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -110,6 +110,8 @@ > </h1> > </xsl:if> > >+ <xsl:call-template name="showComponentParts"/> >+ > <!--Bug 13381 --> > <xsl:if test="marc:datafield[@tag=245]"> > <h1 class="title" property="name"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >index a3db596e87..4beda2edf3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl >@@ -338,6 +338,72 @@ > </xsl:if> > </xsl:template> > >+ <xsl:template name="showComponentParts"> >+ <!-- Component part records: Displaying title and author of component part records --> >+ <xsl:if test="marc:componentPartRecords"> >+ <div class="results_summary componentPartRecordsContainer"> >+ <h5>Component part records</h5> >+ <ol class="componentParts"> >+ <xsl:for-each select="marc:componentPartRecords/marc:record"> >+ <li> >+ <span class="componentPartRecord"> >+ <span class="componentPartRecordTitle"> >+ <a> >+ <xsl:attribute name="href">/cgi-bin/koha/catalogue/detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']" /></xsl:attribute> >+ <xsl:choose> >+ <xsl:when test="marc:datafield[@tag=245]/marc:subfield[@code='a']"> >+ <xsl:value-of select="substring-before( concat(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/'), '/')" /> >+ </xsl:when> >+ <xsl:when test="marc:datafield[@tag=240]/marc:subfield[@code='a']"> >+ <xsl:for-each select="marc:datafield[@tag=240]"> >+ <xsl:call-template name="chopPunctuation"> >+ <xsl:with-param name="chopString"> >+ <xsl:call-template name="subfieldSelect"> >+ <xsl:with-param name="codes">amnp</xsl:with-param> >+ </xsl:call-template> >+ </xsl:with-param> >+ </xsl:call-template> >+ </xsl:for-each> >+ </xsl:when> >+ <xsl:when test="marc:datafield[@tag=130]/marc:subfield[@code='a']"> >+ <xsl:for-each select="marc:datafield[@tag=130]"> >+ <xsl:call-template name="chopPunctuation"> >+ <xsl:with-param name="chopString"> >+ <xsl:call-template name="subfieldSelect"> >+ <xsl:with-param name="codes">amnp</xsl:with-param> >+ </xsl:call-template> >+ </xsl:with-param> >+ </xsl:call-template> >+ </xsl:for-each> >+ </xsl:when> >+ <xsl:otherwise> >+ <xsl:text>[Record with no title statement]</xsl:text> >+ </xsl:otherwise> >+ </xsl:choose> >+ </a> >+ </span> >+ <xsl:choose> >+ <xsl:when test="marc:datafield[@tag=100]/marc:subfield[@code='a']"> >+ - >+ <span class="componentPartRecordAuthor"> >+ <xsl:value-of select="marc:datafield[@tag=100]/marc:subfield[@code='a']" /> >+ </span> >+ </xsl:when> >+ <xsl:when test="marc:datafield[@tag=110]/marc:subfield[@code='a']"> >+ - >+ <span class="componentPartRecordAuthor"> >+ <xsl:value-of select="marc:datafield[@tag=110]/marc:subfield[@code='a']" /> >+ </span> >+ </xsl:when> >+ </xsl:choose> >+ </span> >+ </li> >+ </xsl:for-each> >+ </ol> >+ </div> >+ </xsl:if> >+ </xsl:template> >+ > </xsl:stylesheet> > > <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp. >diff --git a/t/QueryParser.t b/t/QueryParser.t >index 7b694300bd..a2cd25affb 100644 >--- a/t/QueryParser.t >+++ b/t/QueryParser.t >@@ -17,7 +17,7 @@ ok(defined $QParser, 'Successfully created empty QP object'); > ok($QParser->load_config('./etc/searchengine/queryparser.yaml'), 'Loaded QP config'); > > is($QParser->search_class_count, 4, 'Initialized 4 search classes'); >-is (scalar(@{$QParser->search_fields()->{'keyword'}}), 111, "Correct number of search fields for 'keyword' class"); >+is (scalar(@{$QParser->search_fields()->{'keyword'}}), 112, "Correct number of search fields for 'keyword' class"); > > # Set keyword search as the default > $QParser->default_search_class('keyword'); >-- >2.11.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11175
:
22612
|
22649
|
23049
|
24788
|
24789
|
24790
|
24791
|
26402
|
26403
|
26404
|
26405
|
26766
|
26767
|
78022
|
78023
|
78024
|
79687
|
79803
|
79809
|
79810
|
105631
|
105641
|
105703
|
105706
|
105707
|
106692
|
112838
|
112839
|
112840
|
112841
|
112846
|
112847
|
112851
|
112852
|
112853
|
112854
|
112855
|
112856
|
112857
|
113649
|
113650
|
113962
|
113964
|
114326
|
114327
|
114328
|
114329
|
114330
|
114331
|
114332
|
114333
|
114334
|
116819
|
116820
|
116821
|
116822
|
116823
|
116824
|
116825
|
116826
|
116827
|
116828
|
119499
|
119506
|
120206
|
122707
|
122708
|
122709
|
122710
|
122711
|
122712
|
122713
|
122714
|
122715
|
122716
|
122717
|
122718
|
123081
|
123082
|
123083
|
123084
|
123085
|
123086
|
123087
|
123088
|
123089
|
123090
|
123091
|
123092
|
123093
|
123406
|
123410
|
123508
|
123509
|
123510
|
123511
|
123512
|
123513
|
123514
|
123515
|
123516
|
123517
|
123518
|
123519
|
123520
|
123521
|
123522
|
123523
|
123524
|
123541
|
123542
|
123543
|
123544
|
123545
|
123546
|
123547
|
123548
|
123549
|
123550
|
123551
|
123552
|
123553
|
123554
|
123555
|
123556
|
123557
|
123562
|
123564
|
123569
|
123570
|
123571
|
123572
|
123573
|
123574
|
123582
|
123583
|
123608
|
123609
|
123611
|
123612
|
123613
|
123614
|
123617
|
123618
|
123619
|
123620
|
123621
|
123622
|
123623
|
123624
|
123625
|
123626
|
123627
|
123628
|
123629
|
123630
|
123631
|
123632
|
123633
|
123634
|
123635
|
123636
|
123637
|
123638
|
123736
|
123737
|
123738
|
123739
|
123740
|
123741
|
123742
|
123743
|
123744
|
123745
|
123746
|
123747
|
123748
|
123749
|
123750
|
123751
|
123752
|
123753
|
123754
|
123755
|
123756
|
124134
|
124135
|
124136
|
124137
|
124138
|
124139
|
124140
|
124141
|
124142
|
124143
|
124144
|
124145
|
124146
|
124147
|
124148
|
124149
|
124150
|
124151
|
124152
|
124153
|
124154
|
124155
|
124382
|
124383
|
124384
|
124385
|
124386
|
124387
|
124388
|
124389
|
124390
|
124391
|
124392
|
124393
|
124394
|
124395
|
124396
|
124397
|
124398
|
124399
|
124400
|
124401
|
124402
|
124403
|
124404
|
124534
|
124535
|
124536
|
124537
|
124538
|
124539
|
124540
|
124541
|
124542
|
124544
|
124545
|
124546
|
124547
|
124548
|
124549
|
124550
|
124551
|
124552
|
124553
|
124554
|
124555
|
124556
|
124557
|
126057
|
126058
|
126059
|
126060
|
126061
|
126062
|
126063
|
126064
|
126065
|
126066
|
126067
|
126068
|
126069
|
126070
|
126071
|
126072
|
126073
|
126074
|
126075
|
126076
|
126077
|
126078
|
126079
|
126080
|
126081
|
126084
|
126441
|
126442
|
126443
|
126687
|
126688
|
126689
|
126690
|
126692
|
126693
|
126694
|
126695
|
126696
|
126697
|
126698
|
126699
|
126700
|
126701
|
126702
|
126703
|
126704
|
126705
|
126706
|
126707
|
126708
|
126709
|
126710
|
126711
|
126712
|
126713
|
126714
|
126715
|
126716
|
126717
|
126718
|
126719
|
126720
|
126721
|
126722
|
126723
|
126724
|
126725
|
126726
|
126727
|
126728
|
126729
|
126730
|
126731
|
126732
|
126733
|
126734
|
126735
|
126736
|
126737
|
126738
|
126739
|
126740
|
126741
|
126742
|
126743
|
126744
|
126745
|
126816
|
126817
|
126869
|
126870
|
126871
|
126872
|
126873
|
126874
|
126875
|
126876
|
126877
|
126878
|
126879
|
126880
|
126881
|
126882
|
126883
|
126884
|
126885
|
126886
|
126887
|
126888
|
126889
|
126890
|
126891
|
126892
|
126893
|
126894
|
126895
|
126897
|
126898
|
126904
|
126911
|
126912
|
126913