more work on files

This commit is contained in:
marijus
2014-12-27 10:10:56 +01:00
parent 82d3c2a7e0
commit 0cb0c2b1bf
5 changed files with 96 additions and 48 deletions

View File

@@ -173,6 +173,7 @@ class RedBrowser extends DAV\Browser\Plugin {
$type = $this->escapeHTML($type);
$icon = '';
if ($this->enableAssets) {
$node = $this->server->tree->getNodeForPath(($path ? $path . '/' : '') . $name);
foreach (array_reverse($this->iconMap) as $class=>$iconName) {
@@ -209,6 +210,7 @@ class RedBrowser extends DAV\Browser\Plugin {
$ft['size'] = $size;
$ft['sizeFormatted'] = $this->userReadableSize($size);
$ft['lastmodified'] = (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(), $lastmodified) : '');
$ft['iconFromType'] = $this->getIconFromType($type);
$f[] = $ft;
}
@@ -325,6 +327,45 @@ class RedBrowser extends DAV\Browser\Plugin {
return z_root() . '/cloud/?sabreAction=asset&assetName=' . urlencode($assetName);
}
/**
* @brief returns icon name for use with e.g. font-awesome based on filetype
*
* @param string $type
* @return string
*/
protected function getIconFromType($type) {
$iconMap = array(
//Folder
t('Collection') => 'icon-folder-close',
//Common file
'application/octet-stream' => 'icon-file-alt',
//Text
'application/msword' => 'icon-file-text-alt',
'application/pdf' => 'icon-file-text-alt',
'application/vnd.oasis.opendocument.text' => 'icon-file-text-alt',
//Spreadsheet
'application/vnd.oasis.opendocument.spreadsheet' => 'icon-table',
//Image
'image/jpeg' => 'icon-picture',
'image/png' => 'icon-picture',
'image/gif' => 'icon-picture',
'image/svg+xml' => 'icon-picture',
);
$iconFromType = 'icon-file-alt';
if (array_key_exists($type, $iconMap))
{
$iconFromType = $iconMap[$type];
}
return $iconFromType;
}
/**
* @brief Return the hash of an attachment.
*