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

(-)a/C4/XSLT.pm (-1 / +66 lines)
Lines 158-163 sub _get_best_default_xslt_filename { Link Here
158
158
159
sub XSLTParse4Display {
159
sub XSLTParse4Display {
160
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
160
    my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_;
161
162
    my $shouldIPullInComponentPartRecords; #We don't want to pull component part records if they are not needed! Show component part records only for detailed views.
163
161
    my $xslfilename = C4::Context->preference($xslsyspref);
164
    my $xslfilename = C4::Context->preference($xslsyspref);
162
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
165
    if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) {
163
        my $htdocs;
166
        my $htdocs;
Lines 169-174 sub XSLTParse4Display { Link Here
169
            $theme   = C4::Context->preference("template");
172
            $theme   = C4::Context->preference("template");
170
            $xslfile = C4::Context->preference('marcflavour') .
173
            $xslfile = C4::Context->preference('marcflavour') .
171
                       "slim2intranetDetail.xsl";
174
                       "slim2intranetDetail.xsl";
175
            $shouldIPullInComponentPartRecords = 1;
172
        } elsif ($xslsyspref eq "XSLTResultsDisplay") {
176
        } elsif ($xslsyspref eq "XSLTResultsDisplay") {
173
            $htdocs  = C4::Context->config('intrahtdocs');
177
            $htdocs  = C4::Context->config('intrahtdocs');
174
            $theme   = C4::Context->preference("template");
178
            $theme   = C4::Context->preference("template");
Lines 179-184 sub XSLTParse4Display { Link Here
179
            $theme   = C4::Context->preference("opacthemes");
183
            $theme   = C4::Context->preference("opacthemes");
180
            $xslfile = C4::Context->preference('marcflavour') .
184
            $xslfile = C4::Context->preference('marcflavour') .
181
                       "slim2OPACDetail.xsl";
185
                       "slim2OPACDetail.xsl";
186
            $shouldIPullInComponentPartRecords = 1;
182
        } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
187
        } elsif ($xslsyspref eq "OPACXSLTResultsDisplay") {
183
            $htdocs  = C4::Context->config('opachtdocs');
188
            $htdocs  = C4::Context->config('opachtdocs');
184
            $theme   = C4::Context->preference("opacthemes");
189
            $theme   = C4::Context->preference("opacthemes");
Lines 193-200 sub XSLTParse4Display { Link Here
193
        $xslfilename =~ s/\{langcode\}/$lang/;
198
        $xslfilename =~ s/\{langcode\}/$lang/;
194
    }
199
    }
195
200
201
196
    # grab the XML, run it through our stylesheet, push it out to the browser
202
    # grab the XML, run it through our stylesheet, push it out to the browser
197
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
203
    my $record = transformMARCXML4XSLT($biblionumber, $orig_record);
204
    my $f001Data = $record->field('001');
205
    $f001Data = $f001Data->data() if defined $f001Data; #Not all records have the field 001??
206
207
    my $componentPartRecordsXML = '';
208
    $componentPartRecordsXML = _prepareComponentPartRecords($f001Data) if $shouldIPullInComponentPartRecords &&
209
                                                            C4::Context->preference('AddComponentPartRecordsToDetailedViews');;
210
198
    #return $record->as_formatted();
211
    #return $record->as_formatted();
199
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
212
    my $itemsxml  = buildKohaItemsNamespace($biblionumber, $hidden_items);
200
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
213
    my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour'));
Lines 214-220 sub XSLTParse4Display { Link Here
214
        $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n";
227
        $sysxml .= "<syspref name=\"$syspref\">$sp</syspref>\n";
215
    }
228
    }
216
    $sysxml .= "</sysprefs>\n";
229
    $sysxml .= "</sysprefs>\n";
217
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml\<\/record\>/;
230
    $xmlrecord =~ s/\<\/record\>/$itemsxml$sysxml$componentPartRecordsXML\<\/record\>/;
218
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
231
    if ($fixamps) { # We need to correct the ampersand entities that Zebra outputs
219
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
232
        $xmlrecord =~ s/\&amp;amp;/\&amp;/g;
220
    }
233
    }
Lines 313-318 sub buildKohaItemsNamespace { Link Here
313
    return $xml;
326
    return $xml;
314
}
327
}
315
328
329
=head
330
331
  Makes a C4::Search::SimpleSearch() to find all records from the index rcn=Record-control-number matching the given
332
  field 001 value.
333
  Strips some key identifiers from those records.
334
  Builds a XML presentation out of those, ready for the XSLT processing.
335
336
  $componentPartRecordsXML = &_prepareComponentPartRecords($field001Data);
337
338
  In Koha the field 001 is not the same as the biblionumber!
339
340
  Returns: a string containing an XML representation of component part records
341
           In XSL: componentPartRecords/componentPart/title
342
           in addition to title, elements can also be subtitle, biblionumber, author, publishercode, publicationyear
343
           eg. componentPartRecords/componentPart/biblionumber
