improve api detect file format support by browser

skala
Juan Carlos Raña 15 years ago
parent 136c75721c
commit 45e24a8891
  1. 2
      main/document/create_drawing.php
  2. 4
      main/document/document.inc.php
  3. 2
      main/document/document.php
  4. 2
      main/document/edit_drawing.php
  5. 25
      main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php
  6. 32
      main/inc/lib/main_api.lib.php
  7. 15
      main/newscorm/resourcelinker.inc.php

@ -132,7 +132,7 @@ echo '<div class="actions">';
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['dir']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
echo '</div>';
if (api_support_svg()){
if (api_browser_support('svg')){
//automatic loading the course language
$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');

@ -125,7 +125,7 @@ function create_document_link($www, $title, $path, $filetype, $size, $visibility
$ext = strtolower($ext[sizeof($ext) - 1]);
// "htmlfiles" are shown in a frameset
if ($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'pdf' || $ext == 'swf' || $ext == 'mp3' || ($ext== 'ogg' || $ext== 'ogx' || $ext== 'oga' || $ext== 'ogv' && api_support_svg()) ||($ext == 'svg' && api_support_svg())) {
if ($ext == 'htm' || $ext == 'html' || $ext == 'gif' || $ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'pdf' || $ext == 'swf' || $ext == 'mp3' || (($ext== 'ogg' || $ext== 'ogx' || $ext== 'oga' || $ext== 'ogv') && api_browser_support('ogg')) ||($ext == 'svg' && api_browser_support('svg'))) {
$url = 'showinframes.php?'.api_get_cidreq().'&amp;file='.$url_path.$req_gid;
} else {
// url-encode for problematic characters (we may not call them dangerous characters...)
@ -300,7 +300,7 @@ function build_edit_icons($curdirpath, $type, $path, $visibility, $id, $is_templ
if ($is_certificate_mode) {
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'&selectcat='.$gradebook_category.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
}else {
if($extension=='svg' && api_support_svg()){
if($extension=='svg' && api_browser_support('svg')){
$modify_icons = '<a href="edit_drawing.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';
}else{
$modify_icons = '<a href="edit_document.php?'.api_get_cidreq().'&curdirpath='.$curdirpath.'&amp;file='.urlencode($path).$req_gid.'"><img src="../img/edit.gif" border="0" title="'.get_lang('Modify').'" alt="" /></a>';

@ -855,7 +855,7 @@ if ($is_allowed_to_edit || $group_member_with_upload_rights || is_my_shared_fold
<?php
// Create new draw
if (api_support_svg()){
if (api_browser_support('svg')){
?>
<a href="create_drawing.php?<?php echo api_get_cidreq(); ?>&dir=<?php echo $curdirpathurl.$req_gid; ?>">
<?php Display::display_icon('draw_new.png', get_lang('Draw')); echo get_lang('Draw'); ?></a>&nbsp;

@ -111,7 +111,7 @@ echo '<div class="actions">';
echo '<a href="document.php?curdirpath='.Security::remove_XSS($_GET['curdirpath']).'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview')).get_lang('BackTo').' '.get_lang('DocumentsOverview').'</a>';
echo '</div>';
if (api_support_svg()){
if (api_browser_support('svg')){
//automatic loading the course language
$svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn');

@ -160,16 +160,29 @@
define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste
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_array = explode(" ",$viewable);
//api_support_svg() from Chamilo
if (api_support_svg())
{
define("CONFIG_VIEWABLE_VALID_EXTS", '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,ogg,ogx,ogv,oga,svg');//For Chamilo updated
if (api_browser_support('svg')){
$viewable_array[]=',svg';
}
else{
define("CONFIG_VIEWABLE_VALID_EXTS", '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');//For Chamilo updated
if (api_browser_support('ogg')){
$viewable_array[]=',ogg';
$viewable_array[]=',ogx';
$viewable_array[]=',oga';
$viewable_array[]=',ogv';
}
$viewable = implode(" ",$viewable_array);
$viewable = preg_replace('/\s+/', '', $viewable);//clean spaces
//print_r($viewable);
define("CONFIG_VIEWABLE_VALID_EXTS", $viewable);
//define invalid exts
define('CONFIG_UPLOAD_INVALID_EXTS', 'php,php3,php4,php5,php6,phps,phtml,asp,aspx,jsp,cfm,cfc,pl,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll,ini'); //For Chamilo added.
//Preview
define('CONFIG_IMG_THUMBNAIL_MAX_X', 100);

@ -4701,23 +4701,41 @@ function api_get_template($path_type = 'rel') {
/**
* Check browser support for svg files
** This function check if the users browser support a file format
* @param string $format
* @return bool
*
* @author Juan Carlos Raña Trabado
*/
function api_support_svg() {
function api_browser_support($format) {
require_once api_get_path(LIBRARY_PATH).'browser/Browser.php';
$browser = new Browser();
//print_r($browser);
$current_browser = $browser->getBrowser();
$a_versiontemp = explode('.', $browser->getVersion());
$current_majorver= $a_versiontemp[0];
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;
} else {
return false;
}
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;
}
else {
return false;
}
}
elseif($format=='ogg'){
//native support
if (($current_browser == 'Firefox' && $current_majorver >= 3) || ($current_browser == 'Chrome' && $current_majorver >= 3)) {
return true;
}
else {
return false;
}
}
else{
return false;
}
}
/**

@ -271,11 +271,18 @@ function display_addedresource_link($type, $id, $style = '') {
$ext = explode('.', $filename);
$ext = strtolower($ext[sizeof($ext)-1]);
$myrow['path'] = rawurlencode($myrow['path']);
if (api_support_svg()){
$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png', 'svg','svgz'));
}else{
$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
$array_ext=array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png')
if (api_browser_support('svg')){
$array_ext[]='svg';
}
if (api_browser_support('ogg')){
$array_ext[]='ogg';
}
$in_frames = in_array($ext, $array_ext);
echo '<img src="../img/'.$image.'" align="middle" /> <a href="../document/'.($in_frames ? 'showinframes.php?file=' : 'download.php?doc_url=').$myrow['path'].'"'.$styling.'>'.$filename."</a><br />\n";
break;
case 'Externallink':

Loading…
Cancel
Save