Browse Source

Feature #2245 enable pdf preview only for browsers with native support

Juan Carlos Raña 13 years ago
parent
commit
5376b9eaed

+ 4 - 1
main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php

@@ -161,7 +161,7 @@
 	define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,jpeg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,ogg,ogx,ogv,oga, aif,aiff,wav,mp3,swf,flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml,mid, midi, svg, svgz');//For Chamilo updated
 		
 	//define viewable valid exts
-	$viewable='gif,bmp,txt,jpg,jpeg,png,tif,html,htm,mp3,wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf,mid,midi,pdf';//updated by Chamilo
+	$viewable='gif,bmp,txt,jpg,jpeg,png,tif,html,htm,mp3,wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf,mid,midi';//updated by Chamilo
 	$viewable_array = explode(" ",$viewable);
 	
 	if (api_browser_support('svg')){				
@@ -173,6 +173,9 @@
 		$viewable_array[]=',oga';
 		$viewable_array[]=',ogv';
 	}
+	if (api_browser_support('pdf')){
+		$viewable_array[]=',pdf';
+	}
 		
 	$viewable = implode(" ",$viewable_array);
 	$viewable = preg_replace('/\s+/', '', $viewable);//clean spaces

+ 30 - 2
main/inc/lib/main_api.lib.php

@@ -4826,6 +4826,7 @@ function api_browser_support($format="") {
     $a_versiontemp = explode('.', $browser->getVersion());
     $current_majorver= $a_versiontemp[0];
 	
+	//native svg support
 	if ($format=='svg'){
 		if (($current_browser == 'Internet Explorer' && $current_majorver > 8) || ($current_browser == 'Firefox' && $current_majorver > 1) || ($current_browser == 'Safari' && $current_majorver >= 4) || ($current_browser == 'Chrome' && $current_majorver >= 1) || ($current_browser == 'Opera' && $current_majorver > 9)) {
 			return true;
@@ -4835,14 +4836,41 @@ function api_browser_support($format="") {
 		}
 	}
 	elseif($format=='ogg'){
-		//native support
-		if (($current_browser == 'Firefox' && $current_majorver >= 3)  || ($current_browser == 'Chrome' && $current_majorver >= 3)) {			
+	//native ogg... support
+		if (($current_browser == 'Firefox' && $current_majorver >= 3)  || ($current_browser == 'Chrome' && $current_majorver >= 3) || ($current_browser == 'Opera' && $current_majorver >= 11)) {			
 			return true;
 		}
 		else {
 			return false;
 		}		
 	}
+	elseif($format=='pdf'){
+		//native pdf support
+		if($current_browser == 'Chrome' && $current_majorver >= 6){
+			return true;
+		}
+		else{
+			return false;
+		}
+	}
+	elseif($format=='wav'){
+		//native wav support
+		if(($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Opera' && $current_majorver >= 11)|| ($current_browser == 'Internet Explorer' && $current_majorver >= 9)){
+			return true;
+		}
+		else{
+			return false;
+		}
+	}
+	elseif($format=='mp3'){
+		//native mp3 support
+		if(($current_browser == 'Firefox' && $current_majorver >= 4) || ($current_browser == 'Safari' && $current_majorver >= 5) || ($current_browser == 'Chrome' && $current_majorver >=6)|| ($current_browser == 'Internet Explorer' && $current_majorver >= 9)){
+			return true;
+		}
+		else{
+			return false;
+		}
+	}	
 	elseif($format=="check_browser"){
 		$array_check_browser=array($current_browser, $current_majorver);		
 		return $array_check_browser;