Bug 8377: Followup move style in a css file and do not pass template to a pm
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 9 Nov 2012 14:12:59 +0000 (15:12 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Thu, 27 Dec 2012 14:28:00 +0000 (09:28 -0500)
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>

C4/HTML5Media.pm
catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/opac-tmpl/prog/en/css/opac.css
koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt
opac/opac-detail.pl

index aff7192..89620d3 100644 (file)
@@ -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;
index 65866b8..9379704 100755 (executable)
@@ -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));
 }
 
 
index 28d53f4..349a65d 100644 (file)
@@ -2400,3 +2400,7 @@ div.authorizedheading {
 
 /* jQuery UI Accordion */
 .ui-accordion-header { font-weight: bold; font-size : 110%; }
+
+video {
+    width: 480px;
+}
index fc9d6e1..cc68bfe 100644 (file)
@@ -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 %]
index d14ea50..3149784 100644 (file)
@@ -2846,3 +2846,7 @@ body#opac-main #opacmainuserblockmobile {
 #patronregistration a {
     display: block;
 }
+
+video {
+    width: 480px;
+}
index 3ef2470..fa5ec3d 100644 (file)
@@ -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 %]
index 0fe44f5..22c922b 100755 (executable)
@@ -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;