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