forked from extern/egroupware
moved mime_icon method to egw_vfs
This commit is contained in:
parent
09cdf3efe1
commit
0a5be8a725
@ -334,35 +334,6 @@ class filemanager_ui
|
||||
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
|
||||
*
|
||||
@ -407,7 +378,7 @@ class filemanager_ui
|
||||
'name_preg' => $namefilter,
|
||||
),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']);
|
||||
// only show link if we have access to the file or dir
|
||||
if (egw_vfs::check_access($path,egw_vfs::READABLE))
|
||||
@ -469,7 +440,7 @@ class filemanager_ui
|
||||
$content['path'] = $path;
|
||||
$content['hsize'] = egw_vfs::hsize($stat['size']);
|
||||
$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
|
||||
}
|
||||
if (!($content['is_dir'] = egw_vfs::is_dir($path)))
|
||||
|
@ -809,6 +809,39 @@ class egw_vfs extends vfs_stream_wrapper
|
||||
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
|
||||
*
|
||||
@ -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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
static function download_url($path)
|
||||
static function download_url($path,$force_download=false)
|
||||
{
|
||||
return '/filemanager/webdav.php'.$path;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user