aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-27 11:48:39 -0800
committerfriendica <info@friendica.com>2015-01-27 11:48:39 -0800
commit525c62ab1d90ad7fed33267bc64cc85f0c4492f8 (patch)
treee73eb083ad0c416deef3ef02f60d55e6e604e47f
parentf62383e648b50787a5456e452cf5b590d67d0ff4 (diff)
parent17c684e123157dc5cbfbc48854d6b9c0d1d0503b (diff)
downloadvolse-hubzilla-525c62ab1d90ad7fed33267bc64cc85f0c4492f8.tar.gz
volse-hubzilla-525c62ab1d90ad7fed33267bc64cc85f0c4492f8.tar.bz2
volse-hubzilla-525c62ab1d90ad7fed33267bc64cc85f0c4492f8.zip
Merge https://github.com/friendica/red into pending_merge
-rw-r--r--include/RedDAV/RedBrowser.php95
-rw-r--r--include/text.php71
-rw-r--r--mod/sharedwithme.php38
-rw-r--r--view/css/conversation.css4
-rw-r--r--view/css/mod_sharedwithme.css24
-rw-r--r--view/tpl/sharedwithme.tpl24
6 files changed, 154 insertions, 102 deletions
diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php
index 5642c3f86..e893d6ebd 100644
--- a/include/RedDAV/RedBrowser.php
+++ b/include/RedDAV/RedBrowser.php
@@ -82,7 +82,7 @@ class RedBrowser extends DAV\Browser\Plugin {
date_default_timezone_set($this->auth->getTimezone());
require_once('include/conversation.php');
-
+ require_once('include/text.php');
if ($this->auth->owner_nick) {
$html = profile_tabs(get_app(), (($is_owner) ? true : false), $this->auth->owner_nick);
}
@@ -208,9 +208,9 @@ class RedBrowser extends DAV\Browser\Plugin {
$ft['displayName'] = $displayName;
$ft['type'] = $type;
$ft['size'] = $size;
- $ft['sizeFormatted'] = $this->userReadableSize($size);
+ $ft['sizeFormatted'] = userReadableSize($size);
$ft['lastmodified'] = (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(), $lastmodified) : '');
- $ft['iconFromType'] = $this->getIconFromType($type);
+ $ft['iconFromType'] = getIconFromType($type);
$f[] = $ft;
}
@@ -224,13 +224,13 @@ class RedBrowser extends DAV\Browser\Plugin {
if ($used) {
$quotaDesc = t('%1$s used');
$quotaDesc = sprintf($quotaDesc,
- $this->userReadableSize($used));
+ userReadableSize($used));
}
if ($limit && $used) {
$quotaDesc = t('%1$s used of %2$s (%3$s&#37;)');
$quotaDesc = sprintf($quotaDesc,
- $this->userReadableSize($used),
- $this->userReadableSize($limit),
+ userReadableSize($used),
+ userReadableSize($limit),
round($used / $limit, 1));
}
@@ -283,29 +283,6 @@ class RedBrowser extends DAV\Browser\Plugin {
}
/**
- * @brief Returns a human readable formatted string for filesizes.
- *
- * Don't we need such a functionality in other places, too?
- *
- * @param int $size filesize in bytes
- * @return string
- */
- function userReadableSize($size) {
- $ret = "";
- if (is_numeric($size)) {
- $incr = 0;
- $k = 1024;
- $unit = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB');
- while (($size / $k) >= 1){
- $incr++;
- $size = round($size / $k, 2);
- }
- $ret = $size . " " . $unit[$incr];
- }
- return $ret;
- }
-
- /**
* @brief Creates a form to add new folders and upload files.
*
* @param \Sabre\DAV\INode $node
@@ -340,65 +317,6 @@ class RedBrowser extends DAV\Browser\Plugin {
}
/**
- * @brief returns icon name for use with e.g. font-awesome based on mime-type
- *
- * @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
- 'text/plain' => 'icon-file-text-alt',
- 'application/msword' => 'icon-file-text-alt',
- 'application/pdf' => 'icon-file-text-alt',
- 'application/vnd.oasis.opendocument.text' => 'icon-file-text-alt',
- 'application/epub+zip' => 'icon-book',
-
- //Spreadsheet
- 'application/vnd.oasis.opendocument.spreadsheet' => 'icon-table',
- 'application/vnd.ms-excel' => 'icon-table',
-
- //Image
- 'image/jpeg' => 'icon-picture',
- 'image/png' => 'icon-picture',
- 'image/gif' => 'icon-picture',
- 'image/svg+xml' => 'icon-picture',
-
- //Archive
- 'application/zip' => 'icon-archive',
- 'application/x-rar-compressed' => 'icon-archive',
-
- //Audio
- 'audio/mpeg' => 'icon-music',
- 'audio/wav' => 'icon-music',
- 'application/ogg' => 'icon-music',
- 'audio/ogg' => 'icon-music',
- 'audio/webm' => 'icon-music',
- 'audio/mp4' => 'icon-music',
-
- //Video
- 'video/quicktime' => 'icon-film',
- 'video/webm' => 'icon-film',
- 'video/mp4' => 'icon-film'
- );
-
- $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
@@ -412,6 +330,7 @@ class RedBrowser extends DAV\Browser\Plugin {
* The name of the attachment
* @return string
*/
+
protected function findAttachHash($owner, $parentHash, $attachName) {
$r = q("SELECT hash FROM attach WHERE uid = %d AND folder = '%s' AND filename = '%s' ORDER BY edited DESC LIMIT 1",
intval($owner),
diff --git a/include/text.php b/include/text.php
index 47694a17c..cfe87991c 100644
--- a/include/text.php
+++ b/include/text.php
@@ -2378,3 +2378,74 @@ function linkify_tags($a, &$body, $uid) {
return $results;
}
+/**
+ * @brief returns icon name for use with e.g. font-awesome based on mime-type
+ *
+ * @param string $type
+ * @return string
+ */
+function getIconFromType($type) {
+ $iconMap = array(
+ //Folder
+ t('Collection') => 'icon-folder-close',
+ //Common file
+ 'application/octet-stream' => 'icon-file-alt',
+ //Text
+ 'text/plain' => 'icon-file-text-alt',
+ 'application/msword' => 'icon-file-text-alt',
+ 'application/pdf' => 'icon-file-text-alt',
+ 'application/vnd.oasis.opendocument.text' => 'icon-file-text-alt',
+ 'application/epub+zip' => 'icon-book',
+ //Spreadsheet
+ 'application/vnd.oasis.opendocument.spreadsheet' => 'icon-table',
+ 'application/vnd.ms-excel' => 'icon-table',
+ //Image
+ 'image/jpeg' => 'icon-picture',
+ 'image/png' => 'icon-picture',
+ 'image/gif' => 'icon-picture',
+ 'image/svg+xml' => 'icon-picture',
+ //Archive
+ 'application/zip' => 'icon-archive',
+ 'application/x-rar-compressed' => 'icon-archive',
+ //Audio
+ 'audio/mpeg' => 'icon-music',
+ 'audio/wav' => 'icon-music',
+ 'application/ogg' => 'icon-music',
+ 'audio/ogg' => 'icon-music',
+ 'audio/webm' => 'icon-music',
+ 'audio/mp4' => 'icon-music',
+ //Video
+ 'video/quicktime' => 'icon-film',
+ 'video/webm' => 'icon-film',
+ 'video/mp4' => 'icon-film'
+ );
+
+ $iconFromType = 'icon-file-alt';
+
+ if (array_key_exists($type, $iconMap)) {
+ $iconFromType = $iconMap[$type];
+ }
+
+ return $iconFromType;
+}
+
+/**
+ * @brief Returns a human readable formatted string for filesizes.
+ *
+ * @param int $size filesize in bytes
+ * @return string
+ */
+function userReadableSize($size) {
+ $ret = "";
+ if (is_numeric($size)) {
+ $incr = 0;
+ $k = 1024;
+ $unit = array('bytes', 'KB', 'MB', 'GB', 'TB', 'PB');
+ while (($size / $k) >= 1){
+ $incr++;
+ $size = round($size / $k, 2);
+ }
+ $ret = $size . " " . $unit[$incr];
+ }
+ return $ret;
+}
diff --git a/mod/sharedwithme.php b/mod/sharedwithme.php
index 8b7d2661c..56cbc35ec 100644
--- a/mod/sharedwithme.php
+++ b/mod/sharedwithme.php
@@ -73,27 +73,37 @@ function sharedwithme_content(&$a) {
dbesc($channel['channel_hash'])
);
- $o = profile_tabs($a, $is_owner, $channel['channel_address']);
-
- $o .= '<div class="section-title-wrapper">';
-
- $o .= '<a href="/sharedwithme/dropall" onclick="return confirmDelete();" class="btn btn-xs btn-default pull-right"><i class="icon-trash"></i>&nbsp;' . t('Remove all entries') . '</a>';
-
- $o .= '<h2>' . t('Files shared with me') . '</h2>';
-
- $o .= '</div>';
-
- $o .= '<div class="section-content-wrapper">';
+ $items =array();
if($r) {
foreach($r as $rr) {
$object = json_decode($rr['object'],true);
- $url = rawurldecode(get_rel_link($object['link'],'alternate'));
- $o .= '<a href="' . $url . '?f=&zid=' . $channel['xchan_addr'] . '">' . $url . '</a>&nbsp;<a href="/sharedwithme/' . $rr['id'] . '/drop" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a><br><br>';
+
+ $item = array();
+ $item['id'] = $rr['id'];
+ $item['objfiletype'] = $object['filetype'];
+ $item['objfiletypeclass'] = getIconFromType($object['filetype']);
+ $item['objurl'] = rawurldecode(get_rel_link($object['link'],'alternate')) . '?f=&zid=' . $channel['xchan_addr'];
+ $item['objfilename'] = $object['filename'];
+ $item['objfilesize'] = userReadableSize($object['filesize']);
+ $item['objedited'] = $object['edited'];
+
+ $items[] = $item;
+
}
}
- $o .= '</div>';
+ $o = profile_tabs($a, $is_owner, $channel['channel_address']);
+
+ $o .= replace_macros(get_markup_template('sharedwithme.tpl'), array(
+ '$header' => t('Files: shared with me'),
+ '$name' => t('Name'),
+ '$size' => t('Size'),
+ '$lastmod' => t('Last Modified'),
+ '$dropall' => t('Remove all files'),
+ '$drop' => t('Remove this file'),
+ '$items' => $items
+ ));
return $o;
diff --git a/view/css/conversation.css b/view/css/conversation.css
index 7a5ffc2f7..8bc71bb6d 100644
--- a/view/css/conversation.css
+++ b/view/css/conversation.css
@@ -195,6 +195,10 @@ a.wall-item-name-link {
clear: both;
}
+.shared_header {
+ margin-bottom: 20px;
+}
+
/* comment_item */
.comment-edit-text-empty, .comment-edit-text-full {
diff --git a/view/css/mod_sharedwithme.css b/view/css/mod_sharedwithme.css
new file mode 100644
index 000000000..79fe0d7a9
--- /dev/null
+++ b/view/css/mod_sharedwithme.css
@@ -0,0 +1,24 @@
+#cloud-index {
+ width: 100%;
+}
+
+#cloud-index td:nth-child(1){
+ padding: 7px 3px 7px 10px;
+}
+
+#cloud-index th:nth-child(4),
+#cloud-index td:nth-child(4){
+ padding: 7px 3px;
+ white-space: nowrap;
+}
+
+#cloud-index th:nth-child(5),
+#cloud-index td:nth-child(5){
+ padding: 7px 10px 7px 7px;
+ white-space: nowrap;
+}
+
+.cloud-index-tool {
+ padding: 7px 10px;
+}
+
diff --git a/view/tpl/sharedwithme.tpl b/view/tpl/sharedwithme.tpl
new file mode 100644
index 000000000..1aeb9d4d7
--- /dev/null
+++ b/view/tpl/sharedwithme.tpl
@@ -0,0 +1,24 @@
+<div class="section-title-wrapper">
+ <a href="/sharedwithme/dropall" onclick="return confirmDelete();" class="btn btn-xs btn-default pull-right"><i class="icon-trash"></i>&nbsp;{{$dropall}}</a>
+ <h2>{{$header}}</h2>
+</div>
+<div class="generic-content-wrapper section-content-wrapper-np">
+ <table id="cloud-index">
+ <tr>
+ <th width="1%"></th>
+ <th width="92%">{{$name}}</th>
+ <th width="1%"></th>
+ <th width="1%" class="hidden-xs">{{$size}}</th>
+ <th width="1%" class="hidden-xs">{{$lastmod}}</th>
+ </tr>
+ {{foreach $items as $item}}
+ <tr id="cloud-index-{{$item.id}}">
+ <td><i class="{{$item.objfiletypeclass}}" title="{{$item.objfiletype}}"></i></td>
+ <td><a href="{{$item.objurl}}">{{$item.objfilename}}</a></td>
+ <td class="cloud-index-tool"><a href="/sharedwithme/{{$item.id}}/drop" title="{{$drop}}" onclick="return confirmDelete();"><i class="icon-trash drop-icons"></i></a></td>
+ <td class="hidden-xs">{{$item.objfilesize}}</td>
+ <td class="hidden-xs">{{$item.objedited}}</td>
+ </tr>
+ {{/foreach}}
+ </table>
+</div>