Merge https://github.com/friendica/red into pending_merge
This commit is contained in:
commit
525c62ab1d
@ -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%)');
|
||||
$quotaDesc = sprintf($quotaDesc,
|
||||
$this->userReadableSize($used),
|
||||
$this->userReadableSize($limit),
|
||||
userReadableSize($used),
|
||||
userReadableSize($limit),
|
||||
round($used / $limit, 1));
|
||||
}
|
||||
|
||||
@ -282,29 +282,6 @@ class RedBrowser extends DAV\Browser\Plugin {
|
||||
construct_page(get_app());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
@ -339,65 +316,6 @@ 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 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.
|
||||
*
|
||||
@ -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),
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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> ' . 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> <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;
|
||||
|
||||
|
@ -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 {
|
||||
|
24
view/css/mod_sharedwithme.css
Normal file
24
view/css/mod_sharedwithme.css
Normal file
@ -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;
|
||||
}
|
||||
|
24
view/tpl/sharedwithme.tpl
Normal file
24
view/tpl/sharedwithme.tpl
Normal file
@ -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> {{$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>
|
Reference in New Issue
Block a user