Browse Source

Fixing mayuscule MP3 bug in documents #3593

Julio Montoya 13 years ago
parent
commit
1e52cdb5c0
2 changed files with 19 additions and 26 deletions
  1. 12 12
      main/document/document.inc.php
  2. 7 14
      main/document/document.php

+ 12 - 12
main/document/document.inc.php

@@ -237,15 +237,15 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
         //target="'.$target.'"
         if ($filetype == 'file') {
             //Sound preview with jplayer
-			if ( preg_match('/mp3$/',  urldecode($url))  ||
-			     preg_match('/wav$/',  urldecode($url))  ||
-			     preg_match('/ogg$/',  urldecode($url))) {			         
+			if ( preg_match('/mp3$/i',  urldecode($url))  ||
+			     preg_match('/wav$/i',  urldecode($url))  ||
+			     preg_match('/ogg$/i',  urldecode($url))) {			         
 			     return '<span style="float:left" '.$visibility_class.' style="float:left">'.$title.'</span>'.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
             } elseif (
                 //Show preview sith yoxview
-                 preg_match('/swf$/',  urldecode($url))  || 
-			     preg_match('/html$/', urldecode($url))  || 
-			     preg_match('/htm$/',  urldecode($url))  //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
+                 preg_match('/swf$/i',  urldecode($url))  || 
+			     preg_match('/html$/i', urldecode($url))  || 
+			     preg_match('/htm$/i',  urldecode($url))  //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
             ) {
 				$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
 				return '<a href="'.$url.'" class="yoxview" title="'.$tooltip_title_alt.'" target="yoxview" style="float:left" '.$visibility_class.' style="float:left">'.$title.'</a>'.$force_download_html.$copy_to_myfiles.$open_in_new_window_link.$pdf_icon;
@@ -262,16 +262,16 @@ function create_document_link($document_data, $show_as_icon = false, $counter =
         if (preg_match('/shared_folder/', urldecode($url)) && preg_match('/shared_folder$/', urldecode($url))==false && preg_match('/shared_folder_session_'.$current_session_id.'$/', urldecode($url))==false){
 			if ($filetype == 'file') {
                 //Sound preview with jplayer
-                if ( preg_match('/mp3$/',  urldecode($url))  ||
-                     preg_match('/wav$/',  urldecode($url))  ||
-                     preg_match('/ogg$/',  urldecode($url))) {                   
+                if ( preg_match('/mp3$/i',  urldecode($url))  ||
+                     preg_match('/wav$/i',  urldecode($url))  ||
+                     preg_match('/ogg$/i',  urldecode($url))) {                   
                      $sound_preview = DocumentManager::generate_mp3_preview($counter);
                      return $sound_preview ;
                 } elseif (
                     //Show preview sith yoxview
-                     preg_match('/swf$/',  urldecode($url))  || 
-                     preg_match('/html$/', urldecode($url))  || 
-                     preg_match('/htm$/',  urldecode($url))  //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
+                     preg_match('/swf$/i',  urldecode($url))  || 
+                     preg_match('/html$/i', urldecode($url))  || 
+                     preg_match('/htm$/i',  urldecode($url))  //|| (preg_match('/wav$/', urldecode($url)) && api_get_setting('enable_nanogong') == 'true')
                 ) {
 					$url = 'showinframesmin.php?'.api_get_cidreq().'&id='.$document_data['id'].$req_gid;
 					return '<a href="'.$url.'" class="yoxview" title="'.$tooltip_title_alt.'" target="yoxview"'.$visibility_class.' style="float:left">'.build_document_icon_tag($filetype, $path).Display::return_icon('shared.png', get_lang('ResourceShared'), array('hspace' => '5', 'align' => 'middle', 'height' => 22, 'width' => 22)).'</a>';

+ 7 - 14
main/document/document.php

@@ -254,7 +254,6 @@ if ($current_session_id == 0) {
     }
 }
 
-
 /*	MAIN SECTION */
 
 if (isset($_GET['action']) && $_GET['action'] == 'download') {
@@ -371,7 +370,6 @@ if (isset($_GET['createdir'])) {
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateDir'));
 }
 
-
 //jquery thickbox already called from main/inc/header.inc.php
 
 $htmlHeadXtra[] = api_get_jquery_js();
@@ -395,21 +393,23 @@ $docs_and_folders = DocumentManager::get_all_document_data($_course, $curdirpath
 
 $file_list = $format_list = '';
 $count = 1;
+
 if (!empty($docs_and_folders))
 foreach ($docs_and_folders  as $file) {    
     if ($file['filetype'] == 'file') {
-        $path_info = pathinfo($file['path']);   
+        $path_info = pathinfo($file['path']);  
+        $extension = strtolower($path_info['extension']);
         //@todo use a js loop to autogenerate this code
-        if (in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) {
+        if (in_array($extension, array('ogg', 'mp3', 'wav'))) {
             $document_data = DocumentManager::get_document_data_by_id($file['id'], api_get_course_id());
             
-            if ($path_info['extension'] == 'ogg') {
-                $path_info['extension'] = 'oga';
+            if ($extension == 'ogg') {
+                $extension = 'oga';
             }            
             $jquery .= ' $("#jquery_jplayer_'.$count.'").jPlayer({                                
                                 ready: function() {                    
                                     $(this).jPlayer("setMedia", {                                        
-                                        '.$path_info['extension'].' : "'.$document_data['direct_url'].'"                                                                                  
+                                        '.$extension.' : "'.$document_data['direct_url'].'"                                                                                  
                                     });
                                 },                                
                                 swfPath: "'.$js_path.'jquery-jplayer",
@@ -421,7 +421,6 @@ foreach ($docs_and_folders  as $file) {
         }        
     }
 }
-
  
 $htmlHeadXtra[] = '<script type="text/javascript">
 $(document).ready( function() {    
@@ -441,17 +440,11 @@ $(document).ready( function() {
             $(".actions:eq("+i+")").hide();
         }
     }
-
 });
 </script>';
 
-
-
 Display::display_header('','Doc');
-?>
 
-  
-<?php 
 // Lib for event log, stats & tracking & record of the access
 event_access_tool(TOOL_DOCUMENT);