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