From 378aaf4a61176832f91cf8a95b3962915ee13708 Mon Sep 17 00:00:00 2001 From: Paolo Tacconi Date: Wed, 25 Jun 2014 11:54:10 +0200 Subject: Display quota and translatable strings --- include/reddav.php | 103 ++++++++++++++++++++++++++++++++++------------------- mod/cloud.php | 1 + 2 files changed, 67 insertions(+), 37 deletions(-) diff --git a/include/reddav.php b/include/reddav.php index fe05af606..37fa49c20 100644 --- a/include/reddav.php +++ b/include/reddav.php @@ -897,11 +897,11 @@ class RedBrowser extends DAV\Browser\Plugin { - + - - - + + + "; @@ -917,21 +917,19 @@ class RedBrowser extends DAV\Browser\Plugin { if ($path) { - list($parentUri) = DAV\URLUtil::splitPath($path); $fullPath = DAV\URLUtil::encodePath($this->server->getBaseUri() . $parentUri); $icon = $this->enableAssets?'Parent':''; - $html.= " - - - - - - - "; - + $html.= " + + + + + + + "; } foreach($files as $file) { @@ -955,22 +953,22 @@ class RedBrowser extends DAV\Browser\Plugin { // Some name mapping is preferred switch($v) { case '{DAV:}collection' : - $type[$k] = 'Collection'; + $type[$k] = t('Collection'); break; case '{DAV:}principal' : - $type[$k] = 'Principal'; + $type[$k] = t('Principal'); break; case '{urn:ietf:params:xml:ns:carddav}addressbook' : - $type[$k] = 'Addressbook'; + $type[$k] = t('Addressbook'); break; case '{urn:ietf:params:xml:ns:caldav}calendar' : - $type[$k] = 'Calendar'; + $type[$k] = t('Calendar'); break; case '{urn:ietf:params:xml:ns:caldav}schedule-inbox' : - $type[$k] = 'Schedule Inbox'; + $type[$k] = t('Schedule Inbox'); break; case '{urn:ietf:params:xml:ns:caldav}schedule-outbox' : - $type[$k] = 'Schedule Outbox'; + $type[$k] = t('Schedule Outbox'); break; case '{http://calendarserver.org/ns/}calendar-proxy-read' : $type[$k] = 'Proxy-Read'; @@ -1012,7 +1010,6 @@ class RedBrowser extends DAV\Browser\Plugin { break; } - } } @@ -1037,38 +1034,70 @@ class RedBrowser extends DAV\Browser\Plugin { if($is_owner) { $html .= " - "; + "; } else { $html .= ""; } $html .= " - + "; } - $html.= ""; - - $output = ''; + $html.= " +
".t('Name')."".t('Name')."    TypeSizeLast modified".t('Type')."   ".t('Size')."   ".t('Last modified')."

$icon.. - [parent]
$icon.. + [".t('parent')."]
" . (($size) ? $attachIcon : '') . " {$type}". $size ."". $this->userReadableSize($size) ." " . (($lastmodified) ? datetime_convert('UTC', date_default_timezone_get(),$lastmodified) : '') . "


"; + $limit = service_class_fetch ($owner,'attach_upload_limit'); + $r = q("select sum(filesize) as total from attach where aid = %d ", + intval($this->auth->channel_account_id) + ); + $used = $r[0]['total']; + if ($used) { + $quotaDesc = t('%1$s used'); + $quotaDesc = sprintf($quotaDesc, + $this->userReadableSize($used)); + } + if ($limit && $used) { + $quotaDesc = t('%1$s used of %2$s (%3$s%)'); + $quotaDesc = sprintf($quotaDesc, + $this->userReadableSize($used), + $this->userReadableSize($limit), + round($used / $limit, 1)); + } + if ($limit || $used) { + $html.= "

".t('Total')." ".$quotaDesc."

"; + } + + $output = ''; if ($this->enablePost) { $this->server->broadcastEvent('onHTMLActionsPanel',array($parent, &$output)); } - $html.=$output; - - $html.= ""; - - get_app()->page['content'] = $html; - construct_page(get_app()); + + get_app()->page['content'] = $html; + construct_page(get_app()); // return $html; } + function userReadableSize($size){ + 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); + } + return $size." ".$unit[$incr]; + } else { + return ""; + } + } public function htmlActionsPanel(DAV\INode $node, &$output) { @@ -1092,17 +1121,17 @@ class RedBrowser extends DAV\Browser\Plugin { $output.= ' - + - + diff --git a/mod/cloud.php b/mod/cloud.php index 3606325bd..51cedd2fd 100644 --- a/mod/cloud.php +++ b/mod/cloud.php @@ -61,6 +61,7 @@ function cloud_init(&$a) { $auth->channel_name = $channel['channel_address']; $auth->channel_id = $channel['channel_id']; $auth->channel_hash = $channel['channel_hash']; + $auth->channel_account_id = $channel['channel_account_id']; if($channel['channel_timezone']) $auth->timezone = $channel['channel_timezone']; } -- cgit v1.2.3
Create new folder   '.t('Create new folder').'   
- +
Upload file   '.t('Upload file').'   
- +