aboutsummaryrefslogtreecommitdiffstats
path: root/include/RedDAV
diff options
context:
space:
mode:
authormarijus <mario@mariovavti.com>2014-12-27 10:10:56 +0100
committermarijus <mario@mariovavti.com>2014-12-27 10:10:56 +0100
commit0cb0c2b1bfe22cb0fa983361a2f74d6b0fe6a596 (patch)
treef4f222d7d1d531e7246043fddcd57c484d38a59f /include/RedDAV
parent82d3c2a7e0e4ad3b7e46af090956efe66857278d (diff)
downloadvolse-hubzilla-0cb0c2b1bfe22cb0fa983361a2f74d6b0fe6a596.tar.gz
volse-hubzilla-0cb0c2b1bfe22cb0fa983361a2f74d6b0fe6a596.tar.bz2
volse-hubzilla-0cb0c2b1bfe22cb0fa983361a2f74d6b0fe6a596.zip
more work on files
Diffstat (limited to 'include/RedDAV')
-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