moved mime_icon method to egw_vfs

This commit is contained in:
Ralf Becker 2008-04-16 07:07:31 +00:00
parent 09cdf3efe1
commit 0a5be8a725
2 changed files with 126 additions and 120 deletions

View File

@ -334,35 +334,6 @@ class filemanager_ui
return "Unknown action '$action'!"; return "Unknown action '$action'!";
} }
/**
* Get the closest mime icon
*
* @param string $mime_type
* @param int $size=16
* @param boolean $et_image=true return $app/$icon string for etemplate (default) or html image tag if false
* @return string
*/
static function mime_icon($mime_type, $size=16)
{
if ($mime_type == egw_vfs::DIR_MIME_TYPE)
{
$mime_type = 'Directory';
}
if(!$mime_type)
{
$mime_type='unknown';
}
$mime_type= strtolower(str_replace ('/','_',$mime_type));
list($mime_part) = explode('_',$mime_type);
if (!($img=$GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_'.$mime_type)) &&
!($img=$GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_'.$mime_part)))
{
$img = $GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_unknown');
}
return 'filemanager/'.$icon;
}
/** /**
* Callback to fetch the rows for the nextmatch widget * Callback to fetch the rows for the nextmatch widget
* *
@ -407,7 +378,7 @@ class filemanager_ui
'name_preg' => $namefilter, 'name_preg' => $namefilter,
),true) as $path => $row) ),true) as $path => $row)
{ {
$row['icon'] = self::mime_icon($row['mime']); $row['icon'] = egw_vfs::mime_icon($row['mime']);
$row['perms'] = egw_vfs::int2mode($row['mode']); $row['perms'] = egw_vfs::int2mode($row['mode']);
// only show link if we have access to the file or dir // only show link if we have access to the file or dir
if (egw_vfs::check_access($path,egw_vfs::READABLE)) if (egw_vfs::check_access($path,egw_vfs::READABLE))
@ -469,7 +440,7 @@ class filemanager_ui
$content['path'] = $path; $content['path'] = $path;
$content['hsize'] = egw_vfs::hsize($stat['size']); $content['hsize'] = egw_vfs::hsize($stat['size']);
$content['mime'] = egw_vfs::mime_content_type($path); $content['mime'] = egw_vfs::mime_content_type($path);
$content['icon'] = self::mime_icon($content['mime']); $content['icon'] = egw_vfs::mime_icon($content['mime']);
$content['gid'] *= -1; // our widgets use negative gid's $content['gid'] *= -1; // our widgets use negative gid's
} }
if (!($content['is_dir'] = egw_vfs::is_dir($path))) if (!($content['is_dir'] = egw_vfs::is_dir($path)))

View File

@ -809,6 +809,39 @@ class egw_vfs extends vfs_stream_wrapper
return $sP; return $sP;
} }
/**
* Get the closest mime icon
*
* @param string $mime_type
* @param boolean $et_image=true return $app/$icon string for etemplate (default) or html img tag if false
* @param int $size=16
* @return string
*/
static function mime_icon($mime_type, $et_image=true, $size=16)
{
if ($mime_type == egw_vfs::DIR_MIME_TYPE)
{
$mime_type = 'Directory';
}
if(!$mime_type)
{
$mime_type = 'unknown';
}
$mime_full = strtolower(str_replace ('/','_',$mime_type));
list($mime_part) = explode('_',$mime_type);
if (!($img=$GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_'.$mime_full)) &&
!($img=$GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_'.$mime_part)))
{
$img = $GLOBALS['egw']->common->image('filemanager',$icon='mime'.$size.'_unknown');
}
if ($et_image)
{
return 'filemanager/'.$icon;
}
return html::image('filemanager',$icon,lang($mime_type));
}
/** /**
* Human readable size values in k or M * Human readable size values in k or M
* *
@ -897,9 +930,11 @@ class egw_vfs extends vfs_stream_wrapper
* Please note: If you dont use eTemplate or the html class, you have to run this url throught egw::link() to get a full url * Please note: If you dont use eTemplate or the html class, you have to run this url throught egw::link() to get a full url
* *
* @param string $path * @param string $path
* @param boolean $force_download=false add header('Content-disposition: filename="' . basename($path) . '"'), currently not supported!
* @todo get $force_download working through webdav
* @return string * @return string
*/ */
static function download_url($path) static function download_url($path,$force_download=false)
{ {
return '/filemanager/webdav.php'.$path; return '/filemanager/webdav.php'.$path;
} }