Skip to content

Commit

Permalink
Bug 8377: Followup move style in a css file and do not pass template …
Browse files Browse the repository at this point in the history
…to a pm

1/ It's better to set style of the video marked in a css file.

2/ Replace some
  for my $i in (0..#$array)
with
  for my $element in (@array)

3/ the routine in a pm returns a hash not the $template variable

Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
  • Loading branch information
joubu authored and jcamins committed Dec 27, 2012
1 parent 33aa6ec commit 4dbcd07
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
35 changes: 16 additions & 19 deletions C4/HTML5Media.pm
Expand Up @@ -36,13 +36,12 @@ This module gets the relevant data from field 856 (MARC21/UNIMARC) to create a H

=head2 gethtml5media
Get all relevant data from field 856. Takes $template and $record in the subroutine call, sets appropriate params.
Get all relevant data from field 856. Takes a $record in the subroutine call, sets appropriate params.
=cut

sub gethtml5media {
my $self = shift;
my $template = shift;
my $record = shift;
my @HTML5Media_sets = ();
my @HTML5Media_fields = $record->field(856);
Expand Down Expand Up @@ -189,38 +188,36 @@ sub gethtml5media {
}
}
# parent element
for my $i ( 0 .. $#HTML5Media_sets ) {
if ( ($HTML5Media_sets[$i]{mime}) && ($HTML5Media_sets[$i]{mime} =~ /audio/) ) {
for my $media ( @HTML5Media_sets ) {
if ( ($media->{mime}) && ($media->{mime} =~ /audio/) ) {
if ( $HTML5MediaParent ne 'video' ) {
$HTML5MediaParent = 'audio';
$HTML5MediaWidth = '';
}
}
elsif ( ($HTML5Media_sets[$i]{mime}) && ($HTML5Media_sets[$i]{mime} =~ /video/) ) {
elsif ( ($media->{mime}) && ($media->{mime} =~ /video/) ) {
$HTML5MediaParent = 'video';
$HTML5MediaWidth = ' width="480"';
}
}
# child element
for my $j ( 0 .. $#HTML5Media_sets ) {
if ( ($HTML5Media_sets[$j]{type}) && ( ($HTML5Media_sets[$j]{type} eq 'video') || ($HTML5Media_sets[$j]{type} eq 'audio') ) ) {
if ( $HTML5Media_sets[$j]{type} eq $HTML5MediaParent ) {
$HTML5Media_sets[$j]{child} = 'source';
for my $media ( @HTML5Media_sets ) {
if ( ($media->{type}) && ( ($media->{type} eq 'video') || ($media->{type} eq 'audio') ) ) {
if ( $media->{type} eq $HTML5MediaParent ) {
$media->{child} = 'source';
}
}
else {
$HTML5Media_sets[$j]{child} = $HTML5Media_sets[$j]{type};
$media->{child} = $media->{type};
}
}
# template parameters
if ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ) {
$template->param(
HTML5MediaEnabled => 1,
HTML5MediaSets => \@HTML5Media_sets,
HTML5MediaParent => $HTML5MediaParent,
HTML5MediaWidth => $HTML5MediaWidth);
}
return $template;

return (
HTML5MediaEnabled => ( (scalar(@HTML5Media_sets) > 0) && ($HTML5MediaParent) ),
HTML5MediaSets => \@HTML5Media_sets,
HTML5MediaParent => $HTML5MediaParent,
HTML5MediaWidth => $HTML5MediaWidth,
);
}

1;
4 changes: 2 additions & 2 deletions catalogue/detail.pl
Expand Up @@ -381,8 +381,8 @@
}

# HTML5 Media
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'staff') || (C4::Context->preference("HTML5MediaEnabled") eq 'both') ) {
$template = C4::HTML5Media->gethtml5media($template,$record);
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
$template->param( C4::HTML5Media->gethtml5media($record));
}


Expand Down
4 changes: 4 additions & 0 deletions koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
Expand Up @@ -2400,3 +2400,7 @@ div.authorizedheading {

/* jQuery UI Accordion */
.ui-accordion-header { font-weight: bold; font-size : 110%; }

video {
width: 480px;
}
Expand Up @@ -591,7 +591,7 @@ function verify_images() {
[% IF ( HTML5MediaEnabled ) %]
<div id="html5media">
<p>
<[% HTML5MediaParent %][% HTML5MediaWidth %] controls preload=none>
<[% HTML5MediaParent %] controls preload=none>
[% FOREACH HTML5MediaSet IN HTML5MediaSets %]
<[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] />
[% END %]
Expand Down
4 changes: 4 additions & 0 deletions koha-tmpl/opac-tmpl/prog/en/css/opac.css
Expand Up @@ -2846,3 +2846,7 @@ body#opac-main #opacmainuserblockmobile {
#patronregistration a {
display: block;
}

video {
width: 480px;
}
2 changes: 1 addition & 1 deletion koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
Expand Up @@ -1062,7 +1062,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () {
[% IF ( HTML5MediaEnabled ) %]
<div id="html5media">
<p>
<[% HTML5MediaParent %][% HTML5MediaWidth %] controls preload=none>
<[% HTML5MediaParent %] controls preload=none>
[% FOREACH HTML5MediaSet IN HTML5MediaSets %]
<[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] />
[% END %]
Expand Down
4 changes: 2 additions & 2 deletions opac/opac-detail.pl
Expand Up @@ -778,8 +778,8 @@ BEGIN
}

# HTML5 Media
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'opac') || (C4::Context->preference("HTML5MediaEnabled") eq 'both') ) {
$template = C4::HTML5Media->gethtml5media($template,$record);
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'opac') ) {
$template->param( C4::HTML5Media->gethtml5media($record));
}

my $syndetics_elements;
Expand Down

0 comments on commit 4dbcd07

Please sign in to comment.