aboutsummaryrefslogtreecommitdiffstats
path: root/include/RedDAV/RedBrowser.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/RedDAV/RedBrowser.php')
-rw-r--r--include/RedDAV/RedBrowser.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php
index 78aacf92b..6b0c77014 100644
--- a/include/RedDAV/RedBrowser.php
+++ b/include/RedDAV/RedBrowser.php
@@ -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;
}
@@ -326,6 +328,45 @@ class RedBrowser extends DAV\Browser\Plugin {
}
/**
+ * @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.
*
* Given the owner, the parent folder and and attach name get the attachment