@@ -, +, @@ records (aka. component parts) in the detailed views. MARC21slim2intranetDetail.xsl and MARC21slim2OPACDetail.xsl -------------------------------------- -------------------------------------- -AddChildRecordsToDetailedViews system preference needs to be activated. -Catalog a bunch of child records for a host record. --Search a record and go to detailed view. --Use the existing functionality "+ New" -> "New Child Record" to catalog child records. ------------------------ ------------------------ -Search for the record you just made and display it in the normal detail.pl -view. -Verify that a list of child records are displayed on the right side of the browser window. ------------------------ ------------------------ -Search for the record you just made and display it in the opac-detail.pl -view. -Verify that a list of child records are displayed on the right side of the browser window. ------------------------ --- C4/XSLT.pm | 68 +++++++++++++++++++- 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 + koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 3 +- .../prog/en/xslt/MARC21slim2OPACDetail.xsl | 33 +++++++++- 8 files changed, 142 insertions(+), 5 deletions(-) --- a/C4/XSLT.pm +++ a/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,16 @@ 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'); + $f001Data = $f001Data->data() if defined $f001Data; #Not all records have the field 001?? + + 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 +226,7 @@ sub XSLTParse4Display { $sysxml .= "$sp\n"; } $sysxml .= "\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 +325,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 = (''); #@childRecordsXML vs $childRecordsXML is a nice Perl curiosity! + for my $cr ( @{$childRecordISOs} ) { + push @childRecordsXML, ' '; + my $marcrecord = MARC::File::USMARC::decode($cr); + my $childBiblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{}); + + push @childRecordsXML, " $childBiblio->{'title'}" if $childBiblio->{'title'}; + push @childRecordsXML, " $childBiblio->{'subtitle'}" if $childBiblio->{'subtitle'}; + push @childRecordsXML, " $childBiblio->{'biblionumber'}" if $childBiblio->{'biblionumber'}; + push @childRecordsXML, " $childBiblio->{'author'}" if $childBiblio->{'author'}; + push @childRecordsXML, " $childBiblio->{'publishercode'}" if $childBiblio->{'publishercode'}; + push @childRecordsXML, " $childBiblio->{'publicationyear'}" if $childBiblio->{'publicationyear'}; + + push @childRecordsXML, ' '; + } + push @childRecordsXML, ''; + 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; --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -3,6 +3,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcqItemSetSubfieldsWhenReceived','0','','This syspref set a status for item when items are created when receiving (e.g. 995\$o=5)','Free'), ('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'), --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ a/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; --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ a/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 192.168..) - + - "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 --- a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl +++ a/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl @@ -99,7 +99,36 @@ + + + + + +
Child records:
+ + + + + /cgi-bin/koha/catalogue/detail.pl?biblionumber= + + + + + + - + + + + + +
+
+
+
+ + +

--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ a/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; --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -528,6 +528,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
+
[%# This prevents overflow from component childrens list from breaking the detail view. %]
@@ -933,7 +934,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% END %]
- +
[%# End of div class="yui-g" %]
    --- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl +++ a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl @@ -145,6 +145,33 @@

+ + + + + +
Child records:
+ + + + + /cgi-bin/koha/opac-detail.pl?biblionumber= + + + + + + - + + + + + +
+
+
+
+ @@ -175,8 +202,8 @@ - - + + @@ -982,7 +1009,7 @@ - + --