From 4dbcd077f61c5ac50e209b31ac0ecdc65268639e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 9 Nov 2012 15:12:59 +0100 Subject: [PATCH] Bug 8377: Followup move style in a css file and do not pass template 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 Signed-off-by: Chris Cormack Signed-off-by: Jonathan Druart Signed-off-by: Jared Camins-Esakov --- C4/HTML5Media.pm | 35 +++++++++---------- catalogue/detail.pl | 4 +-- .../prog/en/css/staff-global.css | 4 +++ .../prog/en/modules/catalogue/detail.tt | 2 +- koha-tmpl/opac-tmpl/prog/en/css/opac.css | 4 +++ .../opac-tmpl/prog/en/modules/opac-detail.tt | 2 +- opac/opac-detail.pl | 4 +-- 7 files changed, 30 insertions(+), 25 deletions(-) diff --git a/C4/HTML5Media.pm b/C4/HTML5Media.pm index aff71927c3..89620d3a7c 100644 --- a/C4/HTML5Media.pm +++ b/C4/HTML5Media.pm @@ -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); @@ -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; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 65866b818b..93797048ba 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -381,8 +381,8 @@ if ( C4::Context->preference("LocalCoverImages") == 1 ) { } # 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)); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 28d53f42cf..349a65db54 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -2400,3 +2400,7 @@ div.authorizedheading { /* jQuery UI Accordion */ .ui-accordion-header { font-weight: bold; font-size : 110%; } + +video { + width: 480px; +} diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index fc9d6e17bd..cc68bfe14d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -591,7 +591,7 @@ function verify_images() { [% IF ( HTML5MediaEnabled ) %]

- <[% HTML5MediaParent %][% HTML5MediaWidth %] controls preload=none> + <[% HTML5MediaParent %] controls preload=none> [% FOREACH HTML5MediaSet IN HTML5MediaSets %] <[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] /> [% END %] diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css index d14ea508fb..3149784c95 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -2846,3 +2846,7 @@ body#opac-main #opacmainuserblockmobile { #patronregistration a { display: block; } + +video { + width: 480px; +} diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt index 3ef2470367..fa5ec3d058 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt @@ -1062,7 +1062,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { [% IF ( HTML5MediaEnabled ) %]

- <[% HTML5MediaParent %][% HTML5MediaWidth %] controls preload=none> + <[% HTML5MediaParent %] controls preload=none> [% FOREACH HTML5MediaSet IN HTML5MediaSets %] <[% HTML5MediaSet.child %] src="[% HTML5MediaSet.srcblock %]"[% HTML5MediaSet.typeblock %] /> [% END %] diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 0fe44f5dc7..22c922b02c 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -778,8 +778,8 @@ if (C4::Context->preference("OPACLocalCoverImages")){ } # 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; -- 2.39.5