2
0
forked from Wavyzz/dolibarr
This commit is contained in:
Laurent Destailleur
2017-11-10 20:20:59 +01:00
parent a029b16795
commit debc0480dd
4 changed files with 112 additions and 89 deletions

View File

@@ -713,14 +713,14 @@ class FormFile
// Show file name with link to download // Show file name with link to download
$out.= '<td class="tdoverflowmax300">'; $out.= '<td class="tdoverflowmax300">';
$tmp = $this->showPreview($file,$modulepart,$relativepath,0,$param); $out.= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
$out.= ($tmp?$tmp.' ':'');
$out.= '<a class="documentdownload" href="'.$documenturl.'?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).($param?'&'.$param:'').'"';
$mime=dol_mimetype($relativepath,'',0); $mime=dol_mimetype($relativepath,'',0);
if (preg_match('/text/',$mime)) $out.= ' target="_blank"'; if (preg_match('/text/',$mime)) $out.= ' target="_blank"';
$out.= ' target="_blank">'; $out.= ' target="_blank">';
$out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]).' '.$file["name"]; $out.= img_mime($file["name"],$langs->trans("File").': '.$file["name"]);
$out.= $file["name"];
$out.= '</a>'."\n"; $out.= '</a>'."\n";
$out.= $this->showPreview($file,$modulepart,$relativepath,0,$param);
$out.= '</td>'; $out.= '</td>';
// Show file size // Show file size
@@ -741,12 +741,11 @@ class FormFile
//$out.= '&modulepart='.$modulepart; // TODO obsolete ? //$out.= '&modulepart='.$modulepart; // TODO obsolete ?
//$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ? //$out.= '&urlsource='.urlencode($urlsource); // TODO obsolete ?
$out.= '">'.img_picto($langs->trans("Delete"), 'delete.png').'</a>'; $out.= '">'.img_picto($langs->trans("Delete"), 'delete.png').'</a>';
//$out.='</td>';
} }
if ($printer) if ($printer)
{ {
//$out.= '<td align="right">'; //$out.= '<td align="right">';
$out.= '&nbsp;<a href="'.$urlsource.(strpos($urlsource,'?')?'&amp;':'?').'action=print_file&amp;printer='.$modulepart.'&amp;file='.urlencode($relativepath); $out.= '<a class="paddingleft" href="'.$urlsource.(strpos($urlsource,'?')?'&amp;':'?').'action=print_file&amp;printer='.$modulepart.'&amp;file='.urlencode($relativepath);
$out.= ($param?'&amp;'.$param:''); $out.= ($param?'&amp;'.$param:'');
$out.= '">'.img_picto($langs->trans("PrintFile", $relativepath),'printer.png').'</a>'; $out.= '">'.img_picto($langs->trans("PrintFile", $relativepath),'printer.png').'</a>';
} }
@@ -841,21 +840,24 @@ class FormFile
$file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files) $file_list=dol_dir_list($filedir, 'files', 0, $filterforfilesearch, '\.meta$|\.png$'); // Get list of files starting with name of ref (but not followed by "-" to discard uploaded files)
//var_dump($file_list);
// For ajax treatment // For ajax treatment
$out.= '<!-- html.formfile::getDocumentsLink -->'."\n"; $out.= '<!-- html.formfile::getDocumentsLink -->'."\n";
if (! empty($file_list)) if (! empty($file_list))
{ {
$out='<dl class="dropdown inline-block"> $out='<dl class="dropdown inline-block">
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight').'</a></dt> <dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', 'valignbottom').'</a></dt>
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields" style="display: none;">'; <dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields" style="display: none;">';
$tmpout=''; $tmpout='';
// Loop on each file found // Loop on each file found
$found=0;
foreach($file_list as $file) foreach($file_list as $file)
{ {
$i++; $i++;
if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter. if ($filter && ! preg_match('/'.$filter.'/i', $file["name"])) continue; // Discard this. It does not match provided filter.
$found++;
// Define relative path for download link (depends on module) // Define relative path for download link (depends on module)
$relativepath=$file["name"]; // Cas general $relativepath=$file["name"]; // Cas general
if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture... if ($modulesubdir) $relativepath=$modulesubdir."/".$file["name"]; // Cas propal, facture...
@@ -877,21 +879,29 @@ class FormFile
if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone')) if (! empty($conf->use_javascript_ajax) && ($conf->browser->layout != 'phone'))
{ {
$tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity); $tmparray = getAdvancedPreviewUrl($modulepart, $relativepath, 1, '&entity='.$entity);
if ($tmparray && $tmparray['url']) $tmpout.= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css']?' class="'.$tmparray['css'].'"':'').($tmparray['mime']?' mime="'.$tmparray['mime'].'"':'').($tmparray['target']?' target="'.$tmparray['target'].'"':'').'>'.img_picto('','detail').' '.$langs->trans("Preview").' '.$ext.'</a></li>'; if ($tmparray && $tmparray['url'])
{
$tmpout.= '<li><a href="'.$tmparray['url'].'"'.($tmparray['css']?' class="'.$tmparray['css'].'"':'').($tmparray['mime']?' mime="'.$tmparray['mime'].'"':'').($tmparray['target']?' target="'.$tmparray['target'].'"':'').'>';
//$tmpout.= img_picto('','detail');
$tmpout.= '<i class="fa fa-search-plus paddingright" style="color: gray"></i>';
$tmpout.= $langs->trans("Preview").' '.$ext.'</a></li>';
}
} }
// Download // Download
$tmpout.= '<li><a class="pictopreview" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'"'; $tmpout.= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT . '/document.php?modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'"';
$mime=dol_mimetype($relativepath,'',0); $mime=dol_mimetype($relativepath,'',0);
if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"'; if (preg_match('/text/',$mime)) $tmpout.= ' target="_blank"';
$tmpout.= '>'; $tmpout.= '>';
$tmpout.=img_mime($relativepath, $file["name"]).' '; $tmpout.= img_mime($relativepath, $file["name"]);
$tmpout.= $langs->trans("Download").' '.$ext; $tmpout.= $langs->trans("Download").' '.$ext;
$tmpout.= '</a></li>'."\n"; $tmpout.= '</a></li>'."\n";
} }
$out.=$tmpout; $out.=$tmpout;
$out.='</ul></div></dd> $out.='</ul></div></dd>
</dl>'; </dl>';
if (! $found) $out='';
} }
else else
{ {
@@ -1062,6 +1072,7 @@ class FormFile
&& ! preg_match('/\.meta$/i',$file['name'])) && ! preg_match('/\.meta$/i',$file['name']))
{ {
if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid']; if ($filearray[$key]['rowid'] > 0) $lastrowid = $filearray[$key]['rowid'];
$filepath=$relativepath.$file['name'];
$editline=0; $editline=0;
$nboflines++; $nboflines++;
@@ -1071,18 +1082,14 @@ class FormFile
print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'" '.$bcdd[$var].'>'; print '<tr id="row-'.($filearray[$key]['rowid']>0?$filearray[$key]['rowid']:'-AFTER'.$lastrowid.'POS'.($i+1)).'" '.$bcdd[$var].'>';
print '<td class="tdoverflowmax300">'; print '<td class="tdoverflowmax300">';
$filepath=$relativepath.$file['name']; // Show file name with link to download
if (! $editline) print $this->showPreview($file,$modulepart,$filepath);
//print "XX".$file['name']; //$file['name'] must be utf8 //print "XX".$file['name']; //$file['name'] must be utf8
print '<a class="paddingleft" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; print '<a class="paddingright" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
if ($forcedownload) print '&attachment=1'; if ($forcedownload) print '&attachment=1';
if (! empty($object->entity)) print '&entity='.$object->entity; if (! empty($object->entity)) print '&entity='.$object->entity;
print '&file='.urlencode($filepath); print '&file='.urlencode($filepath);
print '">'; print '">';
print img_mime($file['name'], $file['name'].' ('.dol_print_size($file['size'],0,0).')', 'inline-block valignbottom paddingright');
print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' ';
if ($showrelpart == 1) print $relativepath; if ($showrelpart == 1) print $relativepath;
//print dol_trunc($file['name'],$maxlength,'middle'); //print dol_trunc($file['name'],$maxlength,'middle');
if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile'))) if (GETPOST('action','aZ09') == 'editfile' && $file['name'] == basename(GETPOST('urlfile')))
@@ -1097,6 +1104,7 @@ class FormFile
print $file['name']; print $file['name'];
print '</a>'; print '</a>';
} }
if (! $editline) print $this->showPreview($file, $modulepart, $filepath);
print "</td>\n"; print "</td>\n";
@@ -1448,10 +1456,10 @@ class FormFile
// File // File
print '<td>'; print '<td>';
//print "XX".$file['name']; //$file['name'] must be utf8 //print "XX".$file['name']; //$file['name'] must be utf8
print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
if ($forcedownload) print '&attachment=1'; if ($forcedownload) print '&attachment=1';
print '&file='.urlencode($relativefile).'">'; print '&file='.urlencode($relativefile).'">';
print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')');
print dol_trunc($file['name'],$maxlength,'middle'); print dol_trunc($file['name'],$maxlength,'middle');
print '</a>'; print '</a>';
@@ -1678,7 +1686,11 @@ class FormFile
{ {
$out.= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime'])?'':' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target'])?'':' target="'.$urladvancedpreview['target'].'"').'>'; $out.= '<a class="pictopreview '.$urladvancedpreview['css'].'" href="'.$urladvancedpreview['url'].'"'.(empty($urladvancedpreview['mime'])?'':' mime="'.$urladvancedpreview['mime'].'"').' '.(empty($urladvancedpreview['target'])?'':' target="'.$urladvancedpreview['target'].'"').'>';
//$out.= '<a class="pictopreview">'; //$out.= '<a class="pictopreview">';
if (empty($ruleforpicto)) $out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail'); if (empty($ruleforpicto))
{
//$out.= img_picto($langs->trans('Preview').' '.$file['name'], 'detail');
$out.='<span class="fa fa-search-plus" style="color: gray"></span>';
}
else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']); else $out.= img_mime($relativepath, $langs->trans('Preview').' '.$file['name']);
$out.= '</a>'; $out.= '</a>';
} }