344
345
=cut
346
sub _prepareComponentPartRecords {
347
348
    my $field001Data = shift;
349
    my $componentPartRecordsXML;
350
    my ($error, $componentPartRecordISOs, $resultSetSize) = C4::Search::SimpleSearch("rcn=$field001Data");
351
352
    if ($resultSetSize && !$error) {
353
354
        #Collect the XML elements to a array instead of continuously concatenating a string.
355
        #  There might be dozens of component part records and in such a case string concatenation is extremely slow.
356
        my @componentPartRecordXML = ('<componentPartRecords>'); #@@componentPartRecordXML vs $componentPartRecordsXML is a nice Perl curiosity!
357
        for my $cr ( @{$componentPartRecordISOs} ) {
358
            push @componentPartRecordXML, '  <componentPart>';
359
            my $marcrecord = MARC::File::USMARC::decode($cr);
360
            my $componentPartBiblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,q{});
361
362
            push @componentPartRecordXML, "    <title>$componentPartBiblio->{'title'}</title>"                               if $componentPartBiblio->{'title'};
363
            push @componentPartRecordXML, "    <subtitle>$componentPartBiblio->{'subtitle'}</subtitle>"                      if $componentPartBiblio->{'subtitle'};
364
            push @componentPartRecordXML, "    <biblionumber>$componentPartBiblio->{'biblionumber'}</biblionumber>"          if $componentPartBiblio->{'biblionumber'};
365
            push @componentPartRecordXML, "    <author>$componentPartBiblio->{'author'}</author>"                            if $componentPartBiblio->{'author'};
366
            push @componentPartRecordXML, "    <publishercode>$componentPartBiblio->{'publishercode'}</publishercode>"       if $componentPartBiblio->{'publishercode'};
367
            push @componentPartRecordXML, "    <publicationyear>$componentPartBiblio->{'publicationyear'}</publicationyear>" if $componentPartBiblio->{'publicationyear'};
368
369
            push @componentPartRecordXML, '  </componentPart>';
370
        }
371
        push @componentPartRecordXML, '</componentPartRecords>';
372
        push @componentPartRecordXML, ''; #Just to make the join operation end with a newline
373
374
        #Build the real XML string.
375
        $componentPartRecordsXML = join "\n", @componentPartRecordXML;
376
377
        return $componentPartRecordsXML;
378
    }
379
    return ''; #Instantiate this string so we don't get undefined errors when concatenating with this.
380
}
316
381
317
382
318
1;
383
1;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 4-9 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
4
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
4
('AcquisitionDetails', '1', '', 'Hide/Show acquisition details on the biblio detail page.', 'YesNo'),
5
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
5
('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: his own only, any within his branch or all','Choice'),
6
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
6
('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'),
7
('AddComponentPartRecordsToDetailedViews','1',NULL,'Show component part records in the detailed views.','YesNo'),
7
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
8
('AddPatronLists','categorycode','categorycode|category_type','Allow user to choose what list to pick up from when adding patrons','Choice'),
8
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
9
('advancedMARCeditor','0','','If ON, the MARC editor won\'t display field/subfield descriptions','YesNo'),
9
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
10
('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 8074-8079 if ( CheckVersion($DBversion) ) { Link Here
8074
    SetVersion($DBversion);
8074
    SetVersion($DBversion);
8075
}
8075
}
8076
8076
8077
$DBversion = "3.15.00.XXX";
8078
if (CheckVersion($DBversion)) {
8079
    $dbh->do("INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
8080
        ('AddComponentPartRecordsToDetailedViews','1',NULL,'Show component part records in the detailed views.','YesNo');");
8081
    print "Upgrade to $DBversion done (Bug 11175: Show the parent record's component parts in the detailed views.)\n";
8082
    SetVersion($DBversion);
8083
}
8084
8077
=head1 FUNCTIONS
8085
=head1 FUNCTIONS
8078
8086
8079
=head2 TableExists($table)
8087
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (-1 / +8 lines)
Lines 161-166 Cataloging: Link Here
161
              class: short
161
              class: short
162
            - (Leave blank if not used. Define a range like <code>192.168.</code>.)
162
            - (Leave blank if not used. Define a range like <code>192.168.</code>.)
163
        -
163
        -
164
            - "Requires XSLTDetailsDisplay and/or OPACXSLTDetailsDisplay system preferences to be active. Works on MARC21. "
165
            - pref: AddComponentPartRecordsToDetailedViews
166
              choices:
167
                  yes: Show
168
                  no: "Don't show"
169
            - "component part records in the detailed views. This might cause a performance penalty for records with lots of component part records."
170
            - "Technical explanation: This enables appending component part records to the bibliographic record data for the XSLT parsing. Component parts need to be indexed in the rcn-index, in which many by default are."
171
        -
164
            - pref: SeparateHoldings
172
            - pref: SeparateHoldings
165
              choices:
173
              choices:
166
                  yes: Separate
174
                  yes: Separate
167
- 

Return to bug 11175