Lines 284-314
sub XSLTParse4Display {
Link Here
|
284 |
my $partsxml = ''; |
284 |
my $partsxml = ''; |
285 |
# possibly insert component records into Detail views |
285 |
# possibly insert component records into Detail views |
286 |
if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" ) { |
286 |
if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" ) { |
|
|
287 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
288 |
my $components = $biblio->get_marc_components(300); |
289 |
$variables->{show_analytics_link} = ( scalar @{$components} == 0 ) ? 0 : 1; |
290 |
|
287 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
291 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
288 |
if ( $showcomp eq 'both' || |
292 |
if ( |
289 |
($showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) || |
293 |
$variables->{show_analytics_link} |
290 |
($showcomp eq 'opac' && $xslsyspref =~ m/OPAC/ ) ) { |
294 |
&& ( $showcomp eq 'both' |
291 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
295 |
|| ( $showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) |
292 |
my $max_results = 300; |
296 |
|| ( $showcomp eq 'opac' && $xslsyspref =~ m/OPAC/ ) ) |
293 |
|
297 |
) |
294 |
if ( $biblio->get_marc_components($max_results) ) { |
298 |
{ |
295 |
my $search_query = Koha::Util::Search::get_component_part_query($biblionumber); |
299 |
|
296 |
$variables->{ComponentPartQuery} = $search_query; |
300 |
$variables->{show_analytics_link} = 0; |
297 |
|
301 |
|
298 |
my @componentPartRecordXML = ('<componentPartRecords>'); |
302 |
my $search_query = Koha::Util::Search::get_component_part_query($biblionumber); |
299 |
for my $cb ( @{ $biblio->get_marc_components($max_results) } ) { |
303 |
$variables->{ComponentPartQuery} = $search_query; |
300 |
if( ref $cb eq 'MARC::Record'){ |
304 |
|
301 |
$cb = $cb->as_xml_record(); |
305 |
my @componentPartRecordXML = ('<componentPartRecords>'); |
302 |
} else { |
306 |
for my $cb ( @{ $components } ) { |
303 |
$cb = decode('utf8', $cb); |
307 |
if( ref $cb eq 'MARC::Record'){ |
304 |
} |
308 |
$cb = $cb->as_xml_record(); |
305 |
# Remove the xml header |
309 |
} else { |
306 |
$cb =~ s/^<\?xml.*?\?>//; |
310 |
$cb = decode('utf8', $cb); |
307 |
push @componentPartRecordXML,$cb; |
311 |
} |
308 |
} |
312 |
# Remove the xml header |
309 |
push @componentPartRecordXML, '</componentPartRecords>'; |
313 |
$cb =~ s/^<\?xml.*?\?>//; |
310 |
$partsxml = join "\n", @componentPartRecordXML; |
314 |
push @componentPartRecordXML,$cb; |
311 |
} |
315 |
} |
|
|
316 |
push @componentPartRecordXML, '</componentPartRecords>'; |
317 |
$partsxml = join "\n", @componentPartRecordXML; |
312 |
} |
318 |
} |
313 |
} |
319 |
} |
314 |
|
320 |
|