View File

@@ -3216,18 +3216,21 @@ function img_allow($allow, $titlealt = 'default')
* *
* @param string $file Filename * @param string $file Filename
* @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title. * @param string $titlealt Text on alt and title of image. Alt only if param notitle is set to 1. If text is "TextA:TextB", use Text A on alt and Text B on title.
* @param string $morecss More css
* @return string Return img tag * @return string Return img tag
*/ */
function img_mime($file, $titlealt = '') function img_mime($file, $titlealt = '', $morecss='')
{ {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$mimetype = dol_mimetype($file, '', 1); $mimetype = dol_mimetype($file, '', 1);
$mimeimg = dol_mimetype($file, '', 2); $mimeimg = dol_mimetype($file, '', 2);
$mimefa = dol_mimetype($file, '', 4);
if (empty($titlealt)) $titlealt = 'Mime type: '.$mimetype; if (empty($titlealt)) $titlealt = 'Mime type: '.$mimetype;
return img_picto_common($titlealt, 'mime/'.$mimeimg); //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
return '<i class="fa fa-'.$mimefa.' paddingright"></i>';
} }
@@ -6368,7 +6371,7 @@ function printCommonFooter($zone='private')
if (empty($reshook)) if (empty($reshook))
{ {
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
print "\n"; print "\n";
if (! empty($conf->use_javascript_ajax)) if (! empty($conf->use_javascript_ajax))
{ {
@@ -6385,7 +6388,7 @@ function printCommonFooter($zone='private')
print " $('.login_block').toggle()\n"; print " $('.login_block').toggle()\n";
print '});'."\n"; print '});'."\n";
} }
// Google Analytics (need Google module) // Google Analytics (need Google module)
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID)) if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
{ {
@@ -6404,7 +6407,7 @@ function printCommonFooter($zone='private')
print ' })();'."\n"; print ' })();'."\n";
} }
} }
// End of tuning // End of tuning
if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO)) if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO))
{ {
@@ -6434,7 +6437,7 @@ function printCommonFooter($zone='private')
} }
print '");'."\n"; print '");'."\n";
} }
print "\n".'</script>'."\n"; print "\n".'</script>'."\n";
} }
@@ -6443,7 +6446,7 @@ function printCommonFooter($zone='private')
{ {
print_r(xdebug_get_code_coverage()); print_r(xdebug_get_code_coverage());
} }
// If there is some logs in buffer to show // If there is some logs in buffer to show
if (count($conf->logbuffer)) if (count($conf->logbuffer))
{ {
@@ -6736,92 +6739,93 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata=0, $param=''
* *
* @param string $file Filename we looking for MIME type * @param string $file Filename we looking for MIME type
* @param string $default Default mime type if extension not found in known list * @param string $default Default mime type if extension not found in known list
* @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language * @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
* @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive) * @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
* @see image_format_supported (images.lib.php) * @see image_format_supported (images.lib.php)
*/ */
function dol_mimetype($file,$default='application/octet-stream',$mode=0) function dol_mimetype($file, $default='application/octet-stream', $mode=0)
{ {
$mime=$default; $mime=$default;
$imgmime='other.png'; $imgmime='other.png';
$famime='file-o';
$srclang=''; $srclang='';
$tmpfile=preg_replace('/\.noexe$/','',$file); $tmpfile=preg_replace('/\.noexe$/','',$file);
// Text files // Text files
if (preg_match('/\.txt$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; } if (preg_match('/\.txt$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; }
if (preg_match('/\.rtx$/i',$tmpfile)) { $mime='text/richtext'; $imgmime='text.png'; } if (preg_match('/\.rtx$/i',$tmpfile)) { $mime='text/richtext'; $imgmime='text.png'; $famime='file-text-o'; }
if (preg_match('/\.csv$/i',$tmpfile)) { $mime='text/csv'; $imgmime='text.png'; } if (preg_match('/\.csv$/i',$tmpfile)) { $mime='text/csv'; $imgmime='text.png'; $famime='file-text-o'; }
if (preg_match('/\.tsv$/i',$tmpfile)) { $mime='text/tab-separated-values'; $imgmime='text.png'; } if (preg_match('/\.tsv$/i',$tmpfile)) { $mime='text/tab-separated-values'; $imgmime='text.png'; $famime='file-text-o'; }
if (preg_match('/\.(cf|conf|log)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; } if (preg_match('/\.(cf|conf|log)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; }
if (preg_match('/\.ini$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='ini'; } if (preg_match('/\.ini$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='ini'; $famime='file-text-o'; }
if (preg_match('/\.css$/i',$tmpfile)) { $mime='text/css'; $imgmime='css.png'; $srclang='css'; } if (preg_match('/\.css$/i',$tmpfile)) { $mime='text/css'; $imgmime='css.png'; $srclang='css'; $famime='file-text-o'; }
// Certificate files // Certificate files
if (preg_match('/\.(crt|cer|key|pub)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; } if (preg_match('/\.(crt|cer|key|pub)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $famime='file-text-o'; }
// HTML/XML // HTML/XML
if (preg_match('/\.(html|htm|shtml)$/i',$tmpfile)) { $mime='text/html'; $imgmime='html.png'; $srclang='html'; } if (preg_match('/\.(html|htm|shtml)$/i',$tmpfile)) { $mime='text/html'; $imgmime='html.png'; $srclang='html'; $famime='file-text-o'; }
if (preg_match('/\.(xml|xhtml)$/i',$tmpfile)) { $mime='text/xml'; $imgmime='other.png'; $srclang='xml'; } if (preg_match('/\.(xml|xhtml)$/i',$tmpfile)) { $mime='text/xml'; $imgmime='other.png'; $srclang='xml'; $famime='file-text-o'; }
// Languages // Languages
if (preg_match('/\.bas$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='bas'; } if (preg_match('/\.bas$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='bas'; $famime='file-code-o'; }
if (preg_match('/\.(c)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='c'; } if (preg_match('/\.(c)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='c'; $famime='file-code-o'; }
if (preg_match('/\.(cpp)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='cpp'; } if (preg_match('/\.(cpp)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='cpp'; $famime='file-code-o'; }
if (preg_match('/\.(h)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='h'; } if (preg_match('/\.(h)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='h'; $famime='file-code-o'; }
if (preg_match('/\.(java|jsp)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='java'; } if (preg_match('/\.(java|jsp)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='java'; $famime='file-code-o'; }
if (preg_match('/\.php([0-9]{1})?$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; } if (preg_match('/\.php([0-9]{1})?$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; $famime='file-code-o'; }
if (preg_match('/\.phtml$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; } if (preg_match('/\.phtml$/i',$tmpfile)) { $mime='text/plain'; $imgmime='php.png'; $srclang='php'; $famime='file-code-o'; }
if (preg_match('/\.(pl|pm)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='pl.png'; $srclang='perl'; } if (preg_match('/\.(pl|pm)$/i',$tmpfile)) { $mime='text/plain'; $imgmime='pl.png'; $srclang='perl'; $famime='file-code-o'; }
if (preg_match('/\.sql$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='sql'; } if (preg_match('/\.sql$/i',$tmpfile)) { $mime='text/plain'; $imgmime='text.png'; $srclang='sql'; $famime='file-code-o'; }
if (preg_match('/\.js$/i',$tmpfile)) { $mime='text/x-javascript'; $imgmime='jscript.png'; $srclang='js'; } if (preg_match('/\.js$/i',$tmpfile)) { $mime='text/x-javascript'; $imgmime='jscript.png'; $srclang='js'; $famime='file-code-o'; }
// Open office // Open office
if (preg_match('/\.odp$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.presentation'; $imgmime='ooffice.png'; } if (preg_match('/\.odp$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.presentation'; $imgmime='ooffice.png'; $famime='file-powerpoint-o'; }
if (preg_match('/\.ods$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.spreadsheet'; $imgmime='ooffice.png'; } if (preg_match('/\.ods$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.spreadsheet'; $imgmime='ooffice.png'; $famime='file-excel-o'; }
if (preg_match('/\.odt$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.text'; $imgmime='ooffice.png'; } if (preg_match('/\.odt$/i',$tmpfile)) { $mime='application/vnd.oasis.opendocument.text'; $imgmime='ooffice.png'; $famime='file-word-o'; }
// MS Office // MS Office
if (preg_match('/\.mdb$/i',$tmpfile)) { $mime='application/msaccess'; $imgmime='mdb.png'; } if (preg_match('/\.mdb$/i',$tmpfile)) { $mime='application/msaccess'; $imgmime='mdb.png'; $famime='file-o'; }
if (preg_match('/\.doc(x|m)?$/i',$tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; } if (preg_match('/\.doc(x|m)?$/i',$tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; $famime='file-word-o'; }
if (preg_match('/\.dot(x|m)?$/i',$tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; } if (preg_match('/\.dot(x|m)?$/i',$tmpfile)) { $mime='application/msword'; $imgmime='doc.png'; $famime='file-word-o'; }
if (preg_match('/\.xlt(x)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xlt(x)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; }
if (preg_match('/\.xla(m)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xla(m)?$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; }
if (preg_match('/\.xls$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; } if (preg_match('/\.xls$/i',$tmpfile)) { $mime='application/vnd.ms-excel'; $imgmime='xls.png'; $famime='file-excel-o'; }
if (preg_match('/\.xls(b|m|x)$/i',$tmpfile)) { $mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime='xls.png'; } if (preg_match('/\.xls(b|m|x)$/i',$tmpfile)) { $mime='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $imgmime='xls.png'; $famime='file-excel-o'; }
if (preg_match('/\.pps(m|x)?$/i',$tmpfile)) { $mime='application/vnd.ms-powerpoint'; $imgmime='ppt.png'; } if (preg_match('/\.pps(m|x)?$/i',$tmpfile)) { $mime='application/vnd.ms-powerpoint'; $imgmime='ppt.png'; $famime='file-powerpoint-o'; }
if (preg_match('/\.ppt(m|x)?$/i',$tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; } if (preg_match('/\.ppt(m|x)?$/i',$tmpfile)) { $mime='application/x-mspowerpoint'; $imgmime='ppt.png'; $famime='file-powerpoint-o'; }
// Other // Other
if (preg_match('/\.pdf$/i',$tmpfile)) { $mime='application/pdf'; $imgmime='pdf.png'; } if (preg_match('/\.pdf$/i',$tmpfile)) { $mime='application/pdf'; $imgmime='pdf.png'; $famime='file-pdf-o'; }
// Scripts // Scripts
if (preg_match('/\.bat$/i',$tmpfile)) { $mime='text/x-bat'; $imgmime='script.png'; $srclang='dos'; } if (preg_match('/\.bat$/i',$tmpfile)) { $mime='text/x-bat'; $imgmime='script.png'; $srclang='dos'; $famime='file-code-o'; }
if (preg_match('/\.sh$/i',$tmpfile)) { $mime='text/x-sh'; $imgmime='script.png'; $srclang='bash'; } if (preg_match('/\.sh$/i',$tmpfile)) { $mime='text/x-sh'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; }
if (preg_match('/\.ksh$/i',$tmpfile)) { $mime='text/x-ksh'; $imgmime='script.png'; $srclang='bash'; } if (preg_match('/\.ksh$/i',$tmpfile)) { $mime='text/x-ksh'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; }
if (preg_match('/\.bash$/i',$tmpfile)) { $mime='text/x-bash'; $imgmime='script.png'; $srclang='bash'; } if (preg_match('/\.bash$/i',$tmpfile)) { $mime='text/x-bash'; $imgmime='script.png'; $srclang='bash'; $famime='file-code-o'; }
// Images // Images
if (preg_match('/\.ico$/i',$tmpfile)) { $mime='image/x-icon'; $imgmime='image.png'; } if (preg_match('/\.ico$/i',$tmpfile)) { $mime='image/x-icon'; $imgmime='image.png'; $famime='file-image-o'; }
if (preg_match('/\.(jpg|jpeg)$/i',$tmpfile)) { $mime='image/jpeg'; $imgmime='image.png'; } if (preg_match('/\.(jpg|jpeg)$/i',$tmpfile)) { $mime='image/jpeg'; $imgmime='image.png'; $famime='file-image-o'; }
if (preg_match('/\.png$/i',$tmpfile)) { $mime='image/png'; $imgmime='image.png'; } if (preg_match('/\.png$/i',$tmpfile)) { $mime='image/png'; $imgmime='image.png'; $famime='file-image-o'; }
if (preg_match('/\.gif$/i',$tmpfile)) { $mime='image/gif'; $imgmime='image.png'; } if (preg_match('/\.gif$/i',$tmpfile)) { $mime='image/gif'; $imgmime='image.png'; $famime='file-image-o'; }
if (preg_match('/\.bmp$/i',$tmpfile)) { $mime='image/bmp'; $imgmime='image.png'; } if (preg_match('/\.bmp$/i',$tmpfile)) { $mime='image/bmp'; $imgmime='image.png'; $famime='file-image-o'; }
if (preg_match('/\.(tif|tiff)$/i',$tmpfile)) { $mime='image/tiff'; $imgmime='image.png'; } if (preg_match('/\.(tif|tiff)$/i',$tmpfile)) { $mime='image/tiff'; $imgmime='image.png'; $famime='file-image-o'; }
// Calendar // Calendar
if (preg_match('/\.vcs$/i',$tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; } if (preg_match('/\.vcs$/i',$tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; $famime='file-text-o'; }
if (preg_match('/\.ics$/i',$tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; } if (preg_match('/\.ics$/i',$tmpfile)) { $mime='text/calendar'; $imgmime='other.png'; $famime='file-text-o'; }
// Other // Other
if (preg_match('/\.torrent$/i',$tmpfile)) { $mime='application/x-bittorrent'; $imgmime='other.png'; } if (preg_match('/\.torrent$/i',$tmpfile)) { $mime='application/x-bittorrent'; $imgmime='other.png'; $famime='file-o'; }
// Audio // Audio
if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i',$tmpfile)) { $mime='audio'; $imgmime='audio.png'; } if (preg_match('/\.(mp3|ogg|au|wav|wma|mid)$/i',$tmpfile)) { $mime='audio'; $imgmime='audio.png'; $famime='file-audio-o'; }
// Video // Video
if (preg_match('/\.ogv$/i',$tmpfile)) { $mime='video/ogg'; $imgmime='video.png'; } if (preg_match('/\.ogv$/i',$tmpfile)) { $mime='video/ogg'; $imgmime='video.png'; $famime='file-video-o'; }
if (preg_match('/\.webm$/i',$tmpfile)) { $mime='video/webm'; $imgmime='video.png'; } if (preg_match('/\.webm$/i',$tmpfile)) { $mime='video/webm'; $imgmime='video.png'; $famime='file-video-o'; }
if (preg_match('/\.avi$/i',$tmpfile)) { $mime='video/x-msvideo'; $imgmime='video.png'; } if (preg_match('/\.avi$/i',$tmpfile)) { $mime='video/x-msvideo'; $imgmime='video.png'; $famime='file-video-o'; }
if (preg_match('/\.divx$/i',$tmpfile)) { $mime='video/divx'; $imgmime='video.png'; } if (preg_match('/\.divx$/i',$tmpfile)) { $mime='video/divx'; $imgmime='video.png'; $famime='file-video-o'; }
if (preg_match('/\.xvid$/i',$tmpfile)) { $mime='video/xvid'; $imgmime='video.png'; } if (preg_match('/\.xvid$/i',$tmpfile)) { $mime='video/xvid'; $imgmime='video.png'; $famime='file-video-o'; }
if (preg_match('/\.(wmv|mpg|mpeg)$/i',$tmpfile)) { $mime='video'; $imgmime='video.png'; } if (preg_match('/\.(wmv|mpg|mpeg)$/i',$tmpfile)) { $mime='video'; $imgmime='video.png'; $famime='file-video-o'; }
// Archive // Archive
if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i',$tmpfile)) { $mime='archive'; $imgmime='archive.png'; } // application/xxx where zzz is zip, ... if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z|tar|lzh)$/i',$tmpfile)) { $mime='archive'; $imgmime='archive.png'; $famime='file-archive-o'; } // application/xxx where zzz is zip, ...
// Exe // Exe
if (preg_match('/\.(exe|com)$/i',$tmpfile)) { $mime='application/octet-stream'; $imgmime='other.png'; } if (preg_match('/\.(exe|com)$/i',$tmpfile)) { $mime='application/octet-stream'; $imgmime='other.png'; $famime='file-o'; }
// Lib // Lib
if (preg_match('/\.(dll|lib|o|so|a)$/i',$tmpfile)) { $mime='library'; $imgmime='library.png'; } if (preg_match('/\.(dll|lib|o|so|a)$/i',$tmpfile)) { $mime='library'; $imgmime='library.png'; $famime='file-o'; }
// Err // Err
if (preg_match('/\.err$/i',$tmpfile)) { $mime='error'; $imgmime='error.png'; } if (preg_match('/\.err$/i',$tmpfile)) { $mime='error'; $imgmime='error.png'; $famime='file-text-o'; }
// Return string // Return string
if ($mode == 1) if ($mode == 1)
@@ -6837,7 +6841,10 @@ function dol_mimetype($file,$default='application/octet-stream',$mode=0)
{ {
return $srclang; return $srclang;
} }
if ($mode == 4)
{
return $famime;
}
return $mime; return $mime;
} }

View File

@@ -762,7 +762,9 @@ div.myavailability {
box-shadow: 1px 1px 25px #aaa; box-shadow: 1px 1px 25px #aaa;
max-width: calc(100% - 56px); max-width: calc(100% - 56px);
} }
.fa-file-text-o, .fa-file-code-o, .fa-file-powerpoint-o, .fa-file-excel-o, .fa-file-word-o, .fa-file-o, .fa-file-image-o, .fa-file-video-o, .fa-file-audio-o, .fa-file-archive-o, .fa-file-pdf-o {
color: #055;
}
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
/*.table-responsive { /*.table-responsive {

View File

@@ -768,7 +768,9 @@ div.myavailability {
box-shadow: 1px 1px 25px #aaa; box-shadow: 1px 1px 25px #aaa;
max-width: calc(100% - 56px); max-width: calc(100% - 56px);
} }
.fa-file-text-o, .fa-file-code-o, .fa-file-powerpoint-o, .fa-file-excel-o, .fa-file-word-o, .fa-file-o, .fa-file-image-o, .fa-file-video-o, .fa-file-audio-o, .fa-file-archive-o, .fa-file-pdf-o {
color: #505;
}
/* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */ /* DOL_XXX for future usage (when left menu has been removed). If we do not use datatable */
/*.table-responsive { /*.table-responsive {