Lines 36-48
This module gets the relevant data from field 856 (MARC21/UNIMARC) to create a H
Link Here
|
36 |
|
36 |
|
37 |
=head2 gethtml5media |
37 |
=head2 gethtml5media |
38 |
|
38 |
|
39 |
Get all relevant data from field 856. Takes $template and $record in the subroutine call, sets appropriate params. |
39 |
Get all relevant data from field 856. Takes a $record in the subroutine call, sets appropriate params. |
40 |
|
40 |
|
41 |
=cut |
41 |
=cut |
42 |
|
42 |
|
43 |
sub gethtml5media { |
43 |
sub gethtml5media { |
44 |
my $self = shift; |
44 |
my $self = shift; |
45 |
my $template = shift; |
|
|
46 |
my $record = shift; |
45 |
my $record = shift; |
47 |
my @HTML5Media_sets = (); |
46 |
my @HTML5Media_sets = (); |
48 |
my @HTML5Media_fields = $record->field(856); |
47 |
my @HTML5Media_fields = $record->field(856); |
Lines 189-226
sub gethtml5media {
Link Here
|
189 |
} |
188 |
} |
190 |
} |
189 |
} |
191 |
# parent element |
190 |
# parent element |
192 |
for my $i ( 0 .. $#HTML5Media_sets ) { |
191 |
for my $media ( @HTML5Media_sets ) { |
193 |
if ( ($HTML5Media_sets[$i]{mime}) && ($HTML5Media_sets[$i]{mime} =~ /audio/) ) { |
192 |
if ( ($media->{mime}) && ($media->{mime} =~ /audio/) ) { |
194 |
if ( $HTML5MediaParent ne 'video' ) { |
193 |
if ( $HTML5MediaParent ne 'video' ) { |
195 |
$HTML5MediaParent = 'audio'; |
194 |
$HTML5MediaParent = 'audio'; |
196 |
$HTML5MediaWidth = ''; |
195 |
$HTML5MediaWidth = ''; |
197 |
} |
196 |
} |
198 |
} |
197 |
} |
199 |
elsif ( ($HTML5Media_sets[$i]{mime}) && ($HTML5Media_sets[$i]{mime} =~ /video/) ) { |
198 |
elsif ( ($media->{mime}) && ($media->{mime} =~ /video/) ) { |
200 |
$HTML5MediaParent = 'video'; |
199 |
$HTML5MediaParent = 'video'; |
201 |
$HTML5MediaWidth = ' width="480"'; |
200 |
$HTML5MediaWidth = ' width="480"'; |
202 |
} |
201 |
} |
203 |
} |
202 |
} |
204 |
# child element |
203 |
# child element |
205 |
for my $j ( 0 .. $#HTML5Media_sets ) { |
204 |
for my $media ( @HTML5Media_sets ) { |
206 |
if ( ($HTML5Media_sets[$j]{type}) && ( ($HTML5Media_sets[$j]{type} eq 'video') || ($HTML5Media_sets[$j]{type} eq 'audio') ) ) { |
205 |
if ( ($media->{type}) && ( ($media->{type} eq 'video') || ($media->{type} eq 'audio') ) ) { |
207 |
if ( $HTML5Media_sets[$j]{type} eq $HTML5MediaParent ) { |
206 |
if ( $media->{type} eq $HTML5MediaParent ) { |
208 |
$HTML5Media_sets[$j]{child} = 'source'; |
207 |
$media->{child} = 'source'; |
209 |
} |
208 |
} |
210 |
} |
209 |
} |
211 |
else { |
210 |
else { |
212 |
$HTML5Media_sets[$j]{child} = $HTML5Media_sets[$j]{type}; |
211 |
$media->{child} = $media->{type}; |
213 |
} |
212 |
} |
214 |
} |
213 |
} |
215 |
# template parameters |
214 |
|
216 |
if ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ) { |
215 |
return ( |
217 |
$template->param( |
216 |
HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ), |
218 |
HTML5MediaEnabled => 1, |
217 |
HTML5MediaSets => \@HTML5Media_sets, |
219 |
HTML5MediaSets => \@HTML5Media_sets, |
218 |
HTML5MediaParent => $HTML5MediaParent, |
220 |
HTML5MediaParent => $HTML5MediaParent, |
219 |
HTML5MediaWidth => $HTML5MediaWidth, |
221 |
HTML5MediaWidth => $HTML5MediaWidth); |
220 |
); |
222 |
} |
|
|
223 |
return $template; |
224 |
} |
221 |
} |
225 |
|
222 |
|
226 |
1; |
223 |
1; |