From 0cb0c2b1bfe22cb0fa983361a2f74d6b0fe6a596 Mon Sep 17 00:00:00 2001 From: marijus Date: Sat, 27 Dec 2014 10:10:56 +0100 Subject: more work on files --- include/RedDAV/RedBrowser.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'include/RedDAV/RedBrowser.php') 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; } @@ -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. * -- cgit v1.2.3