Lines 269-299
sub XSLTParse4Display {
Link Here
|
269 |
my $partsxml = ''; |
269 |
my $partsxml = ''; |
270 |
# possibly insert component records into Detail views |
270 |
# possibly insert component records into Detail views |
271 |
if ($xslsyspref =~ m/Details/) { |
271 |
if ($xslsyspref =~ m/Details/) { |
|
|
272 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
273 |
my $components = $biblio->get_marc_components(300); |
274 |
$variables->{show_analytics_link} = ( scalar @{$components} == 0 ) ? 0 : 1; |
275 |
|
272 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
276 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
273 |
if ( $showcomp eq 'both' || |
277 |
if ( |
274 |
($showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) || |
278 |
$variables->{show_analytics_link} |
275 |
($showcomp eq 'opac' && $xslsyspref =~ m/OPAC/ ) ) { |
279 |
&& ( $showcomp eq 'both' |
276 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
280 |
|| ( $showcomp eq 'staff' && $xslsyspref !~ m/OPAC/ ) |
277 |
my $max_results = 300; |
281 |
|| ( $showcomp eq 'opac' && $xslsyspref =~ m/OPAC/ ) ) |
278 |
|
282 |
) |
279 |
if ( $biblio->get_marc_components($max_results) ) { |
283 |
{ |
280 |
my $search_query = Koha::Util::Search::get_component_part_query($biblionumber); |
284 |
|
281 |
$variables->{ComponentPartQuery} = $search_query; |
285 |
$variables->{show_analytics_link} = 0; |
282 |
|
286 |
|
283 |
my @componentPartRecordXML = ('<componentPartRecords>'); |
287 |
my $search_query = Koha::Util::Search::get_component_part_query($biblionumber); |
284 |
for my $cb ( @{ $biblio->get_marc_components($max_results) } ) { |
288 |
$variables->{ComponentPartQuery} = $search_query; |
285 |
if( ref $cb eq 'MARC::Record'){ |
289 |
|
286 |
$cb = $cb->as_xml_record(); |
290 |
my @componentPartRecordXML = ('<componentPartRecords>'); |
287 |
} else { |
291 |
for my $cb ( @{ $components } ) { |
288 |
$cb = decode('utf8', $cb); |
292 |
if( ref $cb eq 'MARC::Record'){ |
289 |
} |
293 |
$cb = $cb->as_xml_record(); |
290 |
# Remove the xml header |
294 |
} else { |
291 |
$cb =~ s/^<\?xml.*?\?>//; |
295 |
$cb = decode('utf8', $cb); |
292 |
push @componentPartRecordXML,$cb; |
296 |
} |
293 |
} |
297 |
# Remove the xml header |
294 |
push @componentPartRecordXML, '</componentPartRecords>'; |
298 |
$cb =~ s/^<\?xml.*?\?>//; |
295 |
$partsxml = join "\n", @componentPartRecordXML; |
299 |
push @componentPartRecordXML,$cb; |
296 |
} |
300 |
} |
|
|
301 |
push @componentPartRecordXML, '</componentPartRecords>'; |
302 |
$partsxml = join "\n", @componentPartRecordXML; |
297 |
} |
303 |
} |
298 |
} |
304 |
} |
299 |
|
305 |
|