2
0
forked from Wavyzz/dolibarr

Qual: Removed duplicate code

This commit is contained in:
Laurent Destailleur
2010-11-13 14:34:06 +00:00
parent fcdf5a2646
commit 340b62abf2
2 changed files with 63 additions and 76 deletions

View File

@@ -1514,36 +1514,19 @@ function img_allow($allow,$alt='default')
/**
* \brief Show mime picto
* \param file Filename
* \param alt Alternate text
* \return string Return img tag
* Show MIME img of a file
* @param file Filename
* @param alt Alternate text to show on img mous hover
* @return string Return img tag
*/
function img_mime($file,$alt='')
{
$mime='other';
$mimetype=dol_mimetype($file,'',1);
$mimeimg=dol_mimetype($file,'',2);
if (preg_match('/\.xls(x)?$/i',$file)) $mime='xls';
if (preg_match('/\.ppt(x)?$/i',$file)) $mime='ppt';
if (preg_match('/\.doc(x)?$/i',$file)) $mime='doc';
if (empty($alt)) $alt='Mime type: '.$mimetype;
if (preg_match('/\.pdf$/i',$file)) $mime='pdf';
if (preg_match('/\.(html|htm)$/i',$file)) $mime='html';
if (preg_match('/\.txt$/i',$file)) $mime='other';
if (preg_match('/\.php$/i',$file)) $mime='php';
if (preg_match('/\.pl$/i',$file)) $mime='pl';
if (preg_match('/\.js$/i',$file)) $mime='jscript';
if (preg_match('/\.(png|bmp|jpg|jpeg|gif)$/i',$file)) $mime='image';
if (preg_match('/\.(mp3|ogg|au|wav|wma)$/i',$file)) $mime='audio';
if (preg_match('/\.(avi|divx|xvid|wmv|mpg|mpeg)$/i',$file)) $mime='video';
if (preg_match('/\.(zip|rar|gz|tgz|z|cab|bz2|7z)$/i',$file)) $mime='archive';
if (preg_match('/\.err$/i',$file)) $mime='error';
if (empty($alt)) $alt='Mime type: '.$mime;
$mime.='.png';
return '<img src="'.DOL_URL_ROOT.'/theme/common/mime/'.$mime.'" border="0" alt="'.$alt.'" title="'.$alt.'">';
return '<img src="'.DOL_URL_ROOT.'/theme/common/mime/'.$mimeimg.'" border="0" alt="'.$alt.'" title="'.$alt.'">';
}