Bugzilla – Attachment 22612 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 the parent records child records (aka. component parts) in the detailed views.
Bug-11175---Show-the-parent-records-child-records-.patch (text/plain), 12.87 KB, created by
Olli-Antti Kivilahti
on 2013-10-30 18:33:24 UTC
(
hide
)
Description:
Bug 11175 - Show the parent records child records (aka. component parts) in the detailed views.
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2013-10-30 18:33:24 UTC
Size:
12.87 KB
patch
obsolete
>From 4e3ebf8aa25f4cf4f0f03cafab5bac348fe5bed3 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Wed, 30 Oct 2013 20:32:47 +0200 >Subject: [PATCH] Bug 11175 - Show the parent records child records (aka. > component parts) in the detailed views. > >--- > C4/XSLT.pm | 67 +++++++++++++++++++++- > installer/data/mysql/sysprefs.sql | 1 + > .../intranet-tmpl/prog/en/css/staff-global.css | 3 + > .../en/modules/admin/preferences/cataloguing.pref | 7 +++ > .../prog/en/xslt/MARC21slim2intranetDetail.xsl | 29 ++++++++++ > koha-tmpl/opac-tmpl/prog/en/css/opac.css | 3 + > .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 33 ++++++++++- > 7 files changed, 139 insertions(+), 4 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index d85b048..5e4995e 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -158,6 +158,9 @@ sub _get_best_default_xslt_filename { > > sub XSLTParse4Display { > my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; >+ >+ my $shouldIPullChildRecords; #We don't want to pull child records if they are not needed! Show child records only for detailed views. >+ > my $xslfilename = C4::Context->preference($xslsyspref); > if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { > my $htdocs; >@@ -169,6 +172,7 @@ sub XSLTParse4Display { > $theme = C4::Context->preference("template"); > $xslfile = C4::Context->preference('marcflavour') . > "slim2intranetDetail.xsl"; >+ $shouldIPullChildRecords = 1; > } elsif ($xslsyspref eq "XSLTResultsDisplay") { > $htdocs = C4::Context->config('intrahtdocs'); > $theme = C4::Context->preference("template"); >@@ -179,6 +183,7 @@ sub XSLTParse4Display { > $theme = C4::Context->preference("opacthemes"); > $xslfile = C4::Context->preference('marcflavour') . > "slim2OPACDetail.xsl"; >+ $shouldIPullChildRecords = 1; > } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") { > $htdocs = C4::Context->config('opachtdocs'); > $theme = C4::Context->preference("opacthemes"); >@@ -192,9 +197,15 @@ sub XSLTParse4Display { > my $lang = C4::Templates::_current_language(); > $xslfilename =~ s/\{langcode\}/$lang/; > } >+ > > # grab the XML, run it through our stylesheet, push it out to the browser > my $record = transformMARCXML4XSLT($biblionumber, $orig_record); >+ my $f001Data = $record->field('001')->data(); >+ >+ my $childRecordsXML = _prepareChildRecords($f001Data) if $shouldIPullChildRecords && >+ C4::Context->preference('AddChildRecordsToDetailedViews');; >+ > #return $record->as_formatted(); > my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); >@@ -214,7 +225,7 @@ sub XSLTParse4Display { > $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n"; > } > $sysxml .= "</sysprefs>\n"; >- $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/; >+ $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$childRecordsXML\<\/record\>/; > if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs > $xmlrecord =~ s/\&amp;/\&/g; > } >@@ -313,6 +324,60 @@ sub buildKohaItemsNamespace { > return $xml; > } > >+=head >+ >+ Makes a C4::Search::SimpleSearch() to find all records from the index rcn=Record-control-number matching the given >+ field 001 value. >+ Strips some key identifiers from those records. >+ Builds a XML presentation out of those, ready for the XSLT processing. >+ >+ $childRecordsXML = &_prepareChildRecords($field001Data); >+ >+ In Koha the field 001 is not the same as the biblionumber! >+ >+ Returns: a string containing an XML representation of child records >+ In XSL: childRecords/child/title >+ in addition to title, elements can also be subtitle, biblionumber, author, publishercode, publicationyear >+ eg. childRecords/child/biblionumber >+ >+=cut >+sub _prepareChildRecords { >+ >+ my $field001Data = shift; >+ my $childRecordsXML; >+ my ($error, $childRecordISOs, $resultSetSize) = C4::Search::SimpleSearch("rcn=$field001Data"); >+ #TODO my ($error, $childRecordISOs, $resultSetSize) = C4::Search::SimpleSearch("rcn=$biblionumber title-sort-az"); >+ # how the hell do I sort the result set? BTW I cant sort it by title. le fuuu! >+ >+ if ($resultSetSize && !$error) { >+ >+ #Collect the XML elements to a array instead of continuously concatenating a string. >+ # There might be dozens of child records and in such a case string concatenation is extremely slow. >+ my @childRecordsXML = ('<childRecords>'); #@childRecordsXML vs $childRecordsXML is a nice Perl curiosity! >+ for my $cr ( @{$childRecordISOs} ) { >+ push @childRecordsXML, ' <child>'; >+ my $marcrecord = MARC::File::USMARC::decode($cr); >+ my $childBiblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{}); >+ >+ push @childRecordsXML, " <title>$childBiblio->{'title'}</title>" if $childBiblio->{'title'}; >+ push @childRecordsXML, " <subtitle>$childBiblio->{'subtitle'}</subtitle>" if $childBiblio->{'subtitle'}; >+ push @childRecordsXML, " <biblionumber>$childBiblio->{'biblionumber'}</biblionumber>" if $childBiblio->{'biblionumber'}; >+ push @childRecordsXML, " <author>$childBiblio->{'author'}</author>" if $childBiblio->{'author'}; >+ push @childRecordsXML, " <publishercode>$childBiblio->{'publishercode'}</publishercode>" if $childBiblio->{'publishercode'}; >+ push @childRecordsXML, " <publicationyear>$childBiblio->{'publicationyear'}</publicationyear>" if $childBiblio->{'publicationyear'}; >+ >+ push @childRecordsXML, ' </child>'; >+ } >+ push @childRecordsXML, '</childRecords>'; >+ push @childRecordsXML, ''; #Just to make the join operation end with a newline >+ >+ #Build the real XML string. >+ $childRecordsXML = join "\n", @childRecordsXML; >+ >+ return $childRecordsXML; >+ } >+ return ''; #Instantiate this string so we don't get undefined errors when concatenating with this. >+} > > > 1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 71513ce..b439f1c 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -2,6 +2,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('AcqCreateItem','ordering','ordering|receiving|cataloguing','Define when the item is created : when ordering, when receiving, or in cataloguing module','Choice'), > ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'), > ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), >+('AddChildRecordsToDetailedViews','1',NULL,'Show child records in the detailed views.','YesNo'), > ('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'), > ('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'), > ('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index aa7310c..2ad8bab 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -1871,6 +1871,9 @@ span.permissiondesc { > .results_summary a { > font-weight: normal; > } >+.childRecordsContainer { >+ float: right; >+} > > ul.budget_hierarchy { > margin-left: 0px; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index 96f3603..393ba43 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -161,6 +161,13 @@ Cataloging: > class: short > - (Leave blank if not used. Define a range like <code>192.168.</code>.) > - >+ - "Requires XSLTDetailsDisplay and/or OPACXSLTDetailsDisplay system preferences to be active. " >+ - pref: AddChildRecordsToDetailedViews >+ choices: >+ yes: Show >+ no: "Don't show" >+ - child records in the detailed views. This might cause a performance penalty for records with lots of child records. Technical explanation: This enables appending child records to the bibliographic record data for the XSLT parsing. >+ - > - pref: SeparateHoldings > choices: > yes: Separate >diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >index 14ff809..464ce81 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >+++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl >@@ -99,7 +99,36 @@ > </xsl:call-template> > </h1> > </xsl:if> >+ >+ > >+ <!--Child records: Displaying title and author of child records if available. These are floated to right by css. --> >+ <xsl:if test="marc:childRecords/marc:child"> >+ <span class="childRecordsContainer results_summary"> >+ <h5>Child records:</h5> >+ <xsl:for-each select="marc:childRecords/marc:child"> >+ <span class="childRecord"> >+ <xsl:if test="marc:title"> >+ <span class="childRecordTitle"> >+ <a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:biblionumber" /></xsl:attribute> >+ <xsl:value-of select="marc:title" /> >+ </a> >+ </span> >+ </xsl:if> >+ <xsl:if test="marc:author"> >+ - >+ <span class="childRecordAuthor"> >+ <xsl:value-of select="marc:author" /> >+ </span> >+ </xsl:if> >+ </span> >+ <br /> >+ </xsl:for-each> >+ </span> >+ </xsl:if> >+ >+ >+ > <xsl:if test="marc:datafield[@tag=245]"> > <h1> > <xsl:for-each select="marc:datafield[@tag=245]"> >diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >index c2902c1..31bb0d8 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -1144,6 +1144,9 @@ table#marc div.results_summary ul { > table#marc div.results_summary ul li { > display : inline; > } >+.childRecordsContainer { >+ float: right; >+} > > #basketcount { > display : inline; >diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >index c3a846c..8a05eb0 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl >@@ -145,6 +145,33 @@ > </xsl:for-each> > </h1> > </xsl:if> >+ >+ >+ <!--Child records: Displaying title and author of child records if available. These are floated to right by css. --> >+ <xsl:if test="marc:childRecords/marc:child"> >+ <span class="childRecordsContainer results_summary"> >+ <h5>Child records:</h5> >+ <xsl:for-each select="marc:childRecords/marc:child"> >+ <span class="childRecord"> >+ <xsl:if test="marc:title"> >+ <span class="childRecordTitle"> >+ <a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:biblionumber" /></xsl:attribute> >+ <xsl:value-of select="marc:title" /> >+ </a> >+ </span> >+ </xsl:if> >+ <xsl:if test="marc:author"> >+ - >+ <span class="childRecordAuthor"> >+ <xsl:value-of select="marc:author" /> >+ </span> >+ </xsl:if> >+ </span> >+ <br /> >+ </xsl:for-each> >+ </span> >+ </xsl:if> >+ > > <!-- Author Statement: Alternate Graphic Representation (MARC 880) --> > <xsl:if test="$display880"> >@@ -175,8 +202,8 @@ > <xsl:value-of select="$materialTypeLabel"/> > </span> > </xsl:if> >- </xsl:if> >- >+ </xsl:if> >+ > <!--Series: Alternate Graphic Representation (MARC 880) --> > <xsl:if test="$display880"> > <xsl:call-template name="m880Select"> >@@ -982,7 +1009,7 @@ > </xsl:if> > > </xsl:element> >- </xsl:template> >+ </xsl:template><!-- End of marc:record --> > > <xsl:template name="showAuthor"> > <xsl:param name="authorfield" /> >-- >1.8.1.2
